fix: Codegens farmables (#1001)
This commit is contained in:
parent
4bde9a4c86
commit
933c41070f
20 changed files with 256 additions and 392 deletions
|
|
@ -1,41 +1,22 @@
|
|||
namespace Server.Items
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server.Items;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public partial class FarmableCabbage : FarmableCrop
|
||||
{
|
||||
public class FarmableCabbage : FarmableCrop
|
||||
[Constructible]
|
||||
public FarmableCabbage() : base(GetCropID())
|
||||
{
|
||||
[Constructible]
|
||||
public FarmableCabbage() : base(GetCropID())
|
||||
{
|
||||
}
|
||||
|
||||
public FarmableCabbage(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public static int GetCropID() => 3254;
|
||||
|
||||
public override Item GetCropObject()
|
||||
{
|
||||
var cabbage = new Cabbage();
|
||||
|
||||
cabbage.ItemID = Utility.Random(3195, 2);
|
||||
|
||||
return cabbage;
|
||||
}
|
||||
|
||||
public override int GetPickedID() => 3254;
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.WriteEncodedInt(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetCropID() => 3254;
|
||||
|
||||
public override Item GetCropObject() =>
|
||||
new Cabbage
|
||||
{
|
||||
ItemID = Utility.Random(3195, 2)
|
||||
};
|
||||
|
||||
public override int GetPickedID() => 3254;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,41 +1,22 @@
|
|||
namespace Server.Items
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server.Items;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public partial class FarmableCarrot : FarmableCrop
|
||||
{
|
||||
public class FarmableCarrot : FarmableCrop
|
||||
[Constructible]
|
||||
public FarmableCarrot() : base(GetCropID())
|
||||
{
|
||||
[Constructible]
|
||||
public FarmableCarrot() : base(GetCropID())
|
||||
{
|
||||
}
|
||||
|
||||
public FarmableCarrot(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public static int GetCropID() => 3190;
|
||||
|
||||
public override Item GetCropObject()
|
||||
{
|
||||
var carrot = new Carrot();
|
||||
|
||||
carrot.ItemID = Utility.Random(3191, 2);
|
||||
|
||||
return carrot;
|
||||
}
|
||||
|
||||
public override int GetPickedID() => 3254;
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.WriteEncodedInt(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetCropID() => 3190;
|
||||
|
||||
public override Item GetCropObject() =>
|
||||
new Carrot
|
||||
{
|
||||
ItemID = Utility.Random(3191, 2)
|
||||
};
|
||||
|
||||
public override int GetPickedID() => 3254;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,18 @@
|
|||
namespace Server.Items
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server.Items;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public partial class FarmableCotton : FarmableCrop
|
||||
{
|
||||
public class FarmableCotton : FarmableCrop
|
||||
[Constructible]
|
||||
public FarmableCotton() : base(GetCropID())
|
||||
{
|
||||
[Constructible]
|
||||
public FarmableCotton() : base(GetCropID())
|
||||
{
|
||||
}
|
||||
|
||||
public FarmableCotton(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public static int GetCropID() => Utility.Random(3153, 4);
|
||||
|
||||
public override Item GetCropObject() => new Cotton();
|
||||
|
||||
public override int GetPickedID() => 3254;
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.WriteEncodedInt(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetCropID() => Utility.Random(3153, 4);
|
||||
|
||||
public override Item GetCropObject() => new Cotton();
|
||||
|
||||
public override int GetPickedID() => 3254;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,91 +1,71 @@
|
|||
using System;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Items
|
||||
namespace Server.Items;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public abstract partial class FarmableCrop : Item
|
||||
{
|
||||
public abstract class FarmableCrop : Item
|
||||
[SerializableField(0)]
|
||||
private bool _picked;
|
||||
|
||||
public FarmableCrop(int itemID) : base(itemID) => Movable = false;
|
||||
|
||||
public abstract Item GetCropObject();
|
||||
public abstract int GetPickedID();
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
private bool m_Picked;
|
||||
var map = Map;
|
||||
var loc = Location;
|
||||
|
||||
public FarmableCrop(int itemID) : base(itemID) => Movable = false;
|
||||
|
||||
public FarmableCrop(Serial serial) : base(serial)
|
||||
if (Parent != null || Movable || IsLockedDown || IsSecure || map == null || map == Map.Internal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public abstract Item GetCropObject();
|
||||
public abstract int GetPickedID();
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
if (!from.InRange(loc, 2) || !from.InLOS(this))
|
||||
{
|
||||
var map = Map;
|
||||
var loc = Location;
|
||||
|
||||
if (Parent != null || Movable || IsLockedDown || IsSecure || map == null || map == Map.Internal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!from.InRange(loc, 2) || !from.InLOS(this))
|
||||
{
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
|
||||
}
|
||||
else if (!m_Picked)
|
||||
{
|
||||
OnPicked(from, loc, map);
|
||||
}
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
|
||||
}
|
||||
|
||||
public virtual void OnPicked(Mobile from, Point3D loc, Map map)
|
||||
else if (!_picked)
|
||||
{
|
||||
ItemID = GetPickedID();
|
||||
OnPicked(from, loc, map);
|
||||
}
|
||||
}
|
||||
|
||||
var spawn = GetCropObject();
|
||||
public virtual void OnPicked(Mobile from, Point3D loc, Map map)
|
||||
{
|
||||
ItemID = GetPickedID();
|
||||
|
||||
spawn?.MoveToWorld(loc, map);
|
||||
var spawn = GetCropObject();
|
||||
|
||||
m_Picked = true;
|
||||
spawn?.MoveToWorld(loc, map);
|
||||
|
||||
_picked = true;
|
||||
|
||||
Unlink();
|
||||
|
||||
Timer.StartTimer(TimeSpan.FromMinutes(5.0), Delete);
|
||||
}
|
||||
|
||||
public void Unlink()
|
||||
{
|
||||
if (Spawner != null)
|
||||
{
|
||||
Spawner.Remove(this);
|
||||
Spawner = null;
|
||||
}
|
||||
}
|
||||
|
||||
[AfterDeserialization]
|
||||
private void AfterDeserialization()
|
||||
{
|
||||
if (_picked)
|
||||
{
|
||||
Unlink();
|
||||
|
||||
Timer.StartTimer(TimeSpan.FromMinutes(5.0), Delete);
|
||||
}
|
||||
|
||||
public void Unlink()
|
||||
{
|
||||
if (Spawner != null)
|
||||
{
|
||||
Spawner.Remove(this);
|
||||
Spawner = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.WriteEncodedInt(0); // version
|
||||
|
||||
writer.Write(m_Picked);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadEncodedInt();
|
||||
|
||||
m_Picked = version switch
|
||||
{
|
||||
0 => reader.ReadBool(),
|
||||
_ => m_Picked
|
||||
};
|
||||
|
||||
if (m_Picked)
|
||||
{
|
||||
Unlink();
|
||||
Delete();
|
||||
}
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,41 +1,22 @@
|
|||
namespace Server.Items
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server.Items;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public partial class FarmableFlax : FarmableCrop
|
||||
{
|
||||
public class FarmableFlax : FarmableCrop
|
||||
[Constructible]
|
||||
public FarmableFlax() : base(GetCropID())
|
||||
{
|
||||
[Constructible]
|
||||
public FarmableFlax() : base(GetCropID())
|
||||
{
|
||||
}
|
||||
|
||||
public FarmableFlax(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public static int GetCropID() => Utility.Random(6809, 3);
|
||||
|
||||
public override Item GetCropObject()
|
||||
{
|
||||
var flax = new Flax();
|
||||
|
||||
flax.ItemID = Utility.Random(6812, 2);
|
||||
|
||||
return flax;
|
||||
}
|
||||
|
||||
public override int GetPickedID() => 3254;
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.WriteEncodedInt(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetCropID() => Utility.Random(6809, 3);
|
||||
|
||||
public override Item GetCropObject() =>
|
||||
new Flax
|
||||
{
|
||||
ItemID = Utility.Random(6812, 2)
|
||||
};
|
||||
|
||||
public override int GetPickedID() => 3254;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,41 +1,22 @@
|
|||
namespace Server.Items
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server.Items;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public partial class FarmableLettuce : FarmableCrop
|
||||
{
|
||||
public class FarmableLettuce : FarmableCrop
|
||||
[Constructible]
|
||||
public FarmableLettuce() : base(GetCropID())
|
||||
{
|
||||
[Constructible]
|
||||
public FarmableLettuce() : base(GetCropID())
|
||||
{
|
||||
}
|
||||
|
||||
public FarmableLettuce(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public static int GetCropID() => 3254;
|
||||
|
||||
public override Item GetCropObject()
|
||||
{
|
||||
var lettuce = new Lettuce();
|
||||
|
||||
lettuce.ItemID = Utility.Random(3184, 2);
|
||||
|
||||
return lettuce;
|
||||
}
|
||||
|
||||
public override int GetPickedID() => 3254;
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.WriteEncodedInt(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetCropID() => 3254;
|
||||
|
||||
public override Item GetCropObject() =>
|
||||
new Lettuce
|
||||
{
|
||||
ItemID = Utility.Random(3184, 2)
|
||||
};
|
||||
|
||||
public override int GetPickedID() => 3254;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,41 +1,22 @@
|
|||
namespace Server.Items
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server.Items;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public partial class FarmableOnion : FarmableCrop
|
||||
{
|
||||
public class FarmableOnion : FarmableCrop
|
||||
[Constructible]
|
||||
public FarmableOnion() : base(GetCropID())
|
||||
{
|
||||
[Constructible]
|
||||
public FarmableOnion() : base(GetCropID())
|
||||
{
|
||||
}
|
||||
|
||||
public FarmableOnion(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public static int GetCropID() => 3183;
|
||||
|
||||
public override Item GetCropObject()
|
||||
{
|
||||
var onion = new Onion();
|
||||
|
||||
onion.ItemID = Utility.Random(3181, 2);
|
||||
|
||||
return onion;
|
||||
}
|
||||
|
||||
public override int GetPickedID() => 3254;
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.WriteEncodedInt(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetCropID() => 3183;
|
||||
|
||||
public override Item GetCropObject() =>
|
||||
new Onion
|
||||
{
|
||||
ItemID = Utility.Random(3181, 2)
|
||||
};
|
||||
|
||||
public override int GetPickedID() => 3254;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,43 +1,23 @@
|
|||
namespace Server.Items
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server.Items;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public partial class FarmablePumpkin : FarmableCrop
|
||||
{
|
||||
public class FarmablePumpkin : FarmableCrop
|
||||
[Constructible]
|
||||
public FarmablePumpkin()
|
||||
: base(GetCropID())
|
||||
{
|
||||
[Constructible]
|
||||
public FarmablePumpkin()
|
||||
: base(GetCropID())
|
||||
{
|
||||
}
|
||||
|
||||
public FarmablePumpkin(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public static int GetCropID() => Utility.Random(3166, 3);
|
||||
|
||||
public override Item GetCropObject()
|
||||
{
|
||||
var pumpkin = new Pumpkin();
|
||||
|
||||
pumpkin.ItemID = Utility.Random(3178, 3);
|
||||
|
||||
return pumpkin;
|
||||
}
|
||||
|
||||
public override int GetPickedID() => Utility.Random(3166, 3);
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.WriteEncodedInt(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetCropID() => Utility.Random(3166, 3);
|
||||
|
||||
public override Item GetCropObject() =>
|
||||
new Pumpkin
|
||||
{
|
||||
ItemID = Utility.Random(3178, 3)
|
||||
};
|
||||
|
||||
public override int GetPickedID() => Utility.Random(3166, 3);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,41 +1,22 @@
|
|||
namespace Server.Items
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server.Items;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public partial class FarmableTurnip : FarmableCrop
|
||||
{
|
||||
public class FarmableTurnip : FarmableCrop
|
||||
[Constructible]
|
||||
public FarmableTurnip() : base(GetCropID())
|
||||
{
|
||||
[Constructible]
|
||||
public FarmableTurnip() : base(GetCropID())
|
||||
{
|
||||
}
|
||||
|
||||
public FarmableTurnip(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public static int GetCropID() => Utility.Random(3169, 3);
|
||||
|
||||
public override Item GetCropObject()
|
||||
{
|
||||
var turnip = new Turnip();
|
||||
|
||||
turnip.ItemID = Utility.Random(3385, 2);
|
||||
|
||||
return turnip;
|
||||
}
|
||||
|
||||
public override int GetPickedID() => 3254;
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.WriteEncodedInt(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetCropID() => Utility.Random(3169, 3);
|
||||
|
||||
public override Item GetCropObject() =>
|
||||
new Turnip
|
||||
{
|
||||
ItemID = Utility.Random(3385, 2)
|
||||
};
|
||||
|
||||
public override int GetPickedID() => 3254;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,18 @@
|
|||
namespace Server.Items
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server.Items;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public partial class FarmableWheat : FarmableCrop
|
||||
{
|
||||
public class FarmableWheat : FarmableCrop
|
||||
[Constructible]
|
||||
public FarmableWheat() : base(GetCropID())
|
||||
{
|
||||
[Constructible]
|
||||
public FarmableWheat() : base(GetCropID())
|
||||
{
|
||||
}
|
||||
|
||||
public FarmableWheat(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public static int GetCropID() => Utility.Random(3157, 4);
|
||||
|
||||
public override Item GetCropObject() => new WheatSheaf();
|
||||
|
||||
public override int GetPickedID() => Utility.Random(3502, 2);
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.WriteEncodedInt(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetCropID() => Utility.Random(3157, 4);
|
||||
|
||||
public override Item GetCropObject() => new WheatSheaf();
|
||||
|
||||
public override int GetPickedID() => Utility.Random(3502, 2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.FarmableCabbage"
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.FarmableCarrot"
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.FarmableCotton"
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.FarmableCrop",
|
||||
"properties": [
|
||||
{
|
||||
"name": "Picked",
|
||||
"type": "bool",
|
||||
"rule": "PrimitiveTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
""
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.FarmableFlax"
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.FarmableLettuce"
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.FarmableOnion"
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.FarmablePumpkin"
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.FarmableTurnip"
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.FarmableWheat"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue