From 41efa69b566977d780f745e5b6bc624d559df737 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Fri, 17 Jun 2022 23:26:27 -0700 Subject: [PATCH] fix: Adds OSI candle/torch functionality, codegens lights (#1075) --- Projects/Server/Mobiles/Mobile.cs | 12 +- .../Items/Lights/BaseEquipableLight.cs | 109 ++++++ .../Items/Lights/BaseEquippableLight.cs | 62 --- Projects/UOContent/Items/Lights/BaseLight.cs | 368 +++++++++--------- Projects/UOContent/Items/Lights/Brazier.cs | 43 +- .../UOContent/Items/Lights/BrazierTall.cs | 43 +- Projects/UOContent/Items/Lights/Candelabra.cs | 91 ++--- .../UOContent/Items/Lights/CandelabraStand.cs | 43 +- Projects/UOContent/Items/Lights/Candle.cs | 12 +- .../UOContent/Items/Lights/CandleLarge.cs | 50 +-- Projects/UOContent/Items/Lights/CandleLong.cs | 50 +-- .../UOContent/Items/Lights/CandleShort.cs | 50 +-- .../UOContent/Items/Lights/CandleSkull.cs | 74 +--- Projects/UOContent/Items/Lights/DarkSource.cs | 34 +- .../UOContent/Items/Lights/HangingLantern.cs | 45 +-- .../UOContent/Items/Lights/HeatingStand.cs | 92 ++--- Projects/UOContent/Items/Lights/LampPost1.cs | 45 +-- Projects/UOContent/Items/Lights/LampPost2.cs | 45 +-- Projects/UOContent/Items/Lights/LampPost3.cs | 45 +-- Projects/UOContent/Items/Lights/Lantern.cs | 35 +- .../UOContent/Items/Lights/LightSource.cs | 34 +- .../UOContent/Items/Lights/PaperLantern.cs | 47 +-- .../Items/Lights/RedHangingLantern.cs | 97 ++--- .../Items/Lights/RoundPaperLantern.cs | 47 +-- .../UOContent/Items/Lights/ShojiLantern.cs | 47 +-- Projects/UOContent/Items/Lights/Torch.cs | 12 +- Projects/UOContent/Items/Lights/WallSconce.cs | 105 ++--- Projects/UOContent/Items/Lights/WallTorch.cs | 105 ++--- .../Items/Lights/WhiteHangingLantern.cs | 97 ++--- .../Server.Items.BaseEquipableLight.v0.json | 4 + .../Migrations/Server.Items.BaseLight.v1.json | 43 ++ .../Migrations/Server.Items.Brazier.v0.json | 4 + .../Server.Items.BrazierTall.v0.json | 4 + .../Server.Items.Candelabra.v0.json | 14 + .../Server.Items.CandelabraStand.v0.json | 4 + .../Server.Items.CandleLarge.v0.json | 4 + .../Server.Items.CandleLong.v0.json | 4 + .../Server.Items.CandleShort.v0.json | 4 + .../Server.Items.CandleSkull.v0.json | 4 + .../Server.Items.DarkSource.v0.json | 4 + .../Server.Items.HangingLantern.v0.json | 4 + .../Server.Items.HeatingStand.v0.json | 4 + .../Migrations/Server.Items.LampPost1.v0.json | 4 + .../Migrations/Server.Items.LampPost2.v0.json | 4 + .../Migrations/Server.Items.LampPost3.v0.json | 4 + .../Server.Items.LightSource.v0.json | 4 + .../Server.Items.PaperLantern.v0.json | 4 + .../Server.Items.RedHangingLantern.v0.json | 4 + .../Server.Items.RoundPaperLantern.v0.json | 4 + .../Server.Items.ShojiLantern.v0.json | 4 + .../Server.Items.WallSconce.v0.json | 4 + .../Migrations/Server.Items.WallTorch.v0.json | 4 + .../Server.Items.WhiteHangingLantern.v0.json | 4 + 53 files changed, 865 insertions(+), 1219 deletions(-) create mode 100644 Projects/UOContent/Items/Lights/BaseEquipableLight.cs delete mode 100644 Projects/UOContent/Items/Lights/BaseEquippableLight.cs create mode 100644 Projects/UOContent/Migrations/Server.Items.BaseEquipableLight.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.BaseLight.v1.json create mode 100644 Projects/UOContent/Migrations/Server.Items.Brazier.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.BrazierTall.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.Candelabra.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.CandelabraStand.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.CandleLarge.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.CandleLong.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.CandleShort.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.CandleSkull.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.DarkSource.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.HangingLantern.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.HeatingStand.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.LampPost1.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.LampPost2.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.LampPost3.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.LightSource.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.PaperLantern.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.RedHangingLantern.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.RoundPaperLantern.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.ShojiLantern.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.WallSconce.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.WallTorch.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.WhiteHangingLantern.v0.json diff --git a/Projects/Server/Mobiles/Mobile.cs b/Projects/Server/Mobiles/Mobile.cs index f6c9055a8..c811926af 100644 --- a/Projects/Server/Mobiles/Mobile.cs +++ b/Projects/Server/Mobiles/Mobile.cs @@ -5301,12 +5301,12 @@ namespace Server } } - public static Item LiftItemDupe(Item oldItem, int amount) + public static T LiftItemDupe(T oldItem, int amount) where T : Item { - Item item; + T item; try { - item = oldItem.GetType().CreateInstance(); + item = oldItem.GetType().CreateInstance(); } catch { @@ -5318,6 +5318,9 @@ namespace Server return null; } + var oldAmount = oldItem.Amount; + oldItem.Amount = amount; + item.Visible = oldItem.Visible; item.Movable = oldItem.Movable; item.LootType = oldItem.LootType; @@ -5329,10 +5332,9 @@ namespace Server item.Name = oldItem.Name; item.Weight = oldItem.Weight; - item.Amount = oldItem.Amount - amount; + item.Amount = oldAmount - amount; item.Map = oldItem.Map; - oldItem.Amount = amount; oldItem.OnAfterDuped(item); if (oldItem.Parent is Mobile parentMobile) diff --git a/Projects/UOContent/Items/Lights/BaseEquipableLight.cs b/Projects/UOContent/Items/Lights/BaseEquipableLight.cs new file mode 100644 index 000000000..8e0482cf9 --- /dev/null +++ b/Projects/UOContent/Items/Lights/BaseEquipableLight.cs @@ -0,0 +1,109 @@ +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public abstract partial class BaseEquipableLight : BaseLight +{ + [Constructible] + public BaseEquipableLight(int itemID) : base(itemID) => Layer = Layer.TwoHanded; + + private BaseEquipableLight SplitStack() + { + if (!Stackable || Amount < 2) + { + return null; + } + + var stack = Mobile.LiftItemDupe(this, 1); + stack.BurntOut = BurntOut; + stack.Duration = Duration; + stack.Light = Light; + stack.Protected = Protected; + + return stack; + } + + public override bool OnEquip(Mobile from) + { + if (!base.OnEquip(from)) + { + return false; + } + + var stack = SplitStack(); + if (stack != null && stack.Parent != from.Backpack) + { + if (from.AddToBackpack(stack)) + { + if (this is Candle) + { + from.SendLocalizedMessage(502967); // You put the remaining unlit candles into your backpack. + } + else if (this is Torch) + { + from.SendLocalizedMessage(502970); // You put the remaining unlit torches into your backpack. + } + } + else + { + stack.MoveToWorld(from.Location, from.Map); + } + } + + return true; + } + + public override void Ignite() + { + if (Parent is not Mobile && RootParent is Mobile holder) + { + if (holder.EquipItem(this)) + { + if (this is Candle) + { + holder.SendLocalizedMessage(502969); // You put the candle in your left hand. + } + else if (this is Torch) + { + holder.SendLocalizedMessage(502972); // You put the torch in your left hand. + } + + // No message for lanterns? + } + else + { + SplitStack(); + MoveToWorld(holder.Location, holder.Map); + + if (this is Candle) + { + holder.SendLocalizedMessage(502968); // You cannot hold the candle, so it has been placed at your feet. + } + else if (this is Torch) + { + // 502971 has the wrong message + holder.SendMessage("You cannot hold the torch, so it has been placed at your feet."); + } + + // No message for lanterns? + } + } + else + { + SplitStack(); + } + + base.Ignite(); + } + + public override void OnAdded(IEntity parent) + { + if (Burning && parent is Container) + { + Douse(); + } + + base.OnAdded(parent); + } +} diff --git a/Projects/UOContent/Items/Lights/BaseEquippableLight.cs b/Projects/UOContent/Items/Lights/BaseEquippableLight.cs deleted file mode 100644 index 5310b457c..000000000 --- a/Projects/UOContent/Items/Lights/BaseEquippableLight.cs +++ /dev/null @@ -1,62 +0,0 @@ -namespace Server.Items -{ - public abstract class BaseEquipableLight : BaseLight - { - [Constructible] - public BaseEquipableLight(int itemID) : base(itemID) => Layer = Layer.TwoHanded; - - public BaseEquipableLight(Serial serial) : base(serial) - { - } - - public override void Ignite() - { - if (Parent is not Mobile && RootParent is Mobile holder) - { - if (holder.EquipItem(this)) - { - if (this is Candle) - { - holder.SendLocalizedMessage(502969); // You put the candle in your left hand. - } - else if (this is Torch) - { - holder.SendLocalizedMessage(502971); // You put the torch in your left hand. - } - - base.Ignite(); - } - else - { - holder.SendLocalizedMessage(502449); // You cannot hold this item. - } - } - else - { - base.Ignite(); - } - } - - public override void OnAdded(IEntity parent) - { - if (Burning && parent is Container) - { - Douse(); - } - - base.OnAdded(parent); - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } - } -} diff --git a/Projects/UOContent/Items/Lights/BaseLight.cs b/Projects/UOContent/Items/Lights/BaseLight.cs index eb83b594b..7aa6742d4 100644 --- a/Projects/UOContent/Items/Lights/BaseLight.cs +++ b/Projects/UOContent/Items/Lights/BaseLight.cs @@ -1,233 +1,213 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(1, false)] +public abstract partial class BaseLight : Item { - public abstract class BaseLight : Item + public static readonly bool Burnout = false; + + [SerializableField(0)] + [SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")] + private bool _burntOut; + + // Field 1 + private bool _burning; + + // Field 2 + private TimeSpan _duration = TimeSpan.Zero; + + [SerializableField(3)] + [SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")] + private bool _protected; + + [TimerDrift] + [SerializableField(4, getter: "private", setter: "private")] + private Timer _burnTimer; + + [DeserializeTimerField(4)] + private void DeserializeTimer(TimeSpan delay) { - public static readonly bool Burnout = false; - private bool m_Burning; - private TimeSpan m_Duration = TimeSpan.Zero; - private DateTime m_End; - private Timer m_Timer; - - [Constructible] - public BaseLight(int itemID) : base(itemID) + if (_burning && _duration != TimeSpan.Zero) { + DoTimer(delay); } + } - public BaseLight(Serial serial) : base(serial) + [Constructible] + public BaseLight(int itemID) : base(itemID) + { + } + + public abstract int LitItemID { get; } + + public virtual int UnlitItemID => 0; + public virtual int BurntOutItemID => 0; + + public virtual int LitSound => 0x47; + public virtual int UnlitSound => 0x3be; + public virtual int BurntOutSound => 0x4b8; + + [SerializableField(1)] + [CommandProperty(AccessLevel.GameMaster)] + public bool Burning + { + get => _burning; + set { - } - - public abstract int LitItemID { get; } - - public virtual int UnlitItemID => 0; - public virtual int BurntOutItemID => 0; - - public virtual int LitSound => 0x47; - public virtual int UnlitSound => 0x3be; - public virtual int BurntOutSound => 0x4b8; - - [CommandProperty(AccessLevel.GameMaster)] - public bool Burning - { - get => m_Burning; - set + if (_burning != value) { - if (m_Burning != value) - { - m_Burning = true; - DoTimer(m_Duration); - } + _burning = true; + DoTimer(_duration); + this.MarkDirty(); } } + } - [CommandProperty(AccessLevel.GameMaster)] - public bool BurntOut { get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public bool Protected { get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan Duration + [SerializableField(2)] + [CommandProperty(AccessLevel.GameMaster)] + public TimeSpan Duration + { + get => _duration != TimeSpan.Zero && _burning && _burnTimer != null ? _burnTimer.Next - Core.Now : _duration; + set { - get => m_Duration != TimeSpan.Zero && m_Burning ? m_End - Core.Now : m_Duration; - set => m_Duration = value; + _duration = value; + this.MarkDirty(); + } + } + + public virtual void PlayLitSound() + { + if (LitSound != 0) + { + var loc = GetWorldLocation(); + Effects.PlaySound(loc, Map, LitSound); + } + } + + public virtual void PlayUnlitSound() + { + var sound = UnlitSound; + + if (BurntOut && BurntOutSound != 0) + { + sound = BurntOutSound; } - public virtual void PlayLitSound() + if (sound != 0) { - if (LitSound != 0) - { - var loc = GetWorldLocation(); - Effects.PlaySound(loc, Map, LitSound); - } + var loc = GetWorldLocation(); + Effects.PlaySound(loc, Map, sound); + } + } + + public virtual void Ignite() + { + if (!BurntOut) + { + PlayLitSound(); + + _burning = true; + ItemID = LitItemID; + DoTimer(_duration); + } + } + + public virtual void Douse() + { + _burning = false; + + ItemID = BurntOut && BurntOutItemID != 0 ? BurntOutItemID : UnlitItemID; + + if (BurntOut) + { + _duration = TimeSpan.Zero; + } + else if (_duration != TimeSpan.Zero) + { + _duration = _burnTimer.Next - Core.Now; } - public virtual void PlayUnlitSound() + _burnTimer?.Stop(); + this.MarkDirty(); + + PlayUnlitSound(); + } + + public virtual void Burn() + { + BurntOut = true; + Douse(); + } + + private void DoTimer(TimeSpan delay) + { + _duration = delay; + _burnTimer?.Stop(); + this.MarkDirty(); + + if (delay == TimeSpan.Zero) { - var sound = UnlitSound; - - if (BurntOut && BurntOutSound != 0) - { - sound = BurntOutSound; - } - - if (sound != 0) - { - var loc = GetWorldLocation(); - Effects.PlaySound(loc, Map, sound); - } + return; } - public virtual void Ignite() - { - if (!BurntOut) - { - PlayLitSound(); + _burnTimer = new InternalTimer(this, delay); + _burnTimer.Start(); + this.MarkDirty(); + } - m_Burning = true; - ItemID = LitItemID; - DoTimer(m_Duration); - } + public override void OnDoubleClick(Mobile from) + { + if (_burntOut) + { + return; } - public virtual void Douse() + if (_protected && from.AccessLevel == AccessLevel.Player) { - m_Burning = false; - - if (BurntOut && BurntOutItemID != 0) - { - ItemID = BurntOutItemID; - } - else - { - ItemID = UnlitItemID; - } - - if (BurntOut) - { - m_Duration = TimeSpan.Zero; - } - else if (m_Duration != TimeSpan.Zero) - { - m_Duration = m_End - Core.Now; - } - - m_Timer?.Stop(); - - PlayUnlitSound(); + return; } - public virtual void Burn() + if (!from.InRange(GetWorldLocation(), 2)) + { + return; + } + + if (!_burning) + { + Ignite(); + } + else if (UnlitItemID != 0) { - BurntOut = true; Douse(); } + } - private void DoTimer(TimeSpan delay) + private void Deserialize(IGenericReader reader, int version) + { + _burntOut = reader.ReadBool(); + _burning = reader.ReadBool(); + _duration = reader.ReadTimeSpan(); + _protected = reader.ReadBool(); + + if (_burning && _duration != TimeSpan.Zero) { - m_Duration = delay; - - m_Timer?.Stop(); - - if (delay == TimeSpan.Zero) - { - return; - } - - m_End = Core.Now + delay; - - m_Timer = new InternalTimer(this, delay); - m_Timer.Start(); + DoTimer(reader.ReadDeltaTime() - Core.Now); } + } - public override void OnDoubleClick(Mobile from) + private class InternalTimer : Timer + { + private readonly BaseLight m_Light; + + public InternalTimer(BaseLight light, TimeSpan delay) : base(delay) => m_Light = light; + + protected override void OnTick() { - if (BurntOut) + if (m_Light?.Deleted == false) { - return; - } - - if (Protected && from.AccessLevel == AccessLevel.Player) - { - return; - } - - if (!from.InRange(GetWorldLocation(), 2)) - { - return; - } - - if (m_Burning) - { - if (UnlitItemID != 0) - { - Douse(); - } - } - else - { - Ignite(); - } - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); - writer.Write(BurntOut); - writer.Write(m_Burning); - writer.Write(m_Duration); - writer.Write(Protected); - - if (m_Burning && m_Duration != TimeSpan.Zero) - { - writer.WriteDeltaTime(m_End); - } - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - - switch (version) - { - case 0: - { - BurntOut = reader.ReadBool(); - m_Burning = reader.ReadBool(); - m_Duration = reader.ReadTimeSpan(); - Protected = reader.ReadBool(); - - if (m_Burning && m_Duration != TimeSpan.Zero) - { - DoTimer(reader.ReadDeltaTime() - Core.Now); - } - - break; - } - } - } - - private class InternalTimer : Timer - { - private readonly BaseLight m_Light; - - public InternalTimer(BaseLight light, TimeSpan delay) : base(delay) - { - m_Light = light; - } - - protected override void OnTick() - { - if (m_Light?.Deleted == false) - { - m_Light.Burn(); - } + m_Light.Burn(); } } } diff --git a/Projects/UOContent/Items/Lights/Brazier.cs b/Projects/UOContent/Items/Lights/Brazier.cs index 65b6f8066..56f834c3b 100644 --- a/Projects/UOContent/Items/Lights/Brazier.cs +++ b/Projects/UOContent/Items/Lights/Brazier.cs @@ -1,35 +1,20 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class Brazier : BaseLight { - public class Brazier : BaseLight + [Constructible] + public Brazier() : base(0xE31) { - [Constructible] - public Brazier() : base(0xE31) - { - Movable = false; - Duration = TimeSpan.Zero; // Never burnt out - Burning = true; - Light = LightType.Circle225; - Weight = 20.0; - } - - public Brazier(Serial serial) : base(serial) - { - } - - public override int LitItemID => 0xE31; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + Movable = false; + Duration = TimeSpan.Zero; // Never burnt out + Burning = true; + Light = LightType.Circle225; + Weight = 20.0; } + + public override int LitItemID => 0xE31; } diff --git a/Projects/UOContent/Items/Lights/BrazierTall.cs b/Projects/UOContent/Items/Lights/BrazierTall.cs index 0774217a8..c23945c50 100644 --- a/Projects/UOContent/Items/Lights/BrazierTall.cs +++ b/Projects/UOContent/Items/Lights/BrazierTall.cs @@ -1,35 +1,20 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class BrazierTall : BaseLight { - public class BrazierTall : BaseLight + [Constructible] + public BrazierTall() : base(0x19AA) { - [Constructible] - public BrazierTall() : base(0x19AA) - { - Movable = false; - Duration = TimeSpan.Zero; // Never burnt out - Burning = true; - Light = LightType.Circle300; - Weight = 25.0; - } - - public BrazierTall(Serial serial) : base(serial) - { - } - - public override int LitItemID => 0x19AA; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + Movable = false; + Duration = TimeSpan.Zero; // Never burnt out + Burning = true; + Light = LightType.Circle300; + Weight = 25.0; } + + public override int LitItemID => 0x19AA; } diff --git a/Projects/UOContent/Items/Lights/Candelabra.cs b/Projects/UOContent/Items/Lights/Candelabra.cs index 30d3b98e8..823313f2d 100644 --- a/Projects/UOContent/Items/Lights/Candelabra.cs +++ b/Projects/UOContent/Items/Lights/Candelabra.cs @@ -1,69 +1,44 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class Candelabra : BaseLight, IShipwreckedItem { - public class Candelabra : BaseLight, IShipwreckedItem + [SerializableField(0)] + [SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")] + private bool _isShipwreckedItem; + + [Constructible] + public Candelabra() : base(0xA27) { - [Constructible] - public Candelabra() : base(0xA27) + Duration = TimeSpan.Zero; // Never burnt out + Burning = false; + Light = LightType.Circle225; + Weight = 3.0; + } + + public override int LitItemID => 0xB1D; + public override int UnlitItemID => 0xA27; + + public override void AddNameProperties(IPropertyList list) + { + base.AddNameProperties(list); + + if (IsShipwreckedItem) { - Duration = TimeSpan.Zero; // Never burnt out - Burning = false; - Light = LightType.Circle225; - Weight = 3.0; + list.Add(1041645); // recovered from a shipwreck } + } - public Candelabra(Serial serial) : base(serial) + public override void OnSingleClick(Mobile from) + { + base.OnSingleClick(from); + + if (IsShipwreckedItem) { - } - - public override int LitItemID => 0xB1D; - public override int UnlitItemID => 0xA27; - - [CommandProperty(AccessLevel.GameMaster)] - public bool IsShipwreckedItem { get; set; } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(1); - - writer.Write(IsShipwreckedItem); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - - switch (version) - { - case 1: - { - IsShipwreckedItem = reader.ReadBool(); - break; - } - } - } - - public override void AddNameProperties(IPropertyList list) - { - base.AddNameProperties(list); - - if (IsShipwreckedItem) - { - list.Add(1041645); // recovered from a shipwreck - } - } - - public override void OnSingleClick(Mobile from) - { - base.OnSingleClick(from); - - if (IsShipwreckedItem) - { - LabelTo(from, 1041645); // recovered from a shipwreck - } + LabelTo(from, 1041645); // recovered from a shipwreck } } } diff --git a/Projects/UOContent/Items/Lights/CandelabraStand.cs b/Projects/UOContent/Items/Lights/CandelabraStand.cs index 4f32f5d39..00e49e521 100644 --- a/Projects/UOContent/Items/Lights/CandelabraStand.cs +++ b/Projects/UOContent/Items/Lights/CandelabraStand.cs @@ -1,35 +1,20 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class CandelabraStand : BaseLight { - public class CandelabraStand : BaseLight + [Constructible] + public CandelabraStand() : base(0xA29) { - [Constructible] - public CandelabraStand() : base(0xA29) - { - Duration = TimeSpan.Zero; // Never burnt out - Burning = false; - Light = LightType.Circle225; - Weight = 20.0; - } - - public CandelabraStand(Serial serial) : base(serial) - { - } - - public override int LitItemID => 0xB26; - public override int UnlitItemID => 0xA29; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + Duration = TimeSpan.Zero; // Never burnt out + Burning = false; + Light = LightType.Circle225; + Weight = 20.0; } + + public override int LitItemID => 0xB26; + public override int UnlitItemID => 0xA29; } diff --git a/Projects/UOContent/Items/Lights/Candle.cs b/Projects/UOContent/Items/Lights/Candle.cs index b38bcef4a..8ae12eb43 100644 --- a/Projects/UOContent/Items/Lights/Candle.cs +++ b/Projects/UOContent/Items/Lights/Candle.cs @@ -7,16 +7,10 @@ namespace Server.Items [Constructible] public Candle() : base(0xA28) { - if (Burnout) - { - Duration = TimeSpan.FromMinutes(20); - } - else - { - Duration = TimeSpan.Zero; - } - + Duration = Burnout ? TimeSpan.FromMinutes(20) : TimeSpan.Zero; Burning = false; + + Stackable = true; Light = LightType.Circle150; Weight = 1.0; } diff --git a/Projects/UOContent/Items/Lights/CandleLarge.cs b/Projects/UOContent/Items/Lights/CandleLarge.cs index 9cf17c014..12dfdf188 100644 --- a/Projects/UOContent/Items/Lights/CandleLarge.cs +++ b/Projects/UOContent/Items/Lights/CandleLarge.cs @@ -1,43 +1,21 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class CandleLarge : BaseLight { - public class CandleLarge : BaseLight + [Constructible] + public CandleLarge() : base(0xA26) { - [Constructible] - public CandleLarge() : base(0xA26) - { - if (Burnout) - { - Duration = TimeSpan.FromMinutes(25); - } - else - { - Duration = TimeSpan.Zero; - } + Duration = Burnout ? TimeSpan.FromMinutes(25) : TimeSpan.Zero; - Burning = false; - Light = LightType.Circle150; - Weight = 2.0; - } - - public CandleLarge(Serial serial) : base(serial) - { - } - - public override int LitItemID => 0xB1A; - public override int UnlitItemID => 0xA26; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + Burning = false; + Light = LightType.Circle150; + Weight = 2.0; } + + public override int LitItemID => 0xB1A; + public override int UnlitItemID => 0xA26; } diff --git a/Projects/UOContent/Items/Lights/CandleLong.cs b/Projects/UOContent/Items/Lights/CandleLong.cs index 540550be1..39daca623 100644 --- a/Projects/UOContent/Items/Lights/CandleLong.cs +++ b/Projects/UOContent/Items/Lights/CandleLong.cs @@ -1,43 +1,21 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class CandleLong : BaseLight { - public class CandleLong : BaseLight + [Constructible] + public CandleLong() : base(0x1433) { - [Constructible] - public CandleLong() : base(0x1433) - { - if (Burnout) - { - Duration = TimeSpan.FromMinutes(30); - } - else - { - Duration = TimeSpan.Zero; - } + Duration = Burnout ? TimeSpan.FromMinutes(30) : TimeSpan.Zero; - Burning = false; - Light = LightType.Circle150; - Weight = 1.0; - } - - public CandleLong(Serial serial) : base(serial) - { - } - - public override int LitItemID => 0x1430; - public override int UnlitItemID => 0x1433; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + Burning = false; + Light = LightType.Circle150; + Weight = 1.0; } + + public override int LitItemID => 0x1430; + public override int UnlitItemID => 0x1433; } diff --git a/Projects/UOContent/Items/Lights/CandleShort.cs b/Projects/UOContent/Items/Lights/CandleShort.cs index fd0826f5a..942478f35 100644 --- a/Projects/UOContent/Items/Lights/CandleShort.cs +++ b/Projects/UOContent/Items/Lights/CandleShort.cs @@ -1,43 +1,21 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class CandleShort : BaseLight { - public class CandleShort : BaseLight + [Constructible] + public CandleShort() : base(0x142F) { - [Constructible] - public CandleShort() : base(0x142F) - { - if (Burnout) - { - Duration = TimeSpan.FromMinutes(25); - } - else - { - Duration = TimeSpan.Zero; - } + Duration = Burnout ? TimeSpan.FromMinutes(25) : TimeSpan.Zero; - Burning = false; - Light = LightType.Circle150; - Weight = 1.0; - } - - public CandleShort(Serial serial) : base(serial) - { - } - - public override int LitItemID => 0x142C; - public override int UnlitItemID => 0x142F; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + Burning = false; + Light = LightType.Circle150; + Weight = 1.0; } + + public override int LitItemID => 0x142C; + public override int UnlitItemID => 0x142F; } diff --git a/Projects/UOContent/Items/Lights/CandleSkull.cs b/Projects/UOContent/Items/Lights/CandleSkull.cs index 049a426a3..8cd3a9f21 100644 --- a/Projects/UOContent/Items/Lights/CandleSkull.cs +++ b/Projects/UOContent/Items/Lights/CandleSkull.cs @@ -1,66 +1,22 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class CandleSkull : BaseLight { - public class CandleSkull : BaseLight + [Constructible] + public CandleSkull() : base(0x1853) { - [Constructible] - public CandleSkull() : base(0x1853) - { - if (Burnout) - { - Duration = TimeSpan.FromMinutes(25); - } - else - { - Duration = TimeSpan.Zero; - } + Duration = Burnout ? TimeSpan.FromMinutes(25) : TimeSpan.Zero; - Burning = false; - Light = LightType.Circle150; - Weight = 5.0; - } - - public CandleSkull(Serial serial) : base(serial) - { - } - - public override int LitItemID - { - get - { - if (ItemID is 0x1583 or 0x1854) - { - return 0x1854; - } - - return 0x1858; - } - } - - public override int UnlitItemID - { - get - { - if (ItemID is 0x1853 or 0x1584) - { - return 0x1853; - } - - return 0x1857; - } - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + Burning = false; + Light = LightType.Circle150; + Weight = 5.0; } + + public override int LitItemID => ItemID is 0x1583 or 0x1854 ? 0x1854 : 0x1858; + + public override int UnlitItemID => ItemID is 0x1853 or 0x1584 ? 0x1853 : 0x1857; } diff --git a/Projects/UOContent/Items/Lights/DarkSource.cs b/Projects/UOContent/Items/Lights/DarkSource.cs index 6cf443480..946a6bb12 100644 --- a/Projects/UOContent/Items/Lights/DarkSource.cs +++ b/Projects/UOContent/Items/Lights/DarkSource.cs @@ -1,28 +1,14 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class DarkSource : Item { - public class DarkSource : Item + [Constructible] + public DarkSource() : base(0x1646) { - [Constructible] - public DarkSource() : base(0x1646) - { - Layer = Layer.TwoHanded; - Movable = false; - } - - public DarkSource(Serial serial) : base(serial) - { - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + Layer = Layer.TwoHanded; + Movable = false; } } diff --git a/Projects/UOContent/Items/Lights/HangingLantern.cs b/Projects/UOContent/Items/Lights/HangingLantern.cs index cf4e2fba1..1ae33dcf9 100644 --- a/Projects/UOContent/Items/Lights/HangingLantern.cs +++ b/Projects/UOContent/Items/Lights/HangingLantern.cs @@ -1,36 +1,21 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class HangingLantern : BaseLight { - public class HangingLantern : BaseLight + [Constructible] + public HangingLantern() : base(0xA1D) { - [Constructible] - public HangingLantern() : base(0xA1D) - { - Movable = false; - Duration = TimeSpan.Zero; // Never burnt out - Burning = false; - Light = LightType.Circle300; - Weight = 40.0; - } - - public HangingLantern(Serial serial) : base(serial) - { - } - - public override int LitItemID => 0xA1A; - public override int UnlitItemID => 0xA1D; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + Movable = false; + Duration = TimeSpan.Zero; // Never burnt out + Burning = false; + Light = LightType.Circle300; + Weight = 40.0; } + + public override int LitItemID => 0xA1A; + public override int UnlitItemID => 0xA1D; } diff --git a/Projects/UOContent/Items/Lights/HeatingStand.cs b/Projects/UOContent/Items/Lights/HeatingStand.cs index bfc55fcb1..1b1abe044 100644 --- a/Projects/UOContent/Items/Lights/HeatingStand.cs +++ b/Projects/UOContent/Items/Lights/HeatingStand.cs @@ -1,71 +1,49 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class HeatingStand : BaseLight { - public class HeatingStand : BaseLight + [Constructible] + public HeatingStand() : base(0x1849) { - [Constructible] - public HeatingStand() : base(0x1849) - { - if (Burnout) - { - Duration = TimeSpan.FromMinutes(25); - } - else - { - Duration = TimeSpan.Zero; - } + Duration = Burnout ? TimeSpan.FromMinutes(25) : TimeSpan.Zero; - Burning = false; + Burning = false; + Light = LightType.Empty; + Weight = 1.0; + } + + public override int LitItemID => 0x184A; + public override int UnlitItemID => 0x1849; + + public override void Ignite() + { + base.Ignite(); + + if (ItemID == LitItemID) + { + Light = LightType.Circle150; + } + else if (ItemID == UnlitItemID) + { Light = LightType.Empty; - Weight = 1.0; } + } - public HeatingStand(Serial serial) : base(serial) + public override void Douse() + { + base.Douse(); + + if (ItemID == LitItemID) { + Light = LightType.Circle150; } - - public override int LitItemID => 0x184A; - public override int UnlitItemID => 0x1849; - - public override void Ignite() + else if (ItemID == UnlitItemID) { - base.Ignite(); - - if (ItemID == LitItemID) - { - Light = LightType.Circle150; - } - else if (ItemID == UnlitItemID) - { - Light = LightType.Empty; - } - } - - public override void Douse() - { - base.Douse(); - - if (ItemID == LitItemID) - { - Light = LightType.Circle150; - } - else if (ItemID == UnlitItemID) - { - Light = LightType.Empty; - } - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); + Light = LightType.Empty; } } } diff --git a/Projects/UOContent/Items/Lights/LampPost1.cs b/Projects/UOContent/Items/Lights/LampPost1.cs index 8d9c2bae0..985e6e7b1 100644 --- a/Projects/UOContent/Items/Lights/LampPost1.cs +++ b/Projects/UOContent/Items/Lights/LampPost1.cs @@ -1,36 +1,21 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class LampPost1 : BaseLight { - public class LampPost1 : BaseLight + [Constructible] + public LampPost1() : base(0xB21) { - [Constructible] - public LampPost1() : base(0xB21) - { - Movable = false; - Duration = TimeSpan.Zero; // Never burnt out - Burning = false; - Light = LightType.Circle300; - Weight = 40.0; - } - - public LampPost1(Serial serial) : base(serial) - { - } - - public override int LitItemID => 0xB20; - public override int UnlitItemID => 0xB21; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + Movable = false; + Duration = TimeSpan.Zero; // Never burnt out + Burning = false; + Light = LightType.Circle300; + Weight = 40.0; } + + public override int LitItemID => 0xB20; + public override int UnlitItemID => 0xB21; } diff --git a/Projects/UOContent/Items/Lights/LampPost2.cs b/Projects/UOContent/Items/Lights/LampPost2.cs index e041ea02d..f36bdf4db 100644 --- a/Projects/UOContent/Items/Lights/LampPost2.cs +++ b/Projects/UOContent/Items/Lights/LampPost2.cs @@ -1,36 +1,21 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class LampPost2 : BaseLight { - public class LampPost2 : BaseLight + [Constructible] + public LampPost2() : base(0xB23) { - [Constructible] - public LampPost2() : base(0xB23) - { - Movable = false; - Duration = TimeSpan.Zero; // Never burnt out - Burning = false; - Light = LightType.Circle300; - Weight = 40.0; - } - - public LampPost2(Serial serial) : base(serial) - { - } - - public override int LitItemID => 0xB22; - public override int UnlitItemID => 0xB23; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + Movable = false; + Duration = TimeSpan.Zero; // Never burnt out + Burning = false; + Light = LightType.Circle300; + Weight = 40.0; } + + public override int LitItemID => 0xB22; + public override int UnlitItemID => 0xB23; } diff --git a/Projects/UOContent/Items/Lights/LampPost3.cs b/Projects/UOContent/Items/Lights/LampPost3.cs index 16000c03b..c9cb237a0 100644 --- a/Projects/UOContent/Items/Lights/LampPost3.cs +++ b/Projects/UOContent/Items/Lights/LampPost3.cs @@ -1,36 +1,21 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class LampPost3 : BaseLight { - public class LampPost3 : BaseLight + [Constructible] + public LampPost3() : base(0xb25) { - [Constructible] - public LampPost3() : base(0xb25) - { - Movable = false; - Duration = TimeSpan.Zero; // Never burnt out - Burning = false; - Light = LightType.Circle300; - Weight = 40.0; - } - - public LampPost3(Serial serial) : base(serial) - { - } - - public override int LitItemID => 0xB24; - public override int UnlitItemID => 0xB25; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + Movable = false; + Duration = TimeSpan.Zero; // Never burnt out + Burning = false; + Light = LightType.Circle300; + Weight = 40.0; } + + public override int LitItemID => 0xB24; + public override int UnlitItemID => 0xB25; } diff --git a/Projects/UOContent/Items/Lights/Lantern.cs b/Projects/UOContent/Items/Lights/Lantern.cs index 50635bda3..df38a988c 100644 --- a/Projects/UOContent/Items/Lights/Lantern.cs +++ b/Projects/UOContent/Items/Lights/Lantern.cs @@ -7,14 +7,7 @@ namespace Server.Items [Constructible] public Lantern() : base(0xA25) { - if (Burnout) - { - Duration = TimeSpan.FromMinutes(20); - } - else - { - Duration = TimeSpan.Zero; - } + Duration = Burnout ? TimeSpan.FromMinutes(20) : TimeSpan.Zero; Burning = false; Light = LightType.Circle300; @@ -25,31 +18,9 @@ namespace Server.Items { } - public override int LitItemID - { - get - { - if (ItemID is 0xA15 or 0xA17) - { - return ItemID; - } + public override int LitItemID => ItemID is 0xA15 or 0xA17 ? ItemID : 0xA22; - return 0xA22; - } - } - - public override int UnlitItemID - { - get - { - if (ItemID == 0xA18) - { - return ItemID; - } - - return 0xA25; - } - } + public override int UnlitItemID => ItemID == 0xA18 ? ItemID : 0xA25; public override void Serialize(IGenericWriter writer) { diff --git a/Projects/UOContent/Items/Lights/LightSource.cs b/Projects/UOContent/Items/Lights/LightSource.cs index fb6061ae3..b3a9d1df4 100644 --- a/Projects/UOContent/Items/Lights/LightSource.cs +++ b/Projects/UOContent/Items/Lights/LightSource.cs @@ -1,28 +1,14 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class LightSource : Item { - public class LightSource : Item + [Constructible] + public LightSource() : base(0x1647) { - [Constructible] - public LightSource() : base(0x1647) - { - Layer = Layer.TwoHanded; - Movable = false; - } - - public LightSource(Serial serial) : base(serial) - { - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + Layer = Layer.TwoHanded; + Movable = false; } } diff --git a/Projects/UOContent/Items/Lights/PaperLantern.cs b/Projects/UOContent/Items/Lights/PaperLantern.cs index eabaaa561..681bf7705 100644 --- a/Projects/UOContent/Items/Lights/PaperLantern.cs +++ b/Projects/UOContent/Items/Lights/PaperLantern.cs @@ -1,37 +1,22 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[Flippable] +[SerializationGenerator(0, false)] +public partial class PaperLantern : BaseLight { - [Flippable] - public class PaperLantern : BaseLight + [Constructible] + public PaperLantern() : base(0x24BE) { - [Constructible] - public PaperLantern() : base(0x24BE) - { - Movable = true; - Duration = TimeSpan.Zero; // Never burnt out - Burning = false; - Light = LightType.Circle150; - Weight = 3.0; - } - - public PaperLantern(Serial serial) : base(serial) - { - } - - public override int LitItemID => 0x24BD; - public override int UnlitItemID => 0x24BE; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + Movable = true; + Duration = TimeSpan.Zero; // Never burnt out + Burning = false; + Light = LightType.Circle150; + Weight = 3.0; } + + public override int LitItemID => 0x24BD; + public override int UnlitItemID => 0x24BE; } diff --git a/Projects/UOContent/Items/Lights/RedHangingLantern.cs b/Projects/UOContent/Items/Lights/RedHangingLantern.cs index 216fbd1be..3643c2e12 100644 --- a/Projects/UOContent/Items/Lights/RedHangingLantern.cs +++ b/Projects/UOContent/Items/Lights/RedHangingLantern.cs @@ -1,74 +1,37 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[Flippable] +[SerializationGenerator(0, false)] +public partial class RedHangingLantern : BaseLight { - [Flippable] - public class RedHangingLantern : BaseLight + [Constructible] + public RedHangingLantern() : base(0x24C2) { - [Constructible] - public RedHangingLantern() : base(0x24C2) + Movable = true; + Duration = TimeSpan.Zero; // Never burnt out + Burning = false; + Light = LightType.Circle300; + Weight = 3.0; + } + + public override int LitItemID => ItemID == 0x24C2 ? 0x24C1 : 0x24C3; + + public override int UnlitItemID => ItemID == 0x24C1 ? 0x24C2 : 0x24C4; + + public void Flip() + { + Light = LightType.Circle300; + + ItemID = ItemID switch { - Movable = true; - Duration = TimeSpan.Zero; // Never burnt out - Burning = false; - Light = LightType.Circle300; - Weight = 3.0; - } - - public RedHangingLantern(Serial serial) : base(serial) - { - } - - public override int LitItemID - { - get - { - if (ItemID == 0x24C2) - { - return 0x24C1; - } - - return 0x24C3; - } - } - - public override int UnlitItemID - { - get - { - if (ItemID == 0x24C1) - { - return 0x24C2; - } - - return 0x24C4; - } - } - - public void Flip() - { - Light = LightType.Circle300; - - ItemID = ItemID switch - { - 0x24C2 => 0x24C4, - 0x24C1 => 0x24C3, - 0x24C4 => 0x24C2, - 0x24C3 => 0x24C1, - _ => ItemID - }; - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + 0x24C2 => 0x24C4, + 0x24C1 => 0x24C3, + 0x24C4 => 0x24C2, + 0x24C3 => 0x24C1, + _ => ItemID + }; } } diff --git a/Projects/UOContent/Items/Lights/RoundPaperLantern.cs b/Projects/UOContent/Items/Lights/RoundPaperLantern.cs index 54c732995..3b028a0d3 100644 --- a/Projects/UOContent/Items/Lights/RoundPaperLantern.cs +++ b/Projects/UOContent/Items/Lights/RoundPaperLantern.cs @@ -1,37 +1,22 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[Flippable] +[SerializationGenerator(0, false)] +public partial class RoundPaperLantern : BaseLight { - [Flippable] - public class RoundPaperLantern : BaseLight + [Constructible] + public RoundPaperLantern() : base(0x24CA) { - [Constructible] - public RoundPaperLantern() : base(0x24CA) - { - Movable = true; - Duration = TimeSpan.Zero; // Never burnt out - Burning = false; - Light = LightType.Circle150; - Weight = 3.0; - } - - public RoundPaperLantern(Serial serial) : base(serial) - { - } - - public override int LitItemID => 0x24C9; - public override int UnlitItemID => 0x24CA; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + Movable = true; + Duration = TimeSpan.Zero; // Never burnt out + Burning = false; + Light = LightType.Circle150; + Weight = 3.0; } + + public override int LitItemID => 0x24C9; + public override int UnlitItemID => 0x24CA; } diff --git a/Projects/UOContent/Items/Lights/ShojiLantern.cs b/Projects/UOContent/Items/Lights/ShojiLantern.cs index 979566251..56aa5d81e 100644 --- a/Projects/UOContent/Items/Lights/ShojiLantern.cs +++ b/Projects/UOContent/Items/Lights/ShojiLantern.cs @@ -1,37 +1,22 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[Flippable] +[SerializationGenerator(0, false)] +public partial class ShojiLantern : BaseLight { - [Flippable] - public class ShojiLantern : BaseLight + [Constructible] + public ShojiLantern() : base(0x24BC) { - [Constructible] - public ShojiLantern() : base(0x24BC) - { - Movable = true; - Duration = TimeSpan.Zero; // Never burnt out - Burning = false; - Light = LightType.Circle150; - Weight = 3.0; - } - - public ShojiLantern(Serial serial) : base(serial) - { - } - - public override int LitItemID => 0x24BB; - public override int UnlitItemID => 0x24BC; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + Movable = true; + Duration = TimeSpan.Zero; // Never burnt out + Burning = false; + Light = LightType.Circle150; + Weight = 3.0; } + + public override int LitItemID => 0x24BB; + public override int UnlitItemID => 0x24BC; } diff --git a/Projects/UOContent/Items/Lights/Torch.cs b/Projects/UOContent/Items/Lights/Torch.cs index 8e4eecbf5..083d2ec55 100644 --- a/Projects/UOContent/Items/Lights/Torch.cs +++ b/Projects/UOContent/Items/Lights/Torch.cs @@ -8,16 +8,10 @@ namespace Server.Items [Constructible] public Torch() : base(0xF6B) { - if (Burnout) - { - Duration = TimeSpan.FromMinutes(30); - } - else - { - Duration = TimeSpan.Zero; - } - + Duration = Burnout ? TimeSpan.FromMinutes(30) : TimeSpan.Zero; Burning = false; + + Stackable = true; Light = LightType.Circle300; Weight = 1.0; } diff --git a/Projects/UOContent/Items/Lights/WallSconce.cs b/Projects/UOContent/Items/Lights/WallSconce.cs index 6967d91f0..3268efcaa 100644 --- a/Projects/UOContent/Items/Lights/WallSconce.cs +++ b/Projects/UOContent/Items/Lights/WallSconce.cs @@ -1,81 +1,42 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[Flippable] +[SerializationGenerator(0, false)] +public partial class WallSconce : BaseLight { - [Flippable] - public class WallSconce : BaseLight + [Constructible] + public WallSconce() : base(0x9FB) { - [Constructible] - public WallSconce() : base(0x9FB) + Movable = false; + Duration = TimeSpan.Zero; // Never burnt out + Burning = false; + Light = LightType.WestBig; + Weight = 3.0; + } + + public override int LitItemID => ItemID == 0x9FB ? 0x9FD : 0xA02; + + public override int UnlitItemID => ItemID == 0x9FD ? 0x9FB : 0xA00; + + public void Flip() + { + Light = Light switch { - Movable = false; - Duration = TimeSpan.Zero; // Never burnt out - Burning = false; - Light = LightType.WestBig; - Weight = 3.0; - } + LightType.WestBig => LightType.NorthBig, + LightType.NorthBig => LightType.WestBig, + _ => Light + }; - public WallSconce(Serial serial) : base(serial) + ItemID = ItemID switch { - } - - public override int LitItemID - { - get - { - if (ItemID == 0x9FB) - { - return 0x9FD; - } - - return 0xA02; - } - } - - public override int UnlitItemID - { - get - { - if (ItemID == 0x9FD) - { - return 0x9FB; - } - - return 0xA00; - } - } - - public void Flip() - { - if (Light == LightType.WestBig) - { - Light = LightType.NorthBig; - } - else if (Light == LightType.NorthBig) - { - Light = LightType.WestBig; - } - - ItemID = ItemID switch - { - 0x9FB => 0xA00, - 0x9FD => 0xA02, - 0xA00 => 0x9FB, - 0xA02 => 0x9FD, - _ => ItemID - }; - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + 0x9FB => 0xA00, + 0x9FD => 0xA02, + 0xA00 => 0x9FB, + 0xA02 => 0x9FD, + _ => ItemID + }; } } diff --git a/Projects/UOContent/Items/Lights/WallTorch.cs b/Projects/UOContent/Items/Lights/WallTorch.cs index 084ac8ce5..968b0bbae 100644 --- a/Projects/UOContent/Items/Lights/WallTorch.cs +++ b/Projects/UOContent/Items/Lights/WallTorch.cs @@ -1,81 +1,42 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[Flippable] +[SerializationGenerator(0, false)] +public partial class WallTorch : BaseLight { - [Flippable] - public class WallTorch : BaseLight + [Constructible] + public WallTorch() : base(0xA05) { - [Constructible] - public WallTorch() : base(0xA05) + Movable = false; + Duration = TimeSpan.Zero; // Never burnt out + Burning = false; + Light = LightType.WestBig; + Weight = 3.0; + } + + public override int LitItemID => ItemID == 0xA05 ? 0xA07 : 0xA0C; + + public override int UnlitItemID => ItemID == 0xA07 ? 0xA05 : 0xA0A; + + public void Flip() + { + Light = Light switch { - Movable = false; - Duration = TimeSpan.Zero; // Never burnt out - Burning = false; - Light = LightType.WestBig; - Weight = 3.0; - } + LightType.WestBig => LightType.NorthBig, + LightType.NorthBig => LightType.WestBig, + _ => Light + }; - public WallTorch(Serial serial) : base(serial) + ItemID = ItemID switch { - } - - public override int LitItemID - { - get - { - if (ItemID == 0xA05) - { - return 0xA07; - } - - return 0xA0C; - } - } - - public override int UnlitItemID - { - get - { - if (ItemID == 0xA07) - { - return 0xA05; - } - - return 0xA0A; - } - } - - public void Flip() - { - if (Light == LightType.WestBig) - { - Light = LightType.NorthBig; - } - else if (Light == LightType.NorthBig) - { - Light = LightType.WestBig; - } - - ItemID = ItemID switch - { - 0xA05 => 0xA0A, - 0xA07 => 0xA0C, - 0xA0A => 0xA05, - 0xA0C => 0xA07, - _ => ItemID - }; - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + 0xA05 => 0xA0A, + 0xA07 => 0xA0C, + 0xA0A => 0xA05, + 0xA0C => 0xA07, + _ => ItemID + }; } } diff --git a/Projects/UOContent/Items/Lights/WhiteHangingLantern.cs b/Projects/UOContent/Items/Lights/WhiteHangingLantern.cs index ee21e7458..7d62bde96 100644 --- a/Projects/UOContent/Items/Lights/WhiteHangingLantern.cs +++ b/Projects/UOContent/Items/Lights/WhiteHangingLantern.cs @@ -1,74 +1,37 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[Flippable] +[SerializationGenerator(0, false)] +public partial class WhiteHangingLantern : BaseLight { - [Flippable] - public class WhiteHangingLantern : BaseLight + [Constructible] + public WhiteHangingLantern() : base(0x24C6) { - [Constructible] - public WhiteHangingLantern() : base(0x24C6) + Movable = true; + Duration = TimeSpan.Zero; // Never burnt out + Burning = false; + Light = LightType.Circle300; + Weight = 3.0; + } + + public override int LitItemID => ItemID == 0x24C6 ? 0x24C5 : 0x24C7; + + public override int UnlitItemID => ItemID == 0x24C5 ? 0x24C6 : 0x24C8; + + public void Flip() + { + Light = LightType.Circle300; + + ItemID = ItemID switch { - Movable = true; - Duration = TimeSpan.Zero; // Never burnt out - Burning = false; - Light = LightType.Circle300; - Weight = 3.0; - } - - public WhiteHangingLantern(Serial serial) : base(serial) - { - } - - public override int LitItemID - { - get - { - if (ItemID == 0x24C6) - { - return 0x24C5; - } - - return 0x24C7; - } - } - - public override int UnlitItemID - { - get - { - if (ItemID == 0x24C5) - { - return 0x24C6; - } - - return 0x24C8; - } - } - - public void Flip() - { - Light = LightType.Circle300; - - ItemID = ItemID switch - { - 0x24C6 => 0x24C8, - 0x24C5 => 0x24C7, - 0x24C8 => 0x24C6, - 0x24C7 => 0x24C5, - _ => ItemID - }; - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - writer.Write(0); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - var version = reader.ReadInt(); - } + 0x24C6 => 0x24C8, + 0x24C5 => 0x24C7, + 0x24C8 => 0x24C6, + 0x24C7 => 0x24C5, + _ => ItemID + }; } } diff --git a/Projects/UOContent/Migrations/Server.Items.BaseEquipableLight.v0.json b/Projects/UOContent/Migrations/Server.Items.BaseEquipableLight.v0.json new file mode 100644 index 000000000..83e2e509b --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.BaseEquipableLight.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.BaseEquipableLight" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.BaseLight.v1.json b/Projects/UOContent/Migrations/Server.Items.BaseLight.v1.json new file mode 100644 index 000000000..ca43118d1 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.BaseLight.v1.json @@ -0,0 +1,43 @@ +{ + "version": 1, + "type": "Server.Items.BaseLight", + "properties": [ + { + "name": "BurntOut", + "type": "bool", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + }, + { + "name": "Burning", + "type": "bool", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + }, + { + "name": "Duration", + "type": "System.TimeSpan", + "rule": "PrimitiveTypeMigrationRule" + }, + { + "name": "Protected", + "type": "bool", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + }, + { + "name": "BurnTimer", + "type": "Server.Timer", + "rule": "TimerMigrationRule", + "ruleArguments": [ + "@TimerDrift" + ] + } + ] +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.Brazier.v0.json b/Projects/UOContent/Migrations/Server.Items.Brazier.v0.json new file mode 100644 index 000000000..e241f90d9 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.Brazier.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.Brazier" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.BrazierTall.v0.json b/Projects/UOContent/Migrations/Server.Items.BrazierTall.v0.json new file mode 100644 index 000000000..f89dcfcdf --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.BrazierTall.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.BrazierTall" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.Candelabra.v0.json b/Projects/UOContent/Migrations/Server.Items.Candelabra.v0.json new file mode 100644 index 000000000..8c30f6c7f --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.Candelabra.v0.json @@ -0,0 +1,14 @@ +{ + "version": 0, + "type": "Server.Items.Candelabra", + "properties": [ + { + "name": "IsShipwreckedItem", + "type": "bool", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + } + ] +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.CandelabraStand.v0.json b/Projects/UOContent/Migrations/Server.Items.CandelabraStand.v0.json new file mode 100644 index 000000000..f66380218 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.CandelabraStand.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.CandelabraStand" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.CandleLarge.v0.json b/Projects/UOContent/Migrations/Server.Items.CandleLarge.v0.json new file mode 100644 index 000000000..4a2b3da8d --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.CandleLarge.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.CandleLarge" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.CandleLong.v0.json b/Projects/UOContent/Migrations/Server.Items.CandleLong.v0.json new file mode 100644 index 000000000..2bf422d2e --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.CandleLong.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.CandleLong" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.CandleShort.v0.json b/Projects/UOContent/Migrations/Server.Items.CandleShort.v0.json new file mode 100644 index 000000000..9e7c7864c --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.CandleShort.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.CandleShort" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.CandleSkull.v0.json b/Projects/UOContent/Migrations/Server.Items.CandleSkull.v0.json new file mode 100644 index 000000000..28174b43d --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.CandleSkull.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.CandleSkull" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.DarkSource.v0.json b/Projects/UOContent/Migrations/Server.Items.DarkSource.v0.json new file mode 100644 index 000000000..1f66b7fa7 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.DarkSource.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.DarkSource" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.HangingLantern.v0.json b/Projects/UOContent/Migrations/Server.Items.HangingLantern.v0.json new file mode 100644 index 000000000..e356f97fb --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.HangingLantern.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.HangingLantern" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.HeatingStand.v0.json b/Projects/UOContent/Migrations/Server.Items.HeatingStand.v0.json new file mode 100644 index 000000000..256c5e950 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.HeatingStand.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.HeatingStand" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.LampPost1.v0.json b/Projects/UOContent/Migrations/Server.Items.LampPost1.v0.json new file mode 100644 index 000000000..a71ae5f05 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.LampPost1.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.LampPost1" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.LampPost2.v0.json b/Projects/UOContent/Migrations/Server.Items.LampPost2.v0.json new file mode 100644 index 000000000..3c6a06aa3 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.LampPost2.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.LampPost2" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.LampPost3.v0.json b/Projects/UOContent/Migrations/Server.Items.LampPost3.v0.json new file mode 100644 index 000000000..f31c4e975 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.LampPost3.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.LampPost3" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.LightSource.v0.json b/Projects/UOContent/Migrations/Server.Items.LightSource.v0.json new file mode 100644 index 000000000..dc3adc368 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.LightSource.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.LightSource" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.PaperLantern.v0.json b/Projects/UOContent/Migrations/Server.Items.PaperLantern.v0.json new file mode 100644 index 000000000..f06c1c07a --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.PaperLantern.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.PaperLantern" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.RedHangingLantern.v0.json b/Projects/UOContent/Migrations/Server.Items.RedHangingLantern.v0.json new file mode 100644 index 000000000..7e48a84f6 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.RedHangingLantern.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.RedHangingLantern" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.RoundPaperLantern.v0.json b/Projects/UOContent/Migrations/Server.Items.RoundPaperLantern.v0.json new file mode 100644 index 000000000..70715fb8f --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.RoundPaperLantern.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.RoundPaperLantern" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.ShojiLantern.v0.json b/Projects/UOContent/Migrations/Server.Items.ShojiLantern.v0.json new file mode 100644 index 000000000..68d7d19a0 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.ShojiLantern.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.ShojiLantern" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.WallSconce.v0.json b/Projects/UOContent/Migrations/Server.Items.WallSconce.v0.json new file mode 100644 index 000000000..d0283988d --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.WallSconce.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.WallSconce" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.WallTorch.v0.json b/Projects/UOContent/Migrations/Server.Items.WallTorch.v0.json new file mode 100644 index 000000000..f552e5e58 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.WallTorch.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.WallTorch" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.WhiteHangingLantern.v0.json b/Projects/UOContent/Migrations/Server.Items.WhiteHangingLantern.v0.json new file mode 100644 index 000000000..06213191a --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.WhiteHangingLantern.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.WhiteHangingLantern" +} \ No newline at end of file