Exemplo n.º 1
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map         map        = (Map)parms.target;
            PawnKindDef bossKind   = def.pawnKind;
            PawnKindDef animalKind = GetAnimalKind(parms.points, map.Tile);

            if (bossKind == null || animalKind == null || ManhunterPackIncidentUtility.GetAnimalsCount(animalKind, (parms.points * PointsFactor) - bossKind.combatPower) <= 0)
            {
                return(false);
            }
            IntVec3 result = parms.spawnCenter;

            if (!result.IsValid && !RCellFinder.TryFindRandomPawnEntryCell(out result, map, CellFinder.EdgeRoadChance_Animal))
            {
                return(false);
            }

            List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals(bossKind, map.Tile, bossKind.combatPower, 1);

            list.AddRange(ManhunterPackIncidentUtility.GenerateAnimals(animalKind, map.Tile, (parms.points * PointsFactor) - bossKind.combatPower, parms.pawnCount));
            Rot4 rot = Rot4.FromAngleFlat((map.Center - result).AngleFlat);

            for (int i = 0; i < list.Count; i++)
            {
                Pawn    pawn = list[i];
                IntVec3 loc  = CellFinder.RandomClosewalkCellNear(result, map, 10);
                QuestUtility.AddQuestTag(GenSpawn.Spawn(pawn, loc, map, rot), parms.questTag);
                pawn.health.AddHediff(HediffDefOf.Scaria);
                pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent);
                pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + Rand.Range(AnimalsStayDurationMin, AnimalsStayDurationMax);
            }

            TaggedString labelString = null;

            if (def.letterLabel != null)
            {
                labelString = def.letterLabel;
            }
            else
            {
                labelString = "LetterLabelManhunterPackArrived".Translate();
            }

            TaggedString textString = null;

            if (def.letterText != null)
            {
                textString = def.letterText;
            }
            else
            {
                textString = "ManhunterPackArrived".Translate(animalKind.GetLabelPlural());
            }

            SendStandardLetter(labelString, textString, LetterDefOf.ThreatBig, parms, list[0]);
            Find.TickManager.slower.SignalForceNormalSpeedShort();
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.ForbiddingDoors, OpportunityType.Critical);
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.AllowedAreas, OpportunityType.Important);
            return(true);
        }
Exemplo n.º 2
0
        protected override void RunInt()
        {
            Slate slate = QuestGen.slate;

            if (targets.GetValue(slate) != null)
            {
                string questTagToAdd = QuestGenUtility.HardcodedTargetQuestTagWithQuestID(tag.GetValue(slate));
                foreach (object item in targets.GetValue(slate))
                {
                    Thing thing = item as Thing;
                    if (thing != null)
                    {
                        QuestUtility.AddQuestTag(ref thing.questTags, questTagToAdd);
                    }
                    else
                    {
                        WorldObject worldObject = item as WorldObject;
                        if (worldObject != null)
                        {
                            QuestUtility.AddQuestTag(ref worldObject.questTags, questTagToAdd);
                        }
                    }
                }
            }
        }
        public static Quest MakeAndAddTradeRequestQuest(WorldObject destination, string description, TradeRequestComp tradeRequest)
        {
            Quest quest = Quest.MakeRaw();

            quest.SetInitiallyAccepted();
            string text = "Quest" + quest.id + ".TradeRequestSite";

            QuestUtility.AddQuestTag(ref destination.questTags, text);
            QuestPartUtility.MakeAndAddEndCondition <QuestPart_NoWorldObject>(quest, quest.InitiateSignal, QuestEndOutcome.Unknown).worldObject = destination;
            QuestPartUtility.MakeAndAddEndCondition <QuestPart_NoWorldObject>(quest, text + ".TradeRequestFulfilled", QuestEndOutcome.Success);
            if (destination.rewards != null)
            {
                QuestPart_GiveToCaravan questPart_GiveToCaravan = new QuestPart_GiveToCaravan
                {
                    inSignal = text + ".TradeRequestFulfilled",
                    Things   = destination.rewards
                };
                foreach (Thing thing in questPart_GiveToCaravan.Things)
                {
                    thing.holdingOwner = null;
                }
                quest.AddPart(questPart_GiveToCaravan);
            }
            quest.description = description;
            Find.QuestManager.Add(quest);
            return(quest);
        }
