コード例 #1
0
        public PawnPath findPath(Map map, IntVec3 start, LocalTargetInfo dest, TraverseParms traverseParms, PathEndMode peMode, ByteGrid avoidGrid, Area allowedArea,
                                 int costsCardinal, int costsDiagonal)
        {
            this.map                 = map;
            this.cellIndices         = this.map.cellIndices;
            this.edificeGrid         = map.edificeGrid;
            this.traverseParms       = traverseParms;
            this.dest                = dest;
            this.peMode              = peMode;
            this.costPerMoveCardinal = costsCardinal;
            this.costPerMoveDiagonal = costsDiagonal;
            this.avoidGrid           = avoidGrid;
            this.allowedArea         = allowedArea;
            this.pathGridArray       = map.pathGrid.pathGrid;
            this.pathGrid            = map.pathGrid;
            this.topGrid             = map.terrainGrid.topGrid;
            this.pawn                = traverseParms.pawn;
            this.drafted             = pawn != null && pawn.Drafted;
            this.blueprintGrid       = map.blueprintGrid.InnerArray;

            //Only colonists and tamed animals should respect restrictions.
            //Drafted pawns move unrestricted.
            //Some job types like firefighting should exclude the restrictions.
            List <string> exceptions = QOLMod.getSettings().pfRestrictionExcemptions;

            if (this.pawn.Faction != null && this.pawn.Faction.IsPlayer && !this.pawn.Drafted && (exceptions == null || pawn.jobs.curJob == null || !exceptions.Contains(pawn.jobs.curJob.def.defName)))
            {
                this.pathfinderDirections = map.GetComponent <MapComponent_PathfinderDirections>();
            }
            else
            {
                this.pathfinderDirections = null;
            }
            this.drawPath          = DebugViewSettings.drawPaths;
            this.mapSizeX          = map.Size.x;
            this.mapSizeZ          = map.Size.z;
            this.dontPassWater     = traverseParms.mode == TraverseMode.NoPassClosedDoorsOrWater || traverseParms.mode == TraverseMode.PassAllDestroyableThingsNotWater;
            this.collidesWithPawns = pawn != null && PawnUtility.ShouldCollideWithPawns(pawn);

            Step step = astar(start);

            if (step == null)
            {
                return(PawnPath.NotFound);
            }

            PawnPath emptyPawnPath = map.pawnPathPool.GetEmptyPawnPath();
            int      costs         = step.costToReachThis;

            while (step != null)
            {
                emptyPawnPath.AddNode(step.current);
                step = step.predecessor;
            }
            emptyPawnPath.SetupFound((float)costs, false);
            return(emptyPawnPath);
        }
コード例 #2
0
        public override void DesignateSingleCell(IntVec3 c)
        {
            MapComponent_PathfinderDirections grid = base.Map.GetComponent <MapComponent_PathfinderDirections>();

            if (grid == null)
            {
                grid = new MapComponent_PathfinderDirections(base.Map);
                base.Map.components.Add(grid);
            }
            grid.SetDirections(c, Window_SelectPathfinderFillDirections.selection);
        }
コード例 #3
0
        public override void DesignateSingleCell(IntVec3 c)
        {
            MapComponent_PathfinderDirections grid = base.Map.GetComponent <MapComponent_PathfinderDirections>();

            if (grid == null)
            {
                grid = new MapComponent_PathfinderDirections(base.Map);
                base.Map.components.Add(grid);
            }
            grid.ToggleDirections(c, directions, false);
        }
コード例 #4
0
        public override void SelectedUpdate()
        {
            GenUI.RenderMouseoverBracket();
            MapComponent_PathfinderDirections grid = base.Map.GetComponent <MapComponent_PathfinderDirections>();

            if (grid == null)
            {
                grid = new MapComponent_PathfinderDirections(base.Map);
                base.Map.components.Add(grid);
            }
            grid.MarkForDraw();
        }
コード例 #5
0
        public override void SelectedUpdate()
        {
            GenUI.RenderMouseoverBracket();
            //if ( Find.WindowStack.WindowOfType<Window_SelectPathfinderFillDirections>() == null ) {
            MapComponent_PathfinderDirections grid = base.Map.GetComponent <MapComponent_PathfinderDirections>();

            if (grid == null)
            {
                grid = new MapComponent_PathfinderDirections(base.Map);
                base.Map.components.Add(grid);
            }
            grid.MarkForDraw();
            //}
        }