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); }
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); }
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); }
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]); }