public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; switch (num) { case 0u: if (base.ArchivedOnly) { this.$current = base.Option_Close; if (!this.$disposing) { this.$PC = 1; } return(true); } accept = new DiaOption("RansomDemand_Accept".Translate()); accept.action = delegate() { this.faction.kidnapped.RemoveKidnappedPawn(this.kidnapped); Find.WorldPawns.RemovePawn(this.kidnapped); IntVec3 intVec; if (this.faction.def.techLevel < TechLevel.Industrial) { if (!CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => c.Standable(this.map) && this.map.reachability.CanReachColony(c), this.map, CellFinder.EdgeRoadChance_Friendly, out intVec) && !CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => c.Standable(this.map), this.map, CellFinder.EdgeRoadChance_Friendly, out intVec)) { Log.Warning("Could not find any edge cell.", false); intVec = DropCellFinder.TradeDropSpot(this.map); } GenSpawn.Spawn(this.kidnapped, intVec, this.map, WipeMode.Vanish); } else { intVec = DropCellFinder.TradeDropSpot(this.map); TradeUtility.SpawnDropPod(intVec, this.map, this.kidnapped); } CameraJumper.TryJump(intVec, this.map); TradeUtility.LaunchSilver(this.map, this.fee); Find.LetterStack.RemoveLetter(this); }; accept.resolveTree = true; if (!TradeUtility.ColonyHasEnoughSilver(this.map, this.fee)) { accept.Disable("NeedSilverLaunchable".Translate(new object[] { this.fee.ToString() })); } this.$current = accept; if (!this.$disposing) { this.$PC = 2; } return(true); case 2u: this.$current = base.Option_Reject; if (!this.$disposing) { this.$PC = 3; } return(true); case 3u: this.$current = base.Option_Postpone; if (!this.$disposing) { this.$PC = 4; } return(true); case 4u: this.$PC = -1; break; } return(false); }
public List <Thing> ApplyRewardsForTitle(Faction faction, RoyalTitleDef currentTitle, RoyalTitleDef newTitle, bool onlyForNewestTitle = false) { List <Thing> list = new List <Thing>(); List <ThingCount> list2 = new List <ThingCount>(); if (newTitle != null && newTitle.Awardable && pawn.IsColonist && NewHighestTitle(faction, newTitle)) { int num = ((currentTitle != null) ? faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(currentTitle) : 0) + 1; int num2 = faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(newTitle); if (onlyForNewestTitle) { num = num2; } IntVec3 result = IntVec3.Invalid; Map mapHeld = pawn.MapHeld; if (mapHeld != null) { if (mapHeld.IsPlayerHome) { result = DropCellFinder.TradeDropSpot(mapHeld); } else if (!DropCellFinder.TryFindDropSpotNear(pawn.Position, mapHeld, out result, allowFogged: false, canRoofPunch: false)) { result = DropCellFinder.RandomDropSpot(mapHeld); } } for (int i = num; i <= num2; i++) { RoyalTitleDef royalTitleDef = faction.def.RoyalTitlesAwardableInSeniorityOrderForReading[i]; if (royalTitleDef.rewards == null) { continue; } List <Thing> list3 = royalTitleDef.rewards.Select(delegate(ThingDefCountClass r) { Thing thing = ThingMaker.MakeThing(r.thingDef); thing.stackCount = r.count; return(thing); }).ToList(); for (int j = 0; j < list3.Count; j++) { if (list3[j].def == ThingDefOf.PsychicAmplifier) { Find.History.Notify_PsylinkAvailable(); break; } } if (pawn.Spawned) { DropPodUtility.DropThingsNear(result, mapHeld, list3, 110, canInstaDropDuringInit: false, leaveSlag: false, canRoofPunch: false, forbid: false); } else { foreach (Thing item in list3) { pawn.inventory.TryAddItemNotForSale(item); } } for (int k = 0; k < list3.Count; k++) { list2.Add(new ThingCount(list3[k], list3[k].stackCount)); } list.AddRange(list3); } if (list.Count > 0) { TaggedString text = "LetterRewardsForNewTitle".Translate(pawn.Named("PAWN"), faction.Named("FACTION"), newTitle.GetLabelCapFor(pawn).Named("TITLE")) + "\n\n" + GenLabel.ThingsLabel(list2, " - ", ignoreStackLimit: true) + "\n\n" + (pawn.Spawned ? "LetterRewardsForNewTitleDeliveryBase" : "LetterRewardsForNewTitleDeliveryDirect").Translate(pawn.Named("PAWN")); Find.LetterStack.ReceiveLetter("LetterLabelRewardsForNewTitle".Translate(), text, LetterDefOf.PositiveEvent, list); } } return(list); }