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);
        }
Exemplo n.º 2
0
 protected override Job TryGiveJob(Pawn pawn)
 {
     if (pawn.Position != pawn.DutyLocation())
     {
         return(new Job(JobDefOf.Goto, pawn.DutyLocation())
         {
             locomotionUrgency = pawn.mindState.duty.locomotion,
             expiryInterval = this.jobMaxDuration
         });
     }
     else
     {
         Building_Spaceship spaceship = null;
         foreach (Thing thing in pawn.Position.GetThingList(pawn.Map))
         {
             if (thing is Building_Spaceship)
             {
                 spaceship = thing as Building_Spaceship;
                 break;
             }
         }
         if (spaceship != null)
         {
             return(new Job(Util_JobDefOf.BoardSpaceship, spaceship));
         }
     }
     return(null);
 }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public override void DoAction(Transition trans)
        {
            Lord lord = trans.target.lord;

            foreach (Thing thing in (lord.LordJob as LordJob_MiningCoBase).targetDestination.GetThingList(lord.Map))
            {
                if (thing is Building_Spaceship)
                {
                    Building_Spaceship spaceship = thing as Building_Spaceship;
                    spaceship.RequestTakeOff();
                    break;
                }
            }
        }
Exemplo n.º 5
0
        // ===================== Main function =====================
        public override void Tick()
        {
            base.Tick();

            if (this.ticksToLanding == horizontalTrajectoryDurationInTicks + verticalTrajectoryDurationInTicks)
            {
                // Atmosphere entry sound.
                FlyingSpaceshipLanding.preLandingSound.PlayOneShot(new TargetInfo(this.Position, this.Map));
            }
            this.ticksToLanding--;
            if (this.ticksToLanding == verticalTrajectoryDurationInTicks)
            {
                // Landing on sound.
                FlyingSpaceshipLanding.landingSound.PlayOneShot(new TargetInfo(this.Position, this.Map));
            }
            if (this.ticksToLanding <= verticalTrajectoryDurationInTicks)
            {
                // Throw dust during descent.
                MoteMaker.ThrowDustPuff(GenAdj.CellsAdjacentCardinal(this.landingPadPosition, this.landingPadRotation, Util_ThingDefOf.LandingPad.Size).RandomElement(), this.Map, 3f * (1f - (float)this.ticksToLanding / (float)verticalTrajectoryDurationInTicks));
            }
            if (this.ticksToLanding == 0)
            {
                Building_Spaceship spaceship = null;
                switch (this.spaceshipKind)
                {
                case SpaceshipKind.CargoPeriodic:
                case SpaceshipKind.CargoRequested:
                    // Spawn cargo spaceship.
                    Building_SpaceshipCargo cargoSpaceship = ThingMaker.MakeThing(Util_Spaceship.SpaceshipCargo) as Building_SpaceshipCargo;
                    cargoSpaceship.InitializeData_Cargo(Util_Faction.MiningCoFaction, this.HitPoints, this.landingDuration, this.spaceshipKind);
                    spaceship = GenSpawn.Spawn(cargoSpaceship, this.landingPadPosition, this.Map, this.landingPadRotation) as Building_Spaceship;
                    break;

                case SpaceshipKind.Damaged:
                    // Spawn damaged spaceship.
                    Building_SpaceshipDamaged damagedSpaceship = ThingMaker.MakeThing(Util_Spaceship.SpaceshipDamaged) as Building_SpaceshipDamaged;
                    damagedSpaceship.InitializeData_Damaged(Util_Faction.MiningCoFaction, this.HitPoints, this.landingDuration, this.spaceshipKind, this.HitPoints);
                    // Faction will be set to player when repair materials are delivered.
                    spaceship = GenSpawn.Spawn(damagedSpaceship, this.landingPadPosition, this.Map, this.landingPadRotation) as Building_Spaceship;
                    break;

                case SpaceshipKind.DispatcherDrop:
                    // Spawn dispatcher spaceship.
                    Building_SpaceshipDispatcherDrop dispatcherSpaceshipDrop = ThingMaker.MakeThing(Util_Spaceship.SpaceshipDispatcherDrop) as Building_SpaceshipDispatcherDrop;
                    dispatcherSpaceshipDrop.InitializeData_DispatcherDrop(Util_Faction.MiningCoFaction, this.HitPoints, this.landingDuration, this.spaceshipKind);
                    spaceship = GenSpawn.Spawn(dispatcherSpaceshipDrop, this.landingPadPosition, this.Map, this.landingPadRotation) as Building_Spaceship;
                    break;

                case SpaceshipKind.DispatcherPick:
                    // Spawn dispatcher spaceship.
                    Building_SpaceshipDispatcherPick dispatcherSpaceshipPick = ThingMaker.MakeThing(Util_Spaceship.SpaceshipDispatcherPick) as Building_SpaceshipDispatcherPick;
                    dispatcherSpaceshipPick.InitializeData_DispatcherPick(Util_Faction.MiningCoFaction, this.HitPoints, this.landingDuration, this.spaceshipKind);
                    spaceship = GenSpawn.Spawn(dispatcherSpaceshipPick, this.landingPadPosition, this.Map, this.landingPadRotation) as Building_Spaceship;
                    break;

                case SpaceshipKind.Medical:
                    // Spawn medical spaceship.
                    Building_SpaceshipMedical medicalSpaceship = ThingMaker.MakeThing(Util_Spaceship.SpaceshipMedical) as Building_SpaceshipMedical;
                    medicalSpaceship.InitializeData_Medical(Util_Faction.MiningCoFaction, this.HitPoints, this.landingDuration, this.spaceshipKind);
                    spaceship = GenSpawn.Spawn(medicalSpaceship, this.landingPadPosition, this.Map, this.landingPadRotation) as Building_Spaceship;
                    break;

                default:
                    Log.ErrorOnce("MiningCo. Spaceship: unhandled SpaceshipKind (" + this.spaceshipKind.ToString() + ").", 123456783);
                    break;
                }
                this.Destroy();
            }
        }