Exemplo n.º 4
0
        protected override void RunInt()
        {
            string processedTag = GetProcessedTag(QuestGen.slate);

            QuestUtility.AddQuestTag(ref QuestGen.quest.tags, processedTag);
            if (storeProcessedTagAs.GetValue(QuestGen.slate) != null)
            {
                QuestGen.slate.Set(storeProcessedTagAs.GetValue(QuestGen.slate), processedTag);
            }
        }
Exemplo n.º 5
0
        public static Thing SpawnTunnels(ThingDef hiveDef, int hiveCount, Map map, IntVec3 cell, bool spawnAnywhereIfNoGoodCell = false, bool ignoreRoofedRequirement = false, string questTag = null, Faction faction = null)
        {
            ThingDef         HiveDef   = hiveDef ?? RimWorld.ThingDefOf.Hive;
            HiveDefExtension HiveExt   = HiveDef.GetModExtension <HiveDefExtension>();
            ThingDef         TunnelDef = HiveExt?.TunnelDef ?? RimWorld.ThingDefOf.TunnelHiveSpawner;
            HiveDefExtension extension = HiveDef.GetModExtension <HiveDefExtension>();

            if (extension != null && extension.TunnelDef != null)
            {
                TunnelDef = extension.TunnelDef;
            }
            Thing             thing       = GenSpawn.Spawn(ThingMaker.MakeThing(TunnelDef), cell, map, WipeMode.FullRefund);
            TunnelHiveSpawner hiveSpawner = thing as TunnelHiveSpawner;

            if (hiveSpawner != null)
            {
                if (hiveSpawner.faction == null && faction != null)
                {
                    hiveSpawner.faction = faction;
                }
            }
            if (hiveSpawner.SpawnedFaction != null)
            {
                //	Log.Message(hiveSpawner.Faction.def.defName + ": " + hiveSpawner.faction);
            }
            QuestUtility.AddQuestTag(thing, questTag);
            CompSpawnerHives spawnerHives = thing.TryGetComp <CompSpawnerHives>();

            if (spawnerHives?.Props.tunnelDef != null)
            {
                TunnelDef = spawnerHives.Props.tunnelDef;
            }
            for (int i = 0; i < hiveCount - 1; i++)
            {
                cell = CompSpawnerHives.FindChildHiveLocation(thing.Position, map, HiveDef, HiveDef.GetCompProperties <CompProperties_SpawnerHives>(), ignoreRoofedRequirement, allowUnreachable: true);
                if (cell.IsValid)
                {
                    thing       = GenSpawn.Spawn(ThingMaker.MakeThing(TunnelDef), cell, map, WipeMode.FullRefund);
                    hiveSpawner = thing as TunnelHiveSpawner;
                    if (hiveSpawner != null)
                    {
                        if (hiveSpawner.faction == null && faction != null)
                        {
                            hiveSpawner.faction = faction;
                        }
                    }
                    if (hiveSpawner.SpawnedFaction != null)
                    {
                        //	Log.Message(hiveSpawner.Faction.def.defName + ": " + hiveSpawner.faction);
                    }
                    QuestUtility.AddQuestTag(thing, questTag);
                }
            }
            return(thing);
        }
Exemplo n.º 6
0
 private static void AddSlateQuestTags()
 {
     for (int i = 0; i < slateQuestTagsToAddWhenFinished.Count; i++)
     {
         if (slate.TryGet <object>(slateQuestTagsToAddWhenFinished[i], out var var, isAbsoluteName: true))
         {
             string questTagToAdd = GenerateNewTargetQuestTag(slateQuestTagsToAddWhenFinished[i], ensureUnique: false);
             QuestUtility.AddQuestTag(var, questTagToAdd);
         }
     }
     slateQuestTagsToAddWhenFinished.Clear();
 }
Exemplo n.º 7
0
        public void MakeLords(IncidentParms parms, List <Pawn> pawns)
        {
            Map map = (Map)parms.target;
            List <List <Pawn> > list = IncidentParmsUtility.SplitIntoGroups(pawns, parms.pawnGroups);

            for (int i = 0; i < list.Count; i++)
            {
                List <Pawn> list2 = list[i];
                Lord        lord  = LordMaker.MakeNewLord(parms.faction, new LordJob_AssaultColonyWendigo(parms.faction), map, list2);
                lord.inSignalLeave = parms.inSignalEnd;
                QuestUtility.AddQuestTag(lord, parms.questTag);
                if (DebugViewSettings.drawStealDebug && parms.faction.HostileTo(Faction.OfPlayer))
                {
                    Log.Message("Market value threshold to start stealing (raiders=" + lord.ownedPawns.Count + "): " + StealAIUtility.StartStealingMarketValueThreshold(lord) + " (colony wealth=" + map.wealthWatcher.WealthTotal + ")");
                }
            }
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            float totalPoints = parms.points / 2;

            HashSet <PawnKindDef> hybridsList;

            if (StaticCollectionsClass.AnyMechAntennas())
            {
                hybridsList = DefDatabase <PawnKindDef> .AllDefsListForReading.Where(x => (x.race.tradeTags?.Contains("AnimalGenetic") == true) && (x.race.tradeTags?.Contains("AnimalGeneticFailure") == false) && (x.race.tradeTags?.Contains("AnimalGeneticCentipede") == false)).ToHashSet();
            }
            else
            {
                hybridsList = DefDatabase <PawnKindDef> .AllDefsListForReading.Where(x => (x.race.tradeTags?.Contains("AnimalGenetic") == true) && (x.race.tradeTags?.Contains("AnimalGeneticFailure") == false) && (x.race.tradeTags?.Contains("AnimalGeneticMechanoid") == false)).ToHashSet();
            }

            List <Pawn> list = new List <Pawn>();

            PawnKindDef firstPawn;

            hybridsList.TryRandomElementByWeight((PawnKindDef a) => ManhunterPackIncidentUtility.ManhunterAnimalWeight(a, parms.points), out firstPawn);
            IntVec3 result = parms.spawnCenter;

            if (firstPawn != null)
            {
                if (!result.IsValid && !RCellFinder.TryFindRandomPawnEntryCell(out result, map, CellFinder.EdgeRoadChance_Animal))
                {
                    return(false);
                }
                Pawn item = PawnGenerator.GeneratePawn(new PawnGenerationRequest(firstPawn, null, PawnGenerationContext.NonPlayer, map.Tile));
                list.Add(item);
                totalPoints -= item.kindDef.combatPower;
                while (totalPoints > 0)
                {
                    PawnKindDef nextPawn;
                    hybridsList.TryRandomElementByWeight((PawnKindDef a) => ManhunterPackIncidentUtility.ManhunterAnimalWeight(a, totalPoints), out nextPawn);
                    Pawn nextitem = PawnGenerator.GeneratePawn(new PawnGenerationRequest(nextPawn, null, PawnGenerationContext.NonPlayer, map.Tile));
                    list.Add(nextitem);
                    totalPoints -= nextitem.kindDef.combatPower;
                }
            }


            Rot4 rot = Rot4.FromAngleFlat((map.Center - result).AngleFlat);

            for (int i = 0; i < list.Count; i++)
            {
                Pawn    pawn = list[i];
                IntVec3 loc  = CellFinder.RandomClosewalkCellNear(result, map, 10);
                QuestUtility.AddQuestTag(GenSpawn.Spawn(pawn, loc, map, rot), parms.questTag);
                pawn.health.AddHediff(InternalDefOf.GR_GreaterScaria);
                pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent);
                CompHybrid compHybrid = pawn.TryGetComp <CompHybrid>();

                if (compHybrid != null)
                {
                    compHybrid.quality = QualityUtility.GenerateQualityRandomEqualChance();
                }
            }
            SendStandardLetter("GR_LetterLabelMonstrositiesArrived".Translate(), "GR_LetterMonstrositiesArrived".Translate(), LetterDefOf.ThreatBig, parms, list[0]);
            Find.TickManager.slower.SignalForceNormalSpeedShort();

            return(true);
        }
        protected override void RunInt()
        {
            if (!ModLister.RoyaltyInstalled)
            {
                Log.ErrorOnce("Missions are a Royalty-specific game system. If you want to use this code please check ModLister.RoyaltyInstalled before calling it. See rules on the Ludeon forum for more info.", 324345634);
                return;
            }
            Quest  quest = QuestGen.quest;
            Slate  slate = QuestGen.slate;
            string text  = QuestGenUtility.HardcodedTargetQuestTagWithQuestID(QuestTag);
            int    num   = slate.Get("points", 0);
            Pawn   asker = GetAsker(quest);

            ResolveParameters(slate, out var requiredPawnCount, out var population, out var colonyMap);
            TryFindSiteTile(out var tile);
            slate.Set("asker", asker);
            slate.Set("askerFaction", asker.Faction);
            slate.Set("requiredPawnCount", requiredPawnCount);
            slate.Set("map", colonyMap);
            Site   site                = GenerateSite(asker, num, requiredPawnCount, population, tile);
            string inSignal            = QuestGenUtility.HardcodedSignalWithQuestID("askerFaction.BecameHostileToPlayer");
            string text2               = QuestGenUtility.QuestTagSignal(text, "AllEnemiesDefeated");
            string signalSentSatisfied = QuestGenUtility.HardcodedSignalWithQuestID("shuttle.SentSatisfied");

            QuestGenUtility.HardcodedSignalWithQuestID("shuttle.Spawned");
            string text3            = QuestGenUtility.QuestTagSignal(text, "MapRemoved");
            string signalChosenPawn = QuestGen.GenerateNewSignal("ChosenPawnSignal");

            quest.GiveRewards(new RewardsGeneratorParams
            {
                allowGoodwill    = true,
                allowRoyalFavor  = true,
                giverFaction     = asker.Faction,
                rewardValue      = RewardValueCurve.Evaluate(num),
                chosenPawnSignal = signalChosenPawn
            }, text2, null, null, null, null, null, delegate
            {
                quest.Letter(LetterDefOf.ChoosePawn, null, label: asker.Faction.def.royalFavorLabel, text: "LetterTextHonorAward_BanditCamp".Translate(asker.Faction.def.royalFavorLabel), chosenPawnSignal: signalChosenPawn, relatedFaction: null, useColonistsOnMap: null, useColonistsFromCaravanArg: false, signalListenMode: QuestPart.SignalListenMode.OngoingOnly, lookTargets: null, filterDeadPawnsFromLookTargets: false, textRules: null, labelRules: null, getColonistsFromSignal: signalSentSatisfied);
            }, null, AddCampLootReward, asker);
            Thing shuttle = QuestGen_Shuttle.GenerateShuttle(null, null, null, acceptColonists: true, onlyAcceptColonists: true, onlyAcceptHealthy: false, requiredPawnCount, dropEverythingIfUnsatisfied: true, leaveImmediatelyWhenSatisfied: true, dropEverythingOnArrival: false, stayAfterDroppedEverythingOnArrival: true, site, colonyMap.Parent, requiredPawnCount, null, permitShuttle: false, hideControls: false);

            shuttle.TryGetComp <CompShuttle>().sendAwayIfQuestFinished = quest;
            slate.Set("shuttle", shuttle);
            quest.SpawnWorldObject(site, null, signalSentSatisfied);
            QuestUtility.AddQuestTag(ref shuttle.questTags, text);
            quest.SpawnSkyfaller(colonyMap, ThingDefOf.ShuttleIncoming, Gen.YieldSingle(shuttle), Faction.OfPlayer, null, null, lookForSafeSpot: true, tryLandInShipLandingZone: true);
            quest.ShuttleLeaveDelay(shuttle, 60000, null, Gen.YieldSingle(signalSentSatisfied), null, delegate
            {
                quest.SendShuttleAway(shuttle, dropEverything: true);
                quest.End(QuestEndOutcome.Fail, 0, null, null, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            });
            string inSignal2 = QuestGenUtility.HardcodedSignalWithQuestID("shuttle.Killed");

            quest.SetFactionRelations(asker.Faction, FactionRelationKind.Hostile, inSignal2);
            quest.End(QuestEndOutcome.Fail, 0, null, inSignal2, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            quest.SignalPass(delegate
            {
                quest.End(QuestEndOutcome.Fail, 0, null, null, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            }, inSignal);
            quest.FeedPawns(null, shuttle, signalSentSatisfied);
            Quest  quest2 = quest;
            Action action = delegate
            {
                quest.SendShuttleAway(shuttle, dropEverything: true);
            };
            string inSignalDisable = signalSentSatisfied;

            quest2.SignalPassActivable(action, null, text2, null, null, inSignalDisable);
            QuestUtility.AddQuestTag(ref site.questTags, text);
            slate.Set("site", site);
            quest.SendShuttleAwayOnCleanup(shuttle, dropEverything: true);
            quest.SignalPassActivable(delegate
            {
                quest.Message("MessageMissionGetBackToShuttle".Translate(site.Faction.Named("FACTION")), MessageTypeDefOf.PositiveEvent, getLookTargetsFromSignal: false, null, new LookTargets(shuttle));
            }, signalSentSatisfied, text2);
            quest.SignalPassAllSequence(delegate
            {
                quest.End(QuestEndOutcome.Success, 0, null, null, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            }, new List <string>
            {
                signalSentSatisfied,
                text2,
                text3
            });
            Quest  quest3  = quest;
            Action action2 = delegate
            {
                quest.End(QuestEndOutcome.Fail, 0, null, null, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            };

            inSignalDisable = text2;
            quest3.SignalPassActivable(action2, null, text3, null, null, inSignalDisable);
            int num2 = (int)(timeLimitDays.RandomInRange * 60000f);

            slate.Set("timeoutTicks", num2);
            quest.WorldObjectTimeout(site, num2);
            List <Rule> list = new List <Rule>();

            list.AddRange(GrammarUtility.RulesForWorldObject("site", site));
            QuestGen.AddQuestDescriptionRules(list);
        }
Exemplo n.º 10
0
        public static Thing SpawnTunnels(ThingDef hiveDef, int hiveCount, Map map, bool spawnAnywhereIfNoGoodCell = false, bool ignoreRoofedRequirement = false, string questTag = null, Faction faction = null)
        {
            ThingDef         HiveDef   = hiveDef ?? RimWorld.ThingDefOf.Hive;
            HiveDefExtension HiveExt   = HiveDef.GetModExtension <HiveDefExtension>();
            ThingDef         TunnelDef = HiveExt?.TunnelDef ?? RimWorld.ThingDefOf.TunnelHiveSpawner;

            if (!InfestationCellFinder.TryFindCell(out IntVec3 cell, map, HiveExt))
            {
                if (!spawnAnywhereIfNoGoodCell)
                {
                    return(null);
                }
                if (!RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith(delegate(IntVec3 x)
                {
                    if (!x.Standable(map) || x.Fogged(map))
                    {
                        return(false);
                    }
                    bool flag = false;
                    int num = GenRadial.NumCellsInRadius(3f);
                    for (int j = 0; j < num; j++)
                    {
                        IntVec3 c = x + GenRadial.RadialPattern[j];
                        if (c.InBounds(map))
                        {
                            RoofDef roof = c.GetRoof(map);
                            if (roof != null && roof.isThickRoof)
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    return(flag ? true : false);
                }, map, out cell))
                {
                    return(null);
                }
            }
            HiveDefExtension extension = HiveDef.GetModExtension <HiveDefExtension>();

            if (extension != null && extension.TunnelDef != null)
            {
                TunnelDef = extension.TunnelDef;
            }
            Thing             thing       = GenSpawn.Spawn(ThingMaker.MakeThing(TunnelDef), cell, map, WipeMode.FullRefund);
            TunnelHiveSpawner hiveSpawner = thing as TunnelHiveSpawner;

            if (hiveSpawner != null)
            {
                if (hiveSpawner.faction == null && faction != null)
                {
                    hiveSpawner.faction = faction;
                }
            }
            if (hiveSpawner.SpawnedFaction != null)
            {
                //	Log.Message(hiveSpawner.Faction.def.defName + ": " + hiveSpawner.faction);
            }
            QuestUtility.AddQuestTag(thing, questTag);
            for (int i = 0; i < hiveCount - 1; i++)
            {
                cell = CompSpawnerHives.FindChildHiveLocation(thing.Position, map, HiveDef, HiveDef.GetCompProperties <CompProperties_SpawnerHives>(), ignoreRoofedRequirement, allowUnreachable: true);
                if (cell.IsValid)
                {
                    thing       = GenSpawn.Spawn(ThingMaker.MakeThing(TunnelDef), cell, map, WipeMode.FullRefund);
                    hiveSpawner = thing as TunnelHiveSpawner;
                    if (hiveSpawner != null)
                    {
                        if (hiveSpawner.faction == null && faction != null)
                        {
                            hiveSpawner.faction = faction;
                        }
                    }
                    if (hiveSpawner.SpawnedFaction != null)
                    {
                        //	Log.Message(hiveSpawner.Faction.def.defName+": "+ hiveSpawner.faction);
                    }
                    QuestUtility.AddQuestTag(thing, questTag);
                }
            }
            return(thing);
        }
Exemplo n.º 11
0
        protected override void RunInt()
        {
            if (!ModLister.RoyaltyInstalled)
            {
                Log.ErrorOnce("Bestowing ceremony is a Royalty-specific game system. If you want to use this code please check ModLister.RoyaltyInstalled before calling it. See rules on the Ludeon forum for more info.", 3454535);
                return;
            }
            Quest quest = QuestGen.quest;
            Slate slate = QuestGen.slate;

            if (!TryGetCeremonyTarget(QuestGen.slate, out var pawn, out var bestowingFaction))
            {
                return;
            }
            RoyalTitleDef titleAwardedWhenUpdating = pawn.royalty.GetTitleAwardedWhenUpdating(bestowingFaction, pawn.royalty.GetFavor(bestowingFaction));
            string        text      = QuestGenUtility.HardcodedTargetQuestTagWithQuestID("Bestowing");
            string        text2     = QuestGenUtility.QuestTagSignal(text, "CeremonyExpired");
            string        inSignal  = QuestGenUtility.QuestTagSignal(text, "CeremonyFailed");
            string        inSignal2 = QuestGenUtility.QuestTagSignal(text, "CeremonyDone");
            string        inSignal3 = QuestGenUtility.QuestTagSignal(text, "TitleAwardedWhenUpdatingChanged");
            Thing         thing     = QuestGen_Shuttle.GenerateShuttle(bestowingFaction, null, null, acceptColonists: false, onlyAcceptColonists: false, onlyAcceptHealthy: false, 0, dropEverythingIfUnsatisfied: false, leaveImmediatelyWhenSatisfied: true, dropEverythingOnArrival: true, stayAfterDroppedEverythingOnArrival: true);
            Pawn          pawn2     = quest.GetPawn(new QuestGen_Pawns.GetPawnParms
            {
                mustBeOfKind    = PawnKindDefOf.Empire_Royal_Bestower,
                canGeneratePawn = true,
                mustBeOfFaction = bestowingFaction,
                mustBeWorldPawn = true
            });

            QuestUtility.AddQuestTag(ref thing.questTags, text);
            QuestUtility.AddQuestTag(ref pawn.questTags, text);
            ThingOwner <Thing> innerContainer = pawn2.inventory.innerContainer;

            for (int num = innerContainer.Count - 1; num >= 0; num--)
            {
                if (innerContainer[num].def == ThingDefOf.PsychicAmplifier)
                {
                    Thing thing2 = innerContainer[num];
                    innerContainer.RemoveAt(num);
                    thing2.Destroy();
                }
            }
            int num2 = titleAwardedWhenUpdating.maxPsylinkLevel - pawn.GetPsylinkLevel();

            for (int i = 0; i < num2 + 1; i++)
            {
                innerContainer.TryAdd(ThingMaker.MakeThing(ThingDefOf.PsychicAmplifier), 1);
            }
            List <Pawn> list = new List <Pawn>();

            list.Add(pawn2);
            slate.Set("shuttleContents", list);
            slate.Set("shuttle", thing);
            slate.Set("target", pawn);
            slate.Set("bestowingFaction", bestowingFaction);
            List <Pawn> list2 = new List <Pawn>();

            for (int j = 0; j < 6; j++)
            {
                Pawn item = quest.GeneratePawn(PawnKindDefOf.Empire_Fighter_Janissary, bestowingFaction);
                list.Add(item);
                list2.Add(item);
            }
            slate.Set("defenders", list2);
            CompShuttle compShuttle = thing.TryGetComp <CompShuttle>();

            compShuttle.requiredPawns          = list;
            compShuttle.sendAwayIfAllDespawned = list.Cast <Thing>().ToList();
            compShuttle.sendAwayIfAllPawnsLeftToLoadAreNotOfFaction = bestowingFaction;
            quest.AddContentsToShuttle(thing, list);
            quest.SpawnSkyfaller(null, ThingDefOf.ShuttleIncoming, Gen.YieldSingle(thing), Faction.OfPlayer, null, null, lookForSafeSpot: true, tryLandInShipLandingZone: true, null, pawn);
            quest.FactionGoodwillChange(bestowingFaction, -5, QuestGenUtility.HardcodedSignalWithQuestID("defenders.Killed"), canSendMessage: true, canSendHostilityLetter: true, "GoodwillChangeReason_AttackedFaction".Translate(bestowingFaction));
            QuestPart_BestowingCeremony questPart_BestowingCeremony = new QuestPart_BestowingCeremony();

            questPart_BestowingCeremony.inSignal = QuestGen.slate.Get <string>("inSignal");
            questPart_BestowingCeremony.pawns.Add(pawn2);
            questPart_BestowingCeremony.mapOfPawn = pawn;
            questPart_BestowingCeremony.faction   = pawn2.Faction;
            questPart_BestowingCeremony.bestower  = pawn2;
            questPart_BestowingCeremony.target    = pawn;
            questPart_BestowingCeremony.shuttle   = thing;
            questPart_BestowingCeremony.questTag  = text;
            quest.AddPart(questPart_BestowingCeremony);
            QuestPart_EscortPawn questPart_EscortPawn = new QuestPart_EscortPawn();

            questPart_EscortPawn.inSignal = QuestGen.slate.Get <string>("inSignal");
            questPart_EscortPawn.escortee = pawn2;
            questPart_EscortPawn.pawns.AddRange(list2);
            questPart_EscortPawn.mapOfPawn = pawn;
            questPart_EscortPawn.faction   = pawn2.Faction;
            questPart_EscortPawn.shuttle   = thing;
            quest.AddPart(questPart_EscortPawn);
            string inSignal4 = QuestGenUtility.HardcodedSignalWithQuestID("shuttle.Killed");

            quest.SetFactionRelations(bestowingFaction, FactionRelationKind.Hostile, inSignal4);
            quest.End(QuestEndOutcome.Fail, 0, null, inSignal4, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            QuestPart_RequirementsToAcceptThroneRoom questPart_RequirementsToAcceptThroneRoom = new QuestPart_RequirementsToAcceptThroneRoom();

            questPart_RequirementsToAcceptThroneRoom.faction  = bestowingFaction;
            questPart_RequirementsToAcceptThroneRoom.forPawn  = pawn;
            questPart_RequirementsToAcceptThroneRoom.forTitle = titleAwardedWhenUpdating;
            quest.AddPart(questPart_RequirementsToAcceptThroneRoom);
            QuestPart_RequirementsToAcceptPawnOnColonyMap questPart_RequirementsToAcceptPawnOnColonyMap = new QuestPart_RequirementsToAcceptPawnOnColonyMap();

            questPart_RequirementsToAcceptPawnOnColonyMap.pawn = pawn;
            quest.AddPart(questPart_RequirementsToAcceptPawnOnColonyMap);
            QuestPart_RequirementsToAcceptNoDanger questPart_RequirementsToAcceptNoDanger = new QuestPart_RequirementsToAcceptNoDanger();

            questPart_RequirementsToAcceptNoDanger.map      = pawn.Map;
            questPart_RequirementsToAcceptNoDanger.dangerTo = bestowingFaction;
            quest.AddPart(questPart_RequirementsToAcceptNoDanger);
            string inSignal5 = QuestGenUtility.HardcodedSignalWithQuestID("shuttleContents.Recruited");
            string inSignal6 = QuestGenUtility.HardcodedSignalWithQuestID("bestowingFaction.BecameHostileToPlayer");

            quest.Signal(inSignal5, delegate
            {
                quest.End(QuestEndOutcome.Fail, 0, null, null, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            });
            quest.End(QuestEndOutcome.Fail, 0, null, QuestGenUtility.HardcodedSignalWithQuestID("target.Killed"), QuestPart.SignalListenMode.OngoingOrNotYetAccepted, sendStandardLetter: true);
            quest.Letter(LetterDefOf.NegativeEvent, text2, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, label: "LetterLabelBestowingCeremonyExpired".Translate(), text: "LetterTextBestowingCeremonyExpired".Translate(pawn.Named("TARGET")));
            quest.End(QuestEndOutcome.Fail, 0, null, text2);
            quest.End(QuestEndOutcome.Fail, 0, null, inSignal6, QuestPart.SignalListenMode.OngoingOrNotYetAccepted, sendStandardLetter: true);
            quest.End(QuestEndOutcome.Fail, 0, null, inSignal, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            quest.End(QuestEndOutcome.Fail, 0, null, inSignal3, QuestPart.SignalListenMode.OngoingOrNotYetAccepted, sendStandardLetter: true);
            quest.End(QuestEndOutcome.Success, 0, null, inSignal2);
            QuestPart_Choice questPart_Choice = quest.RewardChoice();

            QuestPart_Choice.Choice item2 = new QuestPart_Choice.Choice
            {
                rewards =
                {
                    (Reward) new Reward_BestowingCeremony
                    {
                        targetPawnName  = pawn.NameShortColored.Resolve(),
                        titleName       = titleAwardedWhenUpdating.GetLabelCapFor(pawn),
                        awardingFaction = bestowingFaction,
                        givePsylink     = (titleAwardedWhenUpdating.maxPsylinkLevel > pawn.GetPsylinkLevel()),
                        royalTitle      = titleAwardedWhenUpdating
                    }
                }
            };
            questPart_Choice.choices.Add(item2);
            List <Rule> list3 = new List <Rule>();

            list3.AddRange(GrammarUtility.RulesForPawn("pawn", pawn));
            list3.Add(new Rule_String("newTitle", titleAwardedWhenUpdating.GetLabelCapFor(pawn)));
            QuestGen.AddQuestNameRules(list3);
            List <Rule> list4 = new List <Rule>();

            list4.AddRange(GrammarUtility.RulesForFaction("faction", bestowingFaction));
            list4.AddRange(GrammarUtility.RulesForPawn("pawn", pawn));
            list4.Add(new Rule_String("newTitle", pawn.royalty.GetTitleAwardedWhenUpdating(bestowingFaction, pawn.royalty.GetFavor(bestowingFaction)).GetLabelFor(pawn)));
            list4.Add(new Rule_String("psylinkLevel", titleAwardedWhenUpdating.maxPsylinkLevel.ToString()));
            QuestGen.AddQuestDescriptionRules(list4);
        }