fix: Converts bedroll/insurance gumps to static. (#2096)
This commit is contained in:
parent
b5e3f49d06
commit
ed87df1a61
3 changed files with 193 additions and 226 deletions
|
|
@ -55,23 +55,26 @@ public partial class Bedroll : Item
|
|||
}
|
||||
}
|
||||
|
||||
private class LogoutGump : Gump
|
||||
private class LogoutGump : StaticGump<LogoutGump>
|
||||
{
|
||||
private Bedroll _dedroll;
|
||||
private readonly Bedroll _bedroll;
|
||||
private TimerExecutionToken _closeTimerToken;
|
||||
|
||||
private CampfireEntry _entry;
|
||||
private readonly CampfireEntry _entry;
|
||||
|
||||
public LogoutGump(CampfireEntry entry, Bedroll bedroll) : base(100, 0)
|
||||
{
|
||||
_entry = entry;
|
||||
_dedroll = bedroll;
|
||||
_bedroll = bedroll;
|
||||
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(10.0), CloseGump, out _closeTimerToken);
|
||||
}
|
||||
|
||||
AddBackground(0, 0, 400, 350, 0xA28);
|
||||
protected override void BuildLayout(ref StaticGumpBuilder builder)
|
||||
{
|
||||
builder.AddBackground(0, 0, 400, 350, 0xA28);
|
||||
|
||||
AddHtmlLocalized(100, 20, 200, 35, 1011015); // <center>Logging out via camping</center>
|
||||
builder.AddHtmlLocalized(100, 20, 200, 35, 1011015); // <center>Logging out via camping</center>
|
||||
|
||||
/* Using a bedroll in the safety of a camp will log you out of the game safely.
|
||||
* If this is what you wish to do choose CONTINUE and you will be logged out.
|
||||
|
|
@ -79,13 +82,13 @@ public partial class Bedroll : Item
|
|||
* The camp will remain secure for 10 seconds at which time this window will close
|
||||
* and you not be logged out.
|
||||
*/
|
||||
AddHtmlLocalized(50, 55, 300, 140, 1011016, true, true);
|
||||
builder.AddHtmlLocalized(50, 55, 300, 140, 1011016, true, true);
|
||||
|
||||
AddButton(45, 298, 0xFA5, 0xFA7, 1);
|
||||
AddHtmlLocalized(80, 300, 110, 35, 1011011); // CONTINUE
|
||||
builder.AddButton(45, 298, 0xFA5, 0xFA7, 1);
|
||||
builder.AddHtmlLocalized(80, 300, 110, 35, 1011011); // CONTINUE
|
||||
|
||||
AddButton(200, 298, 0xFA5, 0xFA7, 0);
|
||||
AddHtmlLocalized(235, 300, 110, 35, 1011012); // CANCEL
|
||||
builder.AddButton(200, 298, 0xFA5, 0xFA7, 0);
|
||||
builder.AddHtmlLocalized(235, 300, 110, 35, 1011012); // CANCEL
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, in RelayInfo info)
|
||||
|
|
@ -99,10 +102,10 @@ public partial class Bedroll : Item
|
|||
return;
|
||||
}
|
||||
|
||||
if (info.ButtonID == 1 && _entry.Safe && _dedroll.Parent == null && _dedroll.IsAccessibleTo(pm)
|
||||
&& _dedroll.VerifyMove(pm) && _dedroll.Map == pm.Map && pm.InRange(_dedroll, 2))
|
||||
if (info.ButtonID == 1 && _entry.Safe && _bedroll.Parent == null && _bedroll.IsAccessibleTo(pm)
|
||||
&& _bedroll.VerifyMove(pm) && _bedroll.Map == pm.Map && pm.InRange(_bedroll, 2))
|
||||
{
|
||||
pm.PlaceInBackpack(_dedroll);
|
||||
pm.PlaceInBackpack(_bedroll);
|
||||
|
||||
pm.BedrollLogout = true;
|
||||
sender.Disconnect("Used a bedroll to log out.");
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ public enum CampfireStatus
|
|||
[SerializationGenerator(0, false)]
|
||||
public partial class Campfire : Item
|
||||
{
|
||||
public static readonly int SecureRange = 7;
|
||||
public const int SecureRange = 7;
|
||||
|
||||
private static readonly Dictionary<Mobile, CampfireEntry> m_Table = new();
|
||||
private static readonly Dictionary<Mobile, CampfireEntry> _table = [];
|
||||
|
||||
private readonly List<CampfireEntry> m_Entries;
|
||||
private readonly List<CampfireEntry> _entries;
|
||||
|
||||
private TimerExecutionToken _timerToken;
|
||||
|
||||
|
|
@ -28,8 +28,7 @@ public partial class Campfire : Item
|
|||
Movable = false;
|
||||
Light = LightType.Circle300;
|
||||
|
||||
m_Entries = new List<CampfireEntry>();
|
||||
|
||||
_entries = [];
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), OnTick, out _timerToken);
|
||||
}
|
||||
|
||||
|
|
@ -79,16 +78,12 @@ public partial class Campfire : Item
|
|||
}
|
||||
}
|
||||
|
||||
public static CampfireEntry GetEntry(Mobile player)
|
||||
{
|
||||
m_Table.TryGetValue(player, out var value);
|
||||
return value;
|
||||
}
|
||||
public static CampfireEntry GetEntry(Mobile player) => _table.GetValueOrDefault(player);
|
||||
|
||||
public static void RemoveEntry(CampfireEntry entry)
|
||||
{
|
||||
m_Table.Remove(entry.Player);
|
||||
entry.Fire.m_Entries.Remove(entry);
|
||||
_table.Remove(entry.Player);
|
||||
entry.Fire._entries.Remove(entry);
|
||||
}
|
||||
|
||||
private void OnTick()
|
||||
|
|
@ -114,9 +109,9 @@ public partial class Campfire : Item
|
|||
return;
|
||||
}
|
||||
|
||||
for (var i = m_Entries.Count - 1; i >= 0; i--)
|
||||
for (var i = _entries.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var entry = m_Entries[i];
|
||||
var entry = _entries[i];
|
||||
|
||||
if (!entry.Valid || entry.Player.NetState == null)
|
||||
{
|
||||
|
|
@ -135,8 +130,8 @@ public partial class Campfire : Item
|
|||
{
|
||||
var entry = new CampfireEntry(pm, this);
|
||||
|
||||
m_Table[pm] = entry;
|
||||
m_Entries.Add(entry);
|
||||
_table[pm] = entry;
|
||||
_entries.Add(entry);
|
||||
|
||||
pm.SendLocalizedMessage(500620); // You feel it would take a few moments to secure your camp.
|
||||
}
|
||||
|
|
@ -145,24 +140,23 @@ public partial class Campfire : Item
|
|||
|
||||
private void ClearEntries()
|
||||
{
|
||||
if (m_Entries == null)
|
||||
if (_entries == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var entry in m_Entries)
|
||||
foreach (var entry in _entries)
|
||||
{
|
||||
m_Table.Remove(entry.Player);
|
||||
_table.Remove(entry.Player);
|
||||
}
|
||||
|
||||
m_Entries.Clear();
|
||||
m_Entries.TrimExcess();
|
||||
_entries.Clear();
|
||||
_entries.TrimExcess();
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
_timerToken.Cancel();
|
||||
|
||||
ClearEntries();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue