public void addNPC(NPC npc) { if(this.npcs.Contains(npc)) return; this.npcs.Add(npc); }
public void addToNPCs(NPC npc) { this.npcs.Add(npc); }
public static int loadNPCs(string mapIdentifier) { if(!Constants.VFSSkip) vfsDataProvider.Instance.unpackFromVFS("data\\map" + mapIdentifier + "\\npc" + mapIdentifier + ".arr", "data\\npcs\\npc" + mapIdentifier + ".arr"); if(!File.Exists(AppDomain.CurrentDomain.BaseDirectory + "data/npcs/npc" + mapIdentifier + ".arr")) return 0; int npc_counts = 0; int mapID = Convert.ToInt32(mapIdentifier); byte[] data = File.ReadAllBytes(AppDomain.CurrentDomain.BaseDirectory + "data/npcs/npc" + mapIdentifier + ".arr"); if(data.Length < 20) return 0; int u = 0; int npc_data_length = 0; if(mapIdentifier != "207") npc_data_length = 28; else npc_data_length = 20; while(u * npc_data_length < data.Length) { int npcmID = BitConverter.ToInt16(data, u * npc_data_length); float x = BitConverter.ToSingle(data, u * npc_data_length + 4); float y = BitConverter.ToSingle(data, u * npc_data_length + 8); NPC npc = new NPC(npcmID, u+1); npc.setMap((short)mapID); npc.setPosition(new float[] { x, y }); Area area = WMap.Instance.getGrid(mapID).getAreaByRound(x, y); if(area != null) { WMap.Instance.addToNPCs(npc); area.addNPC(npc); npc_counts++; } u++; } return npc_counts; }