fix: Codgens more addons (#685)

* Fixes after deserialization not executing for older versions of an object
* Codegens more addons
This commit is contained in:
Kamron Batman 2021-08-15 17:55:04 -07:00 committed by GitHub
parent 25fa9b397b
commit 4c265562bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
255 changed files with 1514 additions and 3742 deletions

View file

@ -16,7 +16,8 @@ namespace Server.Items
Working
}
public class FlourMillEastAddon : BaseAddon, IFlourMill
[Serializable(1, false)]
public partial class FlourMillEastAddon : BaseAddon, IFlourMill
{
private static readonly int[][] m_StageTable =
{
@ -25,7 +26,7 @@ namespace Server.Items
new[] { 0x1924, 0x1924, 0x1928 }
};
private int m_Flour;
private int _flour;
[Constructible]
public FlourMillEastAddon()
@ -35,17 +36,13 @@ namespace Server.Items
AddComponent(new AddonComponent(0x1924), 1, 0, 0);
}
public FlourMillEastAddon(Serial serial) : base(serial)
{
}
public override BaseAddonDeed Deed => new FlourMillEastDeed();
[CommandProperty(AccessLevel.GameMaster)]
public bool HasFlour => m_Flour > 0;
public bool HasFlour => _flour > 0;
[CommandProperty(AccessLevel.GameMaster)]
public bool IsFull => m_Flour >= MaxFlour;
public bool IsFull => _flour >= MaxFlour;
[CommandProperty(AccessLevel.GameMaster)]
public bool IsWorking { get; private set; }
@ -53,14 +50,16 @@ namespace Server.Items
[CommandProperty(AccessLevel.GameMaster)]
public int MaxFlour => 2;
[SerializableField(0)]
[CommandProperty(AccessLevel.GameMaster)]
public int CurFlour
{
get => m_Flour;
get => _flour;
set
{
m_Flour = Math.Max(0, Math.Min(value, MaxFlour));
_flour = Math.Clamp(value, 0, MaxFlour);
UpdateStage();
this.MarkDirty();
}
}
@ -86,7 +85,7 @@ namespace Server.Items
if (from.PlaceInBackpack(flour))
{
m_Flour = 0;
_flour = 0;
}
else
{
@ -165,60 +164,26 @@ namespace Server.Items
}
}
public override void Serialize(IGenericWriter writer)
private void Deserialize(IGenericReader reader, int version)
{
base.Serialize(writer);
writer.Write(1); // version
writer.Write(m_Flour);
}
public override void Deserialize(IGenericReader reader)
[AfterDeserialization]
private void AfterDeserialization()
{
base.Deserialize(reader);
var version = reader.ReadInt();
switch (version)
{
case 1:
{
m_Flour = reader.ReadInt();
break;
}
}
UpdateStage();
}
}
public class FlourMillEastDeed : BaseAddonDeed
[Serializable(0, false)]
public partial class FlourMillEastDeed : BaseAddonDeed
{
[Constructible]
public FlourMillEastDeed()
{
}
public FlourMillEastDeed(Serial serial) : base(serial)
{
}
public override BaseAddon Addon => new FlourMillEastAddon();
public override int LabelNumber => 1044347; // flour mill (east)
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
}