internal void AddMissingModChunk() { Dictionary <string, ModChunk> missingChunks = new Dictionary <string, ModChunk>(ChunkLoader.chunkDictionnary); //Filter existing chunk from missing one foreach (ModChunk existingModChunk in modChunk) { if (missingChunks.ContainsKey(existingModChunk.GetType().FullName)) { missingChunks.Remove(existingModChunk.GetType().FullName); } } foreach (KeyValuePair <string, ModChunk> missingChunk in missingChunks) { ModChunk newChunk = (ModChunk)Activator.CreateInstance(missingChunk.Value.GetType()); if (!newChunk.CanExist) { continue; } if (WorldGen.gen && newChunk.ImpactWorldGen) { InfinityCoreWorld.generationChunks.Add(newChunk); } modChunk.Add(newChunk); } }
internal void Load(TagCompound data) { foreach (KeyValuePair <string, object> keyValuePair in data) { if (ChunkLoader.chunkDictionnary.ContainsKey(keyValuePair.Key)) { ModChunk chunk = (ModChunk)Activator.CreateInstance(keyValuePair.Value.GetType()); chunk.Load(data.GetCompound(keyValuePair.Key)); modChunk.Add(chunk); } } AddMissingModChunk(); }
internal void NetReceiveChunk(BinaryReader reader, bool syncMode = false) { int modChunkCount = reader.ReadInt32(); if (syncMode) { AddMissingModChunk(); } for (int i = 0; i < modChunkCount; i++) { ModChunk chunkType = ChunkLoader.chunkDictionnary[reader.ReadString()]; foreach (ModChunk chunk in modChunk) { if (chunk.GetType().FullName == chunkType.GetType().FullName) { chunk.NetReceive(reader); } } } }
internal static void RegisterModChunk(Type type) { ModChunk chunk = (ModChunk)Activator.CreateInstance(type); chunkDictionnary.Add(type.FullName, chunk); }