Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
 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();
 }
Esempio n. 3
0
        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);
                    }
                }
            }
        }
Esempio n. 4
0
        internal static void RegisterModChunk(Type type)
        {
            ModChunk chunk = (ModChunk)Activator.CreateInstance(type);

            chunkDictionnary.Add(type.FullName, chunk);
        }