public DiaOption GetMedicalSupplyDiaOption(Building_OrbitalRelay orbitalRelay)
        {
            DiaOption           medicalSupplyDiaOption = new DiaOption("Request medical supply (" + Util_Spaceship.medicalSupplyCostInSilver + " silver)");
            Building_LandingPad landingPad             = Util_LandingPad.GetBestAvailableLandingPad(this.Map);

            if (Find.TickManager.TicksGame <= Util_Misc.Partnership.nextMedicalSupplyMinTick[this.Map])
            {
                medicalSupplyDiaOption.Disable("no available ship for now");
            }
            else if (TradeUtility.ColonyHasEnoughSilver(this.Map, Util_Spaceship.medicalSupplyCostInSilver) == false)
            {
                medicalSupplyDiaOption.Disable("not enough silver");
            }
            else if (landingPad == null)
            {
                medicalSupplyDiaOption.Disable("no available landing pad");
            }
            medicalSupplyDiaOption.action = delegate
            {
                TradeUtility.LaunchSilver(this.Map, Util_Spaceship.medicalSupplyCostInSilver);
                Util_Spaceship.SpawnSpaceship(landingPad, SpaceshipKind.Medical);
            };
            DiaNode supplyShipAcceptedDiaNode = new DiaNode("\"We are sending you a medical ship immediately.\n\n"
                                                            + "Hold on down there, we're coming!\n\n"
                                                            + "-- End of transmission --");
            DiaOption supplyShipAcceptedDiaOption = new DiaOption("OK");

            supplyShipAcceptedDiaOption.resolveTree = true;
            supplyShipAcceptedDiaNode.options.Add(supplyShipAcceptedDiaOption);
            medicalSupplyDiaOption.link = supplyShipAcceptedDiaNode;
            return(medicalSupplyDiaOption);
        }
Example #2
0
        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 DiaOption GetCargoSupplyDiaOption(Building_OrbitalRelay orbitalRelay)
        {
            DiaOption           cargoSupplyDiaOption = new DiaOption("Request cargo supply (" + Util_Spaceship.cargoSupplyCostInSilver + " silver)");
            Building_LandingPad landingPad           = Util_LandingPad.GetBestAvailableLandingPad(this.Map);

            if (Find.TickManager.TicksGame <= Util_Misc.Partnership.nextRequestedSupplyMinTick[this.Map])
            {
                cargoSupplyDiaOption.Disable("no available ship for now");
            }
            else if (TradeUtility.ColonyHasEnoughSilver(this.Map, Util_Spaceship.cargoSupplyCostInSilver) == false)
            {
                cargoSupplyDiaOption.Disable("not enough silver");
            }
            else if (landingPad == null)
            {
                cargoSupplyDiaOption.Disable("no available landing pad");
            }
            cargoSupplyDiaOption.action = delegate
            {
                TradeUtility.LaunchSilver(this.Map, Util_Spaceship.cargoSupplyCostInSilver);
                Util_Spaceship.SpawnSpaceship(landingPad, SpaceshipKind.CargoRequested);
            };
            DiaNode supplyShipAcceptedDiaNode = new DiaNode("\"Alright, a supply ship should arrive soon with our best stuff.\n"
                                                            + "Greetings partner!\"\n\n"
                                                            + "-- End of transmission --");
            DiaOption supplyShipAcceptedDiaOption = new DiaOption("OK");

            supplyShipAcceptedDiaOption.resolveTree = true;
            supplyShipAcceptedDiaNode.options.Add(supplyShipAcceptedDiaOption);
            cargoSupplyDiaOption.link = supplyShipAcceptedDiaNode;
            return(cargoSupplyDiaOption);
        }
        protected override bool CanFireNowSub(IIncidentTarget target)
        {
            if (base.CanFireNowSub(target) == false)
            {
                return(false);
            }
            if (Util_Faction.MiningCoFaction.HostileTo(Faction.OfPlayer))
            {
                return(false);
            }
            Map map = (Map)target;

            if (Expedition.IsTemperatureValidForExpedition(map))
            {
                Building_OrbitalRelay orbitalRelay = Util_OrbitalRelay.GetOrbitalRelay(map);
                if ((orbitalRelay != null) &&
                    (orbitalRelay.powerComp.PowerOn))
                {
                    Building_LandingPad landingPad = Util_LandingPad.GetBestAvailableLandingPadReachingMapEdge(map);
                    if (landingPad != null)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Example #5
0
        // Return the primary landing pad if available and reaching map edge
        //     else a random one
        //     else null.
        public static Building_LandingPad GetBestAvailableLandingPadReachingMapEdge(Map map)
        {
            IntVec3 exitSpot = IntVec3.Invalid;
            // Check pawns can reach map edge from best landing pad.
            Building_LandingPad bestLandingPad = GetBestAvailableLandingPad(map);

            if (bestLandingPad != null)
            {
                if (Expedition.TryFindRandomExitSpot(map, bestLandingPad.Position, out exitSpot))
                {
                    return(bestLandingPad);
                }
            }
            // Check pawns can exit map from any landing pad.
            List <Building_LandingPad> allAvailableLandingPads = Util_LandingPad.GetAllFreeAndPoweredLandingPads(map);

            if (allAvailableLandingPads != null)
            {
                foreach (Building_LandingPad landingPad in allAvailableLandingPads.InRandomOrder())
                {
                    if (Expedition.TryFindRandomExitSpot(map, landingPad.Position, out exitSpot))
                    {
                        return(landingPad);
                    }
                }
            }
            return(null);
        }
Example #6
0
        // ===================== Main function =====================
        public override void Tick()
        {
            base.Tick();

            if (powerComp.PowerOn == false)
            {
                StopRotationSound();
            }
            else
            {
                if (Find.TickManager.TicksGame >= this.nextSpaceshipLandingCheckTick)
                {
                    // Update landing pads availability.
                    this.nextSpaceshipLandingCheckTick = Find.TickManager.TicksGame + spaceshipLandingCheckPeriodInTick;
                    UpdateLandingPadAvailability();

                    // Try spawn periodic supply spaceship.
                    if ((Util_Faction.MiningCoFaction.HostileTo(Faction.OfPlayer) == false) &&
                        (Util_Misc.Partnership.feeInSilver[this.Map] == 0) &&
                        (Find.TickManager.TicksGame >= Util_Misc.Partnership.nextPeriodicSupplyTick[this.Map]))
                    {
                        Building_LandingPad landingPad = Util_LandingPad.GetBestAvailableLandingPad(this.Map);
                        if (landingPad != null)
                        {
                            // Found an available landing pad. Spawn periodic supply spaceship.
                            Util_Spaceship.SpawnSpaceship(landingPad, SpaceshipKind.CargoPeriodic);
                        }
                    }
                }

                // Satellite dish rotation.
                UpdateDishRotation();
            }
        }
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            if (base.CanFireNowSub(parms) == false)
            {
                return(false);
            }
            if (Util_Faction.MiningCoFaction.HostileTo(Faction.OfPlayer))
            {
                return(false);
            }
            Map map = (Map)parms.target;
            Building_OrbitalRelay orbitalRelay = Util_OrbitalRelay.GetOrbitalRelay(map);

            if (orbitalRelay == null)
            {
                return(false);
            }
            List <Building_LandingPad> freeLandingPads = Util_LandingPad.GetAllFreeLandingPads(map);

            if (freeLandingPads != null)
            {
                return(true);
            }
            return(false);
        }
        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);
        }
Example #9
0
        protected override bool CanFireNowSub(IIncidentTarget target)
        {
            if (base.CanFireNowSub(target) == false)
            {
                return(false);
            }
            if (Util_Faction.MiningCoFaction.HostileTo(Faction.OfPlayer))
            {
                return(false);
            }
            Map map = (Map)target;
            List <Building_LandingPad> freeLandingPads = Util_LandingPad.GetAllFreeLandingPads(map);

            if (freeLandingPads != null)
            {
                return(true);
            }
            return(false);
        }
Example #10
0
        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));
        }
        // ===================== Main function =====================
        /// <summary>
        /// When powered on, periodically spawn a supply spaceship and update dish rotation.
        /// </summary>
        public override void Tick()
        {
            base.Tick();

            if (powerComp.PowerOn == false)
            {
                StopRotationSound();
            }
            else
            {
                if (Find.TickManager.TicksGame >= this.nextSpaceshipLandingCheckTick)
                {
                    this.nextSpaceshipLandingCheckTick = Find.TickManager.TicksGame + spaceshipLandingCheckPeriodInTick;
                    // Update landing pads availability: it can change due to blocking trees for example.
                    UpdateLandingPadAvailability();

                    // Try spawn periodic supply spaceship.
                    if ((Util_Faction.MiningCoFaction.HostileTo(Faction.OfPlayer) == false) &&
                        (Util_Misc.Partnership.feeInSilver[this.Map] == 0) &&
                        (Find.TickManager.TicksGame >= Util_Misc.Partnership.nextPeriodicSupplyTick[this.Map]) &&
                        this.landingPadIsAvailable &&
                        (this.Map.GameConditionManager.ConditionIsActive(GameConditionDefOf.SolarFlare) == false) &&
                        (this.Map.GameConditionManager.ConditionIsActive(GameConditionDefOf.ToxicFallout) == false))
                    {
                        Building_LandingPad landingPad = Util_LandingPad.GetBestAvailableLandingPad(this.Map);
                        if (landingPad != null)
                        {
                            // Found an available landing pad. Spawn periodic supply spaceship.
                            Util_Spaceship.SpawnLandingSpaceship(landingPad, SpaceshipKind.CargoPeriodic);
                        }
                    }
                }

                // Satellite dish rotation.
                UpdateDishRotation();
            }
        }
 /// <summary>
 /// Check if a landing pad is available.
 /// </summary>
 public void UpdateLandingPadAvailability()
 {
     this.landingPadIsAvailable = (Util_LandingPad.GetAllFreeAndPoweredLandingPads(this.Map) != null);
 }
Example #13
0
        public bool SendPawnBackToMap(Pawn pawn, Map map)
        {
            IntVec3 dropSpot        = IntVec3.Invalid;
            bool    dropSpotIsValid = false;

            // Check orbital relay is powered on.
            Building_OrbitalRelay orbitalRelay = Util_OrbitalRelay.GetOrbitalRelay(map);

            if (orbitalRelay == null)
            {
                return(false);
            }
            if (orbitalRelay.powerComp.PowerOn == false)
            {
                return(false);
            }
            // Look for an available landing pad.
            Building_LandingPad landingPad = Util_LandingPad.GetBestAvailableLandingPad(map);

            if (landingPad == null)
            {
                return(false);
            }
            // Get a nearby drop spot.
            dropSpotIsValid = DropCellFinder.TryFindDropSpotNear(landingPad.Position, map, out dropSpot, false, false);

            if (dropSpot.IsValid)
            {
                string hisHerIts = GenderUtility.GetPossessive(pawn.gender);
                string heSheIt   = GenderUtility.GetPronoun(pawn.gender);
                string himHerIt  = GenderUtility.GetObjective(pawn.gender);

                // Restore needs level.
                pawn.needs.food.ForceSetLevel(Rand.Range(0.75f, 1f));
                pawn.needs.rest.ForceSetLevel(Rand.Range(0.75f, 1f));
                pawn.needs.joy.ForceSetLevel(Rand.Range(0.5f, 0.8f));
                pawn.needs.comfort.ForceSetLevel(Rand.Range(0.6f, 0.9f));
                pawn.needs.space.ForceSetLevel(Rand.Range(0.1f, 0.3f)); // Drop-pod is very small.

                ActiveDropPodInfo dropPodInfo = new ActiveDropPodInfo();
                bool healingSuccessful        = (Rand.Value < 0.98f);
                if (healingSuccessful)
                {
                    string orbitalHealingFailedText = "-- Comlink with MiningCo. --\n\n"
                                                      + "\"Healing of " + pawn.NameStringShort + " is now finished. Everything went fine during the treatment.\n"
                                                      + "We just launched " + hisHerIts + " drop pod toward your colony.\n\n"
                                                      + "I hope you are satisfied of our services.\n\n"
                                                      + "MiningCo. medibay officer out.\"\n\n"
                                                      + "-- End of transmission --";
                    Find.LetterStack.ReceiveLetter("Orbital healing finished", orbitalHealingFailedText, LetterDefOf.PositiveEvent, new TargetInfo(dropSpot, map));
                }
                else
                {
                    // Dying pawn with heart attack.
                    string orbitalHealingSuccessfulText = "-- Comlink with MiningCo. --\n\n"
                                                          + "\"Though we did our best to heal " + pawn.NameStringShort + ", it seems " + hisHerIts + " metabolism was disturbed by the last injection.\n\n"
                                                          + "I am affraid that we need to immediately send " + himHerIt + " back to you as our rules strictly forbid civilian bodies storage.\n\n"
                                                          + "Please accept those silvers as a compensation.\n\n"
                                                          + "MiningCo. medibay officer out.\"\n\n"
                                                          + "-- End of transmission --";
                    Find.LetterStack.ReceiveLetter("Orbital healing interrupted", orbitalHealingSuccessfulText, LetterDefOf.NegativeEvent, new TargetInfo(dropSpot, map));
                    pawn.health.AddHediff(HediffDef.Named("HeartAttack"));
                    pawn.health.AddHediff(HediffDefOf.Anesthetic);
                    Thing compensation = ThingMaker.MakeThing(ThingDefOf.Silver);
                    compensation.stackCount = Mathf.RoundToInt(0.5f * Util_Spaceship.orbitalHealingCost);
                    dropPodInfo.innerContainer.TryAdd(compensation);
                }
                dropPodInfo.innerContainer.TryAdd(pawn);
                dropPodInfo.leaveSlag = true;
                DropPodUtility.MakeDropPodAt(dropSpot, map, dropPodInfo);
                return(true);
            }
            return(false);
        }