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>
161 lines
3.3 KiB
C#
161 lines
3.3 KiB
C#
using System;
|
|
using ModernUO.Serialization;
|
|
using Server.Targeting;
|
|
|
|
namespace Server.Items;
|
|
|
|
[SerializationGenerator(0, false)]
|
|
public partial class Dough : Item
|
|
{
|
|
[Constructible]
|
|
public Dough() : base(0x103d)
|
|
{
|
|
Stackable = Core.ML;
|
|
}
|
|
|
|
public override double DefaultWeight => 1.0;
|
|
}
|
|
|
|
[SerializationGenerator(0, false)]
|
|
public partial class SweetDough : Item
|
|
{
|
|
[Constructible]
|
|
public SweetDough() : base(0x103d)
|
|
{
|
|
Stackable = Core.ML;
|
|
Hue = 150;
|
|
}
|
|
|
|
public override double DefaultWeight => 1.0;
|
|
public override int LabelNumber => 1041340; // sweet dough
|
|
}
|
|
|
|
[SerializationGenerator(0, false)]
|
|
public partial class JarHoney : Item
|
|
{
|
|
[Constructible]
|
|
public JarHoney() : base(0x9ec)
|
|
{
|
|
Stackable = true;
|
|
}
|
|
|
|
public override double DefaultWeight => 1.0;
|
|
}
|
|
|
|
[SerializationGenerator(0, false)]
|
|
public partial class BowlFlour : Item
|
|
{
|
|
[Constructible]
|
|
public BowlFlour() : base(0xa1e)
|
|
{
|
|
}
|
|
|
|
public override double DefaultWeight => 1.0;
|
|
}
|
|
|
|
[SerializationGenerator(0, false)]
|
|
public partial class WoodenBowl : Item
|
|
{
|
|
[Constructible]
|
|
public WoodenBowl() : base(0x15f8)
|
|
{
|
|
}
|
|
|
|
public override double DefaultWeight => 1.0;
|
|
}
|
|
|
|
[TypeAlias("Server.Items.SackFlourOpen")]
|
|
[SerializationGenerator(0, false)]
|
|
public partial class SackFlour : Item, IHasQuantity
|
|
{
|
|
[Constructible]
|
|
public SackFlour() : base(0x1039)
|
|
{
|
|
_quantity = 20;
|
|
}
|
|
|
|
public override double DefaultWeight => 5.0;
|
|
|
|
[SerializableField(0, fieldChanged: nameof(OnQuantityChanged), allowFieldChange: nameof(AllowQuantityChange))]
|
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
|
private int _quantity;
|
|
|
|
private bool AllowQuantityChange(ref int value)
|
|
{
|
|
value = Math.Min(20, Math.Max(0, value));
|
|
return true;
|
|
}
|
|
|
|
private void OnQuantityChanged(int oldValue, int newValue)
|
|
{
|
|
if (_quantity == 0)
|
|
{
|
|
Delete();
|
|
}
|
|
else if (_quantity < 20 && ItemID is 0x1039 or 0x1045)
|
|
{
|
|
++ItemID;
|
|
}
|
|
}
|
|
|
|
public override void OnDoubleClick(Mobile from)
|
|
{
|
|
if (Movable && ItemID is 0x1039 or 0x1045)
|
|
{
|
|
++ItemID;
|
|
}
|
|
}
|
|
}
|
|
|
|
[SerializationGenerator(0, false)]
|
|
public partial class Eggshells : Item
|
|
{
|
|
[Constructible]
|
|
public Eggshells() : base(0x9b4)
|
|
{
|
|
}
|
|
|
|
public override double DefaultWeight => 0.5;
|
|
}
|
|
|
|
[SerializationGenerator(0, false)]
|
|
public partial class WheatSheaf : Item
|
|
{
|
|
[Constructible]
|
|
public WheatSheaf(int amount = 1) : base(7869)
|
|
{
|
|
Stackable = true;
|
|
Amount = amount;
|
|
}
|
|
|
|
public override double DefaultWeight => 1.0;
|
|
|
|
public override void OnDoubleClick(Mobile from)
|
|
{
|
|
if (Movable)
|
|
{
|
|
from.BeginTarget(4, false, TargetFlags.None, OnTarget);
|
|
}
|
|
}
|
|
|
|
public virtual void OnTarget(Mobile from, object obj)
|
|
{
|
|
if (obj is AddonComponent addon)
|
|
{
|
|
obj = addon.Addon;
|
|
}
|
|
|
|
if (obj is IFlourMill mill)
|
|
{
|
|
var needs = mill.MaxFlour - mill.CurFlour;
|
|
|
|
if (needs > Amount)
|
|
{
|
|
needs = Amount;
|
|
}
|
|
|
|
mill.CurFlour += needs;
|
|
Consume(needs);
|
|
}
|
|
}
|
|
}
|