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);
        }
        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);
        }
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        public static void TryUpdateLandingPadAvailability(Map map)
        {
            Building_OrbitalRelay orbitalRelay = GetOrbitalRelay(map);

            if (orbitalRelay != null)
            {
                orbitalRelay.UpdateLandingPadAvailability();
            }
        }
        public DiaOption GetAirSupportDiaOption(Building_OrbitalRelay orbitalRelay, DiaNode parentDiaNode)
        {
            DiaOption airSupportDiaOption = new DiaOption("Request air support");

            if (Find.TickManager.TicksGame >= Util_Misc.Partnership.nextAirstrikeMinTick[this.Map])
            {
                // Air support granted.
                DiaNode airSupportGrantedDiaNode = GetAirSupportGrantedDiaNode(parentDiaNode);
                airSupportDiaOption.link = airSupportGrantedDiaNode;
            }
            else
            {
                // Air support denied.
                DiaNode airSupporDeniedDiaNode = GetAirSupporDeniedDiaNode(parentDiaNode);
                airSupportDiaOption.link = airSupporDeniedDiaNode;
            }
            return(airSupportDiaOption);
        }
        public DiaOption GetFeePaymentDiaOption(Building_OrbitalRelay orbitalRelay)
        {
            int       feeCost             = Util_Misc.Partnership.globalGoodwillFeeInSilver + Util_Misc.Partnership.feeInSilver[this.Map];
            DiaOption feePaymentDiaOption = new DiaOption("Pay partnership fee (" + feeCost + ")");

            feePaymentDiaOption.resolveTree = true;
            feePaymentDiaOption.action      = delegate
            {
                TradeUtility.LaunchSilver(orbitalRelay.Map, feeCost);
                Util_Misc.Partnership.globalGoodwillFeeInSilver = 0;
                Util_Misc.Partnership.feeInSilver[this.Map]     = 0;
                Messages.Message("Partnership fee paid to MiningCo..", MessageTypeDefOf.PositiveEvent);
                if (Util_Faction.MiningCoFaction.GoodwillWith(Faction.OfPlayer) < 0)
                {
                    // Reset goodwill to 0.
                    Util_Faction.AffectFactionGoodwillWithOther(Util_Faction.MiningCoFaction, Faction.OfPlayer, -Util_Faction.MiningCoFaction.GoodwillWith(Faction.OfPlayer));
                }
            };
            if (TradeUtility.ColonyHasEnoughSilver(this.Map, feeCost) == false)
            {
                feePaymentDiaOption.Disable("not enough silver");
            }
            return(feePaymentDiaOption);
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Building_OrbitalRelay orbitalRelay = this.TargetThingA as Building_OrbitalRelay;

            yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.InteractionCell).FailOn(delegate()
            {
                return (orbitalRelay.canUseConsoleNow == false);
            }));

            Toil faceConsoleToil = new Toil()
            {
                initAction = () =>
                {
                    this.GetActor().rotationTracker.FaceCell(orbitalRelay.Position);
                }
            };

            yield return(faceConsoleToil);

            Toil callMiningCoToil = new Toil()
            {
                initAction = () =>
                {
                    DiaNode mainDiaNode = new DiaNode("\"MiningCo. here!\n"
                                                      + "What do you want, partner?\"");

                    // Cargo supply request option.
                    DiaOption cargoSupplyDiaOption = GetCargoSupplyDiaOption(orbitalRelay);
                    mainDiaNode.options.Add(cargoSupplyDiaOption);

                    // Medical supply request option.
                    DiaOption medicalSupplyDiaOption = GetMedicalSupplyDiaOption(orbitalRelay);
                    mainDiaNode.options.Add(medicalSupplyDiaOption);

                    // Air support request option.
                    DiaOption airSupportDiaOption = GetAirSupportDiaOption(orbitalRelay, mainDiaNode);
                    mainDiaNode.options.Add(airSupportDiaOption);

                    // Partnership and goodwill fee payment option.
                    if ((Util_Misc.Partnership.globalGoodwillFeeInSilver > 0) ||
                        (Util_Misc.Partnership.feeInSilver[this.Map] > 0))
                    {
                        foreach (DiaOption option in mainDiaNode.options)
                        {
                            option.Disable("fee unpaid");
                        }
                        DiaOption feePaymentDiaOption = GetFeePaymentDiaOption(orbitalRelay);
                        mainDiaNode.options.Add(feePaymentDiaOption);
                    }

                    // Cancel option.
                    DiaOption disconnectDiaOption = new DiaOption("Disconnect");
                    disconnectDiaOption.resolveTree = true;
                    mainDiaNode.options.Add(disconnectDiaOption);

                    Find.WindowStack.Add(new Dialog_NodeTree(mainDiaNode, true, true, "-- Comlink with MiningCo. --"));
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            };

            yield return(callMiningCoToil);

            yield return(Toils_Reserve.Release(orbitalRelayConsoleIndex));
        }
Exemplo n.º 10
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);
        }