protected override IEnumerable <Toil> MakeNewToils()
        {
            Building_Spaceship spaceship = this.TargetThingA as Building_Spaceship;

            yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.Touch).FailOn(delegate()
            {
                return spaceship.DestroyedOrNull();
            }));

            Toil boardToil = new Toil()
            {
                initAction = () =>
                {
                    bool isLastLordPawn = false;
                    Lord lord           = pawn.GetLord();
                    if (lord != null)
                    {
                        if (lord.ownedPawns.Count == 1)
                        {
                            isLastLordPawn = true;
                        }
                        lord.Notify_PawnLost(pawn, PawnLostCondition.ExitedMap);
                    }
                    spaceship.Notify_PawnBoarding(pawn, isLastLordPawn);
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            };

            yield return(boardToil);
        }
Exemple #2
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Pawn downedPawn = this.TargetThingA as Pawn;

            Toil gotoDownedPawnToil = Toils_Goto.GotoCell(downedPawnIndex, PathEndMode.OnCell).FailOn(delegate()
            {
                return(downedPawn.DestroyedOrNull() ||
                       (downedPawn.Downed == false));
            });

            yield return(gotoDownedPawnToil);

            yield return(Toils_Haul.StartCarryThing(downedPawnIndex));

            Toil gotoTravelDestToil = Toils_Haul.CarryHauledThingToCell(travelDestCellIndex).FailOn(delegate()
            {
                return(this.pawn.carryTracker.CarriedThing.DestroyedOrNull() ||
                       (this.pawn.CanReach(this.pawn.jobs.curJob.targetB.Cell, PathEndMode.OnCell, Danger.Some) == false));
            });

            yield return(gotoTravelDestToil);

            Toil arrivedToil = new Toil()
            {
                initAction = () =>
                {
                    Building_Spaceship spaceship = null;
                    List <Thing>       thingList = this.pawn.Position.GetThingList(this.pawn.Map);
                    foreach (Thing thing in thingList)
                    {
                        if (thing is Building_Spaceship)
                        {
                            spaceship = thing as Building_Spaceship;
                            break;
                        }
                    }
                    Thing carriedPawn = null;
                    this.pawn.carryTracker.TryDropCarriedThing(this.pawn.Position, ThingPlaceMode.Near, out carriedPawn);
                    if (spaceship != null)
                    {
                        spaceship.Notify_PawnBoarding(carriedPawn as Pawn, false);
                    }
                    else if (this.pawn.Position.CloseToEdge(this.pawn.Map, 5))
                    {
                        carriedPawn.Destroy();
                        Util_Faction.AffectGoodwillWith(this.pawn.Faction, Faction.OfPlayer, LordJob_MiningCoBase.pawnExitedGoodwillImpact);
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            };

            yield return(arrivedToil);
        }