void RegisterConfig(string MarkerName, int[] NeighborConfig, bool StopOnFound) { { var Config = new CellSpatialConfig3D(); Config.MarkerName = MarkerName; Config.NeighborConfig = NeighborConfig; Config.RotationOffsetZ = 0; Config.StopOnFound = StopOnFound; CornerConfigs.Add(Config); } var RotatedMap = NeighborConfig; // rotate 3 times by 90 degrees to get all 4 config rotated around 360 degrees for (int i = 1; i < 4; i++) { RotatedMap = Rotate90(RotatedMap); var Config = new CellSpatialConfig3D(); Config.MarkerName = MarkerName; Config.NeighborConfig = RotatedMap; Config.RotationOffsetZ = i * 90; Config.StopOnFound = StopOnFound; CornerConfigs.Add(Config); } }
bool ConfigMatches(GridDungeonModel Model, IntVector Point, CellSpatialConfig3D Config) { var centerCellInfo = Model.GetGridCellLookup(Point.x, Point.z); var neighbors = Config.NeighborConfig; for (int i = 0; i < neighbors.Length; i++) { int code = neighbors[i]; if (code == 0) { // Don't care about this cell continue; } int dx = i % 3; int dz = i / 3; dx--; dz--; // bring to -1..1 range (from previous 0..2) //dy *= -1; int x = Point.x + dx; int z = Point.z + dz; var cellInfo = Model.GetGridCellLookup(x, z); bool empty = cellInfo.CellType == CellType.Unknown; if (!centerCellInfo.ContainsDoor) { empty |= IsRoomCorridor(centerCellInfo.CellType, cellInfo.CellType); } if (!empty && centerCellInfo.CellType == CellType.Room && cellInfo.CellType == CellType.Room && centerCellInfo.CellId != cellInfo.CellId) { if (!mergeRoomCorridor) { empty = true; } } if (!empty) { var cell0 = Model.GetCell(cellInfo.CellId); var cell1 = Model.GetCell(centerCellInfo.CellId); if (cell0.Bounds.Location.y != cell1.Bounds.Location.y) { empty = true; } } if (code == 1 && empty) { // We were expecting a non-empty space here, but it is empty return(false); } else if (code == 2 && !empty) { // We were expecting a empty space here, but it is not empty return(false); } } // Matches, all tests have passed return(true); }