This commit is contained in:
2025-08-14 10:11:23 +08:00
parent 31254ef452
commit bb305a4fc2
6 changed files with 200 additions and 67 deletions

View File

@@ -22,31 +22,38 @@ namespace WulaFallenEmpire
protected override IEnumerable<Toil> MakeNewToils()
{
Log.Warning($"[WulaPodDebug] JobDriver_HaulToMaintenancePod started. Hauler: {pawn.LabelShortCap}, Takee: {Takee.LabelShortCap}");
// Standard failure conditions
this.FailOnDestroyedOrNull(TakeeIndex);
this.FailOnDestroyedOrNull(PodIndex);
this.FailOnAggroMentalStateAndHostile(TakeeIndex);
this.FailOn(() => PodComp == null); // Fail if the pod doesn't have our component
this.FailOn(() => PodComp == null);
this.FailOn(() => !pawn.CanReach(Pod, PathEndMode.InteractionCell, Danger.Deadly));
this.FailOn(() => !Takee.Downed); // Can only haul downed pawns
this.FailOn(() => !Takee.Downed);
// Go to the pawn to be rescued
yield return Toils_Goto.GotoThing(TakeeIndex, PathEndMode.ClosestTouch)
Toil goToTakee = Toils_Goto.GotoThing(TakeeIndex, PathEndMode.ClosestTouch)
.FailOnDespawnedNullOrForbidden(TakeeIndex)
.FailOnDespawnedNullOrForbidden(PodIndex)
.FailOnSomeonePhysicallyInteracting(TakeeIndex);
goToTakee.AddPreInitAction(() => Log.Warning($"[WulaPodDebug] HaulJob: {pawn.LabelShortCap} is going to pick up {Takee.LabelShortCap}."));
yield return goToTakee;
// Start carrying the pawn
yield return Toils_Haul.StartCarryThing(TakeeIndex, false, true, false);
Toil startCarrying = Toils_Haul.StartCarryThing(TakeeIndex, false, true, false);
startCarrying.AddPreInitAction(() => Log.Warning($"[WulaPodDebug] HaulJob: {pawn.LabelShortCap} is now carrying {Takee.LabelShortCap}."));
yield return startCarrying;
// Go to the maintenance pod
yield return Toils_Goto.GotoThing(PodIndex, PathEndMode.InteractionCell);
Toil goToPod = Toils_Goto.GotoThing(PodIndex, PathEndMode.InteractionCell);
goToPod.AddPreInitAction(() => Log.Warning($"[WulaPodDebug] HaulJob: {pawn.LabelShortCap} is hauling {Takee.LabelShortCap} to the pod."));
yield return goToPod;
// Place the pawn inside the pod
Toil placeInPod = ToilMaker.MakeToil("PlaceInPod");
placeInPod.initAction = delegate
{
// The Comp will handle despawning the pawn and starting the cycle
Log.Warning($"[WulaPodDebug] HaulJob: {pawn.LabelShortCap} has arrived and is placing {Takee.LabelShortCap} in the pod.");
PodComp.StartCycle(Takee);
};
placeInPod.defaultCompleteMode = ToilCompleteMode.Instant;