public sealed class DisplayContextMenuOld : Packet
{
public DisplayContextMenuOld(ContextMenu menu)
: base(0xBF)
{
var entries = menu.Entries;
int length = (byte)entries.Length;
EnsureCapacity(12 + (length * 8));
m_Stream.Write((short)0x14);
if (menu.From.NetState.IsKRClient)this.m_Stream.Write((short)0x02); // New layout
else m_Stream.Write((short)0x01);
IEntity target = menu.Target as IEntity;
m_Stream.Write((target == null ? Serial.MinusOne : target.Serial));
m_Stream.Write((byte)length);
Point3D p;
if (target is Mobile)
{
p = target.Location;
}
else if (target is Item)
{
p = ((Item)target).GetWorldLocation();
}
else
{
p = Point3D.Zero;
}
for (int i = 0; i < length; ++i)
{
ContextMenuEntry e = entries[i];
if (menu.From.NetState.IsKRClient)
{
if (e.Number <= 65535) m_Stream.Write((uint)(e.Number + 3000000));
else m_Stream.Write((uint)e.Number);
m_Stream.Write((short)i);
}
else
{
m_Stream.Write((short)i);
m_Stream.Write((ushort)(e.Number - 3000000));
}
int range = e.Range;
if (range == -1)
{
range = 18;
}
CMEFlags flags = (e.Enabled && menu.From.InRange(p, range)) ? CMEFlags.None : CMEFlags.Disabled;
int color = e.Color & 0xFFFF;
if (color != 0xFFFF)
{
flags |= CMEFlags.Colored;
}
flags |= e.Flags;
m_Stream.Write((short)flags);
if ((flags & CMEFlags.Colored) != 0)
{
m_Stream.Write((short)color);
}
}
}
}