public static bool PlayerOrItemStashHas(ThingDef thingDef)
        {
            List <Map> maps = Find.Maps;

            for (int i = 0; i < maps.Count; i++)
            {
                if (maps[i].listerThings.ThingsOfDef(thingDef).Count > 0)
                {
                    return(true);
                }
            }
            List <Caravan> caravans = Find.WorldObjects.Caravans;

            for (int j = 0; j < caravans.Count; j++)
            {
                if (caravans[j].IsPlayerControlled)
                {
                    List <Thing> list = CaravanInventoryUtility.AllInventoryItems(caravans[j]);
                    for (int k = 0; k < list.Count; k++)
                    {
                        if (list[k].def == thingDef)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(PlayerItemAccessibilityUtility.ItemStashHas(thingDef));
        }
Exemplo n.º 2
0
        private static DiaOption RequestAICoreQuest(Map map, Faction faction, Pawn negotiator)
        {
            TaggedString taggedString = "RequestAICoreInformation".Translate(ThingDefOf.AIPersonaCore.label, 1500.ToString());

            if (faction.PlayerGoodwill < 40)
            {
                DiaOption diaOption = new DiaOption(taggedString);
                diaOption.Disable("NeedGoodwill".Translate(40.ToString("F0")));
                return(diaOption);
            }
            bool  num   = PlayerItemAccessibilityUtility.ItemStashHas(ThingDefOf.AIPersonaCore);
            Slate slate = new Slate();

            slate.Set("points", StorytellerUtility.DefaultThreatPointsNow(Find.World));
            slate.Set("asker", faction.leader);
            slate.Set("itemStashSingleThing", ThingDefOf.AIPersonaCore);
            bool flag = QuestScriptDefOf.OpportunitySite_ItemStash.CanRun(slate);

            if (num || !flag)
            {
                DiaOption diaOption2 = new DiaOption(taggedString);
                diaOption2.Disable("NoKnownAICore".Translate(1500));
                return(diaOption2);
            }
            if (AmountSendableSilver(map) < 1500)
            {
                DiaOption diaOption3 = new DiaOption(taggedString);
                diaOption3.Disable("NeedSilverLaunchable".Translate(1500));
                return(diaOption3);
            }
            return(new DiaOption(taggedString)
            {
                action = delegate
                {
                    Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(QuestScriptDefOf.OpportunitySite_ItemStash, slate);
                    if (!quest.hidden)
                    {
                        QuestUtility.SendLetterQuestAvailable(quest);
                    }
                    TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, 1500, map, null);
                    Current.Game.GetComponent <GameComponent_OnetimeNotification>().sendAICoreRequestReminder = false;
                },
                link = new DiaNode("RequestAICoreInformationResult".Translate(faction.leader).CapitalizeFirst())
                {
                    options =
                    {
                        OKToRoot(faction, negotiator)
                    }
                }
            });
        }
Exemplo n.º 3
0
        private static DiaOption RequestAICoreQuest(Map map, Faction faction, Pawn negotiator)
        {
            string text = "RequestAICoreInformation".Translate(ThingDefOf.AIPersonaCore.label, 1500.ToString());

            if (faction.PlayerGoodwill < 40)
            {
                DiaOption diaOption = new DiaOption(text);
                diaOption.Disable("NeedGoodwill".Translate(40.ToString("F0")));
                return(diaOption);
            }
            IncidentDef   def  = IncidentDefOf.Quest_ItemStashAICore;
            bool          flag = PlayerItemAccessibilityUtility.ItemStashHas(ThingDefOf.AIPersonaCore);
            IncidentParms coreIncidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.Misc, Find.World);

            coreIncidentParms.faction = faction;
            bool flag2 = def.Worker.CanFireNow(coreIncidentParms, false);

            if (flag || !flag2)
            {
                DiaOption diaOption2 = new DiaOption(text);
                diaOption2.Disable("NoKnownAICore".Translate(1500));
                return(diaOption2);
            }
            if (FactionDialogMaker.AmountSendableSilver(map) < 1500)
            {
                DiaOption diaOption3 = new DiaOption(text);
                diaOption3.Disable("NeedSilverLaunchable".Translate(1500));
                return(diaOption3);
            }
            DiaOption diaOption4 = new DiaOption(text);

            diaOption4.action = delegate
            {
                if (def.Worker.TryExecute(coreIncidentParms))
                {
                    TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, 1500, map, null);
                }
                Current.Game.GetComponent <GameComponent_OnetimeNotification>().sendAICoreRequestReminder = false;
            };
            string text2 = "RequestAICoreInformationResult".Translate(faction.leader).CapitalizeFirst();

            diaOption4.link = new DiaNode(text2)
            {
                options =
                {
                    FactionDialogMaker.OKToRoot(faction, negotiator)
                }
            };
            return(diaOption4);
        }