public Chunk(IChunkManager <VoxelT> chunkConfiguration, int sideLength) : this(sideLength) { configuration = chunkConfiguration ?? throw new ArgumentNullException(nameof(chunkConfiguration)); behaviour = chunkConfiguration.CreateBehaviour(this); ISet <Vector3I> existingChunkOffsets = chunkConfiguration.CheckoutRegistry(); foreach (Vector3I offset in existingChunkOffsets) { if (offset == Vector3I.Zero) { data = null; } else { new Chunk <VoxelT>(this, offset, false); } } }
private Chunk(Chunk <VoxelT> root, Vector3I offset, bool initializeData) { Root = root ?? throw new ArgumentNullException(nameof(root)); Offset = offset; SideLength = root.SideLength; Dimensions = new Vector3I(SideLength, SideLength, SideLength); chunkRegistry = root.chunkRegistry; behaviour = root.configuration.CreateBehaviour(this); if (initializeData) { data = new VoxelT[SideLength, SideLength, SideLength]; } else { data = null; } RegisterChunk(); }