public BuildVoxelTask(Voxel voxel, VoxelType type) { Name = "Put voxel of type: " + type.Name + " on voxel " + voxel.Position; Voxel = voxel; VoxType = type; Priority = PriorityType.Low; }
public void ModifyVoxel(VoxelCoord vc, VoxelType newtype) { VoxelType oldtype = Global.VoxelsData[vc]; Global.VoxelsData[vc] = newtype; ChunksTree.BuildAndUpdateChunk(vc); }
/// <summary> /// Inserts a new voxel and updates the instance buffers. /// </summary> public void InsertSeed(int x, int y, int z, VoxelType type, Direction from = Direction.DOWN) { Int32 pos = _map.EncodePosition(x, y, z); VoxelType old = _map.Get(pos); InsertVoxel(pos, type, 0, true, 0, 0, from); // Immediate upload (assuming ~1 seed per frame) Upload(); }
public Voxel(VoxelWorldChunk parentChunk, VoxelType type, IntVec3 pos, BoxCollider collider) { ParentChunk = parentChunk; Collider = collider; SetType(type); Exposed = false; Position = pos; ExposedSides = VoxelSide.All; }
public void SetVoxel(int x, int y, int z, bool active, short destructable, VoxelType type, Color top, Color side) { if (x < 0 || y < 0 || z < 0 || x >= X_SIZE || y >= Y_SIZE || z >= Z_SIZE) return; Chunk c = GetChunkAtWorldPosition(x, y, z); c.SetVoxel(x - ((x / Chunk.X_SIZE) * Chunk.X_SIZE), y - ((y / Chunk.Y_SIZE) * Chunk.Y_SIZE), z - ((z / Chunk.Z_SIZE) * Chunk.Z_SIZE), active, destructable, type, top, side); c.Updated = true; }
public Voxel(bool active, VoxelType type, byte tr, byte tg, byte tb, byte sr,byte sg,byte sb, byte destruct) { Active = active; Type = type; TR = tr; TG = tg; TB = tb; SR = sr; SG = sg; SB = sb; Destructable = destruct; }
public VoxelTypeDefinition(VoxelType type, int maxHealth, bool isSolid, bool isVisible, bool isBreakable) { Type = type; MaxHealth = maxHealth; IsSolid = isSolid; IsVisible = isVisible; IsBreakable = isBreakable; UVTopX = 0; UVTopY = 0; UVSideX = 0; UVSideY = 0; UVBottomX = 0; UVBottomY = 0; UVSet = new VoxelUVSet(); }
Color TypeToColor(VoxelType type) { switch (type) { case VoxelType.Empty: return Color.clear; case VoxelType.Red: return Color.red; case VoxelType.Green: return Color.green; case VoxelType.Blue: return Color.blue; case VoxelType.Cyan: return Color.cyan; case VoxelType.Yellow: return Color.yellow; case VoxelType.Magenta: return Color.magenta; case VoxelType.Black: return Color.black; case VoxelType.Grey: return Color.grey; case VoxelType.White: return Color.white; } throw new System.Exception("Invalid code path."); }
public void SetVoxel(int x, int y, int z, bool active, VoxelType type, Color col) { if (x < 0 || y < 0 || z < 0 || x >= X_SIZE || y >= Y_SIZE || z >= Z_SIZE) { return; } Color top = col; Color side = new Color(col.ToVector3() * 0.75f); Voxels[x, y, z].Active = active; Voxels[x, y, z].Type = type; Voxels[x, y, z].TR = top.R; Voxels[x, y, z].TG = top.G; Voxels[x, y, z].TB = top.B; Voxels[x, y, z].SR = side.R; Voxels[x, y, z].SG = side.G; Voxels[x, y, z].SB = side.B; Updated = true; }
void Update() { if (Camera.main != null) { if (Input.GetButtonDown("Fire2")) { Ray CrosshairRay = new Ray(Camera.main.transform.position, Camera.main.transform.forward); AttackBlock(CrosshairRay); } else if (Input.GetButtonDown("Fire1")) { Ray CrosshairRay = new Ray(Camera.main.transform.position, Camera.main.transform.forward); PlaceBlock(CrosshairRay, CurrentBlock); } else if (Input.GetButtonDown("Fire3")) { if (CurrentBlock == VoxelType.Weak) { CurrentBlock = VoxelType.Strong; } else { CurrentBlock = VoxelType.Weak; } } } if (EnergyLastFrame != Energy && Energy == 0) { PlayEnergyEmpty(); } if (EnergyLastFrame != Energy && Energy == EnergyCap - 1) { PlayEnergyFull(); } EnergyLastFrame = Energy; GainEnergy(); }
void PlaceBlock(Ray ray, VoxelType type) { RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo, ReachDistance, ReachMask)) { if (hitInfo.collider is BoxCollider) { Voxel voxel = VoxelWorld.Inst.GetVoxelFromCollider(hitInfo.collider as BoxCollider); if (voxel != null) { float threshold = 0.1f; IntVec3 offset = new IntVec3(0, 0, 0); if (hitInfo.normal.y > threshold) offset.Y = 1; else if (hitInfo.normal.x > threshold) offset.X = 1; else if (hitInfo.normal.z > threshold) offset.Z = 1; else if (hitInfo.normal.y < -threshold) offset.Y = -1; else if (hitInfo.normal.x < -threshold) offset.X = -1; else if (hitInfo.normal.z < -threshold) offset.Z = -1; IntVec3 placePos = voxel.Position.Offset(offset); if (VoxelWorld.Inst.IsVoxelWorldIndexValid(placePos.X, placePos.Y, placePos.Z)) { Voxel placeVoxel = VoxelWorld.Inst.GetVoxel(placePos); if (placeVoxel.TypeDef.Type == VoxelType.Air) { placeVoxel.SetType(type); VoxelWorld.Inst.Refresh(); } } } } } }
public void DrawGhost(Camera camera, GraphicsDevice graphicsDevice, VoxelType voxel, Int32 levelPositionCode) { _voxelEffect.Parameters["ViewProjection"].SetValue(camera.ViewMatrix * camera.ProjectionMatrix); _voxelEffect.Parameters["VoxelTexture"].SetResource(_voxelTypeRenderingData[GetRenderingDataIndex(voxel)].Texture); _voxelEffect.Parameters["Transparency"].SetValue(0.7f); _voxelEffect.Parameters["Ambient"].SetValue(2.0f); _voxelEffect.Parameters["ScalingFactor"].SetValue(TypeInformation.GetScalingFactor(voxel) * 0.5f); _singleInstanceBuffer.SetDynamicData(graphicsDevice, (ptr) => System.Runtime.InteropServices.Marshal.Copy( new Int32[] { levelPositionCode }, 0, ptr, 1)); graphicsDevice.SetRasterizerState(_noneCullingState); graphicsDevice.SetDepthStencilState(_depthStencilStateState); graphicsDevice.SetBlendState(_blendStateTransparent); // Setup the vertices graphicsDevice.SetVertexBuffer(0, _cubeVertexBuffer); graphicsDevice.SetVertexBuffer(1, _singleInstanceBuffer); graphicsDevice.SetVertexInputLayout(_vertexInputLayout); _voxelEffect.CurrentTechnique.Passes[0].Apply(); graphicsDevice.DrawInstanced(PrimitiveType.TriangleList, _cubeVertexBuffer.ElementCount, 1, 0, 0); }
/// <summary> /// Add to map and to living list. Does nothing if tries to set outside. /// </summary> private void InsertVoxel(Int32 positionCode, VoxelType type, int generation, bool living, int resources, int ticks, Direction from) { var pos = _map.DecodePosition(positionCode); if (_map.IsInside(pos.X, pos.Y, pos.Z)) { if (_map.Get(positionCode) != VoxelType.EMPTY) { RemoveVoxel(positionCode); } _map.Set(positionCode, type, living); if (type != VoxelType.EMPTY) { // Insert to instance data only if visible if (!_map.IsOccluded(positionCode)) { _insertionList.Add(new Voxel(positionCode, type)); } RemoveOccludedNeighbours(positionCode); } if (living) { Debug.Assert(!_livingVoxels.ContainsKey(positionCode)); _livingVoxels.Add(positionCode, new LivingVoxel(pos.X, pos.Y, pos.Z, generation, resources, ticks, from)); if (TypeInformation.IsBiomass(type)) { ++_numLivingBiomass; } else if (TypeInformation.IsParasite(type)) { ++_numLivingParasites; } } } }
public static int GetGrowingSteps(VoxelType voxeltype) { return(growingSteps[(int)voxeltype]); }
public static bool CanFungusGrowOn(VoxelType voxeltype) { return(IsBiomass(voxeltype) || voxeltype == VoxelType.GROUND || voxeltype == VoxelType.ROCK); }
public static bool IsBiomass(VoxelType voxeltype) { return(biomass[(int)voxeltype]); }
public static int GetMaxNumberOfVoxels(VoxelType voxeltype) { return(maxNumberOfVoxels[(int)voxeltype]); }
private void ChangeVoxel(Voxel block, VoxelType desiredType) { if (block.type == VoxelType.Indestructable) { return; } if (block.type == desiredType) { return; } block.type = desiredType; var blocks = GetNeighbourBlocks(block.coordinate); blocks.Add(block); UpdateAsync(blocks); }
public void SetVoxel(int x, int y, int z, bool active, short destructable, VoxelType type, Color top, Color side) { if (x < 0 || y < 0 || z < 0 || x >= X_SIZE || y >= Y_SIZE || z >= Z_SIZE) return; Voxels[x, y, z].Active = active; Voxels[x, y, z].Type = type; Voxels[x, y, z].Destructable = destructable; Voxels[x, y, z].TR = top.R; Voxels[x, y, z].TG = top.G; Voxels[x, y, z].TB = top.B; Voxels[x, y, z].SR = side.R; Voxels[x, y, z].SG = side.G; Voxels[x, y, z].SB = side.B; //= new Voxel(active, type, top, side); Updated = true; }
public void SetVoxel(int x, int y, int z, bool active, VoxelType type, Color col) { if (x < 0 || y < 0 || z < 0 || x >= X_SIZE || y >= Y_SIZE || z >= Z_SIZE) return; Color top = col; Color side = new Color(col.ToVector3() * 0.75f); Voxels[x, y, z].Active = active; Voxels[x, y, z].Type = type; Voxels[x, y, z].TR = top.R; Voxels[x, y, z].TG = top.G; Voxels[x, y, z].TB = top.B; Voxels[x, y, z].SR = side.R; Voxels[x, y, z].SG = side.G; Voxels[x, y, z].SB = side.B; Updated = true; }
public static String GetName(VoxelType voxeltype) { return(name[(int)voxeltype]); }
private void ModifyMarkedVoxels(VoxelType desiredType) { ChangeVoxels(voxelsToModify.ToList(), desiredType); voxelsToModify.Clear(); markers.ForEach(m => Destroy(m)); markers.Clear(); }
private Vector2 GetTileCoordsFromVoxelType(VoxelType voxelType) { switch (voxelType) { case VoxelType.Indestructable: return indestructableTile; case VoxelType.Dirt: return dirtTile; case VoxelType.Grass: return grassTile; case VoxelType.Stone: return stoneTile; case VoxelType.Empty: throw new Exception("Chunk: Cannot get coordinates for an empty tile!"); default: throw new Exception("Chunk: Undefined blocktype"); } }
private void AddVoxelsToModify(Vector3 position, int range, VoxelType desiredType) { Voxel centralVoxel; if (TryGetVoxelAt(position, out centralVoxel)) { AddVoxelToModify(centralVoxel, desiredType); var neighbours = GetNeighbourVoxelsAtRange(position.ToCoordinate(), range); neighbours.ForEach(v => AddVoxelToModify(v, desiredType)); } }
private void AddVoxelToModify(Voxel voxel, VoxelType desiredType) { if (!voxel.IsDestructible || voxel.type == desiredType) { return; } voxelsToModify.Add(voxel); if (desiredType == VoxelType.Empty) { var marker = Instantiate(destroyMarker, voxel.coordinate.ToVector3(), Quaternion.identity) as GameObject; marker.transform.parent = markerParent; markers.Add(marker); } else { var marker = Instantiate(buildMarker, voxel.coordinate.ToVector3(), Quaternion.identity) as GameObject; marker.transform.parent = markerParent; markers.Add(marker); } }
private void ChangeVoxels(List<Voxel> voxels, VoxelType desiredType) { var voxelsToRebuild = new List<Voxel>(); foreach (var voxel in voxels) { if (voxel.type == VoxelType.Indestructable) { continue; } if (voxel.type == desiredType) { continue; } voxel.type = desiredType; voxelsToRebuild.Add(voxel); var neighbours = GetNeighbourBlocks(voxel.coordinate); neighbours.ForEach(b => voxelsToRebuild.Add(b)); } UpdateAsync(voxelsToRebuild); }
public static bool IsInsect(VoxelType voxeltype) { return((int)voxeltype >= (int)VoxelType.TERMITES && (int)voxeltype <= (int)VoxelType.GRASSHOPPER); }
private IEnumerator Process() { LoadProgress = 10; int pos = 0; var sw = new StreamReader(new MemoryStream(buffer)); string codename = sw.ReadLine(); Title = sw.ReadLine(); sw.Close(); int foundcount = 0; while (foundcount < 2) { pos++; if (buffer[pos - 1] == 13) { foundcount++; } } while (buffer[pos] == 13 || buffer[pos] == 10) { pos++; } int xs = buffer[pos + 2]; int ys = buffer[pos + 3]; int zs = buffer[pos + 4]; X_CHUNKS = xs; Z_CHUNKS = ys; Y_CHUNKS = zs; Init(); //gameWorld.DisplayName = dispname; //gameWorld.CodeName = codename; //gameWorld.Type = (MapType)buffer[pos]; Theme = (Theme)buffer[pos + 1]; int numSpawns = buffer[pos + 5]; pos += 6; for (int i = 0; i < numSpawns; i++) { //Spawn s = (Spawn)(Instantiate(SpawnPrefab, Vector3.zero, Quaternion.identity)); //s.transform.parent = transform; //s.transform.position = new Vector3(BitConverter.ToInt32(buffer, pos) * Voxel.SIZE, (Y_SIZE - BitConverter.ToInt32(buffer, pos + 8)) * Voxel.SIZE, (Z_SIZE - BitConverter.ToInt32(buffer, pos + 4)) * Voxel.SIZE); //s.Type = (SpawnType)buffer[pos + 12]; //s.transform.rotation = Quaternion.Euler(0f, (90 * buffer[pos + 13])+180 , 0f); //s.name = "Spawn - " + s.Type; //Spawns.Add(s); //s.Position = //s.Type = (SpawnType)buffer[pos + 12]; //s.Rotation = buffer[pos + 13]; //gameWorld.Spawns.Add(s); pos += 14; } LoadProgress = 20; for (int y = 0; y < Y_CHUNKS; y++) { for (int z = Z_CHUNKS - 1; z >= 0; z--) { for (int x = 0; x < X_CHUNKS; x++) { Chunk c = Chunks[x, y, z]; while (pos < buffer.Length) { if (Convert.ToChar(buffer[pos]) != 'c') { int vx = buffer[pos]; int vz = (Chunk.Z_SIZE - 1) - buffer[pos + 1]; int vy = (Chunk.Y_SIZE - 1) - buffer[pos + 2]; VoxelType type = (VoxelType)buffer[pos + 3]; byte destruct = buffer[pos + 4]; Color top = new Color(Helper.ByteToFloat(buffer[pos + 5]), Helper.ByteToFloat(buffer[pos + 6]), Helper.ByteToFloat(buffer[pos + 7])); Color side = new Color(Helper.ByteToFloat(buffer[pos + 8]), Helper.ByteToFloat(buffer[pos + 9]), Helper.ByteToFloat(buffer[pos + 10])); c.SetVoxel(vx, vy, vz, true, destruct, type, top, side); pos += 11; } else { pos++; break; } } AddToUpdateQueue(c); } } } LoadProgress = 30; //UpdateAllChunkMeshes(); //foreach (Chunk c in Chunks) GC.Collect(); return(null); }
public static bool IsNotWoodButBiomass(VoxelType voxeltype) { return(IsBiomass(voxeltype) && !IsWood(voxeltype)); }
void MakeQuad(Vector3 offset, Vector3 tl, Vector3 tr, Vector3 br, Vector3 bl, Color col, VoxelType type) { Vector2 uv2 = Vector2.zero; if (type == VoxelType.Water) { uv2 = new Vector2(UnityEngine.Random.Range(0.1f, 0.5f), 0); } PUCs.Add(new PositionUVColor(offset + tl, new Vector2(1f, 1f), uv2, col)); PUCs.Add(new PositionUVColor(offset + tr, new Vector2(0f, 1f), uv2, col)); PUCs.Add(new PositionUVColor(offset + br, new Vector2(0f, 0f), uv2, col)); PUCs.Add(new PositionUVColor(offset + bl, new Vector2(1f, 0f), uv2, col)); }
public static String[] GetWeakness(VoxelType voxeltype) { String[] result = { weakness[(int)voxeltype, 0], weakness[(int)voxeltype, 1] }; return(result); }
public VoxelTypeInstanceData(GraphicsDevice graphicsDevice, VoxelType voxel) { Voxel = voxel; InstanceBuffer = Buffer.Vertex.New <Int32>(graphicsDevice, TypeInformation.GetMaxNumberOfVoxels(voxel), SharpDX.Direct3D11.ResourceUsage.Dynamic); InstanceDataRAM = new HashSet <Int32>();// System.Runtime.InteropServices.Marshal.AllocHGlobal(sizeof(UInt32) * MAX_NUM_VOXELS_PER_TYPE); }
public void SetType(VoxelType type) { TypeDef = VoxelWorld.Inst.VoxelTypeDefs[type]; Health = TypeDef.MaxHealth; ParentChunk.MakeDirty(true); }
private static int GetRenderingDataIndex(VoxelType voxel) { return((int)voxel - 1); }
public static bool IsParasite(VoxelType voxeltype) { return(parasite[(int)voxeltype]); }
public void Set(Int32 positionCode, VoxelType type, bool living) { Int3 p; p = DecodePosition(positionCode); --_numVoxelsOfType[_voxels[positionCode] & 0x7f]; _voxels[positionCode] = (byte)((living ? 0x80 : 0) | (int)type); ++_numVoxelsOfType[(int)type]; }
public static IVoxelRule GetRule(VoxelType voxeltype) { return(rules[(int)voxeltype]); }
public int GetNumVoxels(VoxelType type) { return _numVoxelsOfType[(int)type]; }
public static float GetScalingFactor(VoxelType voxeltype) { return(scalingFactor[(int)voxeltype]); }
public Voxel(double density, VoxelType type, Vector3 normal) { Density = density; Type = type; Normal = normal; }
public static int GetGrowHeight(VoxelType voxeltype) { return(growHeight[(int)voxeltype]); }
public static void InitializeDefaultLibrary(GraphicsDevice graphics, Texture2D cubeTexture) { if (PrimitiveMap.Count > 0) return; BoxPrimitive grassCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(0, 0), new Point(2, 0), new Point(2, 0)); BoxPrimitive dirtCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(2, 0), new Point(2, 0), new Point(2, 0)); BoxPrimitive stoneCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(4, 2), new Point(1, 0), new Point(4, 2)); BoxPrimitive sandCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(1, 1), new Point(1, 1), new Point(1, 1)); BoxPrimitive ironCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(4, 1), new Point(1, 2), new Point(4, 1)); BoxPrimitive goldCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(3, 1), new Point(0, 2), new Point(3, 1)); BoxPrimitive coalCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(3, 2), new Point(2, 2), new Point(2, 2)); BoxPrimitive manaCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(7, 1), new Point(6, 1), new Point(7, 1)); BoxPrimitive frostCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(0, 1), new Point(2, 1), new Point(2, 0)); BoxPrimitive scaffoldCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(7, 0), new Point(7, 0), new Point(7, 0)); BoxPrimitive plankCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(4, 0), new Point(4, 0), new Point(4, 0)); BoxPrimitive waterCube = CreatePrimitive(graphics, cubeTexture, cubeTexture.Width, cubeTexture.Height, new Point(0, 0), new Point(0, 0), new Point(0, 0)); BoxPrimitive cobblestoneCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(5, 2), new Point(5, 2), new Point(5, 2)); BoxPrimitive magicCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(0, 10), new Point(0, 10), new Point(0, 10)); BoxPrimitive bedrockCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(6, 2), new Point(6, 2), new Point(6, 2)); BoxPrimitive brownTileCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(5, 0), new Point(5, 0), new Point(5, 0)); BoxPrimitive blueTileCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(6, 0), new Point(6, 0), new Point(6, 0)); BoxPrimitive tilledSoilCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(5, 1), new Point(2, 0), new Point(2, 0)); emptyType = new VoxelType { Name = "empty", ReleasesResource = false, IsBuildable = false }; VoxelType tilledSoil = new VoxelType { Name = "TilledSoil", ReleasesResource = false, StartingHealth = 20, CanRamp = true, IsBuildable = false, ParticleType = "dirt_particle", IsSoil = true }; RegisterType(tilledSoil, tilledSoilCube); VoxelType brownTileFloor = new VoxelType { Name = "BrownTileFloor", ReleasesResource = false, StartingHealth = 20, CanRamp = false, IsBuildable = false, ParticleType = "stone_particle" }; RegisterType(brownTileFloor, brownTileCube); VoxelType blueTileFloor = new VoxelType { Name = "BlueTileFloor", ReleasesResource = false, StartingHealth = 20, CanRamp = false, IsBuildable = false, ParticleType = "stone_particle" }; RegisterType(blueTileFloor, blueTileCube); VoxelType cobblestoneFloor = new VoxelType { Name = "CobblestoneFloor", ReleasesResource = false, StartingHealth = 20, CanRamp = false, IsBuildable = false, ParticleType = "stone_particle", HasTransitionTextures = true }; RegisterType(cobblestoneFloor, cobblestoneCube); CreateTransitionUVs(graphics, cubeTexture, 32, 32, new Point(0, 8), new Point(5, 2), new Point(5, 2), cobblestoneFloor.TransitionTextures); VoxelType stockpileType = new VoxelType { Name = "Stockpile", ReleasesResource = false, StartingHealth = 20, CanRamp = false, IsBuildable = false, ParticleType = "stone_particle", HasTransitionTextures = true }; RegisterType(stockpileType, plankCube); CreateTransitionUVs(graphics, cubeTexture, 32, 32, new Point(0, 9), new Point(4, 0), new Point(4, 0), stockpileType.TransitionTextures); VoxelType plankType = new VoxelType { Name = "Plank", ProbabilityOfRelease = 1.0f, ResourceToRelease = ResourceLibrary.ResourceType.Wood, StartingHealth = 20, ReleasesResource = true, CanRamp = true, RampSize = 0.5f, IsBuildable = true, ParticleType = "stone_particle", HasTransitionTextures = true }; CreateTransitionUVs(graphics, cubeTexture, 32, 32, new Point(0, 9), new Point(4, 0), new Point(4, 0), plankType.TransitionTextures); VoxelType magicType = new VoxelType { Name = "Magic", ProbabilityOfRelease = 0.0f, ResourceToRelease = ResourceLibrary.ResourceType.Mana, StartingHealth = 1, ReleasesResource = true, CanRamp = false, IsBuildable = false, ParticleType = "star_particle", ExplosionSound = ContentPaths.Audio.wurp, HasTransitionTextures = false, EmitsLight = true }; CreateTransitionUVs(graphics, cubeTexture, 32, 32, new Point(0, 10), new Point(15, 10), new Point(15, 10), magicType.TransitionTextures); VoxelType scaffoldType = new VoxelType { Name = "Scaffold", StartingHealth = 20, ProbabilityOfRelease = 1.0f, ResourceToRelease = ResourceLibrary.ResourceType.Wood, ReleasesResource = false, CanRamp = false, RampSize = 0.5f, IsBuildable = true, ParticleType = "stone_particle" }; VoxelType grassType = new VoxelType { Name = "Grass", ProbabilityOfRelease = 0.1f, ResourceToRelease = ResourceLibrary.ResourceType.Dirt, StartingHealth = 10, ReleasesResource = true, CanRamp = true, RampSize = 0.5f, IsBuildable = false, ParticleType = "dirt_particle", HasTransitionTextures = true, IsSoil = true }; CreateTransitionUVs(graphics, cubeTexture, 32, 32, new Point(0, 3), new Point(2, 0), new Point(2, 0), grassType.TransitionTextures); VoxelType frostType = new VoxelType { Name = "Frost", ProbabilityOfRelease = 0.1f, ResourceToRelease = ResourceLibrary.ResourceType.Dirt, StartingHealth = 10, ReleasesResource = true, CanRamp = true, RampSize = 0.5f, IsBuildable = false, ParticleType = "dirt_particle", HasTransitionTextures = true }; CreateTransitionUVs(graphics, cubeTexture, 32, 32, new Point(0, 4), new Point(2, 0), new Point(2, 0), frostType.TransitionTextures); VoxelType desertGrass = new VoxelType { Name = "DesertGrass", ProbabilityOfRelease = 0.1f, ResourceToRelease = ResourceLibrary.ResourceType.Sand, StartingHealth = 10, ReleasesResource = true, CanRamp = true, RampSize = 0.5f, IsBuildable = false, ParticleType = "sand_particle", HasTransitionTextures = true }; CreateTransitionUVs(graphics, cubeTexture, 32, 32, new Point(0, 6), new Point(1, 1), new Point(1, 1), desertGrass.TransitionTextures); VoxelType jungleGrass = new VoxelType { Name = "JungleGrass", ProbabilityOfRelease = 0.1f, ResourceToRelease = ResourceLibrary.ResourceType.Dirt, StartingHealth = 10, ReleasesResource = true, CanRamp = true, RampSize = 0.5f, IsBuildable = false, ParticleType = "dirt_particle", HasTransitionTextures = true }; CreateTransitionUVs(graphics, cubeTexture, 32, 32, new Point(0, 5), new Point(2, 0), new Point(2, 0), jungleGrass.TransitionTextures); VoxelType dirtType = new VoxelType { Name = "Dirt", ReleasesResource = true, ResourceToRelease = ResourceLibrary.ResourceType.Dirt, ProbabilityOfRelease = 0.3f, StartingHealth = 10, RampSize = 0.5f, CanRamp = true, IsBuildable = true, ParticleType = "dirt_particle", IsSoil = true }; VoxelType stoneType = new VoxelType { Name = "Stone", ProbabilityOfRelease = 0.5f, ReleasesResource = true, ResourceToRelease = ResourceLibrary.ResourceType.Stone, StartingHealth = 30, IsBuildable = true, ParticleType = "stone_particle" }; VoxelType bedrockType = new VoxelType { Name = "Bedrock", StartingHealth = 255, IsBuildable = false, IsInvincible = true }; VoxelType waterType = new VoxelType { Name = "water", ReleasesResource = false, IsBuildable = false, StartingHealth = 255 }; VoxelType sandType = new VoxelType { Name = "Sand", ReleasesResource = false, StartingHealth = 5, CanRamp = true, RampSize = 0.5f, IsBuildable = false, ParticleType = "sand_particle" }; VoxelType ironType = new VoxelType { Name = "Iron", ProbabilityOfRelease = 0.99f, ReleasesResource = true, ResourceToRelease = ResourceLibrary.ResourceType.Iron, StartingHealth = 80, IsBuildable = false, ParticleType = "stone_particle" }; ResourceSpawns["Iron"] = new ResourceSpawnRate { VeinSize = 0.2f, VeinSpawnThreshold = 0.9f, MinimumHeight = -100, MaximumHeight = 100, Probability = 0.5f }; VoxelType coalType = new VoxelType { Name = "Coal", ProbabilityOfRelease = 0.99f, ReleasesResource = true, ResourceToRelease = ResourceLibrary.ResourceType.Coal, StartingHealth = 75, IsBuildable = false, ParticleType = "stone_particle" }; ResourceSpawns["Coal"] = new ResourceSpawnRate { VeinSize = 0.085f, VeinSpawnThreshold = 0.9f, MinimumHeight = -100, MaximumHeight = 100, Probability = 0.5f }; VoxelType goldType = new VoxelType { Name = "Gold", ProbabilityOfRelease = 1.0f, ReleasesResource = true, ResourceToRelease = ResourceLibrary.ResourceType.Gold, StartingHealth = 90, IsBuildable = false, ParticleType = "stone_particle" }; ResourceSpawns["Gold"] = new ResourceSpawnRate { VeinSize = 0.07f, VeinSpawnThreshold = 0.8f, MinimumHeight = -150, MaximumHeight = 15, Probability = 0.6f }; VoxelType manaType = new VoxelType { Name = "Mana", ProbabilityOfRelease = 1.0f, ReleasesResource = true, ResourceToRelease = ResourceLibrary.ResourceType.Mana, StartingHealth = 200, IsBuildable = false, ParticleType = "stone_particle" }; ResourceSpawns["Mana"] = new ResourceSpawnRate { VeinSize = 0.05f, VeinSpawnThreshold = 0.85f, MinimumHeight = -800, MaximumHeight = 8, Probability = 0.5f }; RegisterType(grassType, grassCube); RegisterType(frostType, frostCube); RegisterType(desertGrass, grassCube); RegisterType(jungleGrass, grassCube); RegisterType(emptyType, null); RegisterType(dirtType, dirtCube); RegisterType(stoneType, stoneCube); RegisterType(waterType, waterCube); RegisterType(sandType, sandCube); RegisterType(ironType, ironCube); RegisterType(goldType, goldCube); RegisterType(manaType, manaCube); RegisterType(plankType, plankCube); RegisterType(scaffoldType, scaffoldCube); RegisterType(bedrockType, bedrockCube); RegisterType(coalType, coalCube); RegisterType(magicType, magicCube); foreach (VoxelType type in VoxelType.TypeList) { Types[type.Name] = type; } }
public static bool IsWood(VoxelType voxeltype) { return((int)voxeltype >= (int)VoxelType.TEAK_WOOD && (int)voxeltype <= (int)VoxelType.REDWOOD); }
public static void PlaceType(VoxelType type, Voxel voxel) { voxel.Type = type; voxel.Water = new WaterCell(); voxel.Health = voxel.Type.StartingHealth; }
public static bool IsGroundOrFungus(VoxelType voxeltype) { return(voxeltype == VoxelType.ROCK || voxeltype == VoxelType.GROUND || voxeltype == VoxelType.WHITEROT_FUNGUS || voxeltype == VoxelType.NOBLEROT_FUNGUS); }
void CreateVoxel(GridCoord coord, VoxelType type) { var voxel = gridGOs[coord.x, coord.y, coord.z]; if (voxel == null) { voxel = (GameObject)Instantiate(voxelGO, coord.WorldPosition, Quaternion.identity); gridGOs[coord.x, coord.y, coord.z] = voxel; } voxel.GetComponent<VoxelMaterialAdjuster>().SetType(type); if (type == VoxelType.Black) { var black = voxel.AddComponent<BlackVoxel>(); black.Initialize(this, coord); } }
public Voxel(Int32 pCode, VoxelType t) { PositionCode = pCode; Type = t; }
void AdjustFillCount(VoxelType from, VoxelType to) { if (from != to) { if (to == VoxelType.Empty) filledCount--; else if (from == VoxelType.Empty) filledCount++; } }
public static String[] GetStrength(VoxelType voxeltype) { String[] result = { strength[(int)voxeltype, 0], strength[(int)voxeltype, 1] }; return(result); }
// public VoxelTemplate(string name, bool isAir, VoxelType type) { this.name = name; this.isAir = isAir; this.type = type; }
public MapConfig() { PhysicalEnvironment = new PhysicalEnvironment(); GroundVoxelType = new VoxelType(); }
static Color GetTopColor(VoxelType type) { switch (type) { case VoxelType.Ground: return new Color(0f, 0.5f + ((float)Helper.Random.NextDouble() * 0.1f), 0f); case VoxelType.Tree: return new Color(0.4f + ((float)Helper.Random.NextDouble() * 0.1f), 0.1f + ((float)Helper.Random.NextDouble() * 0.05f), 0.05f); case VoxelType.Leaf: return new Color(0.2f, 0.8f + ((float)Helper.Random.NextDouble() * 0.1f), 0.2f); } return Color.White; }
public static BoxPrimitive GetPrimitive(VoxelType type) { if(PrimitiveMap.ContainsKey(type)) { return PrimitiveMap[type]; } else { return null; } }
/// <summary> /// Instantiate a voxel. /// </summary> /// <param name="x">X index of the voxel</param> /// <param name="y">Y index of the voxel</param> /// <param name="z">Z index of the voxel</param> /// /// <param name="type">The type of the voxel (Empty, Connection, Block) </param> public Voxel(int x, int y, int z, VoxelType type) { Index = new Vector3Int(x, y, z); Type = type; }
/// <summary> /// Instantiate a block voxel with walkable faces assigned /// </summary> /// <param name="x">X index of the voxel</param> /// <param name="y">Y index of the voxel</param> /// <param name="z">Z index of the voxel</param> /// <param name="type">The type of the voxel (Empty, Connection, Block) </param> /// <param name="parentPattern">Parrent Pattern of the connection</param> /// <param name="orientation">Orientation of the block</param> /// <param name="walkableFaces">The direction vectors between the center of the block and the climable faces eg. (1,0,0)</param> public Voxel(int x, int y, int z, VoxelType type, Vector3Int orientation, Pattern parentPattern, List <Vector3Int> walkableFaces) : this(x, y, z, type, orientation, parentPattern) { WalkableFaces = walkableFaces; }
public DigBlock(VoxelType VoxelType, Creature Miner) { this.VoxelType = VoxelType; this.Miner = Miner; }
public static int GetPrice(VoxelType voxeltype) { return(prices[(int)voxeltype]); }
public static void RegisterType(VoxelType type, BoxPrimitive primitive) { PrimitiveMap[type] = primitive; }
public void Set(GridCoord coord, VoxelType type) { var previousType = grid[coord.x, coord.y, coord.z]; AdjustFillCount(previousType, type); grid[coord.x, coord.y, coord.z] = type; CreateVoxel(coord, type); }