public void DropTeam() { // Find exit spot. IntVec3 exitSpot = IntVec3.Invalid; bool exitSpotIsValid = Expedition.TryFindRandomExitSpot(this.Map, this.Position, out exitSpot); if (exitSpotIsValid) { // Spawn expedition pawns. List <Pawn> stayingAboardPawns = new List <Pawn>(); List <Pawn> droppedPawns = new List <Pawn>(); foreach (Pawn pawn in this.pawnsAboard) { if (pawn.kindDef == Util_PawnKindDefOf.Pilot) { stayingAboardPawns.Add(pawn); } else { droppedPawns.Add(pawn); GenSpawn.Spawn(pawn, this.Position + IntVec3Utility.RandomHorizontalOffset(3f), this.Map); } } this.pawnsAboard = stayingAboardPawns; // Make lord. LordMaker.MakeNewLord(Util_Faction.MiningCoFaction, new LordJob_ExitMap(exitSpot), this.Map, droppedPawns); // Spawn payment. SpawnPayment(droppedPawns.Count); Util_Faction.AffectGoodwillWith(Util_Faction.MiningCoFaction, Faction.OfPlayer, droppedPawns.Count); } }
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); }
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 (this.Map.listerBuildings.ColonistsHaveBuilding(Util_ThingDefOf.OrbitalRelay)) { Messages.Message("A MiningCo. spaceship is taking off.", spaceship, MessageTypeDefOf.NeutralEvent); } DestroyRoof(); } this.things.ClearAndDestroyContentsOrPassToWorld(DestroyMode.Vanish); base.Destroy(mode); }
public override void Notify_PawnLost(Pawn p, PawnLostCondition condition) { base.Notify_PawnLost(p, condition); if (condition == PawnLostCondition.IncappedOrKilled) { Util_Faction.AffectGoodwillWith(Util_Faction.MiningCoFaction, Faction.OfPlayer, pawnLostGoodwillImpact); Messages.Message("A MiningCo. employee has been injured or killed in your area. MiningCo. goodwill toward you decreased: " + pawnLostGoodwillImpact + ".", new TargetInfo(p.Position, this.Map), MessageTypeDefOf.NegativeHealthEvent); } else if (condition == PawnLostCondition.ExitedMap) { Util_Faction.AffectGoodwillWith(Util_Faction.MiningCoFaction, Faction.OfPlayer, pawnExitedGoodwillImpact); } }
public override void Destroy(DestroyMode mode = DestroyMode.Vanish) { if (mode != DestroyMode.KillFinalize) { // Spawn payments according to number of picked pawns. if (this.pawnsAboard.Count > pilotsNumber) { int pickedPawnNumber = this.pawnsAboard.Count - pilotsNumber; SpawnPayment(pickedPawnNumber); Util_Faction.AffectFactionGoodwillWithOther(Util_Faction.MiningCoFaction, Faction.OfPlayer, pickedPawnNumber); } } base.Destroy(mode); }
public override void Notify_PawnLost(Pawn p, PawnLostCondition condition) { base.Notify_PawnLost(p, condition); if (condition == PawnLostCondition.IncappedOrKilled) { if (p.kindDef == Util_PawnKindDefOf.Medic) { Util_Faction.AffectFactionGoodwillWithOther(Util_Faction.MiningCoFaction, Faction.OfPlayer, -5); string letterText = "A MiningCo. medic has been downed or killed while helping your colony.\n\n" + "Medics are precious people, even more on rimworlds. Losing one will obviously anger MiningCo. and nobody wants to anger this company.\n" + "Remember that you must ensure their safety in your area!"; Find.LetterStack.ReceiveLetter("Medic down", letterText, LetterDefOf.NegativeEvent); } } }
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); }
public void DetermineConsequences() { if (this.repairsAreStarted) { if (this.HitPoints == this.MaxHitPoints) { string letterText = "-- Comlink with MiningCo. --\n\n" + "MiningCo. pilot:\n\n" + "\"We are really grateful for your help, partner!\n" + "Tonight, we will drink to your colony in the orbital ship mess.\n" + "Here, take those crates as a compensation for your efforts. You have well earned it.\n\n" + "See you soon partner!\"\n\n" + "-- End of transmission --"; Find.LetterStack.ReceiveLetter("Repairs completed", letterText, LetterDefOf.PositiveEvent, new TargetInfo(this.Position, this.Map)); for (int thingIndex = 0; thingIndex < this.things.Count; thingIndex++) { SpawnCargoContent(1f); } Util_Faction.AffectFactionGoodwillWithOther(Util_Faction.MiningCoFaction, Faction.OfPlayer, 10f); } else if (this.HitPoints >= this.initialHitPoints) { string letterText = "-- Comlink with MiningCo. --\n\n" + "MiningCo. pilot:\n\n" + "\"We are grateful for your help, partner!\n" + "This is not perfect but at least, you tried.\n" + "Here, take those crates as a compensation for your efforts.\n\n" + "See you partner!\"\n\n" + "-- End of transmission --"; Find.LetterStack.ReceiveLetter("Partial repairs", letterText, LetterDefOf.PositiveEvent, new TargetInfo(this.Position, this.Map)); for (int thingIndex = 0; thingIndex < this.things.Count; thingIndex++) { SpawnCargoContent(0.5f); } Util_Faction.AffectFactionGoodwillWithOther(Util_Faction.MiningCoFaction, Faction.OfPlayer, 5f); } else { string letterText = "-- Comlink with MiningCo. --\n\n" + "MiningCo. pilot:\n\n" + "\"Well, it seems the repairs did not go as we expected.\n" + "You have supplied us the materials but our ship is in worse condition than when we landed.\n" + "You should really review the MiningCo. spaceship maintenance manual!\"\n\n" + "See you partner!\"\n\n" + "-- End of transmission --"; Find.LetterStack.ReceiveLetter("Failed repairs", letterText, LetterDefOf.NeutralEvent, new TargetInfo(this.Position, this.Map)); } // No relation impact. } else { if (this.HitPoints >= this.initialHitPoints) { string letterText = "-- Comlink with MiningCo. --\n\n" + "MiningCo. pilot:\n\n" + "\"Well, it seems you cannot help us. Headquarters will not be pleased to hear that.\n" + "MiningCo. does not bother making business with weak partners.\n\n" + "Do not count on our services for some time, \"partner\".\"\n\n" + "-- End of transmission --\n\n" + "Next cargo supply is delayed.\n" + "Air strike is not available for some time."; Find.LetterStack.ReceiveLetter("Repairs?!", letterText, LetterDefOf.NegativeEvent, new TargetInfo(this.Position, this.Map)); Util_Misc.Partnership.nextPeriodicSupplyTick[this.Map] = Find.TickManager.TicksGame + 2 * WorldComponent_Partnership.cargoSpaceshipPeriodicSupplyPeriodInTicks; Util_Misc.Partnership.nextRequestedSupplyMinTick[this.Map] = Find.TickManager.TicksGame + 2 * WorldComponent_Partnership.cargoSpaceshipRequestedSupplyPeriodInTicks; Util_Misc.Partnership.nextAirstrikeMinTick[this.Map] = Find.TickManager.TicksGame + 20 * GenDate.TicksPerDay; Util_Faction.AffectFactionGoodwillWithOther(Util_Faction.MiningCoFaction, Faction.OfPlayer, -10f); } else { string letterText = "-- Comlink with MiningCo. --\n\n" + "MiningCo. pilot:\n\n" + "\"I can't believe it! Our ship is in worse condition than when we landed.\n" + "I am not supplying this rathole any soon!\"\n\n" + "(You can hear insults before the pilot disconnects.)\n\n" + "-- End of transmission --\n\n" + "Next cargo supply is greatly delayed.\n" + "Air strike is not available for a long time."; Find.LetterStack.ReceiveLetter("Repairs?!", letterText, LetterDefOf.NegativeEvent, new TargetInfo(this.Position, this.Map)); Util_Misc.Partnership.nextPeriodicSupplyTick[this.Map] = Find.TickManager.TicksGame + 4 * WorldComponent_Partnership.cargoSpaceshipPeriodicSupplyPeriodInTicks; Util_Misc.Partnership.nextRequestedSupplyMinTick[this.Map] = Find.TickManager.TicksGame + 4 * WorldComponent_Partnership.cargoSpaceshipRequestedSupplyPeriodInTicks; Util_Misc.Partnership.nextAirstrikeMinTick[this.Map] = Find.TickManager.TicksGame + 40 * GenDate.TicksPerDay; Util_Faction.AffectFactionGoodwillWithOther(Util_Faction.MiningCoFaction, Faction.OfPlayer, -20f); } } }