public ArmorCube(ArmorCube cube, Vector3I newPos) { BlockSkin = cube.BlockSkin; Large = cube.Large; type = cube.type; typeS = cube.typeS; color = cube.color; colorS = cube.colorS; BlockPosition = newPos; }
public ArmorCube(ArmorCube cube) { BlockSkin = cube.BlockSkin; Large = cube.Large; type = cube.type; typeS = cube.typeS; color = cube.color; colorS = cube.colorS; pos = cube.pos; posS = cube.posS; }
private bool CheckSlopes(Vector3I gridPos, float c, bool hollow, bool slopes, BitArray grid, out ArmorCube cube, Mesh m) { cube = null; bool xSafe = gridPos.x < grid.Length(0) - 1; bool ySafe = gridPos.y < grid.Length(1) - 1; bool zSafe = gridPos.z < grid.Length(2) - 1; bool b11 = grid [gridPos.x, gridPos.y, gridPos.z]; bool b21 = false; if (ySafe) { b21 = grid [gridPos.x, gridPos.y + 1, gridPos.z]; } bool b31 = false; if (xSafe) { b31 = grid [gridPos.x + 1, gridPos.y, gridPos.z]; } bool b41 = false; if (xSafe && ySafe) { b41 = grid [gridPos.x + 1, gridPos.y + 1, gridPos.z]; } bool b12 = false; if (zSafe) { b12 = grid [gridPos.x, gridPos.y, gridPos.z + 1]; } bool b22 = false; if (ySafe && zSafe) { b22 = grid [gridPos.x, gridPos.y + 1, gridPos.z + 1]; } bool b32 = false; if (xSafe && zSafe) { b32 = grid [gridPos.x + 1, gridPos.y, gridPos.z + 1]; } bool b42 = false; if (xSafe && ySafe && zSafe) { b42 = grid [gridPos.x + 1, gridPos.y + 1, gridPos.z + 1]; } byte count = 0; if (b11) { count++; } if (b21) { count++; } if (b31) { count++; } if (b41) { count++; } if (b12) { count++; } if (b22) { count++; } if (b32) { count++; } if (b42) { count++; } if (count > 0) { if (count == 8 && hollow) { return(false); } } else { Vector3 realPos = (gridPos * c) + m.Bounds.min; if (!lessAccuracy && !m.IntersectsBox(new BoundingBox(realPos, realPos + c))) { return(false); } count = 8; } cube = new ArmorCube(this.cube, gridPos); if (slopes) { if (count == 1) { cube.BlockType = ArmorCube.Type.Corner; if (b11) { cube.BlockForward = ArmorCube.Direction.Left; //cube.BlockUp = ArmorCube.Direction.Up; } else if (b21) { //cube.BlockForward = ArmorCube.Direction.Forward; cube.BlockUp = ArmorCube.Direction.Down; } else if (b31) { //cube.BlockForward = ArmorCube.Direction.Forward; //cube.BlockUp = ArmorCube.Direction.Up; } else if (b41) { cube.BlockForward = ArmorCube.Direction.Right; cube.BlockUp = ArmorCube.Direction.Down; } else if (b12) { cube.BlockForward = ArmorCube.Direction.Backward; //cube.BlockUp = ArmorCube.Direction.Up; } else if (b22) { cube.BlockForward = ArmorCube.Direction.Left; cube.BlockUp = ArmorCube.Direction.Down; } else if (b32) { cube.BlockForward = ArmorCube.Direction.Right; //cube.BlockUp = ArmorCube.Direction.Up; } else { cube.BlockForward = ArmorCube.Direction.Backward; cube.BlockUp = ArmorCube.Direction.Down; } } else if (count == 2) { cube.BlockType = ArmorCube.Type.Slope; if (b11 && b21) { //cube.BlockForward = ArmorCube.Direction.Forward; cube.BlockUp = ArmorCube.Direction.Right; } else if (b21 && b41) { //cube.BlockForward = ArmorCube.Direction.Forward; cube.BlockUp = ArmorCube.Direction.Down; } else if (b41 && b31) { //cube.BlockForward = ArmorCube.Direction.Forward; cube.BlockUp = ArmorCube.Direction.Left; } else if (b31 && b11) { //cube.BlockForward = ArmorCube.Direction.Forward; //cube.BlockUp = ArmorCube.Direction.Up; } else if (b12 && b22) { cube.BlockForward = ArmorCube.Direction.Backward; cube.BlockUp = ArmorCube.Direction.Right; } else if (b22 && b42) { cube.BlockForward = ArmorCube.Direction.Backward; cube.BlockUp = ArmorCube.Direction.Down; } else if (b42 && b32) { cube.BlockForward = ArmorCube.Direction.Backward; cube.BlockUp = ArmorCube.Direction.Left; } else if (b32 && b12) { cube.BlockForward = ArmorCube.Direction.Backward; //cube.BlockUp = ArmorCube.Direction.Up; } else if (b11 && b12) { cube.BlockForward = ArmorCube.Direction.Down; cube.BlockUp = ArmorCube.Direction.Right; } else if (b21 && b22) { cube.BlockForward = ArmorCube.Direction.Left; cube.BlockUp = ArmorCube.Direction.Down; } else if (b31 && b32) { cube.BlockForward = ArmorCube.Direction.Right; //cube.BlockUp = ArmorCube.Direction.Up; } else if (b41 && b42) { cube.BlockForward = ArmorCube.Direction.Up; cube.BlockUp = ArmorCube.Direction.Left; } else { cube.BlockType = ArmorCube.Type.Block; } } else if (count == 3) { cube.BlockType = ArmorCube.Type.InvCorner; if (b21 && b22 && (b11 || b41)) { cube.BlockForward = ArmorCube.Direction.Right; //cube.BlockUp = ArmorCube.Direction.Up; } else if (b41 && b42 && (b31 || b21)) { cube.BlockForward = ArmorCube.Direction.Backward; //cube.BlockUp = ArmorCube.Direction.Up; } else if (b31 && b32 && (b41 || b11)) { cube.BlockForward = ArmorCube.Direction.Left; cube.BlockUp = ArmorCube.Direction.Down; } else if (b11 && b12 && (b31 || b21)) { cube.BlockForward = ArmorCube.Direction.Backward; cube.BlockUp = ArmorCube.Direction.Down; } else if (b22 && b21 && (b12 || b42)) { //cube.BlockForward = ArmorCube.Direction.Forward; //cube.BlockUp = ArmorCube.Direction.Up; } else if (b42 && b41 && (b22 || b32)) { cube.BlockForward = ArmorCube.Direction.Left; //cube.BlockUp = ArmorCube.Direction.Up; } else if (b32 && b31 && (b42 || b12)) { //cube.BlockForward = ArmorCube.Direction.Forward; cube.BlockUp = ArmorCube.Direction.Down; } else if (b12 && b11 && (b32 || b22)) { cube.BlockForward = ArmorCube.Direction.Right; cube.BlockUp = ArmorCube.Direction.Down; } else { cube.BlockType = ArmorCube.Type.Block; } } else if (count == 4) { cube.BlockType = ArmorCube.Type.InvCorner; if (b11 && b21 && b41 && b22) { cube.BlockForward = ArmorCube.Direction.Right; //cube.BlockUp = ArmorCube.Direction.Up; } else if (b21 && b41 && b31 && b42) { cube.BlockForward = ArmorCube.Direction.Backward; //cube.BlockUp = ArmorCube.Direction.Up; } else if (b41 && b31 && b11 && b32) { cube.BlockForward = ArmorCube.Direction.Left; cube.BlockUp = ArmorCube.Direction.Down; } else if (b31 && b11 && b21 && b12) { cube.BlockForward = ArmorCube.Direction.Backward; cube.BlockUp = ArmorCube.Direction.Down; } else if (b12 && b22 && b42 && b21) { //cube.BlockForward = ArmorCube.Direction.Forward; //cube.BlockUp = ArmorCube.Direction.Up; } else if (b22 && b42 && b32 && b41) { cube.BlockForward = ArmorCube.Direction.Left; //cube.BlockUp = ArmorCube.Direction.Up; } else if (b42 && b32 && b12 && b31) { //cube.BlockForward = ArmorCube.Direction.Forward; cube.BlockUp = ArmorCube.Direction.Down; } else if (b32 && b12 && b22 && b11) { cube.BlockForward = ArmorCube.Direction.Right; cube.BlockUp = ArmorCube.Direction.Down; } else { cube.BlockType = ArmorCube.Type.Block; } } } return(true); }