Exemplo n.º 1
0
    void serializeChunkData(SerializableChunk copyTo, WorldChunk copyFrom)
    {
        // save indexes
        copyTo.x = copyFrom.getX();
        copyTo.z = copyFrom.getZ();

        // save chunk sectors
        WorldSector[,] sectors = copyFrom.getAllSectors();
        for (int i = 0; i < GameSettings.LoadedConfig.ChunkLength_Sectors*GameSettings.LoadedConfig.ChunkLength_Sectors; ++i) {
            copyTo.sectors.Add(new SerializableSector());

            int sx = i%GameSettings.LoadedConfig.ChunkLength_Sectors;
            int sz = Mathf.FloorToInt(i/GameSettings.LoadedConfig.ChunkLength_Sectors);
            serializeSectorData(copyTo.sectors[i], sectors[sx, sz]);
        }
    }