fix: Finishes code gen for misc items (#1248)

This commit is contained in:
Kamron Batman 2022-11-13 23:10:13 -08:00 • committed by GitHub
parent 6d00b2caa9
commit 5660f4636e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 2797 additions and 3156 deletions

View file

@ -1,107 +1,81 @@
using ModernUO.Serialization;
using Server.Multis;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0)]
public partial class SerpentPillar : Item
{
public class SerpentPillar : Item
[SerializableField(0)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private bool _active;
[SerializableField(1)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private string _word;
[SerializableField(2)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private Rectangle2D _destination;
[Constructible]
public SerpentPillar() : this(null, new Rectangle2D(), false)
{
[Constructible]
public SerpentPillar() : this(null, new Rectangle2D(), false)
}
public SerpentPillar(string word, Rectangle2D destination, bool active = true) : base(0x233F)
{
Movable = false;
_active = active;
_word = word;
_destination = destination;
}
public override bool HandlesOnSpeech => true;
public override void OnSpeech(SpeechEventArgs e)
{
var from = e.Mobile;
if (!e.Handled && from.InRange(this, 10) && e.Speech.ToLower() == Word)
{
}
var boat = BaseBoat.FindBoatAt(from.Location, from.Map);
public SerpentPillar(string word, Rectangle2D destination, bool active = true) : base(0x233F)
{
Movable = false;
Active = active;
Word = word;
Destination = destination;
}
public SerpentPillar(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public bool Active { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public string Word { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Rectangle2D Destination { get; set; }
public override bool HandlesOnSpeech => true;
public override void OnSpeech(SpeechEventArgs e)
{
var from = e.Mobile;
if (!e.Handled && from.InRange(this, 10) && e.Speech.ToLower() == Word)
if (boat == null)
{
var boat = BaseBoat.FindBoatAt(from.Location, from.Map);
if (boat == null)
{
return;
}
if (!Active)
{
boat.TillerMan
?.Say(
502507
); // Ar, Legend has it that these pillars are inactive! No man knows how it might be undone!
return;
}
var map = from.Map;
for (var i = 0; i < 5; i++) // Try 5 times
{
var x = Utility.Random(Destination.X, Destination.Width);
var y = Utility.Random(Destination.Y, Destination.Height);
var z = map.GetAverageZ(x, y);
var dest = new Point3D(x, y, z);
if (boat.CanFit(dest, map, boat.ItemID))
{
var xOffset = x - boat.X;
var yOffset = y - boat.Y;
var zOffset = z - boat.Z;
boat.Teleport(xOffset, yOffset, zOffset);
return;
}
}
boat.TillerMan?.Say(502508); // Ar, I refuse to take that matey through here!
return;
}
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
if (!Active)
{
// Ar, Legend has it that these pillars are inactive! No man knows how it might be undone!
boat.TillerMan?.Say(502507);
return;
}
writer.WriteEncodedInt(0); // version
var map = from.Map;
writer.Write(Active);
writer.Write(Word);
writer.Write(Destination);
}
for (var i = 0; i < 5; i++) // Try 5 times
{
var x = Utility.Random(Destination.X, Destination.Width);
var y = Utility.Random(Destination.Y, Destination.Height);
var z = map.GetAverageZ(x, y);
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var dest = new Point3D(x, y, z);
var version = reader.ReadEncodedInt();
if (boat.CanFit(dest, map, boat.ItemID))
{
var xOffset = x - boat.X;
var yOffset = y - boat.Y;
var zOffset = z - boat.Z;
Active = reader.ReadBool();
Word = reader.ReadString();
Destination = reader.ReadRect2D();
boat.Teleport(xOffset, yOffset, zOffset);
return;
}
}
boat.TillerMan?.Say(502508); // Ar, I refuse to take that matey through here!
}
}
}