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:
Kamron Batman 2024-08-09 19:07:32 -07:00 • committed by GitHub
parent 40d99f6d1c
commit 8282b00ca2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
246 changed files with 1722 additions and 1383 deletions

View file

@ -135,9 +135,9 @@ namespace Server.Engines.ConPVP
string title = move switch
{
NinjaMove => "Bushido",
NinjaMove => "Bushido",
SamuraiMove => "Ninjitsu",
_ => null
_ => null
};
if (title == null || name == null || Ruleset.GetOption(title, name))
@ -199,15 +199,15 @@ namespace Server.Engines.ConPVP
case MagerySpell magerySpell:
title = magerySpell.Circle switch
{
SpellCircle.First => "1st Circle",
SpellCircle.Second => "2nd Circle",
SpellCircle.Third => "3rd Circle",
SpellCircle.Fourth => "4th Circle",
SpellCircle.Fifth => "5th Circle",
SpellCircle.Sixth => "6th Circle",
SpellCircle.First => "1st Circle",
SpellCircle.Second => "2nd Circle",
SpellCircle.Third => "3rd Circle",
SpellCircle.Fourth => "4th Circle",
SpellCircle.Fifth => "5th Circle",
SpellCircle.Sixth => "6th Circle",
SpellCircle.Seventh => "7th Circle",
SpellCircle.Eighth => "8th Circle",
_ => null
SpellCircle.Eighth => "8th Circle",
_ => null
};
option = magerySpell.Name;
@ -1431,7 +1431,6 @@ namespace Server.Engines.ConPVP
if (prefs != null)
{
e.Mobile.CloseGump<PreferencesGump>();
e.Mobile.SendGump(new PreferencesGump(e.Mobile, prefs));
}
}
@ -1542,23 +1541,18 @@ namespace Server.Engines.ConPVP
p.Nullify(pl);
pm.DuelPlayer = null;
var ns = init.NetState;
if (ns != null)
foreach (var g in init.GetAllGumps())
{
foreach (var g in ns.Gumps)
if (g is ParticipantGump pg && pg.Participant == p)
{
if (g is ParticipantGump pg && pg.Participant == p)
{
init.SendGump(new ParticipantGump(init, dc, p));
break;
}
init.SendGump(new ParticipantGump(init, dc, p));
break;
}
if (g is DuelContextGump dcg && dcg.Context == dc)
{
init.SendGump(new DuelContextGump(init, dc));
break;
}
if (g is DuelContextGump dcg && dcg.Context == dc)
{
init.SendGump(new DuelContextGump(init, dc));
break;
}
}
}
@ -1580,34 +1574,29 @@ namespace Server.Engines.ConPVP
p.Nullify(pl);
pm.DuelPlayer = null;
var ns = init.NetState;
var send = true;
if (ns != null)
foreach (var g in init.GetAllGumps())
{
var send = true;
foreach (var g in ns.Gumps)
if (g is ParticipantGump pg && pg.Participant == p)
{
if (g is ParticipantGump pg && pg.Participant == p)
{
init.SendGump(new ParticipantGump(init, dc, p));
send = false;
break;
}
if (g is DuelContextGump dcg && dcg.Context == dc)
{
init.SendGump(new DuelContextGump(init, dc));
send = false;
break;
}
init.SendGump(new ParticipantGump(init, dc, p));
send = false;
break;
}
if (send)
if (g is DuelContextGump dcg && dcg.Context == dc)
{
init.SendGump(new DuelContextGump(init, dc));
send = false;
break;
}
}
if (send)
{
init.SendGump(new DuelContextGump(init, dc));
}
}
}
else
@ -1629,34 +1618,29 @@ namespace Server.Engines.ConPVP
p.Nullify(pl);
pm.DuelPlayer = null;
var ns = init.NetState;
var send = true;
if (ns != null)
foreach (var g in init.GetAllGumps())
{
var send = true;
foreach (var g in ns.Gumps)
if (g is ParticipantGump pg && pg.Participant == p)
{
if (g is ParticipantGump pg && pg.Participant == p)
{
init.SendGump(new ParticipantGump(init, dc, p));
send = false;
break;
}
if (g is DuelContextGump dcg && dcg.Context == dc)
{
init.SendGump(new DuelContextGump(init, dc));
send = false;
break;
}
init.SendGump(new ParticipantGump(init, dc, p));
send = false;
break;
}
if (send)
if (g is DuelContextGump dcg && dcg.Context == dc)
{
init.SendGump(new DuelContextGump(init, dc));
send = false;
break;
}
}
if (send)
{
init.SendGump(new DuelContextGump(init, dc));
}
}
}
}
@ -1714,13 +1698,15 @@ namespace Server.Engines.ConPVP
public void CloseAllGumps(DuelPlayer pl)
{
pl.Mobile.CloseGump<BeginGump>();
pl.Mobile.CloseGump<DuelContextGump>();
pl.Mobile.CloseGump<ParticipantGump>();
pl.Mobile.CloseGump<PickRulesetGump>();
pl.Mobile.CloseGump<ReadyGump>();
pl.Mobile.CloseGump<ReadyUpGump>();
pl.Mobile.CloseGump<RulesetGump>();
var gumps = pl.Mobile.GetGumps();
gumps.Close<BeginGump>();
gumps.Close<DuelContextGump>();
gumps.Close<ParticipantGump>();
gumps.Close<PickRulesetGump>();
gumps.Close<ReadyGump>();
gumps.Close<ReadyUpGump>();
gumps.Close<RulesetGump>();
}
public void CloseAllGumps()
@ -1799,9 +1785,11 @@ namespace Server.Engines.ConPVP
}
// Close all of them?
mob.CloseGump<DuelContextGump>();
mob.CloseGump<ReadyUpGump>();
mob.CloseGump<ReadyGump>();
var gumps = mob.GetGumps();
gumps.Close<DuelContextGump>();
gumps.Close<ReadyUpGump>();
gumps.Close<ReadyGump>();
}
}
@ -2194,10 +2182,12 @@ namespace Server.Engines.ConPVP
{
if (count == 10)
{
mob.CloseGump<ReadyGump>();
mob.CloseGump<ReadyUpGump>();
mob.CloseGump<BeginGump>();
mob.SendGump(new BeginGump(count));
var gumps = mob.GetGumps();
gumps.Close<ReadyGump>();
gumps.Close<ReadyUpGump>();
gumps.Close<BeginGump>();
gumps.Send(new BeginGump(count));
}
mob.Frozen = true;
@ -2256,8 +2246,7 @@ namespace Server.Engines.ConPVP
if (mob != null && m_Tournament == null)
{
mob.CloseGump<ReadyUpGump>();
mob.SendGump(new ReadyUpGump(mob, this));
mob.SendGump(new ReadyUpGump(mob, this), true);
}
}
}
@ -2512,8 +2501,7 @@ namespace Server.Engines.ConPVP
{
if (m_Tournament == null)
{
mob.CloseGump<ReadyGump>();
mob.SendGump(new ReadyGump(mob, this, count));
mob.SendGump(new ReadyGump(mob, this, count), true);
}
}
else