feat: Updates to Serialization Generator v2.2 (#1157)

* Adds `SerializationProperty` - This will generate the private variable for serialization. Also provides an option `useField` to specify your own. Example:
  ```cs
  [SerializationProperty(0, useField: nameof(_resource)]
  ```
This commit is contained in:
Kamron Batman 2022-09-04 08:45:27 -07:00 committed by GitHub
parent d82028a071
commit 89815ad4d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 242 additions and 361 deletions

View file

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

View file

@ -26,7 +26,7 @@ jobs:
- name: Setup .NET 6
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.300
dotnet-version: 6.0.400
- name: Build
run: ./publish.cmd
- name: Test

View file

@ -59,7 +59,7 @@
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="Nerdbank.GitVersioning" Condition="!Exists('packages.config')">
<Version>3.5.107</Version>
<Version>3.5.109</Version>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<AdditionalFiles Include="..\..\Rules.ruleset" />

View file

@ -3,9 +3,9 @@
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="Moq" Version="4.18.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="Moq" Version="4.18.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
<ProjectReference Include="..\Server\Server.csproj" />
<ProjectReference Include="..\UOContent\UOContent.csproj" />

View file

@ -23,14 +23,6 @@
""
]
},
{
"name": "Absolute",
"type": "bool",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "Value",
"type": "double",

View file

@ -20,12 +20,6 @@ namespace Server;
[SerializationGenerator(0)]
public partial class ResistanceMod : MobileMod
{
// Field 0
private int _offset;
// Field 1
private ResistanceType _type;
public ResistanceMod(Mobile owner) : base(owner)
{
}
@ -36,7 +30,7 @@ public partial class ResistanceMod : MobileMod
_offset = offset;
}
[SerializableField(0)]
[SerializableProperty(0)]
public ResistanceType Type
{
get => _type;
@ -52,7 +46,7 @@ public partial class ResistanceMod : MobileMod
}
}
[SerializableField(1)]
[SerializableProperty(1)]
public int Offset
{
get => _offset;

View file

@ -21,11 +21,6 @@ namespace Server;
[SerializationGenerator(0)]
public abstract partial class SkillMod : MobileMod
{
private bool _obeyCap;
private bool _relative;
private SkillName _skill;
private double _value;
public SkillMod(Mobile owner) : base(owner)
{
}
@ -37,7 +32,7 @@ public abstract partial class SkillMod : MobileMod
_value = value;
}
[SerializableField(0)]
[SerializableProperty(0)]
public bool ObeyCap
{
get => _obeyCap;
@ -51,7 +46,7 @@ public abstract partial class SkillMod : MobileMod
}
}
[SerializableField(1)]
[SerializableProperty(1)]
public SkillName Skill
{
get => _skill;
@ -71,7 +66,7 @@ public abstract partial class SkillMod : MobileMod
}
}
[SerializableField(2)]
[SerializableProperty(2)]
public bool Relative
{
get => _relative;
@ -88,24 +83,13 @@ public abstract partial class SkillMod : MobileMod
}
}
[SerializableField(3)]
public bool Absolute
{
get => !_relative;
set
{
if (_relative == value)
{
_relative = !value;
var sk = Owner?.Skills[_skill];
sk?.Update();
MarkDirty();
}
}
get => !Relative;
set => Relative = !value;
}
[SerializableField(4)]
[SerializableProperty(3)]
public double Value
{
get => _value;

View file

@ -40,8 +40,8 @@
<PackageReference Include="PollGroup" Version="1.2.1" />
<PackageReference Include="Zlib.Bindings" Version="1.9.2" />
<PackageReference Include="ModernUO.Serialization.Annotations" Version="2.0.2" />
<PackageReference Include="ModernUO.Serialization.Generator" Version="2.1.4" />
<PackageReference Include="ModernUO.Serialization.Annotations" Version="2.2.0" />
<PackageReference Include="ModernUO.Serialization.Generator" Version="2.2.2" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="Migrations/*.v*.json" />

View file

@ -3,9 +3,9 @@
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="Moq" Version="4.18.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="Moq" Version="4.18.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
<ProjectReference Include="..\Server\Server.csproj" />
<ProjectReference Include="..\Server.Tests\Server.Tests.csproj" />

View file

@ -18,7 +18,7 @@ namespace Server.Accounting
_lastLogin = content.LastLogin;
_totalGold = content.TotalGold;
_totalPlat = content.TotalPlat;
_rawMobiles = content.Mobiles;
_mobiles = content.Mobiles;
_comments = content.Comments;
_tags = content.Tags;
_loginIPs = content.LoginIPs;
@ -47,10 +47,10 @@ namespace Server.Accounting
_totalPlat = reader.ReadInt();
var length = reader.ReadInt();
_rawMobiles = new Mobile[length];
_mobiles = new Mobile[length];
for (int i = 0; i < length; i++)
{
_rawMobiles[i] = reader.ReadEntity<Mobile>();
_mobiles[i] = reader.ReadEntity<Mobile>();
}
length = reader.ReadInt();

View file

@ -56,12 +56,9 @@ namespace Server.Accounting
[SerializableFieldAttr("[CommandProperty(AccessLevel.Administrator)]")]
public int _totalPlat;
[SerializableField(8, "private", "private")]
private Mobile[] _rawMobiles;
private Mobile[] _mobiles;
private List<AccountComment> _comments;
[SerializableField(9)]
[SerializableProperty(9)]
public List<AccountComment> Comments
{
get => _comments ??= new List<AccountComment>();
@ -72,9 +69,7 @@ namespace Server.Accounting
}
}
private List<AccountTag> _tags;
[SerializableField(10)]
[SerializableProperty(10)]
public List<AccountTag> Tags
{
get => _tags ??= new List<AccountTag>();
@ -95,20 +90,18 @@ namespace Server.Accounting
[SerializableField(12)]
private string[] _ipRestrictions;
private TimeSpan _totalGameTime;
/// <summary>
/// Gets the total game time of this account, also considering the game time of characters
/// that have been deleted.
/// </summary>
[SerializableField(13)]
[SerializableProperty(13)]
public TimeSpan TotalGameTime
{
get
{
for (var i = 0; i < _rawMobiles.Length; i++)
for (var i = 0; i < _mobiles.Length; i++)
{
if (_rawMobiles[i] is PlayerMobile m && m.NetState != null)
if (_mobiles[i] is PlayerMobile m && m.NetState != null)
{
return _totalGameTime + (Core.Now - m.SessionStart);
}
@ -140,7 +133,7 @@ namespace Server.Accounting
_lastLogin = Core.Now;
_totalGameTime = TimeSpan.Zero;
_rawMobiles = new Mobile[7];
_mobiles = new Mobile[7];
_ipRestrictions = Array.Empty<string>();
_loginIPs = Array.Empty<IPAddress>();
@ -188,26 +181,26 @@ namespace Server.Accounting
_totalGold = Utility.GetXMLInt32(Utility.GetText(node["totalGold"], "0"), 0);
_totalPlat = Utility.GetXMLInt32(Utility.GetText(node["totalPlat"], "0"), 0);
_rawMobiles = LoadMobiles(node);
_mobiles = LoadMobiles(node);
_comments = LoadComments(node);
_tags = LoadTags(node);
_loginIPs = LoadAddressList(node);
_ipRestrictions = LoadAccessCheck(node);
for (var i = 0; i < _rawMobiles.Length; ++i)
for (var i = 0; i < _mobiles.Length; ++i)
{
if (_rawMobiles[i] != null)
if (_mobiles[i] != null)
{
_rawMobiles[i].Account = this;
_mobiles[i].Account = this;
}
}
var totalGameTime = Utility.GetXMLTimeSpan(Utility.GetText(node["totalGameTime"], null), TimeSpan.Zero);
if (totalGameTime == TimeSpan.Zero)
{
for (var i = 0; i < _rawMobiles.Length; i++)
for (var i = 0; i < _mobiles.Length; i++)
{
if (_rawMobiles[i] is PlayerMobile m)
if (_mobiles[i] is PlayerMobile m)
{
totalGameTime += m.GameTime;
}
@ -333,19 +326,19 @@ namespace Server.Accounting
_tags = null;
}
for (var i = 0; i < _rawMobiles.Length; ++i)
for (var i = 0; i < _mobiles.Length; ++i)
{
if (_rawMobiles[i] != null)
if (_mobiles[i] != null)
{
_rawMobiles[i].Account = this;
_mobiles[i].Account = this;
}
}
if (_totalGameTime == TimeSpan.Zero)
{
for (var i = 0; i < _rawMobiles.Length; i++)
for (var i = 0; i < _mobiles.Length; i++)
{
if (_rawMobiles[i] is PlayerMobile m)
if (_mobiles[i] is PlayerMobile m)
{
_totalGameTime += m.GameTime;
}
@ -382,7 +375,7 @@ namespace Server.Accounting
m.Delete();
m.Account = null;
_rawMobiles[i] = null;
_mobiles[i] = null;
}
if (_loginIPs.Length != 0 && AccountHandler.IPTable.ContainsKey(_loginIPs[0]))
@ -453,7 +446,7 @@ namespace Server.Accounting
/// <summary>
/// Gets the maximum amount of characters that this account can hold.
/// </summary>
public int Length => _rawMobiles.Length;
public int Length => _mobiles.Length;
/// <summary>
/// Gets or sets the character at a specified index for this account. Out of bound index values are handled; null returned
@ -463,9 +456,9 @@ namespace Server.Accounting
{
get
{
if (index >= 0 && index < _rawMobiles.Length)
if (index >= 0 && index < _mobiles.Length)
{
var m = _rawMobiles[index];
var m = _mobiles[index];
if (m?.Deleted != true)
{
@ -475,7 +468,7 @@ namespace Server.Accounting
// This is the only place that clears a mobile for garbage collection
// outside of an entire account deletion.
m.Account = null;
_rawMobiles[index] = null;
_mobiles[index] = null;
this.MarkDirty();
}
@ -483,19 +476,19 @@ namespace Server.Accounting
}
set
{
if (index >= 0 && index < _rawMobiles.Length)
if (index >= 0 && index < _mobiles.Length)
{
if (_rawMobiles[index] != null)
if (_mobiles[index] != null)
{
_rawMobiles[index].Account = null;
_mobiles[index].Account = null;
}
_rawMobiles[index] = value;
_mobiles[index] = value;
this.MarkDirty();
if (_rawMobiles[index] != null)
if (_mobiles[index] != null)
{
_rawMobiles[index].Account = this;
_mobiles[index].Account = this;
}
}
}
@ -826,9 +819,9 @@ namespace Server.Accounting
{
Young = false;
for (var i = 0; i < _rawMobiles.Length; i++)
for (var i = 0; i < _mobiles.Length; i++)
{
if (_rawMobiles[i] is PlayerMobile { Young: true } m)
if (_mobiles[i] is PlayerMobile { Young: true } m)
{
m.Young = false;
@ -1186,8 +1179,9 @@ namespace Server.Accounting
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Enumerator GetEnumerator() => new(_rawMobiles);
public Enumerator GetEnumerator() => new(_mobiles);
[SerializableProperty(8, useField: nameof(_mobiles))]
public Enumerator Mobiles
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]

View file

@ -24,9 +24,6 @@ namespace Server.Items
[SerializationGenerator(3, false)]
public abstract partial class BaseAddon : Item, IChoppable, IAddon
{
[SerializableField(1, "private", "private")]
private CraftResource _rawResource;
public BaseAddon() : base(1)
{
Movable = false;
@ -66,16 +63,17 @@ namespace Server.Items
}
}
[SerializableProperty(1)]
[CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource
{
get => _rawResource;
get => _resource;
set
{
if (_rawResource != value)
if (_resource != value)
{
RawResource = value;
Hue = CraftResources.GetHue(_rawResource);
_resource = value;
Hue = CraftResources.GetHue(_resource);
InvalidateProperties();
this.MarkDirty();
@ -285,7 +283,7 @@ namespace Server.Items
if (version == 2)
{
_rawResource = (CraftResource)reader.ReadEncodedInt();
_resource = (CraftResource)reader.ReadEncodedInt();
}
}
}

View file

@ -10,9 +10,6 @@ namespace Server.Items
[SerializableField(0, setter: "private")]
private List<AddonContainerComponent> _components;
[SerializableField(1, "private", "private")]
private CraftResource _rawResource;
public BaseAddonContainer(int itemID) : base(itemID)
{
AddonComponent.ApplyLightTo(this);
@ -44,16 +41,17 @@ namespace Server.Items
}
}
[SerializableProperty(1)]
[CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource
{
get => _rawResource;
get => _resource;
set
{
if (_rawResource != value)
if (_resource != value)
{
RawResource = value;
Hue = CraftResources.GetHue(_rawResource);
_resource = value;
Hue = CraftResources.GetHue(_resource);
InvalidateProperties();
this.MarkDirty();
@ -172,9 +170,9 @@ namespace Server.Items
{
base.GetProperties(list);
if (!CraftResources.IsStandard(_rawResource))
if (!CraftResources.IsStandard(_resource))
{
list.Add(CraftResources.GetLocalizationNumber(_rawResource));
list.Add(CraftResources.GetLocalizationNumber(_resource));
}
}
@ -205,7 +203,7 @@ namespace Server.Items
private void Deserialize(IGenericReader reader, int version)
{
_components = reader.ReadEntityList<AddonContainerComponent>();
_rawResource = version == 1 ? reader.ReadEnum<CraftResource>() : (CraftResource)reader.ReadInt();
_resource = version == 1 ? reader.ReadEnum<CraftResource>() : (CraftResource)reader.ReadInt();
}
[AfterDeserialization]

View file

@ -27,8 +27,6 @@ namespace Server.Items
new[] { 0x1924, 0x1924, 0x1928 }
};
private int _flour;
[Constructible]
public FlourMillEastAddon()
{
@ -40,10 +38,10 @@ namespace Server.Items
public override BaseAddonDeed Deed => new FlourMillEastDeed();
[CommandProperty(AccessLevel.GameMaster)]
public bool HasFlour => _flour > 0;
public bool HasFlour => _curFlour > 0;
[CommandProperty(AccessLevel.GameMaster)]
public bool IsFull => _flour >= MaxFlour;
public bool IsFull => _curFlour >= MaxFlour;
[CommandProperty(AccessLevel.GameMaster)]
public bool IsWorking { get; private set; }
@ -51,14 +49,14 @@ namespace Server.Items
[CommandProperty(AccessLevel.GameMaster)]
public int MaxFlour => 2;
[SerializableField(0)]
[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public int CurFlour
{
get => _flour;
get => _curFlour;
set
{
_flour = Math.Clamp(value, 0, MaxFlour);
_curFlour = Math.Clamp(value, 0, MaxFlour);
UpdateStage();
this.MarkDirty();
}
@ -86,7 +84,7 @@ namespace Server.Items
if (from.PlaceInBackpack(flour))
{
_flour = 0;
_curFlour = 0;
}
else
{

View file

@ -14,8 +14,6 @@ namespace Server.Items
new[] { 0x1930, 0x1930, 0x1934 }
};
private int _flour;
[Constructible]
public FlourMillSouthAddon()
{
@ -27,10 +25,10 @@ namespace Server.Items
public override BaseAddonDeed Deed => new FlourMillSouthDeed();
[CommandProperty(AccessLevel.GameMaster)]
public bool HasFlour => _flour > 0;
public bool HasFlour => _curFlour > 0;
[CommandProperty(AccessLevel.GameMaster)]
public bool IsFull => _flour >= MaxFlour;
public bool IsFull => _curFlour >= MaxFlour;
[CommandProperty(AccessLevel.GameMaster)]
public bool IsWorking { get; private set; }
@ -38,14 +36,14 @@ namespace Server.Items
[CommandProperty(AccessLevel.GameMaster)]
public int MaxFlour => 2;
[SerializableField(0)]
[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public int CurFlour
{
get => _flour;
get => _curFlour;
set
{
_flour = Math.Max(0, Math.Min(value, MaxFlour));
_curFlour = Math.Max(0, Math.Min(value, MaxFlour));
UpdateStage();
}
}
@ -74,7 +72,7 @@ namespace Server.Items
if (from.PlaceInBackpack(flour))
{
_flour = 0;
_curFlour = 0;
}
else
{

View file

@ -11,13 +11,6 @@ namespace Server.Items
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private Point3D _teleOffset;
//The extra custom processing done in the property setters causes deserialisation to fail.
//These hidden private members will auto generate properties with no processing which we can point to.
[SerializableField(0, getter: "private", setter: "private")]
private bool _rawActive;
[SerializableField(1, getter: "private", setter: "private")]
private SHTeleComponent _rawTeleDest;
[Constructible]
public SHTeleComponent(int itemID = 0x1775) : this(itemID, new Point3D(0, 0, 0))
{
@ -29,17 +22,18 @@ namespace Server.Items
Movable = false;
Hue = 1;
_rawActive = true;
TeleOffset = offset;
_active = true;
_teleOffset = offset;
}
[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public bool Active
{
get => RawActive;
get => _active;
set
{
RawActive = value;
_active = value;
if (Addon is SHTeleporter sourceAddon)
{
@ -48,13 +42,14 @@ namespace Server.Items
}
}
[SerializableProperty(1)]
[CommandProperty(AccessLevel.GameMaster)]
public SHTeleComponent TeleDest
{
get => RawTeleDest;
get => _teleDest;
set
{
RawTeleDest = value;
_teleDest = value;
if (Addon is SHTeleporter sourceAddon)
{
@ -74,15 +69,15 @@ namespace Server.Items
public override void OnDoubleClick(Mobile m)
{
if (!_rawActive || _rawTeleDest?.Deleted != false || _rawTeleDest.Map == Map.Internal)
if (!_active || _teleDest?.Deleted != false || _teleDest.Map == Map.Internal)
{
return;
}
if (m.InRange(this, 3))
{
var map = _rawTeleDest.Map;
var p = _rawTeleDest.TelePoint;
var map = _teleDest.Map;
var p = _teleDest.TelePoint;
BaseCreature.TeleportPets(m, p, map);

View file

@ -28,11 +28,9 @@ namespace Server.Items
[DirtyTrackingEntity]
private Aquarium _aquarium;
private int _state;
public AquariumState(Aquarium parent) => _aquarium = parent;
[SerializableField(0)]
[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public int State
{

View file

@ -20,7 +20,7 @@ public partial class BaseArmor
Timer.StartTimer(() => _crafter = crafter?.RawName);
_quality = content.Quality ?? ArmorQuality.Regular;
_durability = content.Durability ?? ArmorDurabilityLevel.Regular;
_rawResource = content.RawResource ?? DefaultResource;
_resource = content.RawResource ?? DefaultResource;
_armorBase = content.BaseArmorRating ?? -1;
_strBonus = content.StrBonus ?? -1;
_dexBonus = content.DexBonus ?? -1;
@ -107,12 +107,12 @@ public partial class BaseArmor
if (GetSaveFlag(flags, OldSaveFlag.Protection))
{
_protection = (ArmorProtectionLevel)reader.ReadEncodedInt();
_protectionLevel = (ArmorProtectionLevel)reader.ReadEncodedInt();
}
if (GetSaveFlag(flags, OldSaveFlag.Resource))
{
_rawResource = (CraftResource)reader.ReadEncodedInt();
_resource = (CraftResource)reader.ReadEncodedInt();
}
if (GetSaveFlag(flags, OldSaveFlag.BaseArmor))

View file

@ -94,9 +94,6 @@ namespace Server.Items
[SerializableFieldSaveFlag(8)]
private bool ShouldSerializeMaxHitPoints() => _maxHitPoints != 0;
// Field 9
private int _hitPoints;
[InvalidateProperties]
[SerializableField(10)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
@ -105,21 +102,8 @@ namespace Server.Items
[SerializableFieldSaveFlag(10)]
private bool ShouldSerializeCrafter() => _crafter != null;
// Field 11
private ArmorQuality _quality = ArmorQuality.Regular;
// Field 12
private ArmorDurabilityLevel _durability = ArmorDurabilityLevel.Regular;
// Field 13
private ArmorProtectionLevel _protection = ArmorProtectionLevel.Regular;
// Field 14
[SerializableField(14, "private", "private")]
private CraftResource _rawResource;
[SerializableFieldSaveFlag(14)]
private bool ShouldSerializeResource() => _rawResource != DefaultResource;
private bool ShouldSerializeResource() => _resource != DefaultResource;
// Field 15
private int _armorBase = -1;
@ -168,8 +152,8 @@ namespace Server.Items
{
_crafter = null;
_rawResource = DefaultResource;
Hue = CraftResources.GetHue(_rawResource);
_resource = DefaultResource;
Hue = CraftResources.GetHue(_resource);
_hitPoints = _maxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits);
@ -206,7 +190,7 @@ namespace Server.Items
public virtual int OldDexReq => 0;
public virtual int OldIntReq => 0;
[SerializableField(11)]
[SerializableProperty(11)]
[CommandProperty(AccessLevel.GameMaster)]
public ArmorQuality Quality
{
@ -228,7 +212,7 @@ namespace Server.Items
[SerializableFieldSaveFlag(11)]
private bool ShouldSerializeArmorQuality() => _quality != ArmorQuality.Regular;
[SerializableField(12)]
[SerializableProperty(12)]
[CommandProperty(AccessLevel.GameMaster)]
public ArmorDurabilityLevel Durability
{
@ -250,16 +234,16 @@ namespace Server.Items
[SerializableFieldSaveFlag(12)]
private bool ShouldSerializeDurability() => _durability != ArmorDurabilityLevel.Regular;
[SerializableField(13)]
[SerializableProperty(13)]
[CommandProperty(AccessLevel.GameMaster)]
public ArmorProtectionLevel ProtectionLevel
{
get => _protection;
get => _protectionLevel;
set
{
if (_protection != value)
if (_protectionLevel != value)
{
_protection = value;
_protectionLevel = value;
Invalidate();
InvalidateProperties();
@ -271,23 +255,24 @@ namespace Server.Items
}
[SerializableFieldSaveFlag(13)]
private bool ShouldSerializeProtectionLevel() => _protection != ArmorProtectionLevel.Regular;
private bool ShouldSerializeProtectionLevel() => _protectionLevel != ArmorProtectionLevel.Regular;
[SerializableProperty(14)]
[CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource
{
get => _rawResource;
get => _resource;
set
{
if (_rawResource != value)
if (_resource != value)
{
UnscaleDurability();
RawResource = value;
_resource = value;
if (CraftItem.RetainsColor(GetType()))
{
Hue = CraftResources.GetHue(_rawResource);
Hue = CraftResources.GetHue(_resource);
}
Invalidate();
@ -302,7 +287,7 @@ namespace Server.Items
private CraftResource ResourceDefaultValue() => DefaultResource;
[EncodedInt]
[SerializableField(15)]
[SerializableProperty(15, useField: nameof(_armorBase))]
[CommandProperty(AccessLevel.GameMaster)]
public int BaseArmorRating
{
@ -329,12 +314,12 @@ namespace Server.Items
{
var ar = BaseArmorRating;
if (_protection != ArmorProtectionLevel.Regular)
if (_protectionLevel != ArmorProtectionLevel.Regular)
{
ar += 10 + 5 * (int)_protection;
ar += 10 + 5 * (int)_protectionLevel;
}
ar += _rawResource switch
ar += _resource switch
{
CraftResource.DullCopper => 2,
CraftResource.ShadowIron => 4,
@ -358,7 +343,7 @@ namespace Server.Items
public double ArmorRatingScaled => ArmorRating * ArmorScalar;
[EncodedInt]
[SerializableField(16)]
[SerializableProperty(16, useField: nameof(_strBonus))]
[CommandProperty(AccessLevel.GameMaster)]
public int StrBonus
{
@ -378,7 +363,7 @@ namespace Server.Items
private int StrBonusDefaultValue() => -1;
[EncodedInt]
[SerializableField(17)]
[SerializableProperty(17, useField: nameof(_dexBonus))]
[CommandProperty(AccessLevel.GameMaster)]
public int DexBonus
{
@ -398,7 +383,7 @@ namespace Server.Items
private int DexBonusDefaultValue() => -1;
[EncodedInt]
[SerializableField(18)]
[SerializableProperty(18, useField: nameof(_intBonus))]
[CommandProperty(AccessLevel.GameMaster)]
public int IntBonus
{
@ -418,7 +403,7 @@ namespace Server.Items
private int IntBonusDefaultValue() => -1;
[EncodedInt]
[SerializableField(19)]
[SerializableProperty(19, useField: nameof(_strReq))]
[CommandProperty(AccessLevel.GameMaster)]
public int StrRequirement
{
@ -438,7 +423,7 @@ namespace Server.Items
private int StrReqDefaultValue() => -1;
[EncodedInt]
[SerializableField(20)]
[SerializableProperty(20, useField: nameof(_dexReq))]
[CommandProperty(AccessLevel.GameMaster)]
public int DexRequirement
{
@ -458,7 +443,7 @@ namespace Server.Items
private int DexReqDefaultValue() => -1;
[EncodedInt]
[SerializableField(21)]
[SerializableProperty(21, useField: nameof(_intReq))]
[CommandProperty(AccessLevel.GameMaster)]
public int IntRequirement
{
@ -477,7 +462,7 @@ namespace Server.Items
[SerializableFieldDefault(21)]
private int IntReqDefaultValue() => -1;
[SerializableField(22)]
[SerializableProperty(22, useField: nameof(_meditate))]
[CommandProperty(AccessLevel.GameMaster)]
public AMA MeditationAllowance
{
@ -675,7 +660,7 @@ namespace Server.Items
{
try
{
var res = CraftResources.GetInfo(_rawResource).ResourceTypes[0].CreateInstance<Item>();
var res = CraftResources.GetInfo(_resource).ResourceTypes[0].CreateInstance<Item>();
ScissorHelper(from, res, PlayerConstructed ? item.Resources[0].Amount / 2 : 1);
return true;
@ -693,7 +678,7 @@ namespace Server.Items
public virtual bool CanFortify => true;
[EncodedInt]
[SerializableField(9)]
[SerializableProperty(9)]
[CommandProperty(AccessLevel.GameMaster)]
public int HitPoints
{
@ -864,11 +849,11 @@ namespace Server.Items
}
public CraftAttributeInfo GetResourceAttrs() =>
CraftResources.GetInfo(_rawResource)?.AttributeInfo ?? CraftAttributeInfo.Blank;
CraftResources.GetInfo(_resource)?.AttributeInfo ?? CraftAttributeInfo.Blank;
public int GetProtOffset()
{
return _protection switch
return _protectionLevel switch
{
ArmorProtectionLevel.Guarding => 1,
ArmorProtectionLevel.Hardening => 2,
@ -896,7 +881,7 @@ namespace Server.Items
{
bonus += ArmorAttributes.DurabilityBonus;
var resInfo = CraftResources.GetInfo(_rawResource);
var resInfo = CraftResources.GetInfo(_resource);
CraftAttributeInfo attrInfo = null;
if (resInfo != null)
@ -969,7 +954,7 @@ namespace Server.Items
var v = ArmorAttributes.LowerStatReq;
var info = CraftResources.GetInfo(_rawResource);
var info = CraftResources.GetInfo(_resource);
var attrInfo = info?.AttributeInfo;
@ -1028,9 +1013,9 @@ namespace Server.Items
SkillBonuses.AddTo(m);
}
if (_rawResource == CraftResource.None)
if (_resource == CraftResource.None)
{
_rawResource = DefaultResource;
_resource = DefaultResource;
}
var strBonus = ComputeStatBonus(StatType.Str);
@ -1208,7 +1193,7 @@ namespace Server.Items
public override void AddNameProperty(IPropertyList list)
{
var oreType = _rawResource switch
var oreType = _resource switch
{
CraftResource.DullCopper => 1053108,
CraftResource.ShadowIron => 1053107,
@ -1276,7 +1261,7 @@ namespace Server.Items
return Attributes.SpellChanneling != 0;
}
public virtual int GetLuckBonus() => CraftResources.GetInfo(_rawResource)?.AttributeInfo?.ArmorLuck ?? 0;
public virtual int GetLuckBonus() => CraftResources.GetInfo(_resource)?.AttributeInfo?.ArmorLuck ?? 0;
public override void GetProperties(IPropertyList list)
{
@ -1497,13 +1482,13 @@ namespace Server.Items
attrs.Add(new EquipInfoAttribute(1038000 + (int)_durability));
}
if (_protection > ArmorProtectionLevel.Regular && _protection <= ArmorProtectionLevel.Invulnerability)
if (_protectionLevel > ArmorProtectionLevel.Regular && _protectionLevel <= ArmorProtectionLevel.Invulnerability)
{
attrs.Add(new EquipInfoAttribute(1038005 + (int)_protection));
attrs.Add(new EquipInfoAttribute(1038005 + (int)_protectionLevel));
}
}
else if (_durability != ArmorDurabilityLevel.Regular || _protection > ArmorProtectionLevel.Regular &&
_protection <= ArmorProtectionLevel.Invulnerability)
else if (_durability != ArmorDurabilityLevel.Regular || _protectionLevel > ArmorProtectionLevel.Regular &&
_protectionLevel <= ArmorProtectionLevel.Invulnerability)
{
attrs.Add(new EquipInfoAttribute(1038000)); // Unidentified
}

View file

@ -6,9 +6,6 @@ namespace Server.Items
[SerializationGenerator(1)]
public partial class LeafGloves : BaseArmor, IArcaneEquip
{
private int _maxArcaneCharges;
private int _curArcaneCharges;
[Constructible]
public LeafGloves() : base(0x2FC6) => Weight = 2.0;
@ -33,7 +30,7 @@ namespace Server.Items
public override ArmorMeditationAllowance DefMedAllowance => ArmorMeditationAllowance.All;
[EncodedInt]
[SerializableField(0)]
[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public int CurArcaneCharges
{
@ -47,7 +44,7 @@ namespace Server.Items
}
[EncodedInt]
[SerializableField(1)]
[SerializableProperty(1)]
[CommandProperty(AccessLevel.GameMaster)]
public int MaxArcaneCharges
{

View file

@ -6,9 +6,6 @@ namespace Server.Items
[SerializationGenerator(2, false)]
public partial class LeatherGloves : BaseArmor, IArcaneEquip
{
private int _maxArcaneCharges;
private int _curArcaneCharges;
[Constructible]
public LeatherGloves() : base(0x13C6) => Weight = 1.0;
@ -32,7 +29,7 @@ namespace Server.Items
public override ArmorMeditationAllowance DefMedAllowance => ArmorMeditationAllowance.All;
[EncodedInt]
[SerializableField(0)]
[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public int CurArcaneCharges
{
@ -46,7 +43,7 @@ namespace Server.Items
}
[EncodedInt]
[SerializableField(1)]
[SerializableProperty(1)]
[CommandProperty(AccessLevel.GameMaster)]
public int MaxArcaneCharges
{

View file

@ -4,7 +4,7 @@ public partial class BaseClothing
{
private void MigrateFrom(V6Content content)
{
_rawResource = content.RawResource ?? DefaultResource;
_resource = content.RawResource ?? DefaultResource;
_attributes = content.Attributes ?? AttributesDefaultValue();
_clothingAttributes = content.ClothingAttributes ?? ClothingAttributesDefaultValue();
_skillBonuses = content.SkillBonuses ?? SkillBonusesDefaultValue();
@ -24,11 +24,11 @@ public partial class BaseClothing
if (GetSaveFlag(flags, OldSaveFlag.Resource))
{
_rawResource = (CraftResource)reader.ReadEncodedInt();
_resource = (CraftResource)reader.ReadEncodedInt();
}
else
{
_rawResource = DefaultResource;
_resource = DefaultResource;
}
Attributes = new AosAttributes(this);

View file

@ -26,11 +26,8 @@ namespace Server.Items
[SerializationGenerator(7, false)]
public abstract partial class BaseClothing : Item, IDyable, IScissorable, IFactionItem, ICraftable, IWearableDurability
{
[SerializableField(0, "private", "private")]
private CraftResource _rawResource;
[SerializableFieldSaveFlag(0)]
private bool ShouldSerializeResource() => _rawResource != DefaultResource;
private bool ShouldSerializeResource() => _resource != DefaultResource;
[SerializableField(1, setter: "private")]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster, canModify: true)]")]
@ -81,9 +78,6 @@ namespace Server.Items
[SerializableFieldSaveFlag(5)]
private bool ShouldSerializeMaxHitPoints() => _maxHitPoints != 0;
// Field 6
private int _hitPoints;
[SerializableField(7)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private bool _playerConstructed;
@ -117,7 +111,7 @@ namespace Server.Items
Layer = layer;
Hue = hue;
_rawResource = DefaultResource;
_resource = DefaultResource;
_hitPoints = _maxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits);
@ -127,20 +121,21 @@ namespace Server.Items
Resistances = new AosElementAttributes(this);
}
[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource
{
get => _rawResource;
get => _resource;
set
{
RawResource = value;
Hue = CraftResources.GetHue(_rawResource);
_resource = value;
Hue = CraftResources.GetHue(_resource);
InvalidateProperties();
this.MarkDirty();
}
}
[SerializableField(10)]
[SerializableProperty(10, useField: nameof(_strReq))]
[CommandProperty(AccessLevel.GameMaster)]
public int StrRequirement
{
@ -278,7 +273,7 @@ namespace Server.Items
{
try
{
var info = CraftResources.GetInfo(_rawResource);
var info = CraftResources.GetInfo(_resource);
Type resourceType = null;
if (info?.ResourceTypes.Length > 0)
@ -308,7 +303,7 @@ namespace Server.Items
public virtual bool CanFortify => true;
[EncodedInt]
[SerializableField(6)]
[SerializableProperty(6)]
[CommandProperty(AccessLevel.GameMaster)]
public int HitPoints
{
@ -664,7 +659,7 @@ namespace Server.Items
public override void AddNameProperty(IPropertyList list)
{
var oreType = _rawResource switch
var oreType = _resource switch
{
CraftResource.DullCopper => 1053108,
CraftResource.ShadowIron => 1053107,

View file

@ -15,14 +15,11 @@ namespace Server.Items
[SerializationGenerator(2, false)]
public partial class Cloak : BaseCloak, IArcaneEquip
{
private int _maxArcaneCharges;
private int _curArcaneCharges;
[Constructible]
public Cloak(int hue = 0) : base(0x1515, hue) => Weight = 5.0;
[EncodedInt]
[SerializableField(0)]
[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public int CurArcaneCharges
{
@ -37,7 +34,7 @@ namespace Server.Items
}
[EncodedInt]
[SerializableField(1)]
[SerializableProperty(1)]
[CommandProperty(AccessLevel.GameMaster)]
public int MaxArcaneCharges
{

View file

@ -309,14 +309,11 @@ namespace Server.Items
[SerializationGenerator(2, false)]
public partial class Robe : BaseOuterTorso, IArcaneEquip
{
private int _curArcaneCharges;
private int _maxArcaneCharges;
[Constructible]
public Robe(int hue = 0) : base(0x1F03, hue) => Weight = 3.0;
[EncodedInt]
[SerializableField(0)]
[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public int CurArcaneCharges
{
@ -331,7 +328,7 @@ namespace Server.Items
}
[EncodedInt]
[SerializableField(1)]
[SerializableProperty(1)]
[CommandProperty(AccessLevel.GameMaster)]
public int MaxArcaneCharges
{

View file

@ -43,16 +43,13 @@ namespace Server.Items
[SerializationGenerator(2, false)]
public partial class ThighBoots : BaseShoes, IArcaneEquip
{
private int _maxArcaneCharges;
private int _curArcaneCharges;
[Constructible]
public ThighBoots(int hue = 0) : base(0x1711, hue) => Weight = 4.0;
public override CraftResource DefaultResource => CraftResource.RegularLeather;
[EncodedInt]
[SerializableField(0)]
[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public int CurArcaneCharges
{
@ -67,7 +64,7 @@ namespace Server.Items
}
[EncodedInt]
[SerializableField(1)]
[SerializableProperty(1)]
[CommandProperty(AccessLevel.GameMaster)]
public int MaxArcaneCharges
{

View file

@ -6,9 +6,6 @@ namespace Server.Items;
[SerializationGenerator(2, false)]
public abstract partial class FillableContainer : LockableContainer
{
[SerializableField(0)]
protected FillableContentType _rawContentType;
[TimerDrift]
[SerializableField(1)]
private Timer _respawnTimer;
@ -35,19 +32,20 @@ public abstract partial class FillableContainer : LockableContainer
[CommandProperty(AccessLevel.GameMaster)]
public DateTime NextRespawnTime => _respawnTimer?.Next ?? DateTime.MinValue;
[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public FillableContentType ContentType
{
get => _rawContentType;
get => _contentType;
set
{
if (_rawContentType == value)
if (_contentType == value)
{
return;
}
ClearContents();
_rawContentType = value;
_contentType = value;
Respawn();
}
}
@ -77,14 +75,15 @@ public abstract partial class FillableContainer : LockableContainer
public virtual void AcquireContent()
{
if (_rawContentType != FillableContentType.None)
if (_contentType != FillableContentType.None)
{
return;
}
RawContentType = FillableContent.Acquire(GetWorldLocation(), Map);
// Don't trigger serialization code
_contentType = FillableContent.Acquire(GetWorldLocation(), Map);
if (_rawContentType != FillableContentType.None)
if (_contentType != FillableContentType.None)
{
Respawn();
}
@ -118,7 +117,7 @@ public abstract partial class FillableContainer : LockableContainer
public void CheckRespawn()
{
var canSpawn =
_rawContentType != FillableContentType.None &&
_contentType != FillableContentType.None &&
!Deleted && !Movable && Parent == null && !IsLockedDown && !IsSecure &&
(
GetItemsCount() <= SpawnThreshold ||
@ -147,14 +146,14 @@ public abstract partial class FillableContainer : LockableContainer
_respawnTimer?.Stop();
_respawnTimer = null;
if (_rawContentType == FillableContentType.None || Deleted)
if (_contentType == FillableContentType.None || Deleted)
{
return;
}
GenerateContent();
var level = FillableContent.Lookup(_rawContentType).Level;
var level = FillableContent.Lookup(_contentType).Level;
if (IsLockable)
{
@ -199,12 +198,12 @@ public abstract partial class FillableContainer : LockableContainer
public virtual void GenerateContent()
{
if (_rawContentType == FillableContentType.None || Deleted)
if (_contentType == FillableContentType.None || Deleted)
{
return;
}
var content = FillableContent.Lookup(_rawContentType);
var content = FillableContent.Lookup(_contentType);
var toSpawn = GetSpawnCount();
@ -238,7 +237,7 @@ public abstract partial class FillableContainer : LockableContainer
private void Deserialize(IGenericReader reader, int version)
{
_rawContentType = (FillableContentType)reader.ReadInt();
_contentType = (FillableContentType)reader.ReadInt();
var respawnTimerNext = reader.ReadDeltaTime();
DeserializeRespawnTimer(respawnTimerNext == DateTime.MinValue ? TimeSpan.MinValue : respawnTimerNext - Core.Now);
}

View file

@ -16,13 +16,12 @@ public partial class LibraryBookcase : FillableContainer
public override void AcquireContent()
{
if (_rawContentType != FillableContentType.None)
if (ContentType != FillableContentType.None)
{
return;
}
RawContentType = FillableContentType.Library;
Respawn();
ContentType = FillableContentType.Library;
}
}

View file

@ -12,7 +12,7 @@ public abstract partial class LockableContainer : TrappableContainer, ILockable,
public override bool TrapOnOpen => !_trapOnLockpick;
public override bool DisplaysContent => !_rawLocked;
public override bool DisplaysContent => !_locked;
public int OnCraft(
int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool,
@ -72,18 +72,16 @@ public abstract partial class LockableContainer : TrappableContainer, ILockable,
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private int _lockLevel;
[SerializableField(6, getter: "private", setter: "private")]
private bool _rawLocked;
[SerializableProperty(6)]
[CommandProperty(AccessLevel.GameMaster)]
public virtual bool Locked
{
get => _rawLocked;
get => _locked;
set
{
_rawLocked = value;
_locked = value;
if (_rawLocked)
if (_locked)
{
Picker = null;
}
@ -104,11 +102,11 @@ public abstract partial class LockableContainer : TrappableContainer, ILockable,
}
}
public override bool CheckContentDisplay(Mobile from) => !_rawLocked && base.CheckContentDisplay(from);
public override bool CheckContentDisplay(Mobile from) => !_locked && base.CheckContentDisplay(from);
public override bool TryDropItem(Mobile from, Item dropped, bool sendFullMessage)
{
if (from.AccessLevel < AccessLevel.GameMaster && _rawLocked)
if (from.AccessLevel < AccessLevel.GameMaster && _locked)
{
from.SendLocalizedMessage(501747); // It appears to be locked.
return false;
@ -119,7 +117,7 @@ public abstract partial class LockableContainer : TrappableContainer, ILockable,
public override bool OnDragDropInto(Mobile from, Item item, Point3D p)
{
if (from.AccessLevel < AccessLevel.GameMaster && _rawLocked)
if (from.AccessLevel < AccessLevel.GameMaster && _locked)
{
from.SendLocalizedMessage(501747); // It appears to be locked.
return false;
@ -130,7 +128,7 @@ public abstract partial class LockableContainer : TrappableContainer, ILockable,
public override bool CheckLift(Mobile from, Item item, ref LRReason reject) =>
base.CheckLift(from, item, ref reject) &&
(item == this || from.AccessLevel >= AccessLevel.GameMaster || !_rawLocked);
(item == this || from.AccessLevel >= AccessLevel.GameMaster || !_locked);
public override bool CheckItemUse(Mobile from, Item item)
{
@ -139,7 +137,7 @@ public abstract partial class LockableContainer : TrappableContainer, ILockable,
return false;
}
if (item != this && from.AccessLevel < AccessLevel.GameMaster && _rawLocked)
if (item != this && from.AccessLevel < AccessLevel.GameMaster && _locked)
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
return false;
@ -150,7 +148,7 @@ public abstract partial class LockableContainer : TrappableContainer, ILockable,
public virtual bool CheckLocked(Mobile from)
{
if (!_rawLocked)
if (!_locked)
{
return false;
}

View file

@ -6,9 +6,6 @@ namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class MarkContainer : LockableContainer
{
[SerializableField(0, getter: "private", setter: "private")]
private bool _rawAutoLock;
[TimerDrift]
[SerializableField(1, getter: "private", setter: "private")]
private InternalTimer _relockTimer;
@ -16,7 +13,7 @@ public partial class MarkContainer : LockableContainer
[DeserializeTimerField(1)]
private void DeserializeRelockTimer(TimeSpan delay)
{
if (!Locked && _rawAutoLock)
if (!Locked && _autoLock)
{
_relockTimer = new InternalTimer(this, delay);
}
@ -44,7 +41,7 @@ public partial class MarkContainer : LockableContainer
Hue = 1102;
}
_rawAutoLock = locked;
_autoLock = locked;
Locked = locked;
if (locked)
@ -53,15 +50,16 @@ public partial class MarkContainer : LockableContainer
}
}
[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public bool AutoLock
{
get => _rawAutoLock;
get => _autoLock;
set
{
_rawAutoLock = value;
_autoLock = value;
if (!_rawAutoLock)
if (!_autoLock)
{
StopTimer();
}
@ -93,7 +91,7 @@ public partial class MarkContainer : LockableContainer
{
base.Locked = value;
if (_rawAutoLock)
if (_autoLock)
{
StopTimer();

View file

@ -20,20 +20,18 @@ public partial class DragonBardingDeed : Item, ICraftable
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private bool _exceptional;
[SerializableField(2, "private", "private")]
private CraftResource _rawResource;
public DragonBardingDeed() : base(0x14F0) => Weight = 1.0;
public override int LabelNumber => _exceptional ? 1053181 : 1053012; // dragon barding deed
[SerializableProperty(2)]
[CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource
{
get => _rawResource;
get => _resource;
set
{
_rawResource = value;
_resource = value;
Hue = CraftResources.GetHue(value);
InvalidateProperties();
}
@ -134,6 +132,6 @@ public partial class DragonBardingDeed : Item, ICraftable
reader.ReadInt();
}
_rawResource = (CraftResource)reader.ReadInt();
_resource = (CraftResource)reader.ReadInt();
}
}

View file

@ -227,23 +227,17 @@ public abstract partial class BaseBeverage : Item, IHasQuantity
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private Mobile _poisoner;
[SerializableField(2, getter: "private", setter: "private")]
private BeverageType _rawContent;
[SerializableField(3, getter: "private", setter: "private")]
private int _rawQuantity;
public BaseBeverage() => ItemID = ComputeItemID();
public BaseBeverage(BeverageType type)
{
_rawContent = type;
_rawQuantity = MaxQuantity;
_content = type;
_quantity = MaxQuantity;
ItemID = ComputeItemID();
}
public override int LabelNumber =>
IsEmpty || BaseLabelNumber == 0 ? EmptyLabelNumber : BaseLabelNumber + (int)_rawContent;
IsEmpty || BaseLabelNumber == 0 ? EmptyLabelNumber : BaseLabelNumber + (int)_content;
public virtual bool ShowQuantity => MaxQuantity > 1;
public virtual bool Fillable => true;
@ -255,21 +249,22 @@ public abstract partial class BaseBeverage : Item, IHasQuantity
public abstract int MaxQuantity { get; }
[CommandProperty(AccessLevel.GameMaster)]
public bool IsEmpty => _rawQuantity <= 0;
public bool IsEmpty => _quantity <= 0;
[CommandProperty(AccessLevel.GameMaster)]
public bool ContainsAlcohol => !IsEmpty && _rawContent is not BeverageType.Milk and not BeverageType.Water;
public bool ContainsAlcohol => !IsEmpty && _content is not BeverageType.Milk and not BeverageType.Water;
[CommandProperty(AccessLevel.GameMaster)]
public bool IsFull => _rawQuantity >= MaxQuantity;
public bool IsFull => _quantity >= MaxQuantity;
[SerializableProperty(2)]
[CommandProperty(AccessLevel.GameMaster)]
public BeverageType Content
{
get => _rawContent;
get => _content;
set
{
RawContent = value;
_content = value;
InvalidateProperties();
@ -286,13 +281,14 @@ public abstract partial class BaseBeverage : Item, IHasQuantity
}
}
[SerializableProperty(3)]
[CommandProperty(AccessLevel.GameMaster)]
public int Quantity
{
get => _rawQuantity;
get => _quantity;
set
{
RawQuantity = Math.Clamp(value, 0, MaxQuantity);
_quantity = Math.Clamp(value, 0, MaxQuantity);
InvalidateProperties();
@ -313,7 +309,7 @@ public abstract partial class BaseBeverage : Item, IHasQuantity
public virtual int GetQuantityDescription()
{
return (_rawQuantity * 100 / MaxQuantity) switch
return (_quantity * 100 / MaxQuantity) switch
{
<= 0 => 1042975,
<= 33 => 1042974,
@ -715,8 +711,8 @@ public abstract partial class BaseBeverage : Item, IHasQuantity
{
_poison = reader.ReadPoison();
_poisoner = reader.ReadEntity<Mobile>();
_rawContent = (BeverageType)reader.ReadInt();
_rawQuantity = reader.ReadInt();
_content = (BeverageType)reader.ReadInt();
_quantity = reader.ReadInt();
}
public static void Initialize()

View file

@ -58,8 +58,6 @@ public partial class WoodenBowl : Item
[SerializationGenerator(0, false)]
public partial class SackFlour : Item, IHasQuantity
{
private int _quantity;
[Constructible]
public SackFlour() : base(0x1039)
{
@ -68,7 +66,7 @@ public partial class SackFlour : Item, IHasQuantity
}
[CommandProperty(AccessLevel.GameMaster)]
[SerializableField(0)]
[SerializableProperty(0)]
public int Quantity
{
get => _quantity;

View file

@ -32,12 +32,6 @@ public partial class MahjongGame : Item, ISecurable
[SerializableField(5, setter: "private")]
private MahjongPlayers _players;
// Field 6
private bool _showScores;
// Field 7
private bool _spectatorVision;
private DateTime _lastReset;
[Constructible]
@ -56,7 +50,7 @@ public partial class MahjongGame : Item, ISecurable
}
[CommandProperty(AccessLevel.GameMaster)]
[SerializableField(6)]
[SerializableProperty(6)]
public bool ShowScores
{
get => _showScores;
@ -81,7 +75,7 @@ public partial class MahjongGame : Item, ISecurable
}
[CommandProperty(AccessLevel.GameMaster)]
[SerializableField(7)]
[SerializableProperty(7)]
public bool SpectatorVision
{
get => _spectatorVision;

View file

@ -27,12 +27,6 @@ public abstract partial class BaseJewel : Item, ICraftable
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private int _maxHitPoints;
// Field 1
private int _hitPoints;
[SerializableField(2, "private", "private")]
private CraftResource _rawResource;
[SerializableField(3)]
[InvalidateProperties]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
@ -55,8 +49,8 @@ public abstract partial class BaseJewel : Item, ICraftable
_attributes = new AosAttributes(this);
_resistances = new AosElementAttributes(this);
_skillBonuses = new AosSkillBonuses(this);
_rawResource = CraftResource.Iron;
Hue = CraftResources.GetHue(_rawResource);
_resource = CraftResource.Iron;
Hue = CraftResources.GetHue(_resource);
_gemType = GemType.None;
Layer = layer;
@ -65,7 +59,7 @@ public abstract partial class BaseJewel : Item, ICraftable
}
[EncodedInt]
[SerializableField(1)]
[SerializableProperty(1)]
[CommandProperty(AccessLevel.GameMaster)]
public int HitPoints
{
@ -91,14 +85,15 @@ public abstract partial class BaseJewel : Item, ICraftable
}
}
[SerializableProperty(2)]
[CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource
{
get => _rawResource;
get => _resource;
set
{
_rawResource = value;
Hue = CraftResources.GetHue(_rawResource);
_resource = value;
Hue = CraftResources.GetHue(_resource);
}
}
@ -395,7 +390,7 @@ public abstract partial class BaseJewel : Item, ICraftable
{
_maxHitPoints = reader.ReadEncodedInt();
_hitPoints = reader.ReadEncodedInt();
_rawResource = (CraftResource)reader.ReadEncodedInt();
_resource = (CraftResource)reader.ReadEncodedInt();
_gemType = (GemType)reader.ReadEncodedInt();
_attributes = new AosAttributes(this);
_attributes.Deserialize(reader);

View file

@ -12,12 +12,6 @@ public abstract partial class BaseLight : Item
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private bool _burntOut;
// Field 1
private bool _burning;
// Field 2
private TimeSpan _duration = TimeSpan.Zero;
[SerializableField(3)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private bool _protected;
@ -49,7 +43,7 @@ public abstract partial class BaseLight : Item
public virtual int UnlitSound => 0x3be;
public virtual int BurntOutSound => 0x4b8;
[SerializableField(1)]
[SerializableProperty(1)]
[CommandProperty(AccessLevel.GameMaster)]
public bool Burning
{
@ -65,7 +59,7 @@ public abstract partial class BaseLight : Item
}
}
[SerializableField(2)]
[SerializableProperty(2)]
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan Duration
{

View file

@ -23,8 +23,6 @@ namespace Server.Items
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private bool _redyable;
private int _dyedHue;
[Constructible]
public DyeTub() : base(0xFAB)
{
@ -44,7 +42,7 @@ namespace Server.Items
public virtual bool AllowDyables => true;
[SerializableField(2)]
[SerializableProperty(2)]
[CommandProperty(AccessLevel.GameMaster)]
public int DyedHue
{

View file

@ -61,7 +61,7 @@
]
},
{
"name": "RawMobiles",
"name": "Mobiles",
"type": "Server.Mobile[]",
"rule": "ArrayMigrationRule",
"ruleArguments": [

View file

@ -13,7 +13,7 @@
]
},
{
"name": "RawResource",
"name": "Resource",
"type": "Server.Items.CraftResource",
"rule": "EnumMigrationRule"
}

View file

@ -13,7 +13,7 @@
]
},
{
"name": "RawResource",
"name": "Resource",
"type": "Server.Items.CraftResource",
"rule": "EnumMigrationRule"
}

View file

@ -120,7 +120,7 @@
"rule": "EnumMigrationRule"
},
{
"name": "RawResource",
"name": "Resource",
"type": "Server.Items.CraftResource",
"usesSaveFlag": true,
"rule": "EnumMigrationRule"

View file

@ -16,12 +16,12 @@
"rule": "SerializableInterfaceMigrationRule"
},
{
"name": "RawContent",
"name": "Content",
"type": "Server.Items.BeverageType",
"rule": "EnumMigrationRule"
},
{
"name": "RawQuantity",
"name": "Quantity",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [

View file

@ -3,7 +3,7 @@
"type": "Server.Items.BaseClothing",
"properties": [
{
"name": "RawResource",
"name": "Resource",
"type": "Server.Items.CraftResource",
"usesSaveFlag": true,
"rule": "EnumMigrationRule"

View file

@ -19,7 +19,7 @@
]
},
{
"name": "RawResource",
"name": "Resource",
"type": "Server.Items.CraftResource",
"rule": "EnumMigrationRule"
},

View file

@ -19,7 +19,7 @@
]
},
{
"name": "RawResource",
"name": "Resource",
"type": "Server.Items.CraftResource",
"rule": "EnumMigrationRule"
}

View file

@ -3,7 +3,7 @@
"type": "Server.Items.FillableContainer",
"properties": [
{
"name": "RawContentType",
"name": "ContentType",
"type": "Server.Items.FillableContentType",
"rule": "EnumMigrationRule"
},

View file

@ -51,7 +51,7 @@
]
},
{
"name": "RawLocked",
"name": "Locked",
"type": "bool",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [

View file

@ -3,7 +3,7 @@
"type": "Server.Items.MarkContainer",
"properties": [
{
"name": "RawAutoLock",
"name": "AutoLock",
"type": "bool",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [

View file

@ -45,8 +45,8 @@
<PackageReference Include="Argon2.Bindings" Version="1.13.0" />
<PackageReference Include="Zstd.Binaries" Version="1.4.0" />
<PackageReference Include="ModernUO.Serialization.Annotations" Version="2.0.2" />
<PackageReference Include="ModernUO.Serialization.Generator" Version="2.1.4" />
<PackageReference Include="ModernUO.Serialization.Annotations" Version="2.2.0" />
<PackageReference Include="ModernUO.Serialization.Generator" Version="2.2.2" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="Migrations/*.v*.json" />

View file

@ -18,7 +18,7 @@ jobs:
displayName: 'Install .NET 6'
inputs:
packageType: sdk
version: 6.0.300
version: 6.0.400
- task: NuGetAuthenticate@0
- script: ./publish.cmd Release win
displayName: 'Build'
@ -59,7 +59,7 @@ jobs:
displayName: 'Install .NET 6'
inputs:
packageType: sdk
version: 6.0.300
version: 6.0.400
- task: NuGetAuthenticate@0
- script: ./publish.cmd Release $(os)
displayName: 'Build'