Exemplo n.º 1
0
    public VectorVoxel[] LoadDataFromChunkSave(ChunkCoord chunk)
    {
        if (ChunkSaveObject.ChunkSaveExist(chunk))
        {
            ChunkSaveObject so = ChunkSaveObject.LoadChunk(ChunkSaveObject.GetPathFromChunkCoord(chunk));
            VectorVoxel[]   vv = new VectorVoxel[so.vectors.Length / 4];

            for (int i = 0; i < vv.Length; i++)
            {
                Vector3Int vec  = new Vector3Int(so.vectors[i, 0], so.vectors[i, 1], so.vectors[i, 2]);
                BlockType  bloc = (BlockType)so.vectors[i, 3];
                vv[i] = new VectorVoxel(vec, bloc);
                PrepareToSave(vec.x, vec.y, vec.z, chunk, bloc);
            }
            return(vv);
        }
        return(null);
    }
Exemplo n.º 2
0
    void SaveDataToChunkSave()
    {
        List <ChunkCoord> toRemove = new List <ChunkCoord>();

        foreach (var chunkCoorditem in preparedToSave)
        {
            List <VectorVoxel> vvs = new List <VectorVoxel>();
            foreach (var item in chunkCoorditem.Value)
            {
                VectorVoxel vv = new VectorVoxel(item.Key, item.Value);
                vvs.Add(vv);
            }
            ChunkSaveObject so = new ChunkSaveObject(chunkCoorditem.Key, vvs.ToArray());
            ChunkSaveObject.SaveChunk(so);
            toRemove.Add(chunkCoorditem.Key);
        }
        foreach (ChunkCoord item in toRemove)
        {
            editedBlock.Remove(item);
        }
        preparedToSave.Clear();
    }