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

@ -1,10 +1,10 @@
namespace Server.Items
{
public class JackOLantern : BaseAddon
[Serializable(0)]
public partial class JackOLantern : BaseAddon
{
[Constructible]
public JackOLantern()
: this(Utility.Random(2) < 1)
public JackOLantern() : this(Utility.Random(2) < 1)
{
}
@ -14,7 +14,6 @@ namespace Server.Items
AddComponent(new AddonComponent(5703), 0, 0, +0);
const int hue = 1161;
// ( 1 > Utility.Random( 5 ) ? 2118 : 1161 );
if (!south)
{
@ -30,11 +29,6 @@ namespace Server.Items
}
}
public JackOLantern(Serial serial)
: base(serial)
{
}
public override bool ShareHue => false;
private static AddonComponent GetComponent(int itemID, int hue) =>
@ -44,47 +38,16 @@ namespace Server.Items
Name = "jack-o-lantern"
};
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write((byte)2); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadByte();
if (version <= 1)
{
Timer.StartTimer(() => Fix(version));
}
}
private void Fix(int version)
private void Deserialize(IGenericReader reader, int version)
{
for (var i = 0; i < Components.Count; ++i)
{
var ac = Components[i];
switch (version)
{
case 1:
{
ac.Name = "jack-o-lantern";
goto case 0;
}
case 0:
{
if (ac.Hue == 2118)
{
ac.Hue = 1161;
}
ac.Name = "jack-o-lantern";
break;
}
if (ac.Hue == 2118)
{
ac.Hue = 1161;
}
}
}