diff --git a/Projects/Application/Application.cs b/Projects/Application/Application.cs
index 28964f02f..28c3aeda1 100644
--- a/Projects/Application/Application.cs
+++ b/Projects/Application/Application.cs
@@ -1,6 +1,5 @@
using System.Diagnostics;
using System.Reflection;
-using System.Threading;
namespace Server;
diff --git a/Projects/Server.Tests/Fixtures/ServerFixture.cs b/Projects/Server.Tests/Fixtures/ServerFixture.cs
index 38b4a4c97..b57248286 100644
--- a/Projects/Server.Tests/Fixtures/ServerFixture.cs
+++ b/Projects/Server.Tests/Fixtures/ServerFixture.cs
@@ -1,7 +1,5 @@
using System;
-using System.Diagnostics;
using System.Reflection;
-using System.Threading;
namespace Server.Tests;
diff --git a/Projects/Server.Tests/Tests/Network/Packets/Outgoing/GumpPackets.cs b/Projects/Server.Tests/Tests/Network/Packets/Outgoing/GumpPackets.cs
index d0b8aa069..2620bba2b 100644
--- a/Projects/Server.Tests/Tests/Network/Packets/Outgoing/GumpPackets.cs
+++ b/Projects/Server.Tests/Tests/Network/Packets/Outgoing/GumpPackets.cs
@@ -1,7 +1,6 @@
using System;
using System.Buffers;
using System.Collections.Generic;
-using System.IO.Compression;
using System.Text;
using Server.Compression;
using Server.Gumps;
diff --git a/Projects/Server/Events/EventSink.cs b/Projects/Server/Events/EventSink.cs
index 846779b10..129e256e7 100644
--- a/Projects/Server/Events/EventSink.cs
+++ b/Projects/Server/Events/EventSink.cs
@@ -14,8 +14,6 @@
*************************************************************************/
using System;
-using System.Collections.Generic;
-using Server.Network;
namespace Server;
diff --git a/Projects/Server/Items/VirtualCheck.cs b/Projects/Server/Items/VirtualCheck.cs
index 6adb3cd47..a4362d84c 100644
--- a/Projects/Server/Items/VirtualCheck.cs
+++ b/Projects/Server/Items/VirtualCheck.cs
@@ -13,7 +13,6 @@
* along with this program. If not, see . *
*************************************************************************/
-using System.Drawing;
using ModernUO.Serialization;
using Server.Gumps;
using Server.Network;
diff --git a/Projects/UOContent.Tests/Tests/Multis/Houses/HousePackets.cs b/Projects/UOContent.Tests/Tests/Multis/Houses/HousePackets.cs
index 109e53b7a..2290178a7 100644
--- a/Projects/UOContent.Tests/Tests/Multis/Houses/HousePackets.cs
+++ b/Projects/UOContent.Tests/Tests/Multis/Houses/HousePackets.cs
@@ -1,7 +1,6 @@
using System;
using System.Buffers;
using System.IO;
-using System.IO.Compression;
using Server.Compression;
namespace Server.Network
diff --git a/Projects/UOContent/Items/Misc/GumpToggleItems.cs b/Projects/UOContent/Items/Misc/GumpToggleItems.cs
new file mode 100644
index 000000000..f8c92ea16
--- /dev/null
+++ b/Projects/UOContent/Items/Misc/GumpToggleItems.cs
@@ -0,0 +1,75 @@
+using Server.Gumps;
+using Server.Network;
+
+namespace Server.Items;
+
+public interface IGumpToggleItem
+{
+ public bool IsLockedDown { get; }
+ public bool TurnedOn { get; set; }
+}
+
+public sealed class TurnOnGump : TurnOnOffGump
+{
+ public TurnOnGump(IGumpToggleItem item) : base(item)
+ {
+ }
+
+ protected override void BuildLayout(ref StaticGumpBuilder builder)
+ {
+ base.BuildLayout(ref builder);
+
+ builder.AddHtmlLocalized(45, 20, 300, 35, 1011034); // Activate this item
+ }
+}
+
+public sealed class TurnOffGump : TurnOnOffGump
+{
+ public TurnOffGump(IGumpToggleItem item) : base(item)
+ {
+ }
+
+ protected override void BuildLayout(ref StaticGumpBuilder builder)
+ {
+ base.BuildLayout(ref builder);
+
+ builder.AddHtmlLocalized(45, 20, 300, 35, 1011035); // Deactivate this item
+ }
+}
+
+public abstract class TurnOnOffGump : StaticGump where T : TurnOnOffGump
+{
+ protected readonly IGumpToggleItem _item;
+
+ public TurnOnOffGump(IGumpToggleItem item) : base(150, 200) => _item = item;
+
+ protected override void BuildLayout(ref StaticGumpBuilder builder)
+ {
+ builder.AddBackground(0, 0, 300, 150, 0xA28);
+
+ builder.AddButton(40, 53, 0xFA5, 0xFA7, 1);
+ builder.AddHtmlLocalized(80, 55, 65, 35, 1011036); // OKAY
+
+ builder.AddButton(150, 53, 0xFA5, 0xFA7, 0);
+ builder.AddHtmlLocalized(190, 55, 100, 35, 1011012); // CANCEL
+ }
+
+ public override void OnResponse(NetState sender, in RelayInfo info)
+ {
+ var from = sender.Mobile;
+
+ if (info.ButtonID != 1)
+ {
+ from.SendLocalizedMessage(502694); // Cancelled action.
+ return;
+ }
+
+ var newValue = !_item.TurnedOn;
+ _item.TurnedOn = newValue;
+
+ if (newValue && !_item.IsLockedDown)
+ {
+ from.SendLocalizedMessage(502693); // Remember, this only works when locked down.
+ }
+ }
+}
diff --git a/Projects/UOContent/Items/Misc/WindChimes.cs b/Projects/UOContent/Items/Misc/WindChimes.cs
index 2c9bbcc36..022f6516e 100644
--- a/Projects/UOContent/Items/Misc/WindChimes.cs
+++ b/Projects/UOContent/Items/Misc/WindChimes.cs
@@ -1,12 +1,10 @@
using ModernUO.Serialization;
-using Server.Gumps;
using Server.Multis;
-using Server.Network;
namespace Server.Items;
[SerializationGenerator(0, false)]
-public abstract partial class BaseWindChimes : Item
+public abstract partial class BaseWindChimes : Item, IGumpToggleItem
{
[InvalidateProperties]
[SerializableField(0)]
@@ -46,55 +44,22 @@ public override void GetProperties(IPropertyList list)
}
}
- public bool IsOwner(Mobile mob) => BaseHouse.FindHouseAt(this)?.IsOwner(mob) == true;
+ public bool HasAccess(Mobile mob) => mob.AccessLevel >= AccessLevel.GameMaster ||
+ BaseHouse.FindHouseAt(this)?.IsOwner(mob) == true;
public override void OnDoubleClick(Mobile from)
{
- if (IsOwner(from))
- {
- from.SendGump(new OnOffGump(this));
- }
- else
+ if (!HasAccess(from))
{
from.SendLocalizedMessage(502691); // You must be the owner to use this.
}
- }
-
- private class OnOffGump : Gump
- {
- private readonly BaseWindChimes m_Chimes;
-
- public OnOffGump(BaseWindChimes chimes) : base(150, 200)
+ else if (TurnedOn)
{
- m_Chimes = chimes;
-
- AddBackground(0, 0, 300, 150, 0xA28);
- AddHtmlLocalized(45, 20, 300, 35, chimes.TurnedOn ? 1011035 : 1011034); // [De]Activate this item
- AddButton(40, 53, 0xFA5, 0xFA7, 1);
- AddHtmlLocalized(80, 55, 65, 35, 1011036); // OKAY
- AddButton(150, 53, 0xFA5, 0xFA7, 0);
- AddHtmlLocalized(190, 55, 100, 35, 1011012); // CANCEL
+ from.SendGump(new TurnOffGump(this));
}
-
- public override void OnResponse(NetState sender, in RelayInfo info)
+ else
{
- var from = sender.Mobile;
-
- if (info.ButtonID == 1)
- {
- var newValue = !m_Chimes.TurnedOn;
-
- m_Chimes.TurnedOn = newValue;
-
- if (newValue && !m_Chimes.IsLockedDown)
- {
- from.SendLocalizedMessage(502693); // Remember, this only works when locked down.
- }
- }
- else
- {
- from.SendLocalizedMessage(502694); // Cancelled action.
- }
+ from.SendGump(new TurnOnGump(this));
}
}
}
diff --git a/Projects/UOContent/Items/Special/MonsterStatuette.cs b/Projects/UOContent/Items/Special/MonsterStatuette.cs
index 36f3ceded..2f7dd6752 100644
--- a/Projects/UOContent/Items/Special/MonsterStatuette.cs
+++ b/Projects/UOContent/Items/Special/MonsterStatuette.cs
@@ -1,9 +1,6 @@
-using System;
using ModernUO.Serialization;
using Server.Engines.VeteranRewards;
-using Server.Gumps;
using Server.Multis;
-using Server.Network;
namespace Server.Items;
@@ -53,55 +50,55 @@ public enum MonsterStatuetteType
public class MonsterStatuetteInfo
{
- private static readonly MonsterStatuetteInfo[] m_Table =
- {
- /* Crocodile */ new(1041249, 0x20DA, 660),
- /* Daemon */ new(1041250, 0x20D3, 357),
- /* Dragon */ new(1041251, 0x20D6, 362),
- /* EarthElemental */ new(1041252, 0x20D7, 268),
- /* Ettin */ new(1041253, 0x20D8, 367),
- /* Gargoyle */ new(1041254, 0x20D9, 372),
- /* Gorilla */ new(1041255, 0x20F5, 158),
- /* Lich */ new(1041256, 0x20F8, 1001),
- /* Lizardman */ new(1041257, 0x20DE, 417),
- /* Ogre */ new(1041258, 0x20DF, 427),
- /* Orc */ new(1041259, 0x20E0, 1114),
- /* Ratman */ new(1041260, 0x20E3, 437),
- /* Skeleton */ new(1041261, 0x20E7, 1165),
- /* Troll */ new(1041262, 0x20E9, 461),
- /* Cow */ new(1041263, 0x2103, 120),
- /* Zombie */ new(1041264, 0x20EC, 471),
- /* Llama */ new(1041265, 0x20F6, 1011),
- /* Ophidian */ new(1049742, 0x2133, 634),
- /* Reaper */ new(1049743, 0x20FA, 442),
- /* Mongbat */ new(1049744, 0x20F9, 422),
- /* Gazer */ new(1049768, 0x20F4, 377),
- /* FireElemental */ new(1049769, 0x20F3, 838),
- /* Wolf */ new(1049770, 0x2122, 229),
- /* Phillip's Steed */ new(1063488, 0x3FFE, 168),
- /* Seahorse */ new(1070819, 0x25BA, 138),
- /* Harrower */ new(1080520, 0x25BB, new[] { 0x289, 0x28A, 0x28B }),
- /* Efreet */ new(1080521, 0x2590, 0x300),
- /* Slime */ new(1015246, 0x20E8, 456),
- /* PlagueBeast */ new(1029747, 0x2613, 0x1BF),
- /* RedDeath */ new(1094932, 0x2617, Array.Empty()),
- /* Spider */ new(1029668, 0x25C4, 1170),
- /* OphidianArchMage */ new(1029641, 0x25A9, 639),
- /* OphidianWarrior */ new(1029645, 0x25AD, 634),
- /* OphidianKnight */ new(1029642, 0x25aa, 634),
- /* OphidianMage */ new(1029643, 0x25ab, 639),
- /* DreadHorn */ new(1031651, 0x2D83, 0xA8),
- /* Minotaur */ new(1031657, 0x2D89, 0x596),
- /* Black Cat */ new(1096928, 0x4688, 0x69),
- /* HalloweenGhoul */ new(1076782, 0x2109, 0x482),
- /* Santa */ new(1097968, 0x4A98, 0x669)
- };
+ private static readonly MonsterStatuetteInfo[] _table =
+ [
+ /* Crocodile */new MonsterStatuetteInfo(1041249, 0x20DA, 660),
+ /* Daemon */ new MonsterStatuetteInfo(1041250, 0x20D3, 357),
+ /* Dragon */ new MonsterStatuetteInfo(1041251, 0x20D6, 362),
+ /* EarthElemental */ new MonsterStatuetteInfo(1041252, 0x20D7, 268),
+ /* Ettin */ new MonsterStatuetteInfo(1041253, 0x20D8, 367),
+ /* Gargoyle */ new MonsterStatuetteInfo(1041254, 0x20D9, 372),
+ /* Gorilla */ new MonsterStatuetteInfo(1041255, 0x20F5, 158),
+ /* Lich */ new MonsterStatuetteInfo(1041256, 0x20F8, 1001),
+ /* Lizardman */ new MonsterStatuetteInfo(1041257, 0x20DE, 417),
+ /* Ogre */ new MonsterStatuetteInfo(1041258, 0x20DF, 427),
+ /* Orc */ new MonsterStatuetteInfo(1041259, 0x20E0, 1114),
+ /* Ratman */ new MonsterStatuetteInfo(1041260, 0x20E3, 437),
+ /* Skeleton */ new MonsterStatuetteInfo(1041261, 0x20E7, 1165),
+ /* Troll */ new MonsterStatuetteInfo(1041262, 0x20E9, 461),
+ /* Cow */ new MonsterStatuetteInfo(1041263, 0x2103, 120),
+ /* Zombie */ new MonsterStatuetteInfo(1041264, 0x20EC, 471),
+ /* Llama */ new MonsterStatuetteInfo(1041265, 0x20F6, 1011),
+ /* Ophidian */ new MonsterStatuetteInfo(1049742, 0x2133, 634),
+ /* Reaper */ new MonsterStatuetteInfo(1049743, 0x20FA, 442),
+ /* Mongbat */ new MonsterStatuetteInfo(1049744, 0x20F9, 422),
+ /* Gazer */ new MonsterStatuetteInfo(1049768, 0x20F4, 377),
+ /* FireElemental */ new MonsterStatuetteInfo(1049769, 0x20F3, 838),
+ /* Wolf */ new MonsterStatuetteInfo(1049770, 0x2122, 229),
+ /* Phillip's Steed */ new MonsterStatuetteInfo(1063488, 0x3FFE, 168),
+ /* Seahorse */ new MonsterStatuetteInfo(1070819, 0x25BA, 138),
+ /* Harrower */ new MonsterStatuetteInfo(1080520, 0x25BB, [0x289, 0x28A, 0x28B]),
+ /* Efreet */ new MonsterStatuetteInfo(1080521, 0x2590, 0x300),
+ /* Slime */ new MonsterStatuetteInfo(1015246, 0x20E8, 456),
+ /* PlagueBeast */ new MonsterStatuetteInfo(1029747, 0x2613, 0x1BF),
+ /* RedDeath */ new MonsterStatuetteInfo(1094932, 0x2617, []),
+ /* Spider */ new MonsterStatuetteInfo(1029668, 0x25C4, 1170),
+ /* OphidianArchMage */ new MonsterStatuetteInfo(1029641, 0x25A9, 639),
+ /* OphidianWarrior */ new MonsterStatuetteInfo(1029645, 0x25AD, 634),
+ /* OphidianKnight */ new MonsterStatuetteInfo(1029642, 0x25aa, 634),
+ /* OphidianMage */ new MonsterStatuetteInfo(1029643, 0x25ab, 639),
+ /* DreadHorn */ new MonsterStatuetteInfo(1031651, 0x2D83, 0xA8),
+ /* Minotaur */ new MonsterStatuetteInfo(1031657, 0x2D89, 0x596),
+ /* Black Cat */ new MonsterStatuetteInfo(1096928, 0x4688, 0x69),
+ /* HalloweenGhoul */ new MonsterStatuetteInfo(1076782, 0x2109, 0x482),
+ /* Santa */ new MonsterStatuetteInfo(1097968, 0x4A98, 0x669)
+ ];
public MonsterStatuetteInfo(int labelNumber, int itemID, int baseSoundID)
{
LabelNumber = labelNumber;
ItemID = itemID;
- Sounds = new[] { baseSoundID, baseSoundID + 1, baseSoundID + 2, baseSoundID + 3, baseSoundID + 4 };
+ Sounds = [baseSoundID, baseSoundID + 1, baseSoundID + 2, baseSoundID + 3, baseSoundID + 4];
}
public MonsterStatuetteInfo(int labelNumber, int itemID, int[] sounds)
@@ -121,17 +118,17 @@ public static MonsterStatuetteInfo GetInfo(MonsterStatuetteType type)
{
var v = (int)type;
- if (v < 0 || v >= m_Table.Length)
+ if (v < 0 || v >= _table.Length)
{
v = 0;
}
- return m_Table[v];
+ return _table[v];
}
}
[SerializationGenerator(0, false)]
-public partial class MonsterStatuette : Item, IRewardItem
+public partial class MonsterStatuette : Item, IRewardItem, IGumpToggleItem
{
[InvalidateProperties]
[SerializableField(1)]
@@ -203,13 +200,16 @@ public override void OnMovement(Mobile m, Point3D oldLocation)
base.OnMovement(m, oldLocation);
}
+ private static readonly object[] _typeArgs = new object[1];
+
public override void GetProperties(IPropertyList list)
{
base.GetProperties(list);
if (Core.ML && IsRewardItem)
{
- list.Add(RewardSystem.GetRewardYearLabel(this, new object[] { _type })); // X Year Veteran Reward
+ _typeArgs[0] = _type;
+ list.Add(RewardSystem.GetRewardYearLabel(this, _typeArgs)); // X Year Veteran Reward
}
if (_turnedOn)
@@ -222,58 +222,22 @@ public override void GetProperties(IPropertyList list)
}
}
- public bool IsOwner(Mobile mob) => BaseHouse.FindHouseAt(this)?.IsOwner(mob) == true;
+ public bool HasAccess(Mobile mob) => mob.AccessLevel >= AccessLevel.GameMaster ||
+ BaseHouse.FindHouseAt(this)?.IsOwner(mob) == true;
public override void OnDoubleClick(Mobile from)
{
- if (IsOwner(from))
- {
- var onOffGump = new OnOffGump(this);
- from.SendGump(onOffGump);
- }
- else
+ if (!HasAccess(from))
{
from.SendLocalizedMessage(502691); // You must be the owner to use this.
}
- }
-
- private class OnOffGump : Gump
- {
- private readonly MonsterStatuette m_Statuette;
-
- public OnOffGump(MonsterStatuette statuette) : base(150, 200)
+ else if (TurnedOn)
{
- m_Statuette = statuette;
-
- AddBackground(0, 0, 300, 150, 0xA28);
-
- AddHtmlLocalized(45, 20, 300, 35, statuette.TurnedOn ? 1011035 : 1011034); // [De]Activate this item
-
- AddButton(40, 53, 0xFA5, 0xFA7, 1);
- AddHtmlLocalized(80, 55, 65, 35, 1011036); // OKAY
-
- AddButton(150, 53, 0xFA5, 0xFA7, 0);
- AddHtmlLocalized(190, 55, 100, 35, 1011012); // CANCEL
+ from.SendGump(new TurnOffGump(this));
}
-
- public override void OnResponse(NetState sender, in RelayInfo info)
+ else
{
- var from = sender.Mobile;
-
- if (info.ButtonID == 1)
- {
- var newValue = !m_Statuette.TurnedOn;
- m_Statuette.TurnedOn = newValue;
-
- if (newValue && !m_Statuette.IsLockedDown)
- {
- from.SendLocalizedMessage(502693); // Remember, this only works when locked down.
- }
- }
- else
- {
- from.SendLocalizedMessage(502694); // Cancelled action.
- }
+ from.SendGump(new TurnOnGump(this));
}
}
}
diff --git a/Projects/UOContent/Misc/CrashGuard.cs b/Projects/UOContent/Misc/CrashGuard.cs
index e2245fd04..5273ae070 100644
--- a/Projects/UOContent/Misc/CrashGuard.cs
+++ b/Projects/UOContent/Misc/CrashGuard.cs
@@ -1,5 +1,4 @@
using System;
-using System.Diagnostics;
using System.IO;
using Server.Accounting;
using Server.Logging;