Beispiel #1
0
        protected override void _runAlgorithm(IAlgorithmContext context)
        {
            DungeonTiles workingDungeon = context.D.Tiles;
            ISet <Tile>  deadEnds       = new HashSet <Tile>();

            for (int i = 0; i < this.FillPasses; ++i)
            {
                for (int y = 0; y < workingDungeon.Height; ++y)
                {
                    for (int x = 0; x < workingDungeon.Width; ++x)
                    {
                        if (!context.Mask[y, x] || workingDungeon[y, x].Physics == Tile.MoveType.Wall)
                        {
                            continue;
                        }
                        bool physicsDeadEnd   = (workingDungeon[y, x].Physics.SidesOpened() == 1);
                        bool adjacentsdeadEnd = (workingDungeon.GetAdjacentOpensFor(x, y) == 1);
                        if (!physicsDeadEnd && !adjacentsdeadEnd)
                        {
                            continue;
                        }
                        workingDungeon[y, x].Physics = workingDungeon[y, x].Physics.CloseOff(Tile.MoveType.Open_HORIZ);
                    }
                }
                workingDungeon.Parent.CreateGroup(deadEnds);
            }
        }