ModernUO/Projects/UOContent/Holiday Stuff/Halloween/2006/Items/HalloweenPumpkin.cs
Kamron Batman f2d44e0283
fix(codegen): Reverts & Disables codegen (for now) (#625)
After speaking with the C# devs, it is clear that code gen is not ready.
I can get around this by doing the following:
1. Creating a library
2. Splitting out the schema writing from the source generator
3. Moving the schema loading to `AdditionalFiles`
4. Writing a new post-build application using Roslyn to write the schema files after building.
2021-05-27 19:50:22 -07:00

100 lines
2.6 KiB
C#

using Server.Mobiles;
namespace Server.Items
{
public class HalloweenPumpkin : Item
{
private static readonly string[] m_Staff =
{
"Ryan", "Mark", "Eos", "Athena", "Xavier", "Krrios", "Zippy"
};
[Constructible]
public HalloweenPumpkin()
{
Weight = Utility.RandomMinMax(3, 20);
ItemID = Utility.RandomDouble() <= .02
? Utility.RandomList(0x4694, 0x4698)
: Utility.RandomList(0xc6a, 0xc6b, 0xc6c);
}
public HalloweenPumpkin(Serial serial)
: base(serial)
{
}
public override void OnDoubleClick(Mobile from)
{
if (!from.InRange(GetWorldLocation(), 2))
{
return;
}
var douse = false;
switch (ItemID)
{
case 0x4694:
ItemID = 0x4691;
break;
case 0x4691:
ItemID = 0x4694;
douse = true;
break;
case 0x4698:
ItemID = 0x4695;
break;
case 0x4695:
ItemID = 0x4698;
douse = true;
break;
default: return;
}
from.SendLocalizedMessage(douse ? 1113988 : 1113987); // You extinguish/light the Jack-O-Lantern
Effects.PlaySound(GetWorldLocation(), Map, douse ? 0x3be : 0x47);
}
private void AssignRandomName()
{
Name = $"{m_Staff.RandomElement()}'s Jack-O-Lantern";
}
public override bool OnDragLift(Mobile from)
{
if (Name == null && (ItemID == 0x4694 || ItemID == 0x4691 || ItemID == 0x4698 || ItemID == 0x4695))
{
if (Utility.RandomBool())
{
new PumpkinHead().MoveToWorld(GetWorldLocation(), Map);
Delete();
return false;
}
AssignRandomName();
}
return true;
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(1); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
if (version == 0 && Name == null && ItemID == 0x4698)
{
AssignRandomName();
}
}
}
}