protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; List <Building_LandingPad> freeLandingPads = Util_LandingPad.GetAllFreeLandingPads(map); if (freeLandingPads == null) { // Should not happen if CanFireNowSub returned true. return(false); } Building_LandingPad landingPad = freeLandingPads.RandomElement(); // Spawn landing damaged spaceship. FlyingSpaceshipLanding damagedSpaceship = Util_Spaceship.SpawnSpaceship(landingPad, SpaceshipKind.Damaged); damagedSpaceship.HitPoints = Mathf.RoundToInt(Rand.Range(0.15f, 0.45f) * damagedSpaceship.HitPoints); string letterText = "-- Comlink with MiningCo. --\n\n" + "MiningCo. pilot:\n\n" + "\"Hello partner!\n" + "Our ship is damaged and we need some repairs before going back to the orbital station.\n" + "Help us and we will reward you. Business as usual!\n\n" + "-- End of transmission --\n\n" + "WARNING! Not helping the ship will negatively impact your partnership with MiningCo.."; Find.LetterStack.ReceiveLetter("Repairs request", letterText, LetterDefOf.NeutralEvent, new TargetInfo(landingPad.Position, landingPad.Map)); return(true); }
public static FlyingSpaceshipLanding SpawnSpaceship(Building_LandingPad landingPad, SpaceshipKind spaceshipKind) { Building_OrbitalRelay orbitalRelay = Util_OrbitalRelay.GetOrbitalRelay(landingPad.Map); int landingDuration = 0; switch (spaceshipKind) { case SpaceshipKind.CargoPeriodic: landingDuration = cargoPeriodicSupplyLandingDuration; if (orbitalRelay != null) { orbitalRelay.Notify_CargoSpaceshipPeriodicLanding(); } Util_Misc.Partnership.nextPeriodicSupplyTick[landingPad.Map] = Find.TickManager.TicksGame + WorldComponent_Partnership.cargoSpaceshipPeriodicSupplyPeriodInTicks; Messages.Message("A MiningCo. cargo spaceship is landing.", new TargetInfo(landingPad.Position, landingPad.Map), MessageTypeDefOf.NeutralEvent); break; case SpaceshipKind.CargoRequested: landingDuration = cargoRequestedSupplyLandingDuration; if (orbitalRelay != null) { orbitalRelay.Notify_CargoSpaceshipRequestedLanding(); } Util_Misc.Partnership.nextRequestedSupplyMinTick[landingPad.Map] = Find.TickManager.TicksGame + WorldComponent_Partnership.cargoSpaceshipRequestedSupplyPeriodInTicks; Messages.Message("A MiningCo. cargo spaceship is landing.", new TargetInfo(landingPad.Position, landingPad.Map), MessageTypeDefOf.NeutralEvent); break; case SpaceshipKind.Damaged: landingDuration = damagedSpaceshipLandingDuration.RandomInRange; // Letter is sent by incident worker. break; case SpaceshipKind.DispatcherDrop: landingDuration = dispatcherDropDurationInTicks; Messages.Message("A MiningCo. dispatcher is dropping an expedition team.", new TargetInfo(landingPad.Position, landingPad.Map), MessageTypeDefOf.NeutralEvent); break; case SpaceshipKind.DispatcherPick: landingDuration = dispatcherPickDurationInTicks; Messages.Message("A MiningCo. dispatcher is picking an expedition team.", new TargetInfo(landingPad.Position, landingPad.Map), MessageTypeDefOf.NeutralEvent); break; case SpaceshipKind.Medical: landingDuration = medicalSupplyLandingDuration; if (orbitalRelay != null) { orbitalRelay.Notify_MedicalSpaceshipLanding(); } Util_Misc.Partnership.nextMedicalSupplyMinTick[landingPad.Map] = Find.TickManager.TicksGame + WorldComponent_Partnership.medicalSpaceshipRequestedSupplyPeriodInTicks; Messages.Message("A MiningCo. medical spaceship is landing.", new TargetInfo(landingPad.Position, landingPad.Map), MessageTypeDefOf.NeutralEvent); break; } FlyingSpaceshipLanding flyingSpaceship = ThingMaker.MakeThing(Util_Spaceship.SpaceshipLanding) as FlyingSpaceshipLanding; GenSpawn.Spawn(flyingSpaceship, landingPad.Position, landingPad.Map, landingPad.Rotation); flyingSpaceship.InitializeLandingParameters(landingPad, landingDuration, spaceshipKind); return(flyingSpaceship); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; Building_LandingPad landingPad = Util_LandingPad.GetBestAvailableLandingPadReachingMapEdge(map); if (landingPad == null) { // Should not happen if CanFireNowSub returned true. return(false); } // Spawn landing dispatcher spaceship. FlyingSpaceshipLanding dispatcherSpaceship = Util_Spaceship.SpawnSpaceship(landingPad, SpaceshipKind.DispatcherDrop); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; Building_LandingPad landingPad = Util_LandingPad.GetBestAvailableLandingPadReachingMapEdge(map); if (landingPad == null) { // Should not happen if CanFireNowSub returned true. return(false); } // Spawn landing dispatcher spaceship. FlyingSpaceshipLanding dispatcherSpaceship = Util_Spaceship.SpawnLandingSpaceship(landingPad, SpaceshipKind.DispatcherPick); // Spawn expedition team. List <Pawn> teamPawns = Expedition.GenerateExpeditionPawns(map); if (Rand.Value < 0.2f) { ApplyInjuriesOrIllnessToTeam(map, teamPawns); } return(SpawnTeamOnMapEdge(landingPad.Position, map, teamPawns)); }