internal Quadstate GetSelectedQuadstate(int x, int y, int z, TilePropagatorTileSet tiles) { GetBannedSelected(x, y, z, tiles, out var isBanned, out var isSelected); if (isSelected) { if (isBanned) { return(Quadstate.Contradiction); } else { return(Quadstate.Yes); } } else { if (isBanned) { return(Quadstate.No); } else { return(Quadstate.Maybe); } } }
/// <summary> /// isBanned is set to true if all the tiles are not valid in the location. /// isSelected is set to true if no other the tiles are valid in the location. /// </summary> public void GetBannedSelected(int x, int y, int z, TilePropagatorTileSet tiles, out bool isBanned, out bool isSelected) { TileCoordToPatternCoord(x, y, z, out var px, out var py, out var pz, out var o); var patterns = tileModelMapping.GetPatterns(tiles, o); GetBannedSelectedInternal(px, py, pz, patterns, out isBanned, out isSelected); }
/// <summary> /// Returns a tracker that runs a callback when the banned/selected status of tile changes with respect to a tileset. /// </summary> public SelectedChangeTracker CreateSelectedChangeTracker(TilePropagatorTileSet tileSet, IQuadstateChanged onChange) { var tracker = new SelectedChangeTracker(this, wavePropagator, tileModelMapping, tileSet, onChange); ((ITracker)tracker).Reset(); wavePropagator.AddTracker(tracker); return(tracker); }
/// <summary> /// Returns a tracker that tracks the banned/selected status of each tile with respect to a tileset. /// </summary> public SelectedTracker CreateSelectedTracker(TilePropagatorTileSet tileSet) { var tracker = new SelectedTracker(this, wavePropagator, tileModelMapping, tileSet); ((ITracker)tracker).Reset(); wavePropagator.AddTracker(tracker); return(tracker); }
internal SelectedChangeTracker CreateSelectedChangeTracker(TilePropagatorTileSet tileSet, ITristateChanged onChange) { var tracker = new SelectedChangeTracker(this, wavePropagator, tileModelMapping, tileSet, onChange); tracker.Reset(); wavePropagator.AddTracker(tracker); return(tracker); }
/// <summary> /// Marks the given tiles as not being a valid choice at a given location. /// Then it propagates that information to other nearby tiles. /// </summary> /// <returns>The current <see cref="Status"/></returns> public Resolution Ban(int x, int y, int z, TilePropagatorTileSet tiles) { TileCoordToPatternCoord(x, y, z, out var px, out var py, out var pz, out var o); var patterns = tileModelMapping.GetPatterns(tiles, o); foreach (var p in patterns) { var status = wavePropagator.Ban(px, py, pz, p); if (status != Resolution.Undecided) { return(status); } } return(Resolution.Undecided); }
/// <summary> /// Marks the given tiles as the only valid choice at a given location. /// This is equivalent to banning all other tiles. /// Then it propagates that information to other nearby tiles. /// </summary> /// <returns>The current <see cref="Status"/></returns> public Resolution Select(int x, int y, int z, TilePropagatorTileSet tiles) { TileCoordToPatternCoord(x, y, z, out var px, out var py, out var pz, out var o); var patterns = tileModelMapping.GetPatterns(tiles, o); for (var p = 0; p < wavePropagator.PatternCount; p++) { if (patterns.Contains(p)) { continue; } var status = wavePropagator.Ban(px, py, pz, p); if (status != Resolution.Undecided) { return(status); } } return(Resolution.Undecided); }
internal Tristate GetSelectedTristate(int x, int y, int z, TilePropagatorTileSet tiles) { GetBannedSelected(x, y, z, tiles, out var isBanned, out var isSelected); return(isSelected ? Tristate.Yes : isBanned?Tristate.No : Tristate.Maybe); }