Exemplo n.º 1
0
        // RimWorld.StorytellerUtility
        public static void DefaultParmsNow_PostFix(ref IncidentParms __result, StorytellerDef tellerDef, IncidentCategory incCat, IIncidentTarget target)
        {
            Map map = target as Map;

            if (map != null)
            {
                if (__result.points > 0)
                {
                    try
                    {
                        List <Pawn> forceUsers = map.mapPawns.FreeColonistsSpawned.ToList().FindAll(p => p.GetComp <CompForceUser>() != null);
                        if (forceUsers != null)
                        {
                            foreach (Pawn pawn in forceUsers)
                            {
                                CompForceUser compForce = pawn.GetComp <CompForceUser>();
                                if (compForce.ForceUserLevel > 0)
                                {
                                    __result.points += (5 * compForce.ForceUserLevel);
                                }
                            }
                        }
                    }
                    catch (NullReferenceException)
                    { }
                }
            }
        }
 public void CheckStorytellerChanges()
 {
     if (currentStoryteller != Find.Storyteller.def)
     {
         currentStoryteller = Find.Storyteller.def;
     }
 }
Exemplo n.º 3
0
 public void CheckStorytellerChanges()
 {
     if (currentStoryteller != Find.Storyteller.def)
     {
         currentStoryteller = Find.Storyteller.def;
         ChangeOrRestoreNaturalGoodwill();
     }
 }
 public static IncidentParms DefaultParmsNow(StorytellerDef tellerDef, IncidentCategory incCat)
 {
     var incidentParms = new IncidentParms();
     if (incCat == IncidentCategory.ThreatSmall || incCat == IncidentCategory.ThreatBig)
     {
         var wealthSummaryCost = Find.StoryWatcher.watcherWealth.WealthItems + Find.StoryWatcher.watcherWealth.WealthBuildings * BuildingWealthFactor;
         wealthSummaryCost -= WealthBase;
         if (wealthSummaryCost < 0f)
         {
             wealthSummaryCost = 0f;
         }
         var threatPointsOfWealth = wealthSummaryCost / 1000f * PointsPer1000Wealth;
         var threatPointsOfPopulation = Find.MapPawns.FreeColonistsCount * PointsPerColonist;
         incidentParms.points = threatPointsOfWealth + threatPointsOfPopulation;
         incidentParms.points *= Find.StoryWatcher.watcherRampUp.TotalThreatPointsFactor;
         incidentParms.points *= Find.Storyteller.difficulty.threatScale;
         switch (Find.StoryWatcher.statsRecord.numThreatBigs)
         {
             case 0:
                 incidentParms.points = 35f;
                 incidentParms.raidForceOneIncap = true;
                 incidentParms.raidNeverFleeIndividual = true;
                 break;
             case 1:
                 incidentParms.points *= 0.5f;
                 break;
             case 2:
                 incidentParms.points *= 0.7f;
                 break;
             case 3:
                 incidentParms.points *= 0.8f;
                 break;
             case 4:
                 incidentParms.points *= 0.9f;
                 break;
             default:
                 incidentParms.points *= 1f;
                 break;
         }
         if (incidentParms.points < 0f)
         {
             incidentParms.points = 0f;
         }
         if (incidentParms.points > HalveLimitLo)
         {
             if (incidentParms.points > HalveLimitHi)
             {
                 incidentParms.points = HalveLimitHi + (incidentParms.points - HalveLimitHi) * 0.5f;
             }
             incidentParms.points = HalveLimitLo + (incidentParms.points - HalveLimitLo) * 0.5f;
         }
     }
     return incidentParms;
 }
Exemplo n.º 5
0
        public static void DrawCustomStorytellerInterface(Rect rect, ref StorytellerDef chosenStoryteller, ref DifficultyDef difficulty, Listing_Standard infoListing)
        {
            //if (chosenStoryteller.defName != "StorytellerPacks") return;

            Rect storytellerPacksButton = new Rect(140f, rect.height - 50f, 190f, 38f);

            if (Widgets.ButtonText(storytellerPacksButton, "Storyteller Packs"))
            {
                Window_StorytellerPacks window = new Window_StorytellerPacks();
                Find.WindowStack.TryRemove(window.GetType());
                Find.WindowStack.Add(window);
            }
        }
Exemplo n.º 6
0
 static bool Prefix(Rect rect, ref StorytellerDef chosenStoryteller, ref DifficultyDef difficulty, ref Difficulty difficultyValues, Listing_Standard infoListing)
 {
     if (Find.GameInitData?.permadeathChosen == false)
     {
         Find.GameInitData.permadeathChosen = true;
         Find.GameInitData.permadeath       = false;
     }
     if (difficulty == null)
     {
         difficulty       = DifficultyDefOf.Rough;
         difficultyValues = new Difficulty(difficulty);
     }
     return(true);
 }
        public void Init()
        {
            if (!isInitialized)
            {
                this.isInitialized = true;

                //List<TabRecord> tabs = new List<TabRecord>(2);
                //Tabs selectedTab;
                if (Current.Game != null)
                {
                    this.currentStoryTeller = Current.Game.storyteller.def;

                    /*selectedTab = Tabs.ATS_Game;
                     * tabs.Add(new TabRecord(
                     *  Tabs.ATS_Game.ToString().Translate(),
                     *  delegate { selectedTab = Tabs.ATS_Game; },
                     *  selectedTab == Tabs.ATS_Game));*/
                }
                else
                {
                    this.currentStoryTeller = null;

                    /*selectedTab = Tabs.ATS_Global;
                     * tabs.Add(new TabRecord(
                     *  Tabs.ATS_Global.ToString().Translate(),
                     *  delegate { selectedTab = Tabs.ATS_Global; },
                     *  selectedTab == Tabs.ATS_Global));*/
                }

                if (Settings.GlobalOrbitalTrade == null)
                {
                    Settings.GlobalOrbitalTrade = StoryTellerDefaultsUtil.GetGlobalDefault(IncidentDefOf.OrbitalTraderArrival);
                }

                if (Settings.GameOrbitalTrade == null && StoryTellerUtil.HasOrbitalTraders())
                {
                    Settings.GameOrbitalTrade = new OnOffIncident
                    {
                        Incident  = Settings.GlobalOrbitalTrade.Incident,
                        Days      = Settings.GlobalOrbitalTrade.Days,
                        Instances = Settings.GlobalOrbitalTrade.Instances,
                    };
                }
            }
            this.MakeBuffers();
        }
Exemplo n.º 8
0
 private static bool TryGetAllyInteraction(IncidentDef def, out StorytellerCompProperties_FactionInteraction comp)
 {
     if (Current.Game != null && Current.Game.storyteller != null)
     {
         StorytellerDef d = Current.Game.storyteller.def;
         foreach (StorytellerCompProperties c in d.comps)
         {
             comp = c as StorytellerCompProperties_FactionInteraction;
             if (comp != null && comp.incident == def)
             {
                 return(true);
             }
         }
     }
     comp = null;
     return(false);
 }
Exemplo n.º 9
0
 private static bool TryGetRandom(out StorytellerCompProperties_RandomMain comp)
 {
     comp = null;
     if (Current.Game != null && Current.Game.storyteller != null)
     {
         StorytellerDef d = Current.Game.storyteller.def;
         foreach (StorytellerCompProperties c in d.comps)
         {
             if (c is StorytellerCompProperties_RandomMain rm)
             {
                 comp = rm;
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 10
0
 public static bool TryGetOrbitalTraders(out StorytellerCompProperties_OnOffCycle comp)
 {
     if (Current.Game != null && Current.Game.storyteller != null)
     {
         StorytellerDef d = Current.Game.storyteller.def;
         foreach (StorytellerCompProperties c in d.comps)
         {
             StorytellerCompProperties_OnOffCycle ooc = c as StorytellerCompProperties_OnOffCycle;
             if (ooc != null && ooc.incident == IncidentDefOf.OrbitalTraderArrival)
             {
                 comp = ooc;
                 return(true);
             }
         }
     }
     comp = null;
     return(false);
 }
Exemplo n.º 11
0
        private static StorytellerDef ChooseStoryTeller()
        {
            IEnumerable <StorytellerDef> storytellersFiltered = GetStorytellersFiltered();

            //LogStorytellers(storytellersFiltered);

            if (storytellersFiltered.Count() > 0)
            {
                StorytellerDef newStorytellerDef = storytellersFiltered.RandomElement();
                //Log.Message("Storyteller chosen is: " + newStorytellerDef.defName);

                return(newStorytellerDef);
            }
            else
            {
                throw new System.Exception("No valid storytellers");
            }
        }
Exemplo n.º 12
0
        public static void GenerateColonists()
        {
            do
            {
                ModdedMapInitParams.colonists.Clear();
                for (int i = 0; i < ColonistNum.Amount; i++)
                {
                    ModdedMapInitParams.colonists.Add(PawnGenerator.GeneratePawn("Colonist", Faction.OfColony));
                }
            }while (!ModdedMapInitParams.AnyoneCanDoBasicWorks());
            ModdedMapInitParams.chosenStoryteller = DefDatabase <StorytellerDef> .GetNamed("Cassandra");

            if (ModdedMapInitParams.chosenStoryteller == null)
            {
                ModdedMapInitParams.chosenStoryteller = (
                    from d in DefDatabase <StorytellerDef> .AllDefs
                    orderby d.listOrder
                    select d).First <StorytellerDef>();
            }
        }
Exemplo n.º 13
0
 public override IEnumerable <string> ConfigErrors(StorytellerDef parentDef)
 {
     if (this.incident != null && this.category != null)
     {
         yield return("incident and category should not both be defined");
     }
     if (this.onDays <= 0f)
     {
         yield return("onDays must be above zero");
     }
     if (this.numIncidentsRange.TrueMax <= 0f)
     {
         yield return("numIncidentRange not configured");
     }
     if (this.minSpacingDays * this.numIncidentsRange.TrueMax > this.onDays * 0.9f)
     {
         yield return("minSpacingDays too high compared to max number of incidents.");
     }
     yield break;
 }
Exemplo n.º 14
0
		public static void DrawStorytellerSelectionInterface_Postfix(Rect rect, ref StorytellerDef chosenStoryteller, ref DifficultyDef difficulty, Listing_Standard infoListing) {
			Widgets.CheckboxLabeled (new Rect(140f, 610f, 400f, 30f), "Completely replace vanilla animals with RimMon", ref PokemonConfig.startWith, false, null, null, true);
		}
Exemplo n.º 15
0
 public WeightedChoice(StorytellerDef storytellerDef, int i, float vStorytellerWeight)
 {
     this.storytellerDef = storytellerDef;
     lft  = i;
     rght = (int)vStorytellerWeight;
 }
Exemplo n.º 16
0
 public static void GenerateColonists()
 {
     do
     {
         ModdedMapInitParams.colonists.Clear();
         for (int i = 0; i < ColonistNum.Amount; i++)
         {
             ModdedMapInitParams.colonists.Add(PawnGenerator.GeneratePawn("Colonist", Faction.OfColony));
         }
     }
     while (!ModdedMapInitParams.AnyoneCanDoBasicWorks());
     ModdedMapInitParams.chosenStoryteller = DefDatabase<StorytellerDef>.GetNamed("Cassandra");
     if (ModdedMapInitParams.chosenStoryteller == null)
     {
         ModdedMapInitParams.chosenStoryteller = (
             from d in DefDatabase<StorytellerDef>.AllDefs
             orderby d.listOrder
             select d).First<StorytellerDef>();
     }
 }