public static void Handle(Player player, byte[] buffer) { fixed(byte *p = buffer) { var packet = *(MsgNpcSpawn *)p; BufferPool.RecycleBuffer(buffer); var npc = new Npc { UniqueId = UniqueIdGenerator.GetNext(EntityType.DynamicNpc), MapId = player.MapId, Location = { X = packet.X, Y = packet.Y }, Look = packet.Look, Type = 2, Direction = (Direction)(packet.Look % 10) }; GameWorld.Maps[player.MapId].LoadInEntity(npc); ScreenSystem.Create(npc); ScreenSystem.SendSpawn(npc); Collections.Npcs.Add(npc.UniqueId, npc); } }
public static byte[] Create(Npc npc) { var packet = new MsgNpcSpawn { Size = (ushort)sizeof(MsgNpcSpawn), Id = 2030, UniqueId = npc.UniqueId, Look = (ushort)npc.Look, X = npc.Location.X, Y = npc.Location.Y, Type = npc.Type, Sort = npc.Sort, Base = npc.Base }; return(packet); }