ModernUO/Projects/UOContent/Engines/Veteran Rewards/Character Statue Maker/CharacterStatueMaker.cs
Kamron Batman 4849c80750
refactor: fold hand-written serializable property setters into field hooks
Converts 113 [SerializableProperty] members whose setters only coerce the
value, reject it, or run post-change side effects into plain
[SerializableField] declarations using allowFieldChange and fieldChanged.
Wire- and schema-neutral: the migration schema regeneration produces zero
changes.

Kept as hand-written properties: custom getters (fallback defaults, lazy or
self-healing reads), virtual/override members, pre-assignment state capture
(durability unscale/scale sandwiches), and setters with exotic semantics
(work on equal assignment, early returns that skip persistence).

Behavioral notes: generated setters skip all work when the incoming value
equals the field, and always MarkDirty on change - a handful of converted
setters previously never marked dirty (their changes only persisted if
something else dirtied the entity) or re-ran side effects on equal
assignment.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-22 18:07:47 -07:00

109 lines
2.7 KiB
C#

using ModernUO.Serialization;
using Server.Engines.VeteranRewards;
using Server.Mobiles;
namespace Server.Items;
[SerializationGenerator(1)]
public partial class CharacterStatueMaker : Item, IRewardItem
{
[InvalidateProperties]
[SerializableField(0)]
[SerializedCommandProperty(AccessLevel.GameMaster)]
private bool _isRewardItem;
public CharacterStatueMaker(StatueType type) : base(0x32F0)
{
_statueType = type;
InvalidateHue();
LootType = LootType.Blessed;
}
public override double DefaultWeight => 5.0;
public override int LabelNumber => 1076173; // Character Statue Maker
[SerializableField(1, fieldChanged: nameof(OnStatueTypeChanged))]
[SerializedCommandProperty(AccessLevel.GameMaster)]
private StatueType _statueType;
private void OnStatueTypeChanged(StatueType oldValue, StatueType newValue)
{
InvalidateHue();
}
public override void OnDoubleClick(Mobile from)
{
if (_isRewardItem && !RewardSystem.CheckIsUsableBy(from, this, new object[] { _statueType }))
{
return;
}
if (IsChildOf(from.Backpack))
{
if (!from.IsBodyMod)
{
from.SendLocalizedMessage(1076194); // Select a place where you would like to put your statue.
from.Target = new CharacterStatueTarget(this, _statueType);
}
else
{
from.SendLocalizedMessage(1073648); // You may only proceed while in your original state...
}
}
else
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
}
public override void GetProperties(IPropertyList list)
{
base.GetProperties(list);
if (_isRewardItem)
{
list.Add(1076222); // 6th Year Veteran Reward
}
}
private void Deserialize(IGenericReader reader, int version)
{
_isRewardItem = reader.ReadBool();
_statueType = (StatueType)reader.ReadInt();
}
public void InvalidateHue()
{
Hue = 0xB8F + (int)_statueType * 4;
}
}
[SerializationGenerator(0)]
public partial class MarbleStatueMaker : CharacterStatueMaker
{
[Constructible]
public MarbleStatueMaker() : base(StatueType.Marble)
{
}
}
[SerializationGenerator(0)]
public partial class JadeStatueMaker : CharacterStatueMaker
{
[Constructible]
public JadeStatueMaker() : base(StatueType.Jade)
{
}
}
[SerializationGenerator(0)]
public partial class BronzeStatueMaker : CharacterStatueMaker
{
[Constructible]
public BronzeStatueMaker() : base(StatueType.Bronze)
{
}
}