Exemple #1
0
        public Chunk getChunk(IntVec3 pos)
        {
            IntVec3 localindex = (pos.Float() / Settings.chunk_size).Floor();

            foreach (Chunk chunk in chunks)
            {
                if (chunk.pos == localindex)
                {
                    return(chunk);
                }
            }
            return(null);
        }
Exemple #2
0
        public IntVec3 getChunkIndex(IntVec3 pos)
        {
            if (pos == null)
            {
                return(null);
            }
            IntVec3 localindex = (pos.Float() / Settings.chunk_size).Floor();
            IntVec3 cindex     = localindex - chunkpos + new IntVec3(Settings.offset, Settings.offset, Settings.offset);

            if (!chunkOnMap(cindex))
            {
                return(null);
            }
            return(cindex);
        }
Exemple #3
0
        public IntVec3 getBlockIndex(IntVec3 pos)
        {
            IntVec3 localindex = (pos.Float() / Settings.chunk_size).Floor();
            Chunk   chunk      = getChunk(pos);

            if (chunk == null)
            {
                return(null);
            }
            if (!chunk.loaded)
            {
                return(null);
            }
            return(pos - localindex * Settings.chunk_size);
        }
Exemple #4
0
        public Block getBlock(IntVec3 pos)
        {
            if (pos == null)
            {
                return(new Block("error"));
            }
            IntVec3 localindex = (pos.Float() / Settings.chunk_size).Floor();
            Chunk   chunk      = getChunk(pos);

            if (chunk == null)
            {
                return(new Block("error"));
            }
            if (!chunk.loaded)
            {
                return(new Block("error"));
            }
            IntVec3 bindex = pos - localindex * Settings.chunk_size;

            return(chunk.blocks[bindex.x, bindex.y, bindex.z]);
        }