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; } }