public static NPCDefinition GetNPC(int i) { for (int j = 0; j < 20; j++) { if (cache[j].ID == (long)i) { return(cache[j]); } } StorageCacheIndex = (StorageCacheIndex + 1) % 20; NPCDefinition entityDef = cache[StorageCacheIndex] = new NPCDefinition(); stream.Location = streamIndices[i]; entityDef.ID = i; entityDef.ReadNPC(stream); return(entityDef); }
/*public NPCDefinition method161() * { * int j = -1; * if(anInt57 != -1) * { * VarBit varBit = VarBit.cache[anInt57]; * int k = varBit.anInt648; * int l = varBit.anInt649; * int i1 = varBit.anInt650; * int j1 = client.anIntArray1232[i1 - l]; * j = clientInstance.variousSettings[k] >> l & j1; * } else * if(anInt59 != -1) * j = clientInstance.variousSettings[anInt59]; * if(j < 0 || j >= childrenIDs.Length || childrenIDs[j] == -1) * return null; * else * return forID(childrenIDs[j]); * }*/ public static void UnpackNPCs(Cache loaded_cache, DataBuffer data_file, DataBuffer index_file) { LoadedCache = loaded_cache; stream = data_file; DataBuffer index_stream = index_file; int totalNPCs = index_stream.ReadShort(); streamIndices = new int[totalNPCs]; int i = 2; for (int j = 0; j < totalNPCs; j++) { streamIndices[j] = i; i += index_stream.ReadShort(); } cache = new NPCDefinition[20]; for (int k = 0; k < 20; k++) { cache[k] = new NPCDefinition(); } }
/*public NPCDefinition method161() { int j = -1; if(anInt57 != -1) { VarBit varBit = VarBit.cache[anInt57]; int k = varBit.anInt648; int l = varBit.anInt649; int i1 = varBit.anInt650; int j1 = client.anIntArray1232[i1 - l]; j = clientInstance.variousSettings[k] >> l & j1; } else if(anInt59 != -1) j = clientInstance.variousSettings[anInt59]; if(j < 0 || j >= childrenIDs.Length || childrenIDs[j] == -1) return null; else return forID(childrenIDs[j]); }*/ public static void UnpackNPCs(Cache loaded_cache, DataBuffer data_file, DataBuffer index_file) { LoadedCache = loaded_cache; stream = data_file; DataBuffer index_stream = index_file; int totalNPCs = index_stream.ReadShort(); streamIndices = new int[totalNPCs]; int i = 2; for (int j = 0; j < totalNPCs; j++) { streamIndices[j] = i; i += index_stream.ReadShort(); } cache = new NPCDefinition[20]; for (int k = 0; k < 20; k++) cache[k] = new NPCDefinition(); }
public static NPCDefinition GetNPC(int i) { for (int j = 0; j < 20; j++) if (cache[j].ID == (long)i) return cache[j]; StorageCacheIndex = (StorageCacheIndex + 1) % 20; NPCDefinition entityDef = cache[StorageCacheIndex] = new NPCDefinition(); stream.Location = streamIndices[i]; entityDef.ID = i; entityDef.ReadNPC(stream); return entityDef; }