示例#1
0
 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);
         }
     }
 }
示例#2
0
        /// <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);
        }
示例#3
0
        /// <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);
        }
示例#4
0
        /// <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);
        }
示例#5
0
        internal SelectedChangeTracker CreateSelectedChangeTracker(TilePropagatorTileSet tileSet, ITristateChanged onChange)
        {
            var tracker = new SelectedChangeTracker(this, wavePropagator, tileModelMapping, tileSet, onChange);

            tracker.Reset();
            wavePropagator.AddTracker(tracker);
            return(tracker);
        }
示例#6
0
        /// <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);
        }
示例#7
0
        /// <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);
        }
示例#8
0
 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);
 }