fix: Codegens more misc items (#1216)

This commit is contained in:
Kamron Batman 2022-10-29 16:08:23 -07:00 • committed by GitHub
parent 32a5825ddd
commit 39e6f62ec9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
81 changed files with 3042 additions and 3780 deletions

View file

@ -1,78 +1,60 @@
using System;
using System.Buffers.Binary;
using ModernUO.Serialization;
using Server.Network;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class LOSBlocker : Item
{
public class LOSBlocker : Item
private const ushort GMItemId = 0x36FF;
[Constructible]
public LOSBlocker() : base(0x21A2) => Movable = false;
public LOSBlocker(Serial serial) : base(serial)
{
private const ushort GMItemId = 0x36FF;
}
[Constructible]
public LOSBlocker() : base(0x21A2) => Movable = false;
public override string DefaultName => "no line of sight";
public LOSBlocker(Serial serial) : base(serial)
public static void Initialize()
{
TileData.ItemTable[0x21A2].Flags = TileFlag.Wall | TileFlag.NoShoot;
TileData.ItemTable[0x21A2].Height = 20;
}
public override void SendWorldPacketTo(NetState ns, ReadOnlySpan<byte> world = default)
{
var mob = ns.Mobile;
if (AccessLevel.GameMaster >= mob?.AccessLevel)
{
base.SendWorldPacketTo(ns, world);
return;
}
public override string DefaultName => "no line of sight";
SendGMItem(ns);
}
public static void Initialize()
private void SendGMItem(NetState ns)
{
// GM Packet
Span<byte> buffer = stackalloc byte[OutgoingEntityPackets.MaxWorldEntityPacketLength].InitializePacket();
int length;
if (ns.StygianAbyss)
{
TileData.ItemTable[0x21A2].Flags = TileFlag.Wall | TileFlag.NoShoot;
TileData.ItemTable[0x21A2].Height = 20;
length = OutgoingEntityPackets.CreateWorldEntity(buffer, this, ns.HighSeas);
BinaryPrimitives.WriteUInt16BigEndian(buffer[8..10], GMItemId);
}
else
{
length = OutgoingItemPackets.CreateWorldItem(buffer, this);
BinaryPrimitives.WriteUInt16BigEndian(buffer[7..9], GMItemId);
}
public override void SendWorldPacketTo(NetState ns, ReadOnlySpan<byte> world = default)
{
var mob = ns.Mobile;
if (AccessLevel.GameMaster >= mob?.AccessLevel)
{
base.SendWorldPacketTo(ns, world);
return;
}
SendGMItem(ns);
}
private void SendGMItem(NetState ns)
{
// GM Packet
Span<byte> buffer = stackalloc byte[OutgoingEntityPackets.MaxWorldEntityPacketLength].InitializePacket();
int length;
if (ns.StygianAbyss)
{
length = OutgoingEntityPackets.CreateWorldEntity(buffer, this, ns.HighSeas);
BinaryPrimitives.WriteUInt16BigEndian(buffer[8..10], GMItemId);
}
else
{
length = OutgoingItemPackets.CreateWorldItem(buffer, this);
BinaryPrimitives.WriteUInt16BigEndian(buffer[7..9], GMItemId);
}
ns.Send(buffer[..length]);
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(1);
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
if (version < 1 && ItemID == 0x2199)
{
ItemID = 0x21A2;
}
}
ns.Send(buffer[..length]);
}
}