feat: Moves gumps out of the core (#1916)
> [!Important] > **Developer Note** > This code change will **completely move gumps out of the core** ### Summary - Adds `GetGumps()` convenience which exposes methods to Find/Close/Send multiple gumps. This helper is a performance improvement by eliminating the Dictionary<Player, List> lookup for gumps.
This commit is contained in:
parent
40d99f6d1c
commit
8282b00ca2
246 changed files with 1722 additions and 1383 deletions
|
|
@ -13,14 +13,10 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Server.Accounting;
|
||||
using Server.Collections;
|
||||
using Server.ContextMenus;
|
||||
using Server.Guilds;
|
||||
using Server.Gumps;
|
||||
using Server.HuePickers;
|
||||
using Server.Items;
|
||||
using Server.Logging;
|
||||
|
|
@ -30,6 +26,9 @@ using Server.Network;
|
|||
using Server.Prompts;
|
||||
using Server.Targeting;
|
||||
using Server.Text;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CalcMoves = Server.Movement.Movement;
|
||||
|
||||
namespace Server;
|
||||
|
|
@ -8121,65 +8120,6 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
return false;
|
||||
}
|
||||
|
||||
public BaseGump FindGump<T>() where T : BaseGump => m_NetState?.Gumps.Find(g => g is T);
|
||||
|
||||
public bool CloseGump<T>() where T : BaseGump
|
||||
{
|
||||
if (m_NetState == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var gump = FindGump<T>();
|
||||
|
||||
if (gump != null)
|
||||
{
|
||||
m_NetState.SendCloseGump(gump.TypeID, 0);
|
||||
m_NetState.RemoveGump(gump);
|
||||
gump.OnServerClose(m_NetState);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void CloseAllGumps()
|
||||
{
|
||||
var ns = m_NetState;
|
||||
|
||||
if (ns.CannotSendPackets())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var gumps = new List<BaseGump>(ns.Gumps);
|
||||
|
||||
ns.ClearGumps();
|
||||
|
||||
foreach (var gump in gumps)
|
||||
{
|
||||
ns.SendCloseGump(gump.TypeID, 0);
|
||||
|
||||
gump.OnServerClose(ns);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public bool HasGump<T>() where T : BaseGump => m_NetState?.Gumps.Exists(g => g is T) ?? false;
|
||||
|
||||
public bool SendGump(BaseGump g)
|
||||
{
|
||||
if (m_NetState == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
g.SendTo(m_NetState);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool SendMenu(IMenu m)
|
||||
{
|
||||
if (m_NetState == null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue