feat: adopt serialization generator v4 (field-side linkage, anchored timers) (#2586)

## Summary

Adopts ModernUO.Serialization 4.0.0 across the engine. Three commits, reviewable independently:

1. **Package + tool bump to 4.0.0** (`Server.csproj`, `UOContent.csproj`, `dotnet-tools.json`).
2. **Timers → `[DeserializeTimer]`** — the 8 drifting timers (BaseLight, TreasureMapChest, MarkContainer, FillableContainer, DeathRobe, DecayedCorpse, Corpse, BaseEscortable) now store their next tick as **anchored time**: server downtime no longer consumes the remaining delay, and idle-world saves are byte-stable. This changes their wire format, so each class bumps its serialization version with a `MigrateFrom` that replays the old delta-time read through the migration schema (the new `vN.json` files carry `@AnchoredTimer`; the old ones keep `@TimerDrift`, which the generator reads forever). The 2 wall-clock timers (Aquarium, FountainOfLife) keep their exact format via `wallClock: true` — no bump. Restart methods drop their `TimeSpan.MinValue` sentinel checks: v4 invokes them **only when a timer was actually running at save**.
3. **Linkage → field-side declarations** — 175 conversions across 25 files: `[SerializableFieldSaveFlag(order)]`/`[SerializableFieldDefault(order)]` become `[SaveFlag(nameof(...), nameof(...))]` on the field, and `[SerializableFieldChanged(order)]` becomes the `fieldChanged:` argument of `[SerializableField]`. **Wire-neutral: zero migration schemas changed.**

## Verification

- Solution builds with **0 errors, 0 warnings**; all three 4.0.0 packages verified indexed on nuget.org (no local feed needed).
- **835 + 708 tests green.**
- Generated output inspected: old-version content structs replay `ReadDeltaTime` (e.g. `V3Content.DecayTimerNext = reader.ReadDeltaTime()`), current versions write/read anchored time with the gated restart, and the wall-clock classes emit byte-identical `Write`/`ReadDateTime` framing.
- Schema tool run is committed (CI's `git diff --exit-code` schema check passes): exactly the 8 expected new `vN.json` files, nothing else touched.
- The conversion was scripted with a class-scoped resolver (order → same-class `[SerializableField(order)]`/`[SerializableProperty(order)]`); it planned 175/175 with zero ambiguities before applying.

## Notes

- New `MigrateFrom`s use the content structs' provided `XxxDelay` property, matching the pre-existing idiom in Corpse's and TreasureMapChest's older migrations.
- Follow-up candidate (separate PR, wire-neutral, any time): fold the ~150 eligible hand-written `[SerializableProperty]` setters (clamps, post-change side effects) down to `[SerializableField]` with `allowFieldChange`/`fieldChanged` hooks.
This commit is contained in:
Kamron Batman 2026-08-22 17:54:02 -07:00 committed by GitHub
parent 126a10ce53
commit 73f9688083
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 667 additions and 278 deletions

View file

@ -3,7 +3,7 @@
"isRoot": true, "isRoot": true,
"tools": { "tools": {
"modernuoschemagenerator": { "modernuoschemagenerator": {
"version": "3.0.0", "version": "4.0.0",
"commands": [ "commands": [
"ModernUOSchemaGenerator" "ModernUOSchemaGenerator"
] ]

View file

@ -44,10 +44,10 @@ public partial class Container : Item
internal int _version; internal int _version;
[SerializableField(3)] [SerializableField(3)]
[SaveFlag(nameof(ShouldSerializeLiftOverride))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private bool _liftOverride; private bool _liftOverride;
[SerializableFieldSaveFlag(3)]
private bool ShouldSerializeLiftOverride() => _liftOverride; private bool ShouldSerializeLiftOverride() => _liftOverride;
public Container(int itemID) : base(itemID) public Container(int itemID) : base(itemID)
@ -84,6 +84,7 @@ public partial class Container : Item
[EncodedInt] [EncodedInt]
[SerializableProperty(0)] [SerializableProperty(0)]
[SaveFlag(nameof(ShouldSerializeMaxItems), nameof(MaxItemsDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int MaxItems public int MaxItems
{ {
@ -96,14 +97,13 @@ public partial class Container : Item
} }
} }
[SerializableFieldSaveFlag(0)]
private bool ShouldSerializeMaxItems() => _maxItems != -1; private bool ShouldSerializeMaxItems() => _maxItems != -1;
[SerializableFieldDefault(0)]
private int MaxItemsDefaultValue() => -1; private int MaxItemsDefaultValue() => -1;
[EncodedInt] [EncodedInt]
[SerializableProperty(1)] [SerializableProperty(1)]
[SaveFlag(nameof(ShouldSerializeGumpId), nameof(GumpIDDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int GumpID public int GumpID
{ {
@ -115,14 +115,13 @@ public partial class Container : Item
} }
} }
[SerializableFieldSaveFlag(1)]
private bool ShouldSerializeGumpId() => _gumpID != -1; private bool ShouldSerializeGumpId() => _gumpID != -1;
[SerializableFieldDefault(1)]
private int GumpIDDefaultValue() => -1; private int GumpIDDefaultValue() => -1;
[EncodedInt] [EncodedInt]
[SerializableProperty(2)] [SerializableProperty(2)]
[SaveFlag(nameof(ShouldSerializeDropSound), nameof(DropSoundDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int DropSound public int DropSound
{ {
@ -134,10 +133,8 @@ public partial class Container : Item
} }
} }
[SerializableFieldSaveFlag(2)]
private bool ShouldSerializeDropSound() => _dropSound != -1; private bool ShouldSerializeDropSound() => _dropSound != -1;
[SerializableFieldDefault(2)]
private int DropSoundDefaultValue() => -1; private int DropSoundDefaultValue() => -1;
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]

View file

@ -21,17 +21,15 @@ namespace Server;
[SerializationGenerator(0)] [SerializationGenerator(0)]
public partial class ResistanceMod : MobileMod public partial class ResistanceMod : MobileMod
{ {
[SerializableField(0)] [SerializableField(0, fieldChanged: nameof(OnTypeChanged))]
private ResistanceType _type; private ResistanceType _type;
[SerializableFieldChanged(0)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private void OnTypeChanged(ResistanceType oldValue, ResistanceType newValue) => Owner?.UpdateResistances(); private void OnTypeChanged(ResistanceType oldValue, ResistanceType newValue) => Owner?.UpdateResistances();
[SerializableField(1)] [SerializableField(1, fieldChanged: nameof(OnOffsetChanged))]
private int _offset; private int _offset;
[SerializableFieldChanged(1)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private void OnOffsetChanged(int oldValue, int newValue) => Owner?.UpdateResistances(); private void OnOffsetChanged(int oldValue, int newValue) => Owner?.UpdateResistances();

View file

@ -21,33 +21,29 @@ namespace Server;
[SerializationGenerator(0)] [SerializationGenerator(0)]
public abstract partial class SkillMod : MobileMod public abstract partial class SkillMod : MobileMod
{ {
[SerializableField(0)] [SerializableField(0, fieldChanged: nameof(OnObeyCapChanged))]
private bool _obeyCap; private bool _obeyCap;
[SerializableFieldChanged(0)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private void OnObeCapChanged(bool oldValue, bool newValue) => Owner?.Skills[_skill]?.Update(); private void OnObeyCapChanged(bool oldValue, bool newValue) => Owner?.Skills[_skill]?.Update();
[SerializableField(1)] [SerializableField(1, fieldChanged: nameof(OnSkillChanged))]
private SkillName _skill; private SkillName _skill;
[SerializableFieldChanged(1)]
private void OnSkillChanged(SkillName oldValue, SkillName newValue) private void OnSkillChanged(SkillName oldValue, SkillName newValue)
{ {
Owner?.Skills[newValue]?.Update(); Owner?.Skills[newValue]?.Update();
Owner?.Skills[oldValue]?.Update(); Owner?.Skills[oldValue]?.Update();
} }
[SerializableField(2)] [SerializableField(2, fieldChanged: nameof(OnRelativeChanged))]
private bool _relative; private bool _relative;
[SerializableFieldChanged(2)]
private void OnRelativeChanged(bool oldValue, bool newValue) => Owner?.Skills[_skill]?.Update(); private void OnRelativeChanged(bool oldValue, bool newValue) => Owner?.Skills[_skill]?.Update();
[SerializableField(3)] [SerializableField(3, fieldChanged: nameof(OnValueChanged))]
private double _value; private double _value;
[SerializableFieldChanged(3)]
private void OnValueChanged(double oldValue, double newValue) => Owner?.Skills[_skill]?.Update(); private void OnValueChanged(double oldValue, double newValue) => Owner?.Skills[_skill]?.Update();
public SkillMod(Mobile owner) : base(owner) public SkillMod(Mobile owner) : base(owner)

View file

@ -39,8 +39,8 @@
<PackageReference Include="LibDeflate.Bindings" Version="1.0.4" /> <PackageReference Include="LibDeflate.Bindings" Version="1.0.4" />
<PackageReference Include="System.IO.Hashing" Version="10.0.11" /> <PackageReference Include="System.IO.Hashing" Version="10.0.11" />
<PackageReference Include="ModernUO.Serialization.Annotations" Version="3.0.0" /> <PackageReference Include="ModernUO.Serialization.Annotations" Version="4.0.0" />
<PackageReference Include="ModernUO.Serialization.Generator" Version="3.0.0" PrivateAssets="all" /> <PackageReference Include="ModernUO.Serialization.Generator" Version="4.0.0" PrivateAssets="all" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<AdditionalFiles Include="Migrations/*.v*.json" /> <AdditionalFiles Include="Migrations/*.v*.json" />

View file

@ -6,27 +6,27 @@ namespace Server.Engines.BulkOrders;
public partial class BOBFilter public partial class BOBFilter
{ {
[SerializableField(0)] [SerializableField(0)]
[SaveFlag(nameof(ShouldSerializeType))]
private int _type; private int _type;
[SerializableFieldSaveFlag(0)]
private bool ShouldSerializeType() => _type != 0; private bool ShouldSerializeType() => _type != 0;
[SerializableField(1)] [SerializableField(1)]
[SaveFlag(nameof(ShouldSerializeQuality))]
private int _quality; private int _quality;
[SerializableFieldSaveFlag(1)]
private bool ShouldSerializeQuality() => _quality != 0; private bool ShouldSerializeQuality() => _quality != 0;
[SerializableField(2)] [SerializableField(2)]
[SaveFlag(nameof(ShouldSerializeMaterial))]
private int _material; private int _material;
[SerializableFieldSaveFlag(2)]
private bool ShouldSerializeMaterial() => _material != 0; private bool ShouldSerializeMaterial() => _material != 0;
[SerializableField(3)] [SerializableField(3)]
[SaveFlag(nameof(ShouldSerializeQuantity))]
private int _quantity; private int _quantity;
[SerializableFieldSaveFlag(3)]
private bool ShouldSerializeQuantity() => _quantity != 0; private bool ShouldSerializeQuantity() => _quantity != 0;
private void Deserialize(IGenericReader reader, int version) private void Deserialize(IGenericReader reader, int version)

View file

@ -51,9 +51,9 @@ public partial class ChampionTitleContext
} }
[SerializableField(1)] [SerializableField(1)]
[SaveFlag(nameof(ShouldSerializeAbyss))]
private ChampionTitle _abyss; private ChampionTitle _abyss;
[SerializableFieldSaveFlag(1)]
private bool ShouldSerializeAbyss() => _abyss != null; private bool ShouldSerializeAbyss() => _abyss != null;
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
@ -71,9 +71,9 @@ public partial class ChampionTitleContext
} }
[SerializableField(2)] [SerializableField(2)]
[SaveFlag(nameof(ShouldSerializeArachnid))]
private ChampionTitle _arachnid; private ChampionTitle _arachnid;
[SerializableFieldSaveFlag(2)]
private bool ShouldSerializeArachnid() => _arachnid != null; private bool ShouldSerializeArachnid() => _arachnid != null;
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
@ -91,9 +91,9 @@ public partial class ChampionTitleContext
} }
[SerializableField(3)] [SerializableField(3)]
[SaveFlag(nameof(ShouldSerializeColdBlood))]
private ChampionTitle _coldBlood; private ChampionTitle _coldBlood;
[SerializableFieldSaveFlag(3)]
private bool ShouldSerializeColdBlood() => _coldBlood != null; private bool ShouldSerializeColdBlood() => _coldBlood != null;
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
@ -111,9 +111,9 @@ public partial class ChampionTitleContext
} }
[SerializableField(4)] [SerializableField(4)]
[SaveFlag(nameof(ShouldSerializeForestLord))]
private ChampionTitle _forestLord; private ChampionTitle _forestLord;
[SerializableFieldSaveFlag(4)]
private bool ShouldSerializeForestLord() => _forestLord != null; private bool ShouldSerializeForestLord() => _forestLord != null;
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
@ -131,9 +131,9 @@ public partial class ChampionTitleContext
} }
[SerializableField(5)] [SerializableField(5)]
[SaveFlag(nameof(ShouldSerializeVerminHorde))]
private ChampionTitle _verminHorde; private ChampionTitle _verminHorde;
[SerializableFieldSaveFlag(5)]
private bool ShouldSerializeVerminHorde() => _verminHorde != null; private bool ShouldSerializeVerminHorde() => _verminHorde != null;
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
@ -151,9 +151,9 @@ public partial class ChampionTitleContext
} }
[SerializableField(6)] [SerializableField(6)]
[SaveFlag(nameof(ShouldSerializeUnholyTerror))]
private ChampionTitle _unholyTerror; private ChampionTitle _unholyTerror;
[SerializableFieldSaveFlag(6)]
private bool ShouldSerializeUnholyTerror() => _unholyTerror != null; private bool ShouldSerializeUnholyTerror() => _unholyTerror != null;
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
@ -171,9 +171,9 @@ public partial class ChampionTitleContext
} }
[SerializableField(7)] [SerializableField(7)]
[SaveFlag(nameof(ShouldSerializeSleepingDragon))]
private ChampionTitle _sleepingDragon; private ChampionTitle _sleepingDragon;
[SerializableFieldSaveFlag(7)]
private bool ShouldSerializeSleepingDragon() => _sleepingDragon != null; private bool ShouldSerializeSleepingDragon() => _sleepingDragon != null;
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
@ -191,9 +191,9 @@ public partial class ChampionTitleContext
} }
[SerializableField(8)] [SerializableField(8)]
[SaveFlag(nameof(ShouldSerializeCorrupt))]
private ChampionTitle _corrupt; private ChampionTitle _corrupt;
[SerializableFieldSaveFlag(8)]
private bool ShouldSerializeCorrupt() => _corrupt != null; private bool ShouldSerializeCorrupt() => _corrupt != null;
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
@ -211,9 +211,9 @@ public partial class ChampionTitleContext
} }
[SerializableField(9)] [SerializableField(9)]
[SaveFlag(nameof(ShouldSerializeGlade))]
private ChampionTitle _glade; private ChampionTitle _glade;
[SerializableFieldSaveFlag(9)]
private bool ShouldSerializeGlade() => _glade != null; private bool ShouldSerializeGlade() => _glade != null;
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]

View file

@ -830,10 +830,9 @@ public partial class BRBomb : Item
[SerializationGenerator(0, false)] [SerializationGenerator(0, false)]
public partial class BRGoal : BaseAddon public partial class BRGoal : BaseAddon
{ {
[SerializableField(0)] [SerializableField(0, fieldChanged: nameof(OnNorthChanged))]
private bool _north; private bool _north;
[SerializableFieldChanged(0)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private void OnNorthChanged(bool oldValue, bool newValue) => Remake(); private void OnNorthChanged(bool oldValue, bool newValue) => Remake();

View file

@ -252,10 +252,9 @@ public partial class HillOfTheKing : Item
public partial class KHBoard : Item public partial class KHBoard : Item
{ {
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
[SerializableField(0)] [SerializableField(0, fieldChanged: nameof(OnControllerChanged))]
private KHController _controller; private KHController _controller;
[SerializableFieldChanged(0)]
private void OnControllerChanged(KHController oldValue, KHController newValue) private void OnControllerChanged(KHController oldValue, KHController newValue)
{ {
oldValue?.RemoveBoard(this); oldValue?.RemoveBoard(this);

View file

@ -37,17 +37,17 @@ public partial class PlantItem : Item, ISecurable
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[SerializableField(0)] [SerializableField(0)]
[SaveFlag(nameof(ShouldSerializeSecureLevel))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private SecureLevel _level; private SecureLevel _level;
[SerializableFieldSaveFlag(0)]
private bool ShouldSerializeSecureLevel() => (int)_level != 0; private bool ShouldSerializeSecureLevel() => (int)_level != 0;
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[SerializableField(5, setter: "private")] [SerializableField(5, setter: "private")]
[SaveFlag(nameof(ShouldSerializePlantSystem))]
private PlantSystem _plantSystem; private PlantSystem _plantSystem;
[SerializableFieldSaveFlag(5)]
private bool ShouldSerializePlantSystem() => _plantStatus < PlantStatus.DecorativePlant; private bool ShouldSerializePlantSystem() => _plantStatus < PlantStatus.DecorativePlant;
// For clients older than 7.0.12.0 // For clients older than 7.0.12.0
@ -82,6 +82,7 @@ public partial class PlantItem : Item, ISecurable
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
[SerializableProperty(1)] [SerializableProperty(1)]
[SaveFlag(nameof(ShouldSerializePlantStatus))]
public PlantStatus PlantStatus public PlantStatus PlantStatus
{ {
get => _plantStatus; get => _plantStatus;
@ -120,10 +121,10 @@ public partial class PlantItem : Item, ISecurable
} }
} }
[SerializableFieldSaveFlag(1)]
private bool ShouldSerializePlantStatus() => _plantStatus != PlantStatus.BowlOfDirt; private bool ShouldSerializePlantStatus() => _plantStatus != PlantStatus.BowlOfDirt;
[SerializableProperty(2)] [SerializableProperty(2)]
[SaveFlag(nameof(ShouldSerializePlantType))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public PlantType PlantType public PlantType PlantType
{ {
@ -135,10 +136,10 @@ public partial class PlantItem : Item, ISecurable
} }
} }
[SerializableFieldSaveFlag(2)]
private bool ShouldSerializePlantType() => (int)_plantType != 0; private bool ShouldSerializePlantType() => (int)_plantType != 0;
[SerializableProperty(3)] [SerializableProperty(3)]
[SaveFlag(nameof(ShouldSerializePlantHue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public PlantHue PlantHue public PlantHue PlantHue
{ {
@ -150,10 +151,10 @@ public partial class PlantItem : Item, ISecurable
} }
} }
[SerializableFieldSaveFlag(3)]
private bool ShouldSerializePlantHue() => _plantHue != PlantHue.None; private bool ShouldSerializePlantHue() => _plantHue != PlantHue.None;
[SerializableProperty(4)] [SerializableProperty(4)]
[SaveFlag(nameof(ShouldSerializeShowType))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public bool ShowType public bool ShowType
{ {
@ -166,7 +167,6 @@ public partial class PlantItem : Item, ISecurable
} }
} }
[SerializableFieldSaveFlag(4)]
private bool ShouldSerializeShowType() => _showType; private bool ShouldSerializeShowType() => _showType;
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]

View file

@ -33,24 +33,24 @@ namespace Server.Engines.Plants
private PlantItem _plant; private PlantItem _plant;
[SerializableField(0)] [SerializableField(0)]
[SaveFlag(nameof(ShouldSerializeFertileDirt))]
private bool _fertileDirt; private bool _fertileDirt;
[SerializableFieldSaveFlag(0)]
private bool ShouldSerializeFertileDirt() => _fertileDirt; private bool ShouldSerializeFertileDirt() => _fertileDirt;
[SerializableField(1)] [SerializableField(1)]
private DateTime _nextGrowth; private DateTime _nextGrowth;
[SerializableField(2, setter: "private")] [SerializableField(2, setter: "private")]
[SaveFlag(nameof(ShouldSerializeGrowthIndicator))]
private PlantGrowthIndicator _growthIndicator; private PlantGrowthIndicator _growthIndicator;
[SerializableFieldSaveFlag(2)]
private bool ShouldSerializeGrowthIndicator() => _growthIndicator != PlantGrowthIndicator.None; private bool ShouldSerializeGrowthIndicator() => _growthIndicator != PlantGrowthIndicator.None;
[SerializableField(13)] [SerializableField(13)]
[SaveFlag(nameof(ShouldSerializePollinated))]
private bool _pollinated; private bool _pollinated;
[SerializableFieldSaveFlag(13)]
private bool ShouldSerializePollinated() => _pollinated; private bool ShouldSerializePollinated() => _pollinated;
public PlantSystem(PlantItem plant) public PlantSystem(PlantItem plant)
@ -98,6 +98,7 @@ namespace Server.Engines.Plants
public bool IsFullWater => _water >= 4; public bool IsFullWater => _water >= 4;
[SerializableProperty(3)] [SerializableProperty(3)]
[SaveFlag(nameof(ShouldSerializeWater))]
public int Water public int Water
{ {
get => _water; get => _water;
@ -109,10 +110,10 @@ namespace Server.Engines.Plants
} }
} }
[SerializableFieldSaveFlag(3)]
private bool ShouldSerializeWater() => _water != 0; private bool ShouldSerializeWater() => _water != 0;
[SerializableProperty(4)] [SerializableProperty(4)]
[SaveFlag(nameof(ShouldSerializeHits))]
public int Hits public int Hits
{ {
get => _hits; get => _hits;
@ -135,7 +136,6 @@ namespace Server.Engines.Plants
} }
} }
[SerializableFieldSaveFlag(4)]
private bool ShouldSerializeHits() => _hits != 0; private bool ShouldSerializeHits() => _hits != 0;
public int MaxHits => 10 + (int)Plant.PlantStatus * 2; public int MaxHits => 10 + (int)Plant.PlantStatus * 2;
@ -150,6 +150,7 @@ namespace Server.Engines.Plants
}; };
[SerializableProperty(5)] [SerializableProperty(5)]
[SaveFlag(nameof(ShouldSerializeInfestation))]
public int Infestation public int Infestation
{ {
get => _infestation; get => _infestation;
@ -160,10 +161,10 @@ namespace Server.Engines.Plants
} }
} }
[SerializableFieldSaveFlag(5)]
private bool ShouldSerializeInfestation() => _infestation != 0; private bool ShouldSerializeInfestation() => _infestation != 0;
[SerializableProperty(6)] [SerializableProperty(6)]
[SaveFlag(nameof(ShouldSerializeFungus))]
public int Fungus public int Fungus
{ {
get => _fungus; get => _fungus;
@ -174,10 +175,10 @@ namespace Server.Engines.Plants
} }
} }
[SerializableFieldSaveFlag(6)]
private bool ShouldSerializeFungus() => _fungus != 0; private bool ShouldSerializeFungus() => _fungus != 0;
[SerializableProperty(7)] [SerializableProperty(7)]
[SaveFlag(nameof(ShouldSerializePoison))]
public int Poison public int Poison
{ {
get => _poison; get => _poison;
@ -188,10 +189,10 @@ namespace Server.Engines.Plants
} }
} }
[SerializableFieldSaveFlag(7)]
private bool ShouldSerializePoison() => _poison != 0; private bool ShouldSerializePoison() => _poison != 0;
[SerializableProperty(8)] [SerializableProperty(8)]
[SaveFlag(nameof(ShouldSerializeDisease))]
public int Disease public int Disease
{ {
get => _disease; get => _disease;
@ -202,12 +203,12 @@ namespace Server.Engines.Plants
} }
} }
[SerializableFieldSaveFlag(8)]
private bool ShouldSerializeDisease() => _disease != 0; private bool ShouldSerializeDisease() => _disease != 0;
public bool IsFullPoisonPotion => _poisonPotion >= 2; public bool IsFullPoisonPotion => _poisonPotion >= 2;
[SerializableProperty(9)] [SerializableProperty(9)]
[SaveFlag(nameof(ShouldSerializePoisonPotion))]
public int PoisonPotion public int PoisonPotion
{ {
get => _poisonPotion; get => _poisonPotion;
@ -218,12 +219,12 @@ namespace Server.Engines.Plants
} }
} }
[SerializableFieldSaveFlag(9)]
private bool ShouldSerializePoisonPotion() => _poisonPotion != 0; private bool ShouldSerializePoisonPotion() => _poisonPotion != 0;
public bool IsFullCurePotion => _curePotion >= 2; public bool IsFullCurePotion => _curePotion >= 2;
[SerializableProperty(10)] [SerializableProperty(10)]
[SaveFlag(nameof(ShouldSerializeCurePotion))]
public int CurePotion public int CurePotion
{ {
get => _curePotion; get => _curePotion;
@ -234,12 +235,12 @@ namespace Server.Engines.Plants
} }
} }
[SerializableFieldSaveFlag(10)]
private bool ShouldSerializeCurePotion() => _curePotion != 0; private bool ShouldSerializeCurePotion() => _curePotion != 0;
public bool IsFullHealPotion => _healPotion >= 2; public bool IsFullHealPotion => _healPotion >= 2;
[SerializableProperty(11)] [SerializableProperty(11)]
[SaveFlag(nameof(ShouldSerializeHealPotion))]
public int HealPotion public int HealPotion
{ {
get => _healPotion; get => _healPotion;
@ -250,12 +251,12 @@ namespace Server.Engines.Plants
} }
} }
[SerializableFieldSaveFlag(11)]
private bool ShouldSerializeHealPotion() => _healPotion != 0; private bool ShouldSerializeHealPotion() => _healPotion != 0;
public bool IsFullStrengthPotion => _strengthPotion >= 2; public bool IsFullStrengthPotion => _strengthPotion >= 2;
[SerializableProperty(12)] [SerializableProperty(12)]
[SaveFlag(nameof(ShouldSerializeStrengthPotion))]
public int StrengthPotion public int StrengthPotion
{ {
get => _strengthPotion; get => _strengthPotion;
@ -266,7 +267,6 @@ namespace Server.Engines.Plants
} }
} }
[SerializableFieldSaveFlag(12)]
private bool ShouldSerializeStrengthPotion() => _strengthPotion != 0; private bool ShouldSerializeStrengthPotion() => _strengthPotion != 0;
public bool HasMaladies => Infestation > 0 || Fungus > 0 || Poison > 0 || Disease > 0 || Water != 2; public bool HasMaladies => Infestation > 0 || Fungus > 0 || Poison > 0 || Disease > 0 || Water != 2;
@ -274,6 +274,7 @@ namespace Server.Engines.Plants
public bool PollenProducing => Plant.IsCrossable && Plant.PlantStatus >= PlantStatus.FullGrownPlant; public bool PollenProducing => Plant.IsCrossable && Plant.PlantStatus >= PlantStatus.FullGrownPlant;
[SerializableProperty(14)] [SerializableProperty(14)]
[SaveFlag(nameof(ShouldSerializeSeedType))]
public PlantType SeedType public PlantType SeedType
{ {
get => Pollinated ? _seedType : Plant.PlantType; get => Pollinated ? _seedType : Plant.PlantType;
@ -284,10 +285,10 @@ namespace Server.Engines.Plants
} }
} }
[SerializableFieldSaveFlag(14)]
private bool ShouldSerializeSeedType() => _pollinated; private bool ShouldSerializeSeedType() => _pollinated;
[SerializableProperty(15)] [SerializableProperty(15)]
[SaveFlag(nameof(ShouldSerializeSeedHue))]
public PlantHue SeedHue public PlantHue SeedHue
{ {
get => Pollinated ? _seedHue : Plant.PlantHue; get => Pollinated ? _seedHue : Plant.PlantHue;
@ -298,53 +299,50 @@ namespace Server.Engines.Plants
} }
} }
[SerializableFieldSaveFlag(15)]
private bool ShouldSerializeSeedHue() => _pollinated; private bool ShouldSerializeSeedHue() => _pollinated;
[SerializableProperty(16)] [SerializableProperty(16)]
[SaveFlag(nameof(ShouldSerializeAvailableSeeds))]
public int AvailableSeeds public int AvailableSeeds
{ {
get => _availableSeeds; get => _availableSeeds;
set => _availableSeeds = Math.Max(value, 0); set => _availableSeeds = Math.Max(value, 0);
} }
[SerializableFieldSaveFlag(16)]
private bool ShouldSerializeAvailableSeeds() => _availableSeeds != 0; private bool ShouldSerializeAvailableSeeds() => _availableSeeds != 0;
[SerializableProperty(17)] [SerializableProperty(17)]
[SaveFlag(nameof(ShouldSerializeLeftSeeds), nameof(LeftSeedsDefaultValue))]
public int LeftSeeds public int LeftSeeds
{ {
get => _leftSeeds; get => _leftSeeds;
set => _leftSeeds = Math.Max(value, 0); set => _leftSeeds = Math.Max(value, 0);
} }
[SerializableFieldSaveFlag(17)]
private bool ShouldSerializeLeftSeeds() => _leftSeeds != 8; private bool ShouldSerializeLeftSeeds() => _leftSeeds != 8;
[SerializableFieldDefault(17)]
private int LeftSeedsDefaultValue() => 8; private int LeftSeedsDefaultValue() => 8;
[SerializableProperty(18)] [SerializableProperty(18)]
[SaveFlag(nameof(ShouldSerializeAvailableResources))]
public int AvailableResources public int AvailableResources
{ {
get => _availableResources; get => _availableResources;
set => _availableResources = Math.Max(value, 0); set => _availableResources = Math.Max(value, 0);
} }
[SerializableFieldSaveFlag(18)]
private bool ShouldSerializeAvailableResources() => _availableResources != 0; private bool ShouldSerializeAvailableResources() => _availableResources != 0;
[SerializableProperty(19)] [SerializableProperty(19)]
[SaveFlag(nameof(ShouldSerializeLeftResources), nameof(LeftResourcesDefaultValue))]
public int LeftResources public int LeftResources
{ {
get => _leftResources; get => _leftResources;
set => _leftResources = Math.Max(value, 0); set => _leftResources = Math.Max(value, 0);
} }
[SerializableFieldSaveFlag(19)]
private bool ShouldSerializeLeftResources() => _leftResources != 8; private bool ShouldSerializeLeftResources() => _leftResources != 8;
[SerializableFieldDefault(19)]
private int LeftResourcesDefaultValue() => 8; private int LeftResourcesDefaultValue() => 8;
public void Reset(bool potions) public void Reset(bool potions)

View file

@ -54,10 +54,10 @@ public abstract partial class BaseSpawner : Item, ISpawner
[SerializedCommandProperty(AccessLevel.Developer)] [SerializedCommandProperty(AccessLevel.Developer)]
private Guid _guid; private Guid _guid;
[SerializableFieldSaveFlag(1)]
private bool ShouldSerializeReturnOnDeactivate() => _returnOnDeactivate; private bool ShouldSerializeReturnOnDeactivate() => _returnOnDeactivate;
[SerializableField(1)] [SerializableField(1)]
[SaveFlag(nameof(ShouldSerializeReturnOnDeactivate))]
[SerializedCommandProperty(AccessLevel.Developer)] [SerializedCommandProperty(AccessLevel.Developer)]
private bool _returnOnDeactivate; private bool _returnOnDeactivate;
@ -67,48 +67,46 @@ public abstract partial class BaseSpawner : Item, ISpawner
private int _walkingRange = -1; private int _walkingRange = -1;
[SerializableFieldSaveFlag(4)]
private bool ShouldSerializeWayPoint() => _wayPoint != null; private bool ShouldSerializeWayPoint() => _wayPoint != null;
[SerializableField(4)] [SerializableField(4)]
[SaveFlag(nameof(ShouldSerializeWayPoint))]
[SerializedCommandProperty(AccessLevel.Developer)] [SerializedCommandProperty(AccessLevel.Developer)]
private WayPoint _wayPoint; private WayPoint _wayPoint;
[SerializableFieldSaveFlag(5)]
private bool ShouldSerializeGroup() => _group; private bool ShouldSerializeGroup() => _group;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(5)] [SerializableField(5)]
[SaveFlag(nameof(ShouldSerializeGroup))]
[SerializedCommandProperty(AccessLevel.Developer)] [SerializedCommandProperty(AccessLevel.Developer)]
private bool _group; private bool _group;
[SerializableFieldSaveFlag(6)]
private bool ShouldSerializeMinDelay() => _minDelay != DefaultMinDelay; private bool ShouldSerializeMinDelay() => _minDelay != DefaultMinDelay;
[SerializableFieldDefault(6)]
private TimeSpan MinDelayDefault() => DefaultMinDelay; private TimeSpan MinDelayDefault() => DefaultMinDelay;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(6)] [SerializableField(6)]
[SaveFlag(nameof(ShouldSerializeMinDelay), nameof(MinDelayDefault))]
[SerializedCommandProperty(AccessLevel.Developer)] [SerializedCommandProperty(AccessLevel.Developer)]
private TimeSpan _minDelay; private TimeSpan _minDelay;
[SerializableFieldSaveFlag(7)]
private bool ShouldSerializeMaxDelay() => _maxDelay != DefaultMaxDelay; private bool ShouldSerializeMaxDelay() => _maxDelay != DefaultMaxDelay;
[SerializableFieldDefault(7)]
private TimeSpan MaxDelayDefault() => DefaultMaxDelay; private TimeSpan MaxDelayDefault() => DefaultMaxDelay;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(7)] [SerializableField(7)]
[SaveFlag(nameof(ShouldSerializeMaxDelay), nameof(MaxDelayDefault))]
[SerializedCommandProperty(AccessLevel.Developer)] [SerializedCommandProperty(AccessLevel.Developer)]
private TimeSpan _maxDelay; private TimeSpan _maxDelay;
[SerializableFieldSaveFlag(9)]
private bool ShouldSerializeTeam() => _team != 0; private bool ShouldSerializeTeam() => _team != 0;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(9)] [SerializableField(9)]
[SaveFlag(nameof(ShouldSerializeTeam))]
[SerializedCommandProperty(AccessLevel.Developer)] [SerializedCommandProperty(AccessLevel.Developer)]
private int _team; private int _team;
@ -125,29 +123,29 @@ public abstract partial class BaseSpawner : Item, ISpawner
/// If true, the home location of the spawn is the location where it spawned /// If true, the home location of the spawn is the location where it spawned
/// If false, the home location of the spawn is the location of the spawner /// If false, the home location of the spawn is the location of the spawner
/// </summary> /// </summary>
[SerializableFieldSaveFlag(11)]
private bool ShouldSerializeSpawnLocationIsHome() => _spawnLocationIsHome; private bool ShouldSerializeSpawnLocationIsHome() => _spawnLocationIsHome;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(11)] [SerializableField(11)]
[SaveFlag(nameof(ShouldSerializeSpawnLocationIsHome))]
[SerializedCommandProperty(AccessLevel.Developer)] [SerializedCommandProperty(AccessLevel.Developer)]
private bool _spawnLocationIsHome; private bool _spawnLocationIsHome;
[SerializableFieldSaveFlag(12)]
private bool ShouldSerializeEnd() => _end != default; private bool ShouldSerializeEnd() => _end != default;
[SerializableField(12)] [SerializableField(12)]
[SaveFlag(nameof(ShouldSerializeEnd))]
[SerializedCommandProperty(AccessLevel.Developer)] [SerializedCommandProperty(AccessLevel.Developer)]
private DateTime _end; private DateTime _end;
/// <summary> /// <summary>
/// Controls how spawn position optimization is handled. /// Controls how spawn position optimization is handled.
/// </summary> /// </summary>
[SerializableFieldSaveFlag(13)]
private bool ShouldSerializeSpawnPositionMode() => private bool ShouldSerializeSpawnPositionMode() =>
_spawnPositionMode is not SpawnPositionMode.Automatic and not SpawnPositionMode.Abandoned; _spawnPositionMode is not SpawnPositionMode.Automatic and not SpawnPositionMode.Abandoned;
[SerializableField(13)] [SerializableField(13)]
[SaveFlag(nameof(ShouldSerializeSpawnPositionMode))]
[SerializedCommandProperty(AccessLevel.Developer)] [SerializedCommandProperty(AccessLevel.Developer)]
private SpawnPositionMode _spawnPositionMode; private SpawnPositionMode _spawnPositionMode;
@ -156,13 +154,12 @@ public abstract partial class BaseSpawner : Item, ISpawner
/// <summary> /// <summary>
/// Maximum number of random position attempts before engaging optimization. /// Maximum number of random position attempts before engaging optimization.
/// </summary> /// </summary>
[SerializableFieldSaveFlag(14)]
private bool ShouldSerializeMaxSpawnAttempts() => _maxSpawnAttempts != DefaultMaxSpawnAttempts; private bool ShouldSerializeMaxSpawnAttempts() => _maxSpawnAttempts != DefaultMaxSpawnAttempts;
[SerializableFieldDefault(14)]
private int MaxSpawnAttemptsDefault() => DefaultMaxSpawnAttempts; private int MaxSpawnAttemptsDefault() => DefaultMaxSpawnAttempts;
[SerializableField(14)] [SerializableField(14)]
[SaveFlag(nameof(ShouldSerializeMaxSpawnAttempts), nameof(MaxSpawnAttemptsDefault))]
[SerializedCommandProperty(AccessLevel.Developer)] [SerializedCommandProperty(AccessLevel.Developer)]
private int _maxSpawnAttempts; private int _maxSpawnAttempts;

View file

@ -10,17 +10,17 @@ public partial class Spawner : BaseSpawner
/// When true, enables proactive spiral scanning to find valid spawn positions. /// When true, enables proactive spiral scanning to find valid spawn positions.
/// Only relevant when SpawnPositionMode is Automatic or Enabled. /// Only relevant when SpawnPositionMode is Automatic or Enabled.
/// </summary> /// </summary>
[SerializableFieldSaveFlag(0)]
private bool ShouldSerializeUseSpiralScan() => _useSpiralScan; private bool ShouldSerializeUseSpiralScan() => _useSpiralScan;
[SerializableField(0)] [SerializableField(0)]
[SaveFlag(nameof(ShouldSerializeUseSpiralScan))]
[SerializedCommandProperty(AccessLevel.Developer)] [SerializedCommandProperty(AccessLevel.Developer)]
private bool _useSpiralScan; private bool _useSpiralScan;
[SerializableFieldSaveFlag(1)]
private bool ShouldSerializeSpawnBounds() => _spawnBounds != default; private bool ShouldSerializeSpawnBounds() => _spawnBounds != default;
[SerializableProperty(1)] [SerializableProperty(1)]
[SaveFlag(nameof(ShouldSerializeSpawnBounds))]
[CommandProperty(AccessLevel.Developer)] [CommandProperty(AccessLevel.Developer)]
public override Rectangle3D SpawnBounds public override Rectangle3D SpawnBounds
{ {

View file

@ -10,97 +10,97 @@ public partial class VirtueContext
{ {
[DeltaDateTime] [DeltaDateTime]
[SerializableField(0)] [SerializableField(0)]
[SaveFlag(nameof(ShouldSerializeLastSacrificeGain))]
[SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] [SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
private DateTime _lastSacrificeGain; private DateTime _lastSacrificeGain;
[SerializableFieldSaveFlag(0)]
private bool ShouldSerializeLastSacrificeGain() => !SacrificeVirtue.CanGain(this); private bool ShouldSerializeLastSacrificeGain() => !SacrificeVirtue.CanGain(this);
[DeltaDateTime] [DeltaDateTime]
[SerializableField(1)] [SerializableField(1)]
[SaveFlag(nameof(ShouldSerializeLastSacrificeLoss))]
[SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] [SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
private DateTime _lastSacrificeLoss; private DateTime _lastSacrificeLoss;
[SerializableFieldSaveFlag(1)]
private bool ShouldSerializeLastSacrificeLoss() => !SacrificeVirtue.CanAtrophy(this); private bool ShouldSerializeLastSacrificeLoss() => !SacrificeVirtue.CanAtrophy(this);
[SerializableField(2)] [SerializableField(2)]
[SaveFlag(nameof(ShouldSerializeAvailableResurrects))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _availableResurrects; private int _availableResurrects;
[SerializableFieldSaveFlag(2)]
private bool ShouldSerializeAvailableResurrects() => _availableResurrects > 0; private bool ShouldSerializeAvailableResurrects() => _availableResurrects > 0;
[DeltaDateTime] [DeltaDateTime]
[SerializableField(3)] [SerializableField(3)]
[SaveFlag(nameof(ShouldSerializeLastJusticeLoss))]
[SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] [SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
private DateTime _lastJusticeLoss; private DateTime _lastJusticeLoss;
[SerializableFieldSaveFlag(3)]
private bool ShouldSerializeLastJusticeLoss() => !JusticeVirtue.CanAtrophy(this); private bool ShouldSerializeLastJusticeLoss() => !JusticeVirtue.CanAtrophy(this);
[DeltaDateTime] [DeltaDateTime]
[SerializableField(4)] [SerializableField(4)]
[SaveFlag(nameof(ShouldSerializeLastCompassionLoss))]
[SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] [SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
private DateTime _lastCompassionLoss; private DateTime _lastCompassionLoss;
[SerializableFieldSaveFlag(4)]
private bool ShouldSerializeLastCompassionLoss() => !CompassionVirtue.CanAtrophy(this); private bool ShouldSerializeLastCompassionLoss() => !CompassionVirtue.CanAtrophy(this);
[DeltaDateTime] [DeltaDateTime]
[SerializableField(5)] [SerializableField(5)]
[SaveFlag(nameof(ShouldSerializeNextCompassionDay))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private DateTime _nextCompassionDay; private DateTime _nextCompassionDay;
[SerializableFieldSaveFlag(5)]
private bool ShouldSerializeNextCompassionDay() => _nextCompassionDay > Core.Now; private bool ShouldSerializeNextCompassionDay() => _nextCompassionDay > Core.Now;
[SerializableField(6)] [SerializableField(6)]
[SaveFlag(nameof(ShouldSerializeCompassionGains))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _compassionGains; private int _compassionGains;
[SerializableFieldSaveFlag(6)]
private bool ShouldSerializeCompassionGains() => _compassionGains > 0; private bool ShouldSerializeCompassionGains() => _compassionGains > 0;
[DeltaDateTime] [DeltaDateTime]
[SerializableField(7)] [SerializableField(7)]
[SaveFlag(nameof(ShouldSerializeValorLoss))]
[SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] [SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
private DateTime _lastValorLoss; private DateTime _lastValorLoss;
[SerializableFieldSaveFlag(7)]
private bool ShouldSerializeValorLoss() => !ValorVirtue.CanAtrophy(this); private bool ShouldSerializeValorLoss() => !ValorVirtue.CanAtrophy(this);
[DeltaDateTime] [DeltaDateTime]
[SerializableField(8)] [SerializableField(8)]
[SaveFlag(nameof(ShouldSerializeLastHonorUse))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private DateTime _lastHonorUse; private DateTime _lastHonorUse;
[SerializableFieldSaveFlag(8)]
private bool ShouldSerializeLastHonorUse() => !HonorVirtue.CanUse(this); private bool ShouldSerializeLastHonorUse() => !HonorVirtue.CanUse(this);
[SerializableField(9)] [SerializableField(9)]
[SaveFlag(nameof(ShouldSerializeHonorActive))]
[SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] [SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
private bool _honorActive; private bool _honorActive;
[SerializableFieldSaveFlag(9)]
private bool ShouldSerializeHonorActive() => _honorActive; private bool ShouldSerializeHonorActive() => _honorActive;
[SerializableField(10)] [SerializableField(10)]
[SaveFlag(nameof(ShouldSerializeJusticeProtection))]
private PlayerMobile _justiceProtection; private PlayerMobile _justiceProtection;
[SerializableFieldSaveFlag(10)]
private bool ShouldSerializeJusticeProtection() => _justiceProtection != null && _justiceStatus != JusticeProtectorStatus.None; private bool ShouldSerializeJusticeProtection() => _justiceProtection != null && _justiceStatus != JusticeProtectorStatus.None;
[SerializableField(11)] [SerializableField(11)]
[SaveFlag(nameof(ShouldSerializeJusticeStatus))]
private JusticeProtectorStatus _justiceStatus; private JusticeProtectorStatus _justiceStatus;
[SerializableFieldSaveFlag(11)]
private bool ShouldSerializeJusticeStatus() => _justiceProtection != null && _justiceStatus != JusticeProtectorStatus.None; private bool ShouldSerializeJusticeStatus() => _justiceProtection != null && _justiceStatus != JusticeProtectorStatus.None;
[SerializableField(12, setter: "private")] [SerializableField(12, setter: "private")]
[SaveFlag(nameof(ShouldSerializeValues))]
private int[] _values; private int[] _values;
[SerializableFieldSaveFlag(12)]
private bool ShouldSerializeValues() private bool ShouldSerializeValues()
{ {
if (_values == null) if (_values == null)

View file

@ -31,9 +31,9 @@ namespace Server.Items
private bool m_EvaluateDay; private bool m_EvaluateDay;
[SerializableField(0, setter: "private")] [SerializableField(0, setter: "private")]
[DeserializeTimer(nameof(DeserializeEvaluateTimer), wallClock: true)]
private Timer _evaluateTimer; private Timer _evaluateTimer;
[DeserializeTimerField(0)]
private void DeserializeEvaluateTimer(TimeSpan delay) private void DeserializeEvaluateTimer(TimeSpan delay)
{ {
_evaluateTimer = Timer.DelayCall(delay, EvaluationInterval, Evaluate); _evaluateTimer = Timer.DelayCall(delay, EvaluationInterval, Evaluate);

View file

@ -18,95 +18,92 @@ namespace Server.Items
{ {
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[SerializableField(0, setter: "private")] [SerializableField(0, setter: "private")]
[SaveFlag(nameof(ShouldSerializeAosAttributes), nameof(AttributesDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
private AosAttributes _attributes; private AosAttributes _attributes;
[SerializableFieldSaveFlag(0)]
private bool ShouldSerializeAosAttributes() => !_attributes.IsEmpty; private bool ShouldSerializeAosAttributes() => !_attributes.IsEmpty;
[SerializableFieldDefault(0)]
private AosAttributes AttributesDefaultValue() => new(this); private AosAttributes AttributesDefaultValue() => new(this);
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[SerializableField(1, setter: "private")] [SerializableField(1, setter: "private")]
[SaveFlag(nameof(ShouldSerializeArmorAttributes), nameof(ArmorAttributesDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
private AosArmorAttributes _armorAttributes; private AosArmorAttributes _armorAttributes;
[SerializableFieldSaveFlag(1)]
private bool ShouldSerializeArmorAttributes() => !_armorAttributes.IsEmpty; private bool ShouldSerializeArmorAttributes() => !_armorAttributes.IsEmpty;
[SerializableFieldDefault(1)]
private AosArmorAttributes ArmorAttributesDefaultValue() => new(this); private AosArmorAttributes ArmorAttributesDefaultValue() => new(this);
[EncodedInt] [EncodedInt]
[InvalidateProperties] [InvalidateProperties]
[SerializableField(2)] [SerializableField(2)]
[SaveFlag(nameof(ShouldSerializePhysicalBonus))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _physicalBonus; private int _physicalBonus;
[SerializableFieldSaveFlag(2)]
private bool ShouldSerializePhysicalBonus() => _physicalBonus != 0; private bool ShouldSerializePhysicalBonus() => _physicalBonus != 0;
[EncodedInt] [EncodedInt]
[InvalidateProperties] [InvalidateProperties]
[SerializableField(3)] [SerializableField(3)]
[SaveFlag(nameof(ShouldSerializeFireBonus))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _fireBonus; private int _fireBonus;
[SerializableFieldSaveFlag(3)]
private bool ShouldSerializeFireBonus() => _fireBonus != 0; private bool ShouldSerializeFireBonus() => _fireBonus != 0;
[EncodedInt] [EncodedInt]
[InvalidateProperties] [InvalidateProperties]
[SerializableField(4)] [SerializableField(4)]
[SaveFlag(nameof(ShouldSerializeColdBonus))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _coldBonus; private int _coldBonus;
[SerializableFieldSaveFlag(4)]
private bool ShouldSerializeColdBonus() => _coldBonus != 0; private bool ShouldSerializeColdBonus() => _coldBonus != 0;
[EncodedInt] [EncodedInt]
[InvalidateProperties] [InvalidateProperties]
[SerializableField(5)] [SerializableField(5)]
[SaveFlag(nameof(ShouldSerializePoisonBonus))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _poisonBonus; private int _poisonBonus;
[SerializableFieldSaveFlag(5)]
private bool ShouldSerializePoisonBonus() => _poisonBonus != 0; private bool ShouldSerializePoisonBonus() => _poisonBonus != 0;
[EncodedInt] [EncodedInt]
[InvalidateProperties] [InvalidateProperties]
[SerializableField(6)] [SerializableField(6)]
[SaveFlag(nameof(ShouldSerializeEnergyBonus))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _energyBonus; private int _energyBonus;
[SerializableFieldSaveFlag(6)]
private bool ShouldSerializeEnergyBonus() => _energyBonus != 0; private bool ShouldSerializeEnergyBonus() => _energyBonus != 0;
[SerializableField(7)] [SerializableField(7)]
[SaveFlag(nameof(ShouldSerializeIdentified))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private bool _identified; private bool _identified;
[SerializableFieldSaveFlag(7)]
private bool ShouldSerializeIdentified() => _identified; private bool ShouldSerializeIdentified() => _identified;
[EncodedInt] [EncodedInt]
[SerializableField(8)] [SerializableField(8)]
[SaveFlag(nameof(ShouldSerializeMaxHitPoints))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _maxHitPoints; private int _maxHitPoints;
[SerializableFieldSaveFlag(8)]
private bool ShouldSerializeMaxHitPoints() => _maxHitPoints != 0; private bool ShouldSerializeMaxHitPoints() => _maxHitPoints != 0;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(10)] [SerializableField(10)]
[SaveFlag(nameof(ShouldSerializeCrafter))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private string _crafter; private string _crafter;
[SerializableFieldSaveFlag(10)]
private bool ShouldSerializeCrafter() => !string.IsNullOrEmpty(_crafter); private bool ShouldSerializeCrafter() => !string.IsNullOrEmpty(_crafter);
[SerializableFieldSaveFlag(14)]
private bool ShouldSerializeResource() => _resource != DefaultResource; private bool ShouldSerializeResource() => _resource != DefaultResource;
// Field 15 // Field 15
@ -135,13 +132,12 @@ namespace Server.Items
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[SerializableField(23, setter: "private")] [SerializableField(23, setter: "private")]
[SaveFlag(nameof(ShouldSerializeSkillBonuses), nameof(SkillBonusesDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosSkillBonuses _skillBonuses; public AosSkillBonuses _skillBonuses;
[SerializableFieldSaveFlag(23)]
private bool ShouldSerializeSkillBonuses() => !_skillBonuses.IsEmpty; private bool ShouldSerializeSkillBonuses() => !_skillBonuses.IsEmpty;
[SerializableFieldDefault(23)]
private AosSkillBonuses SkillBonusesDefaultValue() => new(this); private AosSkillBonuses SkillBonusesDefaultValue() => new(this);
private FactionItem m_FactionState; private FactionItem m_FactionState;
@ -190,6 +186,7 @@ namespace Server.Items
public virtual int OldIntReq => 0; public virtual int OldIntReq => 0;
[SerializableProperty(11)] [SerializableProperty(11)]
[SaveFlag(nameof(ShouldSerializeArmorQuality), nameof(QualityDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public ArmorQuality Quality public ArmorQuality Quality
{ {
@ -202,13 +199,12 @@ namespace Server.Items
} }
} }
[SerializableFieldSaveFlag(11)]
private bool ShouldSerializeArmorQuality() => _quality != ArmorQuality.Regular; private bool ShouldSerializeArmorQuality() => _quality != ArmorQuality.Regular;
[SerializableFieldDefault(11)]
private ArmorQuality QualityDefaultValue() => ArmorQuality.Regular; private ArmorQuality QualityDefaultValue() => ArmorQuality.Regular;
[SerializableProperty(12)] [SerializableProperty(12)]
[SaveFlag(nameof(ShouldSerializeDurability))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public ArmorDurabilityLevel Durability public ArmorDurabilityLevel Durability
{ {
@ -221,10 +217,10 @@ namespace Server.Items
} }
} }
[SerializableFieldSaveFlag(12)]
private bool ShouldSerializeDurability() => _durability != ArmorDurabilityLevel.Regular; private bool ShouldSerializeDurability() => _durability != ArmorDurabilityLevel.Regular;
[SerializableProperty(13)] [SerializableProperty(13)]
[SaveFlag(nameof(ShouldSerializeProtectionLevel))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public ArmorProtectionLevel ProtectionLevel public ArmorProtectionLevel ProtectionLevel
{ {
@ -244,10 +240,10 @@ namespace Server.Items
} }
} }
[SerializableFieldSaveFlag(13)]
private bool ShouldSerializeProtectionLevel() => _protectionLevel != ArmorProtectionLevel.Regular; private bool ShouldSerializeProtectionLevel() => _protectionLevel != ArmorProtectionLevel.Regular;
[SerializableProperty(14)] [SerializableProperty(14)]
[SaveFlag(nameof(ShouldSerializeResource), nameof(ResourceDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource public CraftResource Resource
{ {
@ -273,11 +269,11 @@ namespace Server.Items
} }
} }
[SerializableFieldDefault(14)]
private CraftResource ResourceDefaultValue() => DefaultResource; private CraftResource ResourceDefaultValue() => DefaultResource;
[EncodedInt] [EncodedInt]
[SerializableProperty(15, useField: nameof(_armorBase))] [SerializableProperty(15, useField: nameof(_armorBase))]
[SaveFlag(nameof(ShouldSerializeArmorBase), nameof(ArmorBaseDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int BaseArmorRating public int BaseArmorRating
{ {
@ -290,10 +286,8 @@ namespace Server.Items
} }
} }
[SerializableFieldSaveFlag(15)]
private bool ShouldSerializeArmorBase() => _armorBase != -1; private bool ShouldSerializeArmorBase() => _armorBase != -1;
[SerializableFieldDefault(15)]
private int ArmorBaseDefaultValue() => -1; private int ArmorBaseDefaultValue() => -1;
public double BaseArmorRatingScaled => BaseArmorRating * ArmorScalar; public double BaseArmorRatingScaled => BaseArmorRating * ArmorScalar;
@ -343,6 +337,7 @@ namespace Server.Items
[EncodedInt] [EncodedInt]
[SerializableProperty(16, useField: nameof(_strBonus))] [SerializableProperty(16, useField: nameof(_strBonus))]
[SaveFlag(nameof(ShouldSerializeStrBonus), nameof(StrBonusDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int StrBonus public int StrBonus
{ {
@ -355,14 +350,13 @@ namespace Server.Items
} }
} }
[SerializableFieldSaveFlag(16)]
private bool ShouldSerializeStrBonus() => _strBonus != -1; private bool ShouldSerializeStrBonus() => _strBonus != -1;
[SerializableFieldDefault(16)]
private int StrBonusDefaultValue() => -1; private int StrBonusDefaultValue() => -1;
[EncodedInt] [EncodedInt]
[SerializableProperty(17, useField: nameof(_dexBonus))] [SerializableProperty(17, useField: nameof(_dexBonus))]
[SaveFlag(nameof(ShouldSerializeDexBonus), nameof(DexBonusDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int DexBonus public int DexBonus
{ {
@ -375,14 +369,13 @@ namespace Server.Items
} }
} }
[SerializableFieldSaveFlag(17)]
private bool ShouldSerializeDexBonus() => _dexBonus != -1; private bool ShouldSerializeDexBonus() => _dexBonus != -1;
[SerializableFieldDefault(17)]
private int DexBonusDefaultValue() => -1; private int DexBonusDefaultValue() => -1;
[EncodedInt] [EncodedInt]
[SerializableProperty(18, useField: nameof(_intBonus))] [SerializableProperty(18, useField: nameof(_intBonus))]
[SaveFlag(nameof(ShouldSerializeIntBonus), nameof(IntBonusDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int IntBonus public int IntBonus
{ {
@ -395,14 +388,13 @@ namespace Server.Items
} }
} }
[SerializableFieldSaveFlag(18)]
private bool ShouldSerializeIntBonus() => _intBonus != -1; private bool ShouldSerializeIntBonus() => _intBonus != -1;
[SerializableFieldDefault(18)]
private int IntBonusDefaultValue() => -1; private int IntBonusDefaultValue() => -1;
[EncodedInt] [EncodedInt]
[SerializableProperty(19, useField: nameof(_strReq))] [SerializableProperty(19, useField: nameof(_strReq))]
[SaveFlag(nameof(ShouldSerializeStrReq), nameof(StrReqDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int StrRequirement public int StrRequirement
{ {
@ -415,14 +407,13 @@ namespace Server.Items
} }
} }
[SerializableFieldSaveFlag(19)]
private bool ShouldSerializeStrReq() => _strReq != -1; private bool ShouldSerializeStrReq() => _strReq != -1;
[SerializableFieldDefault(19)]
private int StrReqDefaultValue() => -1; private int StrReqDefaultValue() => -1;
[EncodedInt] [EncodedInt]
[SerializableProperty(20, useField: nameof(_dexReq))] [SerializableProperty(20, useField: nameof(_dexReq))]
[SaveFlag(nameof(ShouldSerializeDexReq), nameof(DexReqDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int DexRequirement public int DexRequirement
{ {
@ -435,14 +426,13 @@ namespace Server.Items
} }
} }
[SerializableFieldSaveFlag(20)]
private bool ShouldSerializeDexReq() => _dexReq != -1; private bool ShouldSerializeDexReq() => _dexReq != -1;
[SerializableFieldDefault(20)]
private int DexReqDefaultValue() => -1; private int DexReqDefaultValue() => -1;
[EncodedInt] [EncodedInt]
[SerializableProperty(21, useField: nameof(_intReq))] [SerializableProperty(21, useField: nameof(_intReq))]
[SaveFlag(nameof(ShouldSerializeIntReq), nameof(IntReqDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int IntRequirement public int IntRequirement
{ {
@ -455,13 +445,12 @@ namespace Server.Items
} }
} }
[SerializableFieldSaveFlag(21)]
private bool ShouldSerializeIntReq() => _intReq != -1; private bool ShouldSerializeIntReq() => _intReq != -1;
[SerializableFieldDefault(21)]
private int IntReqDefaultValue() => -1; private int IntReqDefaultValue() => -1;
[SerializableProperty(22, useField: nameof(_meditate))] [SerializableProperty(22, useField: nameof(_meditate))]
[SaveFlag(nameof(ShouldSerializeMeditationAllowance))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public AMA MeditationAllowance public AMA MeditationAllowance
{ {
@ -473,7 +462,6 @@ namespace Server.Items
} }
} }
[SerializableFieldSaveFlag(22)]
private bool ShouldSerializeMeditationAllowance() => _meditate >= AMA.All; private bool ShouldSerializeMeditationAllowance() => _meditate >= AMA.All;
public virtual double ArmorScalar public virtual double ArmorScalar
@ -689,6 +677,7 @@ namespace Server.Items
[EncodedInt] [EncodedInt]
[SerializableProperty(9)] [SerializableProperty(9)]
[SaveFlag(nameof(ShouldSerializeHitPoints))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int HitPoints public int HitPoints
{ {
@ -716,7 +705,6 @@ namespace Server.Items
} }
} }
[SerializableFieldSaveFlag(9)]
private bool ShouldSerializeHitPoints() => _hitPoints != 0; private bool ShouldSerializeHitPoints() => _hitPoints != 0;
public virtual int InitMinHits => 0; public virtual int InitMinHits => 0;

View file

@ -31,13 +31,12 @@ namespace Server.Items
public override ArmorMeditationAllowance DefMedAllowance => ArmorMeditationAllowance.All; public override ArmorMeditationAllowance DefMedAllowance => ArmorMeditationAllowance.All;
[SerializableField(0, setter: "private")] [SerializableField(0, setter: "private")]
[SaveFlag(nameof(ShouldSerializeWeaponAttributes), nameof(WeaponAttributesDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosWeaponAttributes _weaponAttributes; public AosWeaponAttributes _weaponAttributes;
[SerializableFieldSaveFlag(0)]
private bool ShouldSerializeWeaponAttributes() => !_weaponAttributes.IsEmpty; private bool ShouldSerializeWeaponAttributes() => !_weaponAttributes.IsEmpty;
[SerializableFieldDefault(0)]
private AosWeaponAttributes WeaponAttributesDefaultValue() => new(this); private AosWeaponAttributes WeaponAttributesDefaultValue() => new(this);
public override void AppendChildNameProperties(IPropertyList list) public override void AppendChildNameProperties(IPropertyList list)

View file

@ -19,41 +19,38 @@ namespace Server.Items
[InternString] [InternString]
[InvalidateProperties] [InvalidateProperties]
[SerializableField(1)] [SerializableField(1)]
[SaveFlag(nameof(ShouldSerializeTitle), nameof(TitleDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private string _title; private string _title;
[SerializableFieldSaveFlag(1)]
private bool ShouldSerializeTitle() => _title != DefaultContent?.Title; private bool ShouldSerializeTitle() => _title != DefaultContent?.Title;
[SerializableFieldDefault(1)]
private string TitleDefaultValue() => DefaultContent?.Title; private string TitleDefaultValue() => DefaultContent?.Title;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(2)] [SerializableField(2)]
[SaveFlag(nameof(ShouldSerializeAuthor), nameof(AuthorDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private string _author; private string _author;
[SerializableFieldSaveFlag(2)]
private bool ShouldSerializeAuthor() => _author != DefaultContent?.Author; private bool ShouldSerializeAuthor() => _author != DefaultContent?.Author;
[SerializableFieldDefault(2)]
private string AuthorDefaultValue() => DefaultContent?.Author; private string AuthorDefaultValue() => DefaultContent?.Author;
[SerializableField(3)] [SerializableField(3)]
[SaveFlag(nameof(ShouldSerializeWritable))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private bool _writable; private bool _writable;
[SerializableFieldSaveFlag(3)]
private bool ShouldSerializeWritable() => _writable; private bool ShouldSerializeWritable() => _writable;
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[SerializableField(4, setter: "protected")] [SerializableField(4, setter: "protected")]
[SaveFlag(nameof(ShouldSerializePages), nameof(PagesDefaultValue))]
private BookPageInfo[] _pages; private BookPageInfo[] _pages;
[SerializableFieldSaveFlag(4)]
private bool ShouldSerializePages() => DefaultContent?.IsMatch(_pages) != true; private bool ShouldSerializePages() => DefaultContent?.IsMatch(_pages) != true;
[SerializableFieldDefault(4)]
private BookPageInfo[] PagesDefaultValue() => DefaultContent?.Copy() ?? Array.Empty<BookPageInfo>(); private BookPageInfo[] PagesDefaultValue() => DefaultContent?.Copy() ?? Array.Empty<BookPageInfo>();
[Constructible] [Constructible]

View file

@ -26,76 +26,71 @@ namespace Server.Items
public abstract partial class BaseClothing public abstract partial class BaseClothing
: Item, IDyable, IScissorable, IFactionItem, ICraftable, IWearableDurability, IAosItem : Item, IDyable, IScissorable, IFactionItem, ICraftable, IWearableDurability, IAosItem
{ {
[SerializableFieldSaveFlag(0)]
private bool ShouldSerializeResource() => _resource != DefaultResource; private bool ShouldSerializeResource() => _resource != DefaultResource;
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[SerializableField(1, setter: "private")] [SerializableField(1, setter: "private")]
[SaveFlag(nameof(ShouldSerializeAttributes), nameof(AttributesDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
private AosAttributes _attributes; private AosAttributes _attributes;
[SerializableFieldSaveFlag(1)]
private bool ShouldSerializeAttributes() => !_attributes.IsEmpty; private bool ShouldSerializeAttributes() => !_attributes.IsEmpty;
[SerializableFieldDefault(1)]
private AosAttributes AttributesDefaultValue() => new(this); private AosAttributes AttributesDefaultValue() => new(this);
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[SerializableField(2, setter: "private")] [SerializableField(2, setter: "private")]
[SaveFlag(nameof(ShouldSerializeClothingAttributes), nameof(ClothingAttributesDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
private AosArmorAttributes _clothingAttributes; private AosArmorAttributes _clothingAttributes;
[SerializableFieldSaveFlag(2)]
private bool ShouldSerializeClothingAttributes() => !_clothingAttributes.IsEmpty; private bool ShouldSerializeClothingAttributes() => !_clothingAttributes.IsEmpty;
[SerializableFieldDefault(2)]
private AosArmorAttributes ClothingAttributesDefaultValue() => new(this); private AosArmorAttributes ClothingAttributesDefaultValue() => new(this);
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[SerializableField(3, setter: "private")] [SerializableField(3, setter: "private")]
[SaveFlag(nameof(ShouldSerializeSkillBonuses), nameof(SkillBonusesDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
private AosSkillBonuses _skillBonuses; private AosSkillBonuses _skillBonuses;
[SerializableFieldSaveFlag(3)]
private bool ShouldSerializeSkillBonuses() => !_skillBonuses.IsEmpty; private bool ShouldSerializeSkillBonuses() => !_skillBonuses.IsEmpty;
[SerializableFieldDefault(3)]
private AosSkillBonuses SkillBonusesDefaultValue() => new(this); private AosSkillBonuses SkillBonusesDefaultValue() => new(this);
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[SerializableField(4, setter: "private")] [SerializableField(4, setter: "private")]
[SaveFlag(nameof(ShouldSerializeResistances), nameof(ResistancesDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
private AosElementAttributes _resistances; private AosElementAttributes _resistances;
[SerializableFieldSaveFlag(4)]
private bool ShouldSerializeResistances() => !_resistances.IsEmpty; private bool ShouldSerializeResistances() => !_resistances.IsEmpty;
[SerializableFieldDefault(4)]
private AosElementAttributes ResistancesDefaultValue() => new(this); private AosElementAttributes ResistancesDefaultValue() => new(this);
[EncodedInt] [EncodedInt]
[InvalidateProperties] [InvalidateProperties]
[SerializableField(5)] [SerializableField(5)]
[SaveFlag(nameof(ShouldSerializeMaxHitPoints))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _maxHitPoints; private int _maxHitPoints;
[SerializableFieldSaveFlag(5)]
private bool ShouldSerializeMaxHitPoints() => _maxHitPoints != 0; private bool ShouldSerializeMaxHitPoints() => _maxHitPoints != 0;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(7)] [SerializableField(7)]
[SaveFlag(nameof(ShouldSerializeCrafter))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private string _crafter; private string _crafter;
[SerializableFieldSaveFlag(7)]
private bool ShouldSerializeCrafter() => !string.IsNullOrEmpty(_crafter); private bool ShouldSerializeCrafter() => !string.IsNullOrEmpty(_crafter);
[InvalidateProperties] [InvalidateProperties]
[SerializableField(8)] [SerializableField(8)]
[SaveFlag(nameof(ShouldSerializeQuality))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private ClothingQuality _quality = ClothingQuality.Regular; private ClothingQuality _quality = ClothingQuality.Regular;
[SerializableFieldSaveFlag(8)]
private bool ShouldSerializeQuality() => _quality != ClothingQuality.Regular; private bool ShouldSerializeQuality() => _quality != ClothingQuality.Regular;
// Field 9 // Field 9
@ -119,6 +114,7 @@ namespace Server.Items
} }
[SerializableProperty(0)] [SerializableProperty(0)]
[SaveFlag(nameof(ShouldSerializeResource))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource public CraftResource Resource
{ {
@ -133,6 +129,7 @@ namespace Server.Items
} }
[SerializableProperty(9, useField: nameof(_strReq))] [SerializableProperty(9, useField: nameof(_strReq))]
[SaveFlag(nameof(ShouldSerializeStrReq))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int StrRequirement public int StrRequirement
{ {
@ -145,7 +142,6 @@ namespace Server.Items
} }
} }
[SerializableFieldSaveFlag(9)]
private bool ShouldSerializeStrReq() => _strReq != -1; private bool ShouldSerializeStrReq() => _strReq != -1;
public virtual CraftResource DefaultResource => CraftResource.None; public virtual CraftResource DefaultResource => CraftResource.None;
@ -299,6 +295,7 @@ namespace Server.Items
[EncodedInt] [EncodedInt]
[SerializableProperty(6)] [SerializableProperty(6)]
[SaveFlag(nameof(ShouldSerializeHitPoints))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int HitPoints public int HitPoints
{ {
@ -324,7 +321,6 @@ namespace Server.Items
} }
} }
[SerializableFieldSaveFlag(6)]
private bool ShouldSerializeHitPoints() => _hitPoints != 0; private bool ShouldSerializeHitPoints() => _hitPoints != 0;
public virtual int InitMinHits => 0; public virtual int InitMinHits => 0;

View file

@ -37,21 +37,22 @@ namespace Server.Items
public override double DefaultWeight => 3.0; public override double DefaultWeight => 3.0;
} }
[SerializationGenerator(3, false)] [SerializationGenerator(4, false)]
public partial class DeathRobe : Robe public partial class DeathRobe : Robe
{ {
private static readonly TimeSpan m_DefaultDecayTime = TimeSpan.FromMinutes(1.0); private static readonly TimeSpan m_DefaultDecayTime = TimeSpan.FromMinutes(1.0);
[TimerDrift]
[SerializableField(0)] [SerializableField(0)]
[DeserializeTimer(nameof(DeserializeDecayTimer))]
private Timer _decayTimer; private Timer _decayTimer;
[DeserializeTimerField(0)] private void DeserializeDecayTimer(TimeSpan delay) => BeginDecay(delay);
private void DeserializeDecayTimer(TimeSpan delay)
private void MigrateFrom(V3Content content)
{ {
if (delay != TimeSpan.MinValue) if (content.DecayTimerDelay != TimeSpan.MinValue)
{ {
BeginDecay(delay); DeserializeDecayTimer(content.DecayTimerDelay);
} }
} }

View file

@ -54,11 +54,10 @@ namespace Server.Items
{ {
[EncodedInt] [EncodedInt]
[InvalidateProperties] [InvalidateProperties]
[SerializableField(0)] [SerializableField(0, fieldChanged: nameof(OnCurArcaneChargesChanged))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _curArcaneCharges; private int _curArcaneCharges;
[SerializableFieldChanged(0)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private void OnCurArcaneChargesChanged(int oldValue, int newValue) => Update(); private void OnCurArcaneChargesChanged(int oldValue, int newValue) => Update();

View file

@ -3,19 +3,22 @@ using ModernUO.Serialization;
namespace Server.Items; namespace Server.Items;
[SerializationGenerator(2, false)] [SerializationGenerator(3, false)]
public abstract partial class FillableContainer : LockableContainer public abstract partial class FillableContainer : LockableContainer
{ {
[TimerDrift]
[SerializableField(1)] [SerializableField(1)]
[DeserializeTimer(nameof(DeserializeRespawnTimer))]
private Timer _respawnTimer; private Timer _respawnTimer;
[DeserializeTimerField(1)] private void DeserializeRespawnTimer(TimeSpan delay) => _respawnTimer = Timer.DelayCall(delay, Respawn);
private void DeserializeRespawnTimer(TimeSpan delay)
private void MigrateFrom(V2Content content)
{ {
if (delay > TimeSpan.MinValue) _contentType = content.ContentType;
if (content.RespawnTimerDelay != TimeSpan.MinValue)
{ {
_respawnTimer = Timer.DelayCall(delay, Respawn); DeserializeRespawnTimer(content.RespawnTimerDelay);
} }
} }

View file

@ -3,14 +3,13 @@ using ModernUO.Serialization;
namespace Server.Items; namespace Server.Items;
[SerializationGenerator(0, false)] [SerializationGenerator(1, false)]
public partial class MarkContainer : LockableContainer public partial class MarkContainer : LockableContainer
{ {
[TimerDrift]
[SerializableField(1, getter: "private", setter: "private")] [SerializableField(1, getter: "private", setter: "private")]
[DeserializeTimer(nameof(DeserializeRelockTimer))]
private InternalTimer _relockTimer; private InternalTimer _relockTimer;
[DeserializeTimerField(1)]
private void DeserializeRelockTimer(TimeSpan delay) private void DeserializeRelockTimer(TimeSpan delay)
{ {
if (!Locked && _autoLock) if (!Locked && _autoLock)
@ -19,6 +18,19 @@ public partial class MarkContainer : LockableContainer
} }
} }
private void MigrateFrom(V0Content content)
{
_autoLock = content.AutoLock;
_targetMap = content.TargetMap;
_target = content.Target;
_description = content.Description;
if (content.RelockTimerDelay != TimeSpan.MinValue)
{
DeserializeRelockTimer(content.RelockTimerDelay);
}
}
[SerializableField(2)] [SerializableField(2)]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private Map _targetMap; private Map _targetMap;

View file

@ -9,7 +9,7 @@ using Server.Network;
namespace Server.Items; namespace Server.Items;
[SerializationGenerator(3, false)] [SerializationGenerator(4, false)]
public partial class TreasureMapChest : LockableContainer public partial class TreasureMapChest : LockableContainer
{ {
[Tidy] [Tidy]
@ -29,12 +29,11 @@ public partial class TreasureMapChest : LockableContainer
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _level; private int _level;
[TimerDrift]
[SerializableField(4)] [SerializableField(4)]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
[DeserializeTimer(nameof(DeserializeExpireTimer))]
private Timer _expireTimer; private Timer _expireTimer;
[DeserializeTimerField(4)]
private void DeserializeExpireTimer(TimeSpan delay) private void DeserializeExpireTimer(TimeSpan delay)
{ {
if (!_temporary) if (!_temporary)
@ -43,6 +42,20 @@ public partial class TreasureMapChest : LockableContainer
} }
} }
private void MigrateFrom(V3Content content)
{
_guardians = content.Guardians;
_temporary = content.Temporary;
_owner = content.Owner;
_level = content.Level;
_lifted = content.Lifted;
if (content.ExpireTimerDelay != TimeSpan.MinValue)
{
DeserializeExpireTimer(content.ExpireTimerDelay);
}
}
[Tidy] [Tidy]
[CanBeNull] [CanBeNull]
[SerializableField(5, setter: "private")] [SerializableField(5, setter: "private")]

View file

@ -3,7 +3,7 @@ using ModernUO.Serialization;
namespace Server.Items; namespace Server.Items;
[SerializationGenerator(1, false)] [SerializationGenerator(2, false)]
public abstract partial class BaseLight : Item public abstract partial class BaseLight : Item
{ {
public static readonly bool Burnout = false; public static readonly bool Burnout = false;
@ -16,11 +16,10 @@ public abstract partial class BaseLight : Item
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private bool _protected; private bool _protected;
[TimerDrift]
[SerializableField(4, getter: "private", setter: "private")] [SerializableField(4, getter: "private", setter: "private")]
[DeserializeTimer(nameof(DeserializeTimer))]
private Timer _burnTimer; private Timer _burnTimer;
[DeserializeTimerField(4)]
private void DeserializeTimer(TimeSpan delay) private void DeserializeTimer(TimeSpan delay)
{ {
if (_burning && _duration != TimeSpan.Zero) if (_burning && _duration != TimeSpan.Zero)
@ -29,6 +28,19 @@ public abstract partial class BaseLight : Item
} }
} }
private void MigrateFrom(V1Content content)
{
_burntOut = content.BurntOut;
_burning = content.Burning;
_duration = content.Duration;
_protected = content.Protected;
if (content.BurnTimerDelay != TimeSpan.MinValue)
{
DeserializeTimer(content.BurnTimerDelay);
}
}
[Constructible] [Constructible]
public BaseLight(int itemID) : base(itemID) public BaseLight(int itemID) : base(itemID)
{ {

View file

@ -86,7 +86,7 @@ public enum CorpseFlag
OwnerWasAnimatedDead = 0x00000800 OwnerWasAnimatedDead = 0x00000800
} }
[SerializationGenerator(17, false)] [SerializationGenerator(18, false)]
public partial class Corpse : Container, ICarvable public partial class Corpse : Container, ICarvable
{ {
public static readonly TimeSpan MonsterLootRightSacrifice = TimeSpan.FromMinutes(2.0); public static readonly TimeSpan MonsterLootRightSacrifice = TimeSpan.FromMinutes(2.0);
@ -114,13 +114,37 @@ public partial class Corpse : Container, ICarvable
[SerializableField(3, getter: "private", setter: "private")] [SerializableField(3, getter: "private", setter: "private")]
private Dictionary<Item, Point3D> _restoreTable; private Dictionary<Item, Point3D> _restoreTable;
[TimerDrift]
[SerializableField(4, getter: "private", setter: "private")] [SerializableField(4, getter: "private", setter: "private")]
[DeserializeTimer(nameof(DeserializeDecayTimer))]
private Timer _decayTimer; private Timer _decayTimer;
[DeserializeTimerField(4)]
private void DeserializeDecayTimer(TimeSpan delay) => BeginDecay(delay); private void DeserializeDecayTimer(TimeSpan delay) => BeginDecay(delay);
private void MigrateFrom(V17Content content)
{
_restoreEquip = content.RestoreEquip;
_flags = content.Flags;
_timeOfDeath = content.TimeOfDeath;
_restoreTable = content.RestoreTable;
_looters = content.Looters;
_killer = content.Killer;
_aggressors = content.Aggressors;
_owner = content.Owner;
_corpseName = content.CorpseName;
_accessLevel = content.AccessLevel;
_guild = content.Guild;
_equipItems = content.EquipItems;
_hairItemId = content.HairItemId;
_hairHue = content.HairHue;
_facialHairItemId = content.FacialHairItemId;
_facialHairHue = content.FacialHairHue;
if (content.DecayTimerDelay != TimeSpan.MinValue)
{
DeserializeDecayTimer(content.DecayTimerDelay);
}
}
[SerializableField(5, setter: "private")] [SerializableField(5, setter: "private")]
private HashSet<Mobile> _looters; private HashSet<Mobile> _looters;

View file

@ -3,18 +3,25 @@ using ModernUO.Serialization;
namespace Server.Items; namespace Server.Items;
[SerializationGenerator(2, false)] [SerializationGenerator(3, false)]
public partial class DecayedCorpse : Container public partial class DecayedCorpse : Container
{ {
private static TimeSpan _defaultDecayTime = TimeSpan.FromMinutes(7.0); private static TimeSpan _defaultDecayTime = TimeSpan.FromMinutes(7.0);
[TimerDrift]
[SerializableField(0, getter: "private", setter: "private")] [SerializableField(0, getter: "private", setter: "private")]
[DeserializeTimer(nameof(DeserializeDecayTimer))]
private Timer _decayTimer; private Timer _decayTimer;
[DeserializeTimerField(0)]
private void DeserializeDecayTimer(TimeSpan delay) => BeginDecay(delay); private void DeserializeDecayTimer(TimeSpan delay) => BeginDecay(delay);
private void MigrateFrom(V2Content content)
{
if (content.DecayTimerDelay != TimeSpan.MinValue)
{
DeserializeDecayTimer(content.DecayTimerDelay);
}
}
public DecayedCorpse(string name) : base(Utility.Random(0xECA, 9)) public DecayedCorpse(string name) : base(Utility.Random(0xECA, 9))
{ {
Movable = false; Movable = false;

View file

@ -11,64 +11,62 @@ public partial class BaseQuiver : Container, ICraftable, IAosItem
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[SerializableField(0, setter: "private")] [SerializableField(0, setter: "private")]
[SaveFlag(nameof(ShouldSerializeAosAttributes), nameof(AttributesDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
private AosAttributes _attributes; private AosAttributes _attributes;
[SerializableFieldSaveFlag(0)]
private bool ShouldSerializeAosAttributes() => !_attributes.IsEmpty; private bool ShouldSerializeAosAttributes() => !_attributes.IsEmpty;
[SerializableFieldDefault(0)]
private AosAttributes AttributesDefaultValue() => new(this); private AosAttributes AttributesDefaultValue() => new(this);
[InvalidateProperties] [InvalidateProperties]
[SerializableField(1)] [SerializableField(1)]
[SaveFlag(nameof(ShouldSerializeLowerAmmoCost))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _lowerAmmoCost; private int _lowerAmmoCost;
[SerializableFieldSaveFlag(1)]
private bool ShouldSerializeLowerAmmoCost() => _lowerAmmoCost != 0; private bool ShouldSerializeLowerAmmoCost() => _lowerAmmoCost != 0;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(2)] [SerializableField(2)]
[SaveFlag(nameof(ShouldSerializeWeightReduction))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _weightReduction; private int _weightReduction;
[SerializableFieldSaveFlag(2)]
private bool ShouldSerializeWeightReduction() => _weightReduction != 0; private bool ShouldSerializeWeightReduction() => _weightReduction != 0;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(3)] [SerializableField(3)]
[SaveFlag(nameof(ShouldSerializeDamageIncrease))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _damageIncrease; private int _damageIncrease;
[SerializableFieldSaveFlag(3)]
private bool ShouldSerializeDamageIncrease() => _damageIncrease != 0; private bool ShouldSerializeDamageIncrease() => _damageIncrease != 0;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(4)] [SerializableField(4)]
[SaveFlag(nameof(ShouldSerializeCrafter))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private string _crafter; private string _crafter;
[SerializableFieldSaveFlag(4)]
private bool ShouldSerializeCrafter() => !string.IsNullOrEmpty(_crafter); private bool ShouldSerializeCrafter() => !string.IsNullOrEmpty(_crafter);
[InvalidateProperties] [InvalidateProperties]
[SerializableField(5)] [SerializableField(5)]
[SaveFlag(nameof(ShouldSerializeQuality), nameof(QualityDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private ClothingQuality _quality; private ClothingQuality _quality;
[SerializableFieldSaveFlag(5)]
private bool ShouldSerializeQuality() => _quality != ClothingQuality.Regular; private bool ShouldSerializeQuality() => _quality != ClothingQuality.Regular;
[SerializableFieldDefault(5)]
private ClothingQuality QualityDefaultValue() => ClothingQuality.Regular; private ClothingQuality QualityDefaultValue() => ClothingQuality.Regular;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(6)] [SerializableField(6)]
[SaveFlag(nameof(ShouldSerializeCapacity))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _capacity; private int _capacity;
[SerializableFieldSaveFlag(6)]
private bool ShouldSerializeCapacity() => _capacity != 0; private bool ShouldSerializeCapacity() => _capacity != 0;
public BaseQuiver(int itemID = 0x2FB7) : base(itemID) public BaseQuiver(int itemID = 0x2FB7) : base(itemID)

View file

@ -371,27 +371,27 @@ public partial class RunebookEntry
private Runebook _runebook; private Runebook _runebook;
[SerializableField(0)] [SerializableField(0)]
[SaveFlag(nameof(ShouldSerializeHouse))]
private BaseHouse _house; private BaseHouse _house;
[SerializableFieldSaveFlag(0)]
public bool ShouldSerializeHouse() => _house?.Deleted == false; public bool ShouldSerializeHouse() => _house?.Deleted == false;
[SerializableField(1)] [SerializableField(1)]
[SaveFlag(nameof(ShouldSerializeLocation))]
private Point3D _location; private Point3D _location;
[SerializableFieldSaveFlag(1)]
public bool ShouldSerializeLocation() => _house?.Deleted != false; public bool ShouldSerializeLocation() => _house?.Deleted != false;
[SerializableField(2)] [SerializableField(2)]
[SaveFlag(nameof(ShouldSerializeMap))]
private Map _map; private Map _map;
[SerializableFieldSaveFlag(2)]
public bool ShouldSerializeMap() => _house?.Deleted != false; public bool ShouldSerializeMap() => _house?.Deleted != false;
[SerializableField(3)] [SerializableField(3)]
[SaveFlag(nameof(ShouldSerializeDesc))]
private string _description; private string _description;
[SerializableFieldSaveFlag(3)]
public bool ShouldSerializeDesc() => _house?.Deleted != false; public bool ShouldSerializeDesc() => _house?.Deleted != false;
public RunebookEntry( public RunebookEntry(

View file

@ -31,6 +31,7 @@ public partial class FountainOfLife : BaseAddonContainer
public const int MaxCharges = 10; public const int MaxCharges = 10;
[SerializableField(1)] [SerializableField(1)]
[DeserializeTimer(nameof(DeserializeTimer), wallClock: true)]
private Timer _timer; private Timer _timer;
[Constructible] [Constructible]
@ -39,7 +40,6 @@ public partial class FountainOfLife : BaseAddonContainer
_charges = charges; _charges = charges;
} }
[DeserializeTimerField(1)]
private void DeserializeTimer(TimeSpan delay) private void DeserializeTimer(TimeSpan delay)
{ {
_timer = Timer.DelayCall(Utility.Max(delay, TimeSpan.Zero), RechargeTime, Recharge); _timer = Timer.DelayCall(Utility.Max(delay, TimeSpan.Zero), RechargeTime, Recharge);

View file

@ -128,136 +128,131 @@ public partial class BaseTalisman : Item, IAosItem
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[SerializableField(0, setter: "private")] [SerializableField(0, setter: "private")]
[SaveFlag(nameof(ShouldSerializeAttributes), nameof(AttributesDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
private AosAttributes _attributes; private AosAttributes _attributes;
[SerializableFieldSaveFlag(0)]
public bool ShouldSerializeAttributes() => !_attributes.IsEmpty; public bool ShouldSerializeAttributes() => !_attributes.IsEmpty;
[SerializableFieldDefault(0)]
private AosAttributes AttributesDefaultValue() => new(this); private AosAttributes AttributesDefaultValue() => new(this);
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[SerializableField(1, setter: "private")] [SerializableField(1, setter: "private")]
[SaveFlag(nameof(ShouldSerializeSkillBonuses), nameof(SkillBonusesDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
private AosSkillBonuses _skillBonuses; private AosSkillBonuses _skillBonuses;
[SerializableFieldSaveFlag(1)]
public bool ShouldSerializeSkillBonuses() => !_skillBonuses.IsEmpty; public bool ShouldSerializeSkillBonuses() => !_skillBonuses.IsEmpty;
[SerializableFieldDefault(1)]
private AosSkillBonuses SkillBonusesDefaultValue() => new(this); private AosSkillBonuses SkillBonusesDefaultValue() => new(this);
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[InvalidateProperties] [InvalidateProperties]
[SerializableField(2)] [SerializableField(2)]
[SaveFlag(nameof(ShouldSerializeProtection), nameof(ProtectionDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
private TalismanAttribute _protection; private TalismanAttribute _protection;
[SerializableFieldSaveFlag(2)]
public bool ShouldSerializeProtection() => !_protection.IsEmpty; public bool ShouldSerializeProtection() => !_protection.IsEmpty;
[SerializableFieldDefault(2)]
private TalismanAttribute ProtectionDefaultValue() => new(); private TalismanAttribute ProtectionDefaultValue() => new();
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[InvalidateProperties] [InvalidateProperties]
[SerializableField(3)] [SerializableField(3)]
[SaveFlag(nameof(ShouldSerializeKiller), nameof(KillerDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
private TalismanAttribute _killer; private TalismanAttribute _killer;
[SerializableFieldSaveFlag(3)]
public bool ShouldSerializeKiller() => !_killer.IsEmpty; public bool ShouldSerializeKiller() => !_killer.IsEmpty;
[SerializableFieldDefault(3)]
private TalismanAttribute KillerDefaultValue() => new(); private TalismanAttribute KillerDefaultValue() => new();
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[InvalidateProperties] [InvalidateProperties]
[SerializableField(4)] [SerializableField(4)]
[SaveFlag(nameof(ShouldSerializeSummoner), nameof(SummonerDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
private TalismanAttribute _summoner; private TalismanAttribute _summoner;
[SerializableFieldSaveFlag(4)]
public bool ShouldSerializeSummoner() => !_summoner.IsEmpty; public bool ShouldSerializeSummoner() => !_summoner.IsEmpty;
[SerializableFieldDefault(4)]
private TalismanAttribute SummonerDefaultValue() => new(); private TalismanAttribute SummonerDefaultValue() => new();
[InvalidateProperties] [InvalidateProperties]
[SerializableField(5)] [SerializableField(5)]
[SaveFlag(nameof(ShouldSerializeRemoval))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private TalismanRemoval _removal; private TalismanRemoval _removal;
[SerializableFieldSaveFlag(5)]
public bool ShouldSerializeRemoval() => _removal != TalismanRemoval.None; public bool ShouldSerializeRemoval() => _removal != TalismanRemoval.None;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(6)] [SerializableField(6)]
[SaveFlag(nameof(ShouldSerializeSkill))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private SkillName _skill; private SkillName _skill;
[SerializableFieldSaveFlag(6)]
public bool ShouldSerializeSkill() => (int)_skill != 0; public bool ShouldSerializeSkill() => (int)_skill != 0;
[EncodedInt] [EncodedInt]
[InvalidateProperties] [InvalidateProperties]
[SerializableField(7)] [SerializableField(7)]
[SaveFlag(nameof(ShouldSerializeSuccessBonus))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _successBonus; private int _successBonus;
[SerializableFieldSaveFlag(7)]
public bool ShouldSerializeSuccessBonus() => _successBonus != 0; public bool ShouldSerializeSuccessBonus() => _successBonus != 0;
[EncodedInt] [EncodedInt]
[InvalidateProperties] [InvalidateProperties]
[SerializableField(8)] [SerializableField(8)]
[SaveFlag(nameof(ShouldSerializeExceptionalBonus))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _exceptionalBonus; private int _exceptionalBonus;
[SerializableFieldSaveFlag(8)]
public bool ShouldSerializeExceptionalBonus() => _exceptionalBonus != 0; public bool ShouldSerializeExceptionalBonus() => _exceptionalBonus != 0;
[EncodedInt] [EncodedInt]
[InvalidateProperties] [InvalidateProperties]
[SerializableField(9)] [SerializableField(9)]
[SaveFlag(nameof(ShouldSerializeMaxCharges))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _maxCharges; private int _maxCharges;
[SerializableFieldSaveFlag(9)]
public bool ShouldSerializeMaxCharges() => _maxCharges != 0; public bool ShouldSerializeMaxCharges() => _maxCharges != 0;
[EncodedInt] [EncodedInt]
[InvalidateProperties] [InvalidateProperties]
[SerializableField(11)] [SerializableField(11)]
[SaveFlag(nameof(ShouldSerializeMaxChargeTime))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _maxChargeTime; private int _maxChargeTime;
[SerializableFieldSaveFlag(11)]
public bool ShouldSerializeMaxChargeTime() => _maxChargeTime != 0; public bool ShouldSerializeMaxChargeTime() => _maxChargeTime != 0;
[EncodedInt] [EncodedInt]
[InvalidateProperties] [InvalidateProperties]
[SerializableField(12)] [SerializableField(12)]
[SaveFlag(nameof(ShouldSerializeChargeTime))]
private int _chargeTime; private int _chargeTime;
[SerializableFieldSaveFlag(12)]
public bool ShouldSerializeChargeTime() => _chargeTime != 0; public bool ShouldSerializeChargeTime() => _chargeTime != 0;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(13)] [SerializableField(13)]
[SaveFlag(nameof(ShouldSerializeBlessed))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private bool _blessed; private bool _blessed;
[SerializableFieldSaveFlag(13)]
public bool ShouldSerializeBlessed() => _blessed; public bool ShouldSerializeBlessed() => _blessed;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(14)] [SerializableField(14)]
[SaveFlag(nameof(ShouldSerializeSlayer))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private TalismanSlayerName _slayer; private TalismanSlayerName _slayer;
[SerializableFieldSaveFlag(14)]
public bool ShouldSerializeSlayer() => _slayer != TalismanSlayerName.None; public bool ShouldSerializeSlayer() => _slayer != TalismanSlayerName.None;
private BaseCreature _creature; private BaseCreature _creature;
@ -285,6 +280,7 @@ public partial class BaseTalisman : Item, IAosItem
public virtual bool ForceShowName => false; // used to override default summoner/removal name public virtual bool ForceShowName => false; // used to override default summoner/removal name
[SerializableProperty(10)] [SerializableProperty(10)]
[SaveFlag(nameof(ShouldSerializeCharges))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int Charges public int Charges
{ {
@ -303,7 +299,6 @@ public partial class BaseTalisman : Item, IAosItem
} }
} }
[SerializableFieldSaveFlag(10)]
public bool ShouldSerializeCharges() => _charges != 0; public bool ShouldSerializeCharges() => _charges != 0;
public static void Configure() public static void Configure()

View file

@ -56,130 +56,126 @@ public abstract partial class BaseWeapon
[InvalidateProperties] [InvalidateProperties]
[SerializableField(0)] [SerializableField(0)]
[SaveFlag(nameof(ShouldSerializeDamageLevel))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private WeaponDamageLevel _damageLevel; private WeaponDamageLevel _damageLevel;
[SerializableFieldSaveFlag(0)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool ShouldSerializeDamageLevel() => _damageLevel != WeaponDamageLevel.Regular; private bool ShouldSerializeDamageLevel() => _damageLevel != WeaponDamageLevel.Regular;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(5)] [SerializableField(5)]
[SaveFlag(nameof(ShouldSerializeMaxHitPoints))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _maxHitPoints; private int _maxHitPoints;
[SerializableFieldSaveFlag(5)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool ShouldSerializeMaxHitPoints() => _maxHitPoints != 0; private bool ShouldSerializeMaxHitPoints() => _maxHitPoints != 0;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(6)] [SerializableField(6)]
[SaveFlag(nameof(ShouldSerializeSlayer))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private SlayerName _slayer; private SlayerName _slayer;
[SerializableFieldSaveFlag(6)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool ShouldSerializeSlayer() => _slayer != SlayerName.None; private bool ShouldSerializeSlayer() => _slayer != SlayerName.None;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(7)] [SerializableField(7)]
[SaveFlag(nameof(ShouldSerializePoison))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private Poison _poison; private Poison _poison;
[SerializableFieldSaveFlag(7)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool ShouldSerializePoison() => _poison != null; private bool ShouldSerializePoison() => _poison != null;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(8)] [SerializableField(8)]
[SaveFlag(nameof(ShouldSerializePoisonCharges))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private int _poisonCharges; private int _poisonCharges;
[SerializableFieldSaveFlag(8)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool ShouldSerializePoisonCharges() => _poisonCharges > 0; private bool ShouldSerializePoisonCharges() => _poisonCharges > 0;
[InvalidateProperties] [InvalidateProperties]
[SerializableField(9)] [SerializableField(9)]
[SaveFlag(nameof(ShouldSerializeCrafter))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private string _crafter; private string _crafter;
[SerializableFieldSaveFlag(9)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool ShouldSerializeCrafter() => !string.IsNullOrEmpty(_crafter); private bool ShouldSerializeCrafter() => !string.IsNullOrEmpty(_crafter);
[InvalidateProperties] [InvalidateProperties]
[SerializableField(10)] [SerializableField(10)]
[SaveFlag(nameof(ShouldSerializeIdentified))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private bool _identified; private bool _identified;
[SerializableFieldSaveFlag(10)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool ShouldSerializeIdentified() => _identified; private bool ShouldSerializeIdentified() => _identified;
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[SerializableField(24, setter: "private")] [SerializableField(24, setter: "private")]
[SaveFlag(nameof(ShouldSerializeAttributes), nameof(AttributesDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
private AosAttributes _attributes; private AosAttributes _attributes;
[SerializableFieldSaveFlag(24)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool ShouldSerializeAttributes() => !_attributes.IsEmpty; private bool ShouldSerializeAttributes() => !_attributes.IsEmpty;
[SerializableFieldDefault(24)]
private AosAttributes AttributesDefaultValue() => new(this); private AosAttributes AttributesDefaultValue() => new(this);
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[SerializableField(25, setter: "private")] [SerializableField(25, setter: "private")]
[SaveFlag(nameof(ShouldSerializeWeaponAttributes), nameof(WeaponAttributesDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
private AosWeaponAttributes _weaponAttributes; private AosWeaponAttributes _weaponAttributes;
[SerializableFieldSaveFlag(25)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool ShouldSerializeWeaponAttributes() => !_weaponAttributes.IsEmpty; private bool ShouldSerializeWeaponAttributes() => !_weaponAttributes.IsEmpty;
[SerializableFieldDefault(25)]
private AosWeaponAttributes WeaponAttributesDefaultValue() => new(this); private AosWeaponAttributes WeaponAttributesDefaultValue() => new(this);
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[SerializableField(26, setter: "private")] [SerializableField(26, setter: "private")]
[SaveFlag(nameof(ShouldSerializeSkillBonuses), nameof(SkillBonusesDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
private AosSkillBonuses _skillBonuses; private AosSkillBonuses _skillBonuses;
[SerializableFieldSaveFlag(26)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool ShouldSerializeSkillBonuses() => !_skillBonuses.IsEmpty; private bool ShouldSerializeSkillBonuses() => !_skillBonuses.IsEmpty;
[SerializableFieldDefault(26)]
private AosSkillBonuses SkillBonusesDefaultValue() => new(this); private AosSkillBonuses SkillBonusesDefaultValue() => new(this);
[InvalidateProperties] [InvalidateProperties]
[SerializableField(27)] [SerializableField(27)]
[SaveFlag(nameof(ShouldSerializeSlayer2))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private SlayerName _slayer2; private SlayerName _slayer2;
[SerializableFieldSaveFlag(27)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool ShouldSerializeSlayer2() => _slayer2 != SlayerName.None; private bool ShouldSerializeSlayer2() => _slayer2 != SlayerName.None;
[SerializedIgnoreDupe] [SerializedIgnoreDupe]
[SerializableField(28, setter: "private")] [SerializableField(28, setter: "private")]
[SaveFlag(nameof(ShouldSerializeElementAttributes), nameof(AosElementAttributesDefaultValue))]
[SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)] [SerializedCommandProperty(AccessLevel.GameMaster, canModify: true)]
private AosElementAttributes _aosElementDamages; private AosElementAttributes _aosElementDamages;
[SerializableFieldSaveFlag(28)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool ShouldSerializeElementAttributes() => !_aosElementDamages.IsEmpty; private bool ShouldSerializeElementAttributes() => !_aosElementDamages.IsEmpty;
[SerializableFieldDefault(28)]
private AosElementAttributes AosElementAttributesDefaultValue() => new(this); private AosElementAttributes AosElementAttributesDefaultValue() => new(this);
[InvalidateProperties] [InvalidateProperties]
[SerializableField(29)] [SerializableField(29)]
[SaveFlag(nameof(ShouldSerializeEngravedText))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
private string _engravedText; private string _engravedText;
[SerializableFieldSaveFlag(29)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool ShouldSerializeEngravedText() => !string.IsNullOrEmpty(_engravedText); private bool ShouldSerializeEngravedText() => !string.IsNullOrEmpty(_engravedText);
@ -286,6 +282,7 @@ public abstract partial class BaseWeapon
public bool Consecrated { get; set; } public bool Consecrated { get; set; }
[SerializableProperty(1)] [SerializableProperty(1)]
[SaveFlag(nameof(ShouldSerializeWeaponAccuracy))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public WeaponAccuracyLevel AccuracyLevel public WeaponAccuracyLevel AccuracyLevel
{ {
@ -321,10 +318,10 @@ public abstract partial class BaseWeapon
} }
} }
[SerializableFieldSaveFlag(1)]
private bool ShouldSerializeWeaponAccuracy() => _accuracyLevel != WeaponAccuracyLevel.Regular; private bool ShouldSerializeWeaponAccuracy() => _accuracyLevel != WeaponAccuracyLevel.Regular;
[SerializableProperty(2)] [SerializableProperty(2)]
[SaveFlag(nameof(ShouldSerializeDurabilityLevel))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public WeaponDurabilityLevel DurabilityLevel public WeaponDurabilityLevel DurabilityLevel
{ {
@ -339,10 +336,10 @@ public abstract partial class BaseWeapon
} }
} }
[SerializableFieldSaveFlag(2)]
private bool ShouldSerializeDurabilityLevel() => _durabilityLevel != WeaponDurabilityLevel.Regular; private bool ShouldSerializeDurabilityLevel() => _durabilityLevel != WeaponDurabilityLevel.Regular;
[SerializableProperty(3)] [SerializableProperty(3)]
[SaveFlag(nameof(ShouldSerializeQuality), nameof(QualityDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public WeaponQuality Quality public WeaponQuality Quality
{ {
@ -357,13 +354,12 @@ public abstract partial class BaseWeapon
} }
} }
[SerializableFieldSaveFlag(3)]
private bool ShouldSerializeQuality() => _quality != WeaponQuality.Regular; private bool ShouldSerializeQuality() => _quality != WeaponQuality.Regular;
[SerializableFieldDefault(3)]
private WeaponQuality QualityDefaultValue() => WeaponQuality.Regular; private WeaponQuality QualityDefaultValue() => WeaponQuality.Regular;
[SerializableProperty(4)] [SerializableProperty(4)]
[SaveFlag(nameof(ShouldSerializeHitPoints))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int HitPoints public int HitPoints
{ {
@ -387,10 +383,10 @@ public abstract partial class BaseWeapon
} }
} }
[SerializableFieldSaveFlag(4)]
private bool ShouldSerializeHitPoints() => _hitPoints > 0; private bool ShouldSerializeHitPoints() => _hitPoints > 0;
[SerializableProperty(11)] [SerializableProperty(11)]
[SaveFlag(nameof(ShouldSerializeStrReq), nameof(StrReqDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int StrRequirement public int StrRequirement
{ {
@ -403,13 +399,12 @@ public abstract partial class BaseWeapon
} }
} }
[SerializableFieldSaveFlag(11)]
private bool ShouldSerializeStrReq() => _strRequirement != -1; private bool ShouldSerializeStrReq() => _strRequirement != -1;
[SerializableFieldDefault(11)]
private int StrReqDefaultValue() => -1; private int StrReqDefaultValue() => -1;
[SerializableProperty(12)] [SerializableProperty(12)]
[SaveFlag(nameof(ShouldSerializeDexReq), nameof(DexReqDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int DexRequirement public int DexRequirement
{ {
@ -422,13 +417,12 @@ public abstract partial class BaseWeapon
} }
} }
[SerializableFieldSaveFlag(12)]
private bool ShouldSerializeDexReq() => _dexRequirement != -1; private bool ShouldSerializeDexReq() => _dexRequirement != -1;
[SerializableFieldDefault(12)]
private int DexReqDefaultValue() => -1; private int DexReqDefaultValue() => -1;
[SerializableProperty(13)] [SerializableProperty(13)]
[SaveFlag(nameof(ShouldSerializeIntReq), nameof(IntReqDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int IntRequirement public int IntRequirement
{ {
@ -441,13 +435,12 @@ public abstract partial class BaseWeapon
} }
} }
[SerializableFieldSaveFlag(13)]
private bool ShouldSerializeIntReq() => _intRequirement != -1; private bool ShouldSerializeIntReq() => _intRequirement != -1;
[SerializableFieldDefault(13)]
private int IntReqDefaultValue() => -1; private int IntReqDefaultValue() => -1;
[SerializableProperty(14)] [SerializableProperty(14)]
[SaveFlag(nameof(ShouldSerializeMinDamage), nameof(MinDamageDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int MinDamage public int MinDamage
{ {
@ -460,13 +453,12 @@ public abstract partial class BaseWeapon
} }
} }
[SerializableFieldSaveFlag(14)]
private bool ShouldSerializeMinDamage() => _minDamage != -1; private bool ShouldSerializeMinDamage() => _minDamage != -1;
[SerializableFieldDefault(14)]
private int MinDamageDefaultValue() => -1; private int MinDamageDefaultValue() => -1;
[SerializableProperty(15)] [SerializableProperty(15)]
[SaveFlag(nameof(ShouldSerializeMaxDamage), nameof(MaxDamageDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int MaxDamage public int MaxDamage
{ {
@ -479,13 +471,12 @@ public abstract partial class BaseWeapon
} }
} }
[SerializableFieldSaveFlag(15)]
private bool ShouldSerializeMaxDamage() => _maxDamage != -1; private bool ShouldSerializeMaxDamage() => _maxDamage != -1;
[SerializableFieldDefault(15)]
private int MaxDamageDefaultValue() => -1; private int MaxDamageDefaultValue() => -1;
[SerializableProperty(16)] [SerializableProperty(16)]
[SaveFlag(nameof(ShouldSerializeHitSound), nameof(HitSoundDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int HitSound public int HitSound
{ {
@ -497,13 +488,12 @@ public abstract partial class BaseWeapon
} }
} }
[SerializableFieldSaveFlag(16)]
private bool ShouldSerializeHitSound() => _hitSound != -1; private bool ShouldSerializeHitSound() => _hitSound != -1;
[SerializableFieldDefault(16)]
private int HitSoundDefaultValue() => -1; private int HitSoundDefaultValue() => -1;
[SerializableProperty(17)] [SerializableProperty(17)]
[SaveFlag(nameof(ShouldSerializeMissSound), nameof(MissSoundDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int MissSound public int MissSound
{ {
@ -515,13 +505,12 @@ public abstract partial class BaseWeapon
} }
} }
[SerializableFieldSaveFlag(17)]
private bool ShouldSerializeMissSound() => _missSound != -1; private bool ShouldSerializeMissSound() => _missSound != -1;
[SerializableFieldDefault(17)]
private int MissSoundDefaultValue() => -1; private int MissSoundDefaultValue() => -1;
[SerializableProperty(18)] [SerializableProperty(18)]
[SaveFlag(nameof(ShouldSerializeSpeed), nameof(SpeedDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public float Speed public float Speed
{ {
@ -552,13 +541,12 @@ public abstract partial class BaseWeapon
} }
} }
[SerializableFieldSaveFlag(18)]
private bool ShouldSerializeSpeed() => _speed != -1; private bool ShouldSerializeSpeed() => _speed != -1;
[SerializableFieldDefault(18)]
private float SpeedDefaultValue() => -1; private float SpeedDefaultValue() => -1;
[SerializableProperty(19)] [SerializableProperty(19)]
[SaveFlag(nameof(ShouldSerializeMaxRange), nameof(MaxRangeDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int MaxRange public int MaxRange
{ {
@ -571,13 +559,12 @@ public abstract partial class BaseWeapon
} }
} }
[SerializableFieldSaveFlag(19)]
private bool ShouldSerializeMaxRange() => _maxRange != -1; private bool ShouldSerializeMaxRange() => _maxRange != -1;
[SerializableFieldDefault(19)]
private int MaxRangeDefaultValue() => -1; private int MaxRangeDefaultValue() => -1;
[SerializableProperty(20)] [SerializableProperty(20)]
[SaveFlag(nameof(ShouldSerializeSkill), nameof(SkillNameDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public SkillName Skill public SkillName Skill
{ {
@ -590,13 +577,12 @@ public abstract partial class BaseWeapon
} }
} }
[SerializableFieldSaveFlag(20)]
private bool ShouldSerializeSkill() => _skill != (SkillName)(-1); private bool ShouldSerializeSkill() => _skill != (SkillName)(-1);
[SerializableFieldDefault(20)]
private SkillName SkillNameDefaultValue() => (SkillName)(-1); private SkillName SkillNameDefaultValue() => (SkillName)(-1);
[SerializableProperty(21)] [SerializableProperty(21)]
[SaveFlag(nameof(ShouldSerializeType), nameof(TypeDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public WeaponType Type public WeaponType Type
{ {
@ -608,13 +594,12 @@ public abstract partial class BaseWeapon
} }
} }
[SerializableFieldSaveFlag(21)]
private bool ShouldSerializeType() => _type != (WeaponType)(-1); private bool ShouldSerializeType() => _type != (WeaponType)(-1);
[SerializableFieldDefault(21)]
private WeaponType TypeDefaultValue() => (WeaponType)(-1); private WeaponType TypeDefaultValue() => (WeaponType)(-1);
[SerializableProperty(22)] [SerializableProperty(22)]
[SaveFlag(nameof(ShouldSerializeAnimation), nameof(AnimationDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public WeaponAnimation Animation public WeaponAnimation Animation
{ {
@ -626,13 +611,12 @@ public abstract partial class BaseWeapon
} }
} }
[SerializableFieldSaveFlag(22)]
private bool ShouldSerializeAnimation() => _animation != (WeaponAnimation)(-1); private bool ShouldSerializeAnimation() => _animation != (WeaponAnimation)(-1);
[SerializableFieldDefault(22)]
private WeaponAnimation AnimationDefaultValue() => (WeaponAnimation)(-1); private WeaponAnimation AnimationDefaultValue() => (WeaponAnimation)(-1);
[SerializableProperty(23)] [SerializableProperty(23)]
[SaveFlag(nameof(ShouldSerializeResource), nameof(ResourceDefaultValue))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource public CraftResource Resource
{ {
@ -648,10 +632,8 @@ public abstract partial class BaseWeapon
} }
} }
[SerializableFieldSaveFlag(23)]
private bool ShouldSerializeResource() => _resource != CraftResource.Iron; private bool ShouldSerializeResource() => _resource != CraftResource.Iron;
[SerializableFieldDefault(23)]
private CraftResource ResourceDefaultValue() => CraftResource.Iron; private CraftResource ResourceDefaultValue() => CraftResource.Iron;
public virtual int OnCraft( public virtual int OnCraft(

View file

@ -0,0 +1,43 @@
{
"version": 2,
"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": [
"@AnchoredTimer"
]
}
]
}

View file

@ -0,0 +1,137 @@
{
"version": 18,
"type": "Server.Items.Corpse",
"properties": [
{
"name": "RestoreEquip",
"type": "System.Collections.Generic.List\u003CServer.Item\u003E",
"rule": "ListMigrationRule",
"ruleArguments": [
"Server.Item",
"SerializableInterfaceMigrationRule"
]
},
{
"name": "Flags",
"type": "Server.Items.CorpseFlag",
"rule": "EnumMigrationRule"
},
{
"name": "TimeOfDeath",
"type": "System.DateTime",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
"DeltaTime"
]
},
{
"name": "RestoreTable",
"type": "System.Collections.Generic.Dictionary\u003CServer.Item, Server.Point3D\u003E",
"rule": "DictionaryMigrationRule",
"ruleArguments": [
"Server.Item",
"SerializableInterfaceMigrationRule",
"0",
"Server.Point3D",
"PrimitiveUOTypeMigrationRule",
"1",
"Point3D"
]
},
{
"name": "DecayTimer",
"type": "Server.Timer",
"rule": "TimerMigrationRule",
"ruleArguments": [
"@AnchoredTimer"
]
},
{
"name": "Looters",
"type": "System.Collections.Generic.HashSet\u003CServer.Mobile\u003E",
"rule": "HashSetMigrationRule",
"ruleArguments": [
"Server.Mobile",
"SerializableInterfaceMigrationRule"
]
},
{
"name": "Killer",
"type": "Server.Mobile",
"rule": "SerializableInterfaceMigrationRule"
},
{
"name": "Aggressors",
"type": "System.Collections.Generic.List\u003CServer.Mobile\u003E",
"rule": "ListMigrationRule",
"ruleArguments": [
"Server.Mobile",
"SerializableInterfaceMigrationRule"
]
},
{
"name": "Owner",
"type": "Server.Mobile",
"rule": "SerializableInterfaceMigrationRule"
},
{
"name": "CorpseName",
"type": "string",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "AccessLevel",
"type": "Server.AccessLevel",
"rule": "EnumMigrationRule"
},
{
"name": "Guild",
"type": "Server.Guilds.Guild",
"rule": "SerializableInterfaceMigrationRule"
},
{
"name": "EquipItems",
"type": "System.Collections.Generic.List\u003CServer.Item\u003E",
"rule": "ListMigrationRule",
"ruleArguments": [
"Server.Item",
"SerializableInterfaceMigrationRule"
]
},
{
"name": "HairItemId",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "HairHue",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "FacialHairItemId",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "FacialHairHue",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
}
]
}

View file

@ -0,0 +1,14 @@
{
"version": 4,
"type": "Server.Items.DeathRobe",
"properties": [
{
"name": "DecayTimer",
"type": "Server.Timer",
"rule": "TimerMigrationRule",
"ruleArguments": [
"@AnchoredTimer"
]
}
]
}

View file

@ -0,0 +1,14 @@
{
"version": 3,
"type": "Server.Items.DecayedCorpse",
"properties": [
{
"name": "DecayTimer",
"type": "Server.Timer",
"rule": "TimerMigrationRule",
"ruleArguments": [
"@AnchoredTimer"
]
}
]
}

View file

@ -0,0 +1,19 @@
{
"version": 3,
"type": "Server.Items.FillableContainer",
"properties": [
{
"name": "ContentType",
"type": "Server.Items.FillableContentType",
"rule": "EnumMigrationRule"
},
{
"name": "RespawnTimer",
"type": "Server.Timer",
"rule": "TimerMigrationRule",
"ruleArguments": [
"@AnchoredTimer"
]
}
]
}

View file

@ -0,0 +1,46 @@
{
"version": 1,
"type": "Server.Items.MarkContainer",
"properties": [
{
"name": "AutoLock",
"type": "bool",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "RelockTimer",
"type": "Server.Items.MarkContainer.InternalTimer",
"rule": "TimerMigrationRule",
"ruleArguments": [
"@AnchoredTimer"
]
},
{
"name": "TargetMap",
"type": "Server.Map",
"rule": "PrimitiveUOTypeMigrationRule",
"ruleArguments": [
"Map"
]
},
{
"name": "Target",
"type": "Server.Point3D",
"rule": "PrimitiveUOTypeMigrationRule",
"ruleArguments": [
"Point3D"
]
},
{
"name": "Description",
"type": "string",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
}
]
}

View file

@ -0,0 +1,57 @@
{
"version": 4,
"type": "Server.Items.TreasureMapChest",
"properties": [
{
"name": "Guardians",
"type": "System.Collections.Generic.List\u003CServer.Mobile\u003E",
"rule": "ListMigrationRule",
"ruleArguments": [
"@Tidy",
"@CanBeNull",
"Server.Mobile",
"SerializableInterfaceMigrationRule"
]
},
{
"name": "Temporary",
"type": "bool",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "Owner",
"type": "Server.Mobile",
"rule": "SerializableInterfaceMigrationRule"
},
{
"name": "Level",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "ExpireTimer",
"type": "Server.Timer",
"rule": "TimerMigrationRule",
"ruleArguments": [
"@AnchoredTimer"
]
},
{
"name": "Lifted",
"type": "System.Collections.Generic.HashSet\u003CServer.Item\u003E",
"rule": "HashSetMigrationRule",
"ruleArguments": [
"@Tidy",
"@CanBeNull",
"Server.Item",
"SerializableInterfaceMigrationRule"
]
}
]
}

View file

@ -0,0 +1,43 @@
{
"version": 3,
"type": "Server.Mobiles.BaseEscortable",
"properties": [
{
"name": "DestinationString",
"type": "string",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "DeleteTimer",
"type": "Server.Timer",
"rule": "TimerMigrationRule",
"ruleArguments": [
"@AnchoredTimer"
]
},
{
"name": "MlQuestType",
"type": "System.Type",
"rule": "PrimitiveTypeMigrationRule"
},
{
"name": "MlQuestDestinationMessage",
"type": "Server.TextDefinition",
"rule": "PrimitiveUOTypeMigrationRule",
"ruleArguments": [
"TextDefinition"
]
},
{
"name": "MlQuestPaymentMessage",
"type": "Server.TextDefinition",
"rule": "PrimitiveUOTypeMigrationRule",
"ruleArguments": [
"TextDefinition"
]
}
]
}

View file

@ -11,19 +11,19 @@ namespace Server.Mobiles
public partial class EtherealMount : Item, IMount, IMountItem, IRewardItem public partial class EtherealMount : Item, IMount, IMountItem, IRewardItem
{ {
[SerializableField(0)] [SerializableField(0)]
[SaveFlag(nameof(ShouldSerializeIsDonationItem))]
[SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] [SerializedCommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
public bool _isDonationItem; public bool _isDonationItem;
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
[SerializableFieldSaveFlag(0)]
public bool ShouldSerializeIsDonationItem() => _isDonationItem; public bool ShouldSerializeIsDonationItem() => _isDonationItem;
[SerializableField(1)] [SerializableField(1)]
[SaveFlag(nameof(ShouldSerializeIsRewardItem))]
[SerializedCommandProperty(AccessLevel.GameMaster)] [SerializedCommandProperty(AccessLevel.GameMaster)]
public bool _isRewardItem; public bool _isRewardItem;
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
[SerializableFieldSaveFlag(1)]
public bool ShouldSerializeIsRewardItem() => _isRewardItem; public bool ShouldSerializeIsRewardItem() => _isRewardItem;
[Constructible] [Constructible]
@ -87,6 +87,7 @@ namespace Server.Mobiles
public virtual int EtherealHue => 0x4001; public virtual int EtherealHue => 0x4001;
[SerializableProperty(4)] [SerializableProperty(4)]
[SaveFlag(nameof(ShouldSerializeRider))]
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public Mobile Rider public Mobile Rider
{ {
@ -124,11 +125,11 @@ namespace Server.Mobiles
} }
} }
[SerializableFieldSaveFlag(4)]
private bool ShouldSerializeRider() => _rider != null; private bool ShouldSerializeRider() => _rider != null;
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
[SerializableProperty(5)] [SerializableProperty(5)]
[SaveFlag(nameof(ShouldSerializeSteps))]
public int Steps public int Steps
{ {
get => _steps; get => _steps;
@ -139,7 +140,6 @@ namespace Server.Mobiles
} }
} }
[SerializableFieldSaveFlag(5)]
private bool ShouldSerializeSteps() => _steps != StepsMax; private bool ShouldSerializeSteps() => _steps != StepsMax;
public virtual int StepsMax => 3840; // Should be same as horse public virtual int StepsMax => 3840; // Should be same as horse

View file

@ -17,7 +17,7 @@ using EDI = Server.Mobiles.EscortDestinationInfo;
namespace Server.Mobiles; namespace Server.Mobiles;
[SerializationGenerator(2, false)] [SerializationGenerator(3, false)]
public partial class BaseEscortable : BaseCreature public partial class BaseEscortable : BaseCreature
{ {
private static readonly ILogger logger = LogFactory.GetLogger(typeof(BaseEscortable)); private static readonly ILogger logger = LogFactory.GetLogger(typeof(BaseEscortable));
@ -158,16 +158,22 @@ public partial class BaseEscortable : BaseCreature
[SerializableField(0, setter: "private")] [SerializableField(0, setter: "private")]
private string _destinationString; private string _destinationString;
[TimerDrift]
[SerializableField(1)] [SerializableField(1)]
[DeserializeTimer(nameof(DeserializeDeleteTimer))]
private Timer _deleteTimer; private Timer _deleteTimer;
[DeserializeTimerField(1)] private void DeserializeDeleteTimer(TimeSpan delay) => Timer.DelayCall(delay, Delete);
private void DeserializeDeleteTimer(TimeSpan delay)
private void MigrateFrom(V2Content content)
{ {
if (delay >= TimeSpan.Zero) _destinationString = content.DestinationString;
_mlQuestType = content.MlQuestType;
_mlQuestDestinationMessage = content.MlQuestDestinationMessage;
_mlQuestPaymentMessage = content.MlQuestPaymentMessage;
if (content.DeleteTimerDelay != TimeSpan.MinValue)
{ {
Timer.DelayCall(delay, Delete); DeserializeDeleteTimer(content.DeleteTimerDelay);
} }
} }

View file

@ -50,8 +50,8 @@
<PackageReference Include="ModernUO.CodeGeneratedEvents.Generator" Version="1.0.3.2" PrivateAssets="all" /> <PackageReference Include="ModernUO.CodeGeneratedEvents.Generator" Version="1.0.3.2" PrivateAssets="all" />
<PackageReference Include="ZstdNet" Version="1.5.7" /> <PackageReference Include="ZstdNet" Version="1.5.7" />
<PackageReference Include="ModernUO.Serialization.Annotations" Version="3.0.0" /> <PackageReference Include="ModernUO.Serialization.Annotations" Version="4.0.0" />
<PackageReference Include="ModernUO.Serialization.Generator" Version="3.0.0" PrivateAssets="all" /> <PackageReference Include="ModernUO.Serialization.Generator" Version="4.0.0" PrivateAssets="all" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<AdditionalFiles Include="Migrations/*.v*.json" /> <AdditionalFiles Include="Migrations/*.v*.json" />