public void SetVoxel(LoadedVoxelMaterial mat, ushort height, Vector3Int pos) { var cx = (pos.x + (pos.x < 0 ? 1 : 0)) / ChunkDataSettings.XSize - (pos.x < 0 ? 1 : 0); var cy = (pos.y + (pos.y < 0 ? 1 : 0)) / ChunkDataSettings.YSize - (pos.y < 0 ? 1 : 0); var cz = (pos.z + (pos.z < 0 ? 1 : 0)) / ChunkDataSettings.ZSize - (pos.z < 0 ? 1 : 0); var chunk = _chunks[cx, cy, cz] ?? _chunks.Init(cx, cy, cz, new FluidUpdater()); chunk.SetVoxel(mat, height, pos); }
public void SetVoxel(LoadedVoxelMaterial mat, ushort height, Vector3Int pos) { if (mat.Id == 0 || height == 0) { _fluids.Remove(new Vector3Int(pos.x, pos.y, pos.z)); } else { _fluids[pos.x, pos.y, pos.z] = new Fluid(mat, height); } }
public void Init(MaterialCollection collection) { _fill = collection.GetMaterial(FillMaterial); _fluid = collection.GetMaterial(Fluid); var layers = new List <LoadedVoxelMaterial>(); foreach (var layerConfig in Layers) { for (var i = 0; i < layerConfig.Count; i++) { layers.Add(collection.GetMaterial(layerConfig.Material)); } } _layers = layers.ToArray(); }
public void SetVoxel(LoadedVoxelMaterial mat, Vector3Int pos, ushort height = 8) { if (mat.Fluid) { if (height == 0) { FluidChunks.SetVoxel(_materialCollection.GetById(0), pos); FluidUpdater.SetVoxel(mat, height, pos); } else { FluidChunks.SetVoxel(mat, pos, height); FluidUpdater.SetVoxel(mat, height, pos); } } else { SolidChunks.SetVoxel(mat, pos); } }
public void SetVoxel(LoadedVoxelMaterial material, Vector3Int pos, ushort height) { SetVoxel(material.Id, pos, height); }
public void SetVoxel(LoadedVoxelMaterial material, Vector3Int pos) { SetVoxel(material.Id, pos); }
private static bool IsTransparent(int x, int y, int z, IVoxelContainer container, MaterialCollection matCol, LoadedVoxelMaterial mat, ushort height) { if (container == null) { return(true); } var id = container.GetVoxelData(new Vector3Int(x, y, z)); var myHeight = (ushort)(8 - (ushort)(id >> 13)); id = (ushort)((ushort)(id << 3) >> 3); if (height != myHeight) { return(true); } if (id == mat.Id) { return(false); } return(id == 0 || matCol.GetById(id).Transparent); }
private static bool IsTransparent(int x, int y, int z, IVoxelContainer container, MaterialCollection matCol, LoadedVoxelMaterial mat, int?slice = null) { if (container == null) { return(true); } if (slice != null && slice <= y) { return(true); } var id = container.GetVoxelData(new Vector3Int(x, y, z)); if (id == mat.Id) { return(false); } return(id == 0 || matCol.GetById(id).Transparent); }
public Fluid(LoadedVoxelMaterial mat, ushort height) { Mat = mat; Height = height; }
private static Task BuildRect(World world, Cuboid c, BiomeConfiguration configuration = null, LoadedVoxelMaterial mat = null) { return(Task.Run(() => { for (var x = c.Pos.x; x < c.Pos.x + c.Size.x; x++) { for (var z = c.Pos.z; z < c.Pos.z + c.Size.z; z++) { var i = 0; for (var y = c.Pos.y + c.Size.y - 1; y >= c.Pos.y; y--) { if (configuration != null) { mat = configuration.GetLayer(i); } world.SetVoxel(mat, new Vector3Int(x, y, z)); i++; } } } })); }