public Chunk LoadChunk(Vector3i pos, int posMult) { if (LoadedChunks.TryGetValue(pos, out Chunk chunk)) { while (chunk.SucceededBy != null) { chunk = chunk.SucceededBy; } // TODO: ?!?!?!? if (chunk.PosMultiplier != posMult) { Chunk ch = chunk; chunk = new Chunk(posMult) { OwningRegion = this, adding = ch.adding, rendering = ch.rendering, _VBOSolid = null, _VBOTransp = null, WorldPosition = pos, IsNew = true }; chunk.OnRendered = () => { LoadedChunks.Remove(pos); ch.Destroy(false); LoadedChunks.Add(pos, chunk); }; ch.SucceededBy = chunk; } } else { chunk = new Chunk(posMult) { OwningRegion = this, WorldPosition = pos, IsNew = true }; LoadedChunks.Add(pos, chunk); } return(chunk); }
public Chunk LoadChunk(Vector3i pos, int posMult) { Chunk chunk; if (LoadedChunks.TryGetValue(pos, out chunk)) { while (chunk.SucceededBy != null) { chunk = chunk.SucceededBy; } // TODO: ?!?!?!? if (chunk.PosMultiplier != posMult) { Chunk ch = chunk; chunk = new Chunk(posMult); chunk.OwningRegion = this; chunk.adding = ch.adding; chunk.rendering = ch.rendering; chunk._VBO = null; chunk.WorldPosition = pos; ch.SucceededBy = chunk; chunk.OnRendered = () => { LoadedChunks.Remove(pos); ch.Destroy(); LoadedChunks.Add(pos, chunk); }; } } else { chunk = new Chunk(posMult); chunk.OwningRegion = this; chunk.WorldPosition = pos; LoadedChunks.Add(pos, chunk); } return(chunk); }