Example #1
0
        protected override bool CanFireNowSub(IIncidentTarget target)
        {
            if (!base.CanFireNowSub(target))
            {
                return(false);
            }
            if (Find.AnyPlayerHomeMap == null)
            {
                return(false);
            }
            if (!CommsConsoleUtility.PlayerHasPoweredCommsConsole())
            {
                return(false);
            }
            int num = default(int);

            if (!this.TryFindTile(out num))
            {
                return(false);
            }
            SitePartDef sitePartDef = default(SitePartDef);
            Faction     faction     = default(Faction);

            if (!SiteMakerHelper.TryFindSiteParams_SingleSitePart(SiteCoreDefOf.PrisonerWillingToJoin, IncidentWorker_QuestPrisonerWillingToJoin.PrisonerWillingToJoinQuestThreatTag, out sitePartDef, out faction, (Faction)null, true, (Predicate <Faction>)null))
            {
                return(false);
            }
            return(true);
        }
 private string GetSitePartInfo(SitePartDef sitePart, string leaderLabel)
 {
     if (sitePart == null)
     {
         return("ItemStashSitePart_Nothing".Translate(leaderLabel));
     }
     return("ItemStashSitePart_Part".Translate(leaderLabel, string.Format(sitePart.descriptionDialogue)));
 }
Example #3
0
        public static Site CreateSite(int tile, SitePartDef sitePart, int days, Faction siteFaction)
        {
            Site site = SiteMaker.MakeSite(SiteCoreDefOf.ItemStash, sitePart, tile, siteFaction);

            site.sitePartsKnown = true;
            site.GetComponent <TimeoutComp>().StartTimeout(days * 60000);
            Find.WorldObjects.Add(site);
            return(site);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Faction faction = Find.FactionManager.RandomAlliedFaction(false, false, false, TechLevel.Undefined);

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

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

            if (!SiteMakerHelper.TryFindSiteParams_SingleSitePart(SiteCoreDefOf.ItemStash, (!Rand.Chance(0.15f)) ? IncidentWorker_QuestItemStash.ItemStashQuestThreatTag : null, out sitePart, out siteFaction, (Faction)null, true, (Predicate <Faction>)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(base.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(base.def.letterLabel, letterText, base.def.letterDef, o, null);
            }
            return(true);
        }
        public static Site CreateSite(int tile, SitePartDef sitePart, int days, Faction siteFaction, IList <Thing> items)
        {
            Site site = SiteMaker.MakeSite(SiteCoreDefOf.ItemStash, sitePart, siteFaction, true);

            site.Tile           = tile;
            site.sitePartsKnown = true;
            site.GetComponent <TimeoutComp>().StartTimeout(days * 60000);
            site.GetComponent <ItemStashContentsComp>().contents.TryAddRangeOrTransfer(items, false, false);
            Find.WorldObjects.Add(site);
            return(site);
        }
Example #6
0
        public static Site CreateSite(int tile, SitePartDef sitePart, int days, Faction siteFaction, IList <Thing> items, bool sitePartsKnown)
        {
            Site site = (Site)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Site);

            site.Tile           = tile;
            site.core           = SiteCoreDefOf.ItemStash;
            site.writeSiteParts = sitePartsKnown;
            if (sitePart != null)
            {
                site.parts.Add(sitePart);
            }
            site.SetFaction(siteFaction);
            site.GetComponent <TimeoutComp>().StartTimeout(days * 60000);
            site.GetComponent <ItemStashContentsComp>().contents.TryAddRangeOrTransfer(items, false, false);
            Find.WorldObjects.Add(site);
            return(site);
        }
Example #7
0
 public bool CompatibleWith(SitePartDef part)
 {
     for (int i = 0; i < part.excludesTags.Count; i++)
     {
         if (tags.Contains(part.excludesTags[i]))
         {
             return(false);
         }
     }
     for (int j = 0; j < excludesTags.Count; j++)
     {
         if (part.tags.Contains(excludesTags[j]))
         {
             return(false);
         }
     }
     return(true);
 }
Example #8
0
        private string GetLetterText(Faction alliedFaction, List <Thing> items, int days, SitePartDef sitePart, bool sitePartsKnown, int fee)
        {
            string text;

            if (sitePartsKnown)
            {
                text = this.GetSitePartInfo(sitePart, alliedFaction.leader.LabelShort).CapitalizeFirst();
            }
            else
            {
                text = "ItemStashSitePart_Unknown".Translate(new object[]
                {
                    alliedFaction.leader.LabelShort
                }).CapitalizeFirst();
            }
            string text2 = string.Format(this.def.letterText, new object[]
            {
                alliedFaction.leader.LabelShort,
                alliedFaction.def.leaderTitle,
                alliedFaction.Name,
                GenLabel.ThingsLabel(items).TrimEndNewlines(),
                days.ToString(),
                text
            }).CapitalizeFirst();

            if (fee > 0)
            {
                text2 = text2 + "\n\n" + "ItemStashQuestFeeDemand".Translate(new object[]
                {
                    alliedFaction.leader.LabelShort,
                    fee
                }).CapitalizeFirst();
            }
            if (items.Count == 1)
            {
                string text3 = text2;
                text2 = string.Concat(new string[]
                {
                    text3,
                    "\n\n---\n\n",
                    items[0].LabelCap,
                    ": ",
                    items[0].GetDescription()
                });
            }
            return(text2);
        }
        private string GetLetterText(Faction alliedFaction, List <Thing> items, int days, SitePartDef sitePart, bool sitePartsKnown, int fee)
        {
            string text  = (!sitePartsKnown) ? "ItemStashSitePart_Unknown".Translate(alliedFaction.leader.LabelShort).CapitalizeFirst() : this.GetSitePartInfo(sitePart, alliedFaction.leader.LabelShort).CapitalizeFirst();
            string text2 = string.Format(base.def.letterText, alliedFaction.leader.LabelShort, alliedFaction.def.leaderTitle, alliedFaction.Name, GenLabel.ThingsLabel(items).TrimEndNewlines(), days.ToString(), text).CapitalizeFirst();

            if (fee > 0)
            {
                text2 = text2 + "\n\n" + "ItemStashQuestFeeDemand".Translate(alliedFaction.leader.LabelShort, fee).CapitalizeFirst();
            }
            if (items.Count == 1)
            {
                string text3 = text2;
                text2 = text3 + "\n\n---\n\n" + items[0].LabelCap + ": " + items[0].GetDescription();
            }
            return(text2);
        }