Exemplo n.º 1
0
        // ===================== Setup work =====================
        public override void SpawnSetup(Map map, bool respawningAfterLoad)
        {
            base.SpawnSetup(map, respawningAfterLoad);
            this.powerComp = base.GetComp <CompPowerTrader>();

            // Check if there is already another primary landing pad.
            if (this.Map.listerBuildings.ColonistsHaveBuilding(Util_ThingDefOf.LandingPad))
            {
                foreach (Building building in this.Map.listerBuildings.AllBuildingsColonistOfDef(Util_ThingDefOf.LandingPad))
                {
                    Building_LandingPad landingPad = building as Building_LandingPad;
                    if ((landingPad != this) &&
                        landingPad.isPrimary)
                    {
                        this.isPrimary = false;
                        break;
                    }
                }
            }
            if (this.beaconsAreSpawned == false)
            {
                SpawnBeacons();
                this.beaconsAreSpawned = true;
            }
            if (Scribe.mode == LoadSaveMode.PostLoadInit)
            {
                CheckForBlockingThing();
            }
            Util_OrbitalRelay.TryUpdateLandingPadAvailability(this.Map);
        }
        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.º 4
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.º 5
0
 /// <summary>
 /// Notify beacons that powered is stopped.
 /// </summary>
 public void Notify_PowerStopped()
 {
     Util_OrbitalRelay.TryUpdateLandingPadAvailability(this.Map);
     foreach (Building building in this.Map.listerBuildings.AllBuildingsColonistOfDef(Util_ThingDefOf.LandingPadBeacon))
     {
         Building_LandingPadBeacon beacon = building as Building_LandingPadBeacon;
         if (beacon.landingPad == this)
         {
             beacon.Notify_PowerStopped();
         }
     }
 }
Exemplo n.º 6
0
        public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
        {
            // Free landing pad.
            Thing landingPad = this.Position.GetFirstThing(this.Map, Util_ThingDefOf.LandingPad);

            if (landingPad != null)
            {
                (landingPad as Building_LandingPad).Notify_ShipTakingOff();
            }
            if (mode == DestroyMode.KillFinalize)
            {
                // Spaceship is destroyed.
                SpawnSurvivingPawns();
                SpawnExplosions();
                SpawnFuelPuddleAndFire();
                // Add spaceship cost fee.
                Util_Misc.Partnership.feeInSilver[this.Map] += Mathf.RoundToInt(this.def.BaseMarketValue * 0.5f);
                // Add spaceship cargo cost fee and spread it around.
                int cargoFeeInSilver = SpawnCargoContent(0.5f);
                Util_Misc.Partnership.feeInSilver[this.Map] += Mathf.RoundToInt(cargoFeeInSilver * 0.5f);
                Util_Faction.AffectGoodwillWith(Util_Faction.MiningCoFaction, Faction.OfPlayer, -30);

                string spaceshipDestroyedText = "-- Comlink with MiningCo. --\n\n"
                                                + "\"We just lost contact with one of our ships in your sector.\n"
                                                + "Whatever happened, you are held responsible of this loss.\n\n"
                                                + "Pay a compensation or say goodbye to our partnership!\"\n\n"
                                                + "-- End of transmission --";
                Find.LetterStack.ReceiveLetter("Spaceship destroyed", spaceshipDestroyedText, LetterDefOf.ThreatSmall, new TargetInfo(this.Position, this.Map));
            }
            else
            {
                // Spaceship is taking off.
                // Destroy remaining pawns aboard.
                foreach (Pawn pawn in this.pawnsAboard)
                {
                    pawn.Destroy();
                }
                this.pawnsAboard.Clear();
                // Spawn taking off spaceship.
                FlyingSpaceshipTakingOff spaceship = ThingMaker.MakeThing(Util_Spaceship.SpaceshipTakingOff) as FlyingSpaceshipTakingOff;
                GenSpawn.Spawn(spaceship, this.Position, this.Map, this.Rotation);
                spaceship.InitializeTakingOffParameters(this.Position, this.Rotation, this.spaceshipKind);
                spaceship.HitPoints = this.HitPoints;
                if (Util_OrbitalRelay.GetOrbitalRelay(this.Map) != null)
                {
                    Messages.Message("A MiningCo. spaceship is taking off.", spaceship, MessageTypeDefOf.NeutralEvent);
                }
                DestroyRoof();
            }
            this.things.ClearAndDestroyContentsOrPassToWorld(DestroyMode.Vanish);
            base.Destroy(mode);
        }
Exemplo n.º 7
0
        public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
        {
            Map map = this.Map;

            // Destroy all landing pad beacons.
            foreach (IntVec3 cell in this.OccupiedRect().Cells)
            {
                Thing thing = cell.GetFirstThing(this.Map, Util_ThingDefOf.LandingPadBeacon);
                if (thing != null)
                {
                    thing.Destroy();
                }
            }
            Util_OrbitalRelay.TryUpdateLandingPadAvailability(map);
            base.Destroy(mode);
        }
Exemplo n.º 8
0
 public void NotifyShipTakingOff()
 {
     this.isReserved = false;
     Util_OrbitalRelay.TryUpdateLandingPadAvailability(this.Map);
 }
Exemplo n.º 9
0
 // ===================== Other functions =====================
 public void NotifyShipLanding()
 {
     this.isReserved = true;
     Util_OrbitalRelay.TryUpdateLandingPadAvailability(this.Map);
 }
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);
        }