Example #1
0
        public bool SetSquareUnWalkableIfMaintainsConnectivity(Point p)
        {
            if (p.x < 0 || p.y < 0 || p.x >= thisMap.Width || p.y >= thisMap.Height)
            {
                throw new ApplicationException("Point off template.");
            }

            var oldTerrain = thisMap.getCell(p);

            thisMap.setCell(p, PathingTerrain.Unwalkable);

            var isConnected = IsConnected();

            if (!isConnected)
            {
                thisMap.setCell(p, oldTerrain);
            }

            return(isConnected);
        }
Example #2
0
        public bool SetSquareUnwalkableIfDoorPathingIsPreserved(Point p)
        {
            if (p.x < 0 || p.y < 0 || p.x >= template.Width || p.y >= template.Height)
            {
                return(false);
            }

            //Set square unwalkable to test
            var originalTerrain = pathingMap.getCell(p.x, p.y);

            pathFinding.updateMap(0, p, PathingTerrain.Unwalkable);

            //Check all doors are pathable to each other
            bool pathable = true;

            var doors = template.PotentialDoors;

            for (int i = 0; i < doors.Count; i++)
            {
                for (int j = 0; j < doors.Count; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }

                    if (!pathFinding.arePointsConnected(0, doors[i].Location, doors[j].Location, Pathing.PathingPermission.Normal))
                    {
                        pathable = false;
                        break;
                    }
                }
            }

            if (!pathable)
            {
                pathFinding.updateMap(0, p, originalTerrain);
                return(false);
            }
            return(true);
        }