protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Faction faction = parms.faction;

            if (faction == null)
            {
                faction = Find.FactionManager.RandomNonHostileFaction(false, false, false, TechLevel.Undefined);
            }
            if (faction == null)
            {
                return(false);
            }
            int tile;

            if (!this.TryFindTile(out tile))
            {
                return(false);
            }
            SitePartDef sitePart;
            Faction     siteFaction;

            if (!SiteMakerHelper.TryFindSiteParams_SingleSitePart(SiteCoreDefOf.ItemStash, (!Rand.Chance(0.15f)) ? "ItemStashQuestThreat" : null, out sitePart, out siteFaction, null, true, null))
            {
                return(false);
            }
            int          randomInRange = SiteTuning.QuestSiteTimeoutDaysRange.RandomInRange;
            Site         site          = IncidentWorker_QuestItemStash.CreateSite(tile, sitePart, randomInRange, siteFaction);
            List <Thing> list          = this.GenerateItems(siteFaction, site.desiredThreatPoints);

            site.GetComponent <ItemStashContentsComp>().contents.TryAddRangeOrTransfer(list, false, false);
            string letterText = this.GetLetterText(faction, list, randomInRange, site, site.parts.FirstOrDefault <SitePart>());

            Find.LetterStack.ReceiveLetter(this.def.letterLabel, letterText, this.def.letterDef, site, faction, null);
            return(true);
        }
Beispiel #2
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Faction faction = Find.FactionManager.RandomAlliedFaction(false, false, false, TechLevel.Undefined);

            if (faction == null)
            {
                return(false);
            }
            int tile;

            if (!TileFinder.TryFindNewSiteTile(out tile, 8, 30, false, true, -1))
            {
                return(false);
            }
            SitePartDef sitePart;
            Faction     siteFaction;

            if (!SiteMakerHelper.TryFindSiteParams_SingleSitePart(SiteCoreDefOf.ItemStash, (!Rand.Chance(0.15f)) ? IncidentWorker_QuestItemStash.ItemStashQuestThreatTag : null, out sitePart, out siteFaction, null, true, null))
            {
                return(false);
            }
            int          randomInRange  = IncidentWorker_QuestItemStash.TimeoutDaysRange.RandomInRange;
            List <Thing> list           = this.GenerateItems(siteFaction);
            bool         sitePartsKnown = Rand.Chance(0.5f);
            int          num            = 0;

            if (Rand.Chance(this.FeeDemandChance(faction)))
            {
                num = IncidentWorker_QuestItemStash.FeeRange.RandomInRange;
            }
            string letterText = this.GetLetterText(faction, list, randomInRange, sitePart, sitePartsKnown, num);

            if (num > 0)
            {
                Map map = TradeUtility.PlayerHomeMapWithMostLaunchableSilver();
                ChoiceLetter_ItemStashFeeDemand choiceLetter_ItemStashFeeDemand = (ChoiceLetter_ItemStashFeeDemand)LetterMaker.MakeLetter(this.def.letterLabel, letterText, LetterDefOf.ItemStashFeeDemand);
                choiceLetter_ItemStashFeeDemand.title           = "ItemStashQuestTitle".Translate();
                choiceLetter_ItemStashFeeDemand.radioMode       = true;
                choiceLetter_ItemStashFeeDemand.map             = map;
                choiceLetter_ItemStashFeeDemand.fee             = num;
                choiceLetter_ItemStashFeeDemand.siteDaysTimeout = randomInRange;
                choiceLetter_ItemStashFeeDemand.items.TryAddRangeOrTransfer(list, false, false);
                choiceLetter_ItemStashFeeDemand.siteFaction    = siteFaction;
                choiceLetter_ItemStashFeeDemand.sitePart       = sitePart;
                choiceLetter_ItemStashFeeDemand.alliedFaction  = faction;
                choiceLetter_ItemStashFeeDemand.sitePartsKnown = sitePartsKnown;
                choiceLetter_ItemStashFeeDemand.StartTimeout(60000);
                Find.LetterStack.ReceiveLetter(choiceLetter_ItemStashFeeDemand, null);
            }
            else
            {
                Site o = IncidentWorker_QuestItemStash.CreateSite(tile, sitePart, randomInRange, siteFaction, list, sitePartsKnown);
                Find.LetterStack.ReceiveLetter(this.def.letterLabel, letterText, this.def.letterDef, o, null);
            }
            return(true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Faction faction = parms.faction;

            if (faction == null)
            {
                faction = Find.FactionManager.RandomNonHostileFaction(false, false, false, TechLevel.Undefined);
            }
            bool        result;
            int         tile;
            SitePartDef sitePart;
            Faction     siteFaction;

            if (faction == null)
            {
                result = false;
            }
            else if (!TileFinder.TryFindNewSiteTile(out tile, 7, 27, false, true, -1))
            {
                result = false;
            }
            else if (!SiteMakerHelper.TryFindSiteParams_SingleSitePart(SiteCoreDefOf.ItemStash, (!Rand.Chance(0.15f)) ? IncidentWorker_QuestItemStash.ItemStashQuestThreatTag : null, out sitePart, out siteFaction, null, true, null))
            {
                result = false;
            }
            else
            {
                int          randomInRange = IncidentWorker_QuestItemStash.TimeoutDaysRange.RandomInRange;
                List <Thing> items         = this.GenerateItems(siteFaction);
                Site         site          = IncidentWorker_QuestItemStash.CreateSite(tile, sitePart, randomInRange, siteFaction, items);
                string       letterText    = this.GetLetterText(faction, items, randomInRange, site, site.parts.FirstOrDefault <SitePart>());
                Find.LetterStack.ReceiveLetter(this.def.letterLabel, letterText, this.def.letterDef, site, faction, null);
                result = true;
            }
            return(result);
        }