private void AddCube(Coordinate4D cubeCoordinate) { if (!_activeCubes.ContainsKey(cubeCoordinate.Z)) { _activeCubes[cubeCoordinate.Z] = new Hashtable(); } var yDimensionHashtable = _activeCubes[cubeCoordinate.Z] as Hashtable; if (!yDimensionHashtable.ContainsKey(cubeCoordinate.Y)) { yDimensionHashtable[cubeCoordinate.Y] = new Hashtable(); } var xDimensionHashtable = yDimensionHashtable[cubeCoordinate.Y] as Hashtable; if (!xDimensionHashtable.ContainsKey(cubeCoordinate.X)) { xDimensionHashtable[cubeCoordinate.X] = new HashSet <Coordinate4D>(_coordinateComparer); } var wDimensionHashSet = xDimensionHashtable[cubeCoordinate.X] as HashSet <Coordinate4D>; wDimensionHashSet.Add(cubeCoordinate); }
public IEnumerable <Coordinate4D> GetNeighbours(Coordinate4D cube) { for (var z = cube.Z - 1; z <= cube.Z + 1; z++) { for (var y = cube.Y - 1; y <= cube.Y + 1; y++) { for (var x = cube.X - 1; x <= cube.X + 1; x++) { yield return(new Coordinate4D { Z = z, Y = y, X = x, W = cube.W - 1 }); yield return(new Coordinate4D { Z = z, Y = y, X = x, W = cube.W + 1 }); } } } for (var z = cube.Z - 1; z <= cube.Z + 1; z++) { for (var y = cube.Y - 1; y <= cube.Y + 1; y++) { yield return(new Coordinate4D { Z = z, Y = y, X = cube.X - 1, W = cube.W }); yield return(new Coordinate4D { Z = z, Y = y, X = cube.X + 1, W = cube.W }); } } for (var z = cube.Z - 1; z <= cube.Z + 1; z++) { yield return(new Coordinate4D { Z = z, Y = cube.Y - 1, X = cube.X, W = cube.W }); yield return(new Coordinate4D { Z = z, Y = cube.Y + 1, X = cube.X, W = cube.W }); } yield return(new Coordinate4D { Z = cube.Z - 1, Y = cube.Y, X = cube.X, W = cube.W }); yield return(new Coordinate4D { Z = cube.Z + 1, Y = cube.Y, X = cube.X, W = cube.W }); }
private void RemoveCube(Coordinate4D cubeCoordinate) { ((HashSet <Coordinate4D>)((Hashtable)((Hashtable)_activeCubes[cubeCoordinate.Z])?[cubeCoordinate.Y])?[cubeCoordinate.X])?.Remove(cubeCoordinate); }