public static TargetInfo ResolvePathMode(Pawn pawn, TargetInfo dest, ref PathEndMode peMode) { TargetInfo result; if (dest.HasThing && !dest.Thing.Spawned) { peMode = PathEndMode.Touch; result = dest; } else if (peMode == PathEndMode.InteractionCell) { if (!dest.HasThing) { Log.Error("Pathed to cell " + dest + " with PathEndMode.InteractionCell.", false); } peMode = PathEndMode.OnCell; result = new TargetInfo(dest.Thing.InteractionCell, dest.Thing.Map, false); } else { if (peMode == PathEndMode.ClosestTouch) { peMode = GenPath.ResolveClosestTouchPathMode(pawn, dest.Map, dest.Cell); } result = dest; } return(result); }
public static PathEndMode ResolveClosestTouchPathMode(Pawn pawn, Map map, IntVec3 target) { if (GenPath.ShouldNotEnterCell(pawn, map, target)) { return(PathEndMode.Touch); } return(PathEndMode.OnCell); }
public void StartPath(LocalTargetInfo dest, PathEndMode peMode) { dest = (LocalTargetInfo)GenPath.ResolvePathMode(this.pawn, dest.ToTargetInfo(this.pawn.Map), ref peMode); if (dest.HasThing && dest.ThingDestroyed) { Log.Error(this.pawn + " pathing to destroyed thing " + dest.Thing, false); this.PatherFailed(); } else { if (!this.PawnCanOccupy(this.pawn.Position)) { if (!this.TryRecoverFromUnwalkablePosition(true)) { return; } } if (!this.moving || this.curPath == null || !(this.destination == dest) || this.peMode != peMode) { if (!this.pawn.Map.reachability.CanReach(this.pawn.Position, dest, peMode, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false))) { this.PatherFailed(); } else { this.peMode = peMode; this.destination = dest; if (!this.IsNextCellWalkable()) { this.nextCell = this.pawn.Position; } if (!this.destination.HasThing && this.pawn.Map.pawnDestinationReservationManager.MostRecentReservationFor(this.pawn) != this.destination.Cell) { this.pawn.Map.pawnDestinationReservationManager.ObsoleteAllClaimedBy(this.pawn); } if (this.AtDestinationPosition()) { this.PatherArrived(); } else if (this.pawn.Downed) { Log.Error(this.pawn.LabelCap + " tried to path while downed. This should never happen. curJob=" + this.pawn.CurJob.ToStringSafe <Job>(), false); this.PatherFailed(); } else { if (this.curPath != null) { this.curPath.ReleaseToPool(); } this.curPath = null; this.moving = true; this.pawn.jobs.posture = PawnPosture.Standing; } } } } }
public void StartPath(LocalTargetInfo dest, PathEndMode peMode) { dest = (LocalTargetInfo)GenPath.ResolvePathMode(pawn, dest.ToTargetInfo(pawn.Map), ref peMode); if (dest.HasThing && dest.ThingDestroyed) { Log.Error(string.Concat(pawn, " pathing to destroyed thing ", dest.Thing)); PatherFailed(); } else { if ((!PawnCanOccupy(pawn.Position) && !TryRecoverFromUnwalkablePosition()) || (moving && curPath != null && destination == dest && this.peMode == peMode)) { return; } if (!pawn.Map.reachability.CanReach(pawn.Position, dest, peMode, TraverseParms.For(TraverseMode.PassDoors))) { PatherFailed(); return; } this.peMode = peMode; destination = dest; if (!IsNextCellWalkable() || NextCellDoorToWaitForOrManuallyOpen() != null || nextCellCostLeft == nextCellCostTotal) { ResetToCurrentPosition(); } PawnDestinationReservationManager.PawnDestinationReservation pawnDestinationReservation = pawn.Map.pawnDestinationReservationManager.MostRecentReservationFor(pawn); if (pawnDestinationReservation != null && ((destination.HasThing && pawnDestinationReservation.target != destination.Cell) || (pawnDestinationReservation.job != pawn.CurJob && pawnDestinationReservation.target != destination.Cell))) { pawn.Map.pawnDestinationReservationManager.ObsoleteAllClaimedBy(pawn); } if (AtDestinationPosition()) { PatherArrived(); return; } if (pawn.Downed) { Log.Error(pawn.LabelCap + " tried to path while downed. This should never happen. curJob=" + pawn.CurJob.ToStringSafe()); PatherFailed(); return; } if (curPath != null) { curPath.ReleaseToPool(); } curPath = null; moving = true; pawn.jobs.posture = PawnPosture.Standing; } }
public static PathEndMode ResolveClosestTouchPathMode(Pawn pawn, Map map, IntVec3 target) { PathEndMode result; if (GenPath.ShouldNotEnterCell(pawn, map, target)) { result = PathEndMode.Touch; } else { result = PathEndMode.OnCell; } return(result); }