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(); return; } if (!this.PawnCanOccupy(this.pawn.Position) && !this.TryRecoverFromUnwalkablePosition(true)) { return; } if (this.moving && this.curPath != null && this.destination == dest && this.peMode == peMode) { return; } if (!this.pawn.Map.reachability.CanReach(this.pawn.Position, dest, peMode, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false))) { this.PatherFailed(); return; } this.peMode = peMode; this.destination = dest; if (!this.IsNextCellWalkable() || this.NextCellDoorToManuallyOpen() != null || this.nextCellCostLeft == this.nextCellCostTotal) { this.ResetToCurrentPosition(); } PawnDestinationReservationManager.PawnDestinationReservation pawnDestinationReservation = this.pawn.Map.pawnDestinationReservationManager.MostRecentReservationFor(this.pawn); if (pawnDestinationReservation != null && ((this.destination.HasThing && pawnDestinationReservation.target != this.destination.Cell) || (pawnDestinationReservation.job != this.pawn.CurJob && pawnDestinationReservation.target != this.destination.Cell))) { this.pawn.Map.pawnDestinationReservationManager.ObsoleteAllClaimedBy(this.pawn); } if (this.AtDestinationPosition()) { this.PatherArrived(); return; } 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(); return; } 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 void StartPath(LocalTargetInfo dest, PathEndMode peMode) { if (!pawn.Drafted) { PatherFailed(); return; } if (pawn.IsBoat()) { dest = (LocalTargetInfo)GenPathVehicles.ResolvePathMode(pawn, dest.ToTargetInfo(pawn.Map), ref peMode); if (dest.HasThing && dest.ThingDestroyed) { Log.Error(pawn + " pathing to destroyed thing " + dest.Thing); PatherFailed(); return; } //Add Building and Position Recoverable extras if (!GenGridVehicles.Walkable(pawn.Position, pawn.Map.GetCachedMapComponent <VehicleMapping>())) { return; } if (Moving && curPath != null && destination == dest && this.peMode == peMode) { return; } if (!pawn.Map.GetCachedMapComponent <VehicleMapping>().VehicleReachability?.CanReachShip(pawn.Position, dest, peMode, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false)) ?? false) { PatherFailed(); return; } this.peMode = peMode; destination = dest; if ((GenGridVehicles.Walkable(nextCell, pawn.Map.GetCachedMapComponent <VehicleMapping>()) || WillCollideWithPawnOnNextPathCell()) || nextCellCostLeft == nextCellCostTotal) { ResetToCurrentPosition(); } PawnDestinationReservationManager.PawnDestinationReservation pawnDestinationReservation = pawn.Map.pawnDestinationReservationManager. MostRecentReservationFor(pawn); if (!(pawnDestinationReservation is null) && ((Destination.HasThing && pawnDestinationReservation.target != Destination.Cell) || (pawnDestinationReservation.job != pawn.CurJob && pawnDestinationReservation.target != Destination.Cell))) { pawn.Map.pawnDestinationReservationManager.ObsoleteAllClaimedBy(pawn); } if (VehicleReachabilityImmediate.CanReachImmediateShip(pawn, dest, peMode)) { PatherArrived(); return; } if (curPath != null) { curPath.ReleaseToPool(); } curPath = null; moving = true; pawn.jobs.posture = PawnPosture.Standing; return; } else { dest = (LocalTargetInfo)GenPath.ResolvePathMode(pawn, dest.ToTargetInfo(pawn.Map), ref peMode); if (dest.HasThing && dest.ThingDestroyed) { Log.Error(pawn + " pathing to destroyed thing " + dest.Thing); PatherFailed(); return; } if (!PawnCanOccupy(pawn.Position) && !TryRecoverFromUnwalkablePosition(true)) { return; } if (moving && curPath != null && destination == dest && this.peMode == peMode) { return; } if (!pawn.Map.reachability.CanReach(pawn.Position, dest, peMode, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false))) { 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; } }