public override void ExposeData()
        {
            base.ExposeData();

            Scribe_Collections.Look(ref Configvalues, "TA_Expose_Numbers", LookMode.Value, LookMode.Value);
            int isPplDictSaved = 1;

            //LogOutput.WriteLogMessage(Errorlevel.Information, "val:" + isPplDictSaved.ToString());
            Scribe_Values.Look(ref isPplDictSaved, "TA_Expose_People_isSaved", -1, true);
            //LogOutput.WriteLogMessage(Errorlevel.Information, "val:" + isPplDictSaved.ToString());
            if (ColonyPeople != null)
            {
                ColonyPeople.RemoveAll(x => x.Key == null);
            }
            if (isPplDictSaved == 1)
            {
                Scribe_Collections.Look(ref ColonyPeople, "TA_Expose_People", LookMode.Reference, LookMode.Reference);
                //LogOutput.WriteLogMessage(Errorlevel.Information, "Read TA_ExposePeople");
            }
            TechAdvancing_Config_Tab.ExposeData(TA_Expose_Mode.Load);
            if (ColonyPeople == null)
            {
                ColonyPeople = new Dictionary <Pawn, Faction>();
            }
            LogOutput.WriteLogMessage(Errorlevel.Information, "Loading finished.");
        }
Exemple #2
0
        static void Postfix(Verse.ResearchProjectDef __instance, ref float __result, TechLevel researcherTechLevel)
        {
            if (researcherTechLevel == __instance.techLevel)
            {
                __result = 1f;
            }
            else if (researcherTechLevel > __instance.techLevel)
            {
                int techlevelDifference = researcherTechLevel - __instance.techLevel;
                var discountFactor      = (float)Math.Pow(1d - (TechAdvancing_Config_Tab.ConfigDiscountPctForLowerTechs / 100d), techlevelDifference);
                __result *= discountFactor;
            }
            else
            {
                int num = __instance.techLevel - researcherTechLevel;
                __result = 1f + num * 0.5f;

                if (TechAdvancing_Config_Tab.ConfigCheckboxDisableCostMultiplicatorCap == 0)
                {
                    __result = Mathf.Min(__result, 2);
                }

                if (TechAdvancing_Config_Tab.ConfigCheckboxMakeHigherResearchesSuperExpensive == 1)
                {
                    __result *= (float)(TechAdvancing_Config_Tab.ConfigCheckboxMakeHigherResearchesSuperExpensiveFac * Math.Pow(2, num));
                }
            }

            __result *= TechAdvancing_Config_Tab.ConfigChangeResearchCostFacAsFloat();

            __result = (float)Math.Round(__result, 2);
        }
Exemple #3
0
        internal static void LoadCfgValues()
        {
            if (TechAdvancing_Config_Tab.worldCompSaveHandler.world != Find.World)
            {
                LogOutput.WriteLogMessage(Errorlevel.Warning, "wcsh not referencing the current world!!!");
            }

            TechAdvancing_Config_Tab.ExposeData(TA_Expose_Mode.Load);
        }
        public override void ExposeData()
        {
            LogOutput.WriteLogMessage(Errorlevel.Debug, $"Loading begun. Factiondef techlevel: {Find.FactionManager.OfPlayer.def.techLevel}");
            if (Scribe.mode == LoadSaveMode.LoadingVars)
            {
                if (TA_ResearchManager.originalTechlevelCache.ContainsKey(Find.FactionManager.OfPlayer.Name))
                {
                    var correctTl = TA_ResearchManager.originalTechlevelCache[Find.FactionManager.OfPlayer.Name];
                    LogOutput.WriteLogMessage(Errorlevel.Information, $"The playerfaction is the same as one which was previously loaded. " +
                                              $"Resetting the techlevel to what it was before we changed it. Current faction techlevel: {Find.FactionManager.OfPlayer.def.techLevel} New (correct) techlevel: {correctTl}");
                    Find.FactionManager.OfPlayer.def.techLevel = correctTl;
                }
                else
                {
                    LogOutput.WriteLogMessage(Errorlevel.Debug, $"Scribe mode is LoadingVars. The playerfaction is new, adding it to cache, with techlevel {Find.FactionManager.OfPlayer.def.techLevel}.");
                    TA_ResearchManager.originalTechlevelCache.Add(Find.FactionManager.OfPlayer.Name, Find.FactionManager.OfPlayer.def.techLevel);
                }
            }

            TechAdvancing_Config_Tab.worldCompSaveHandler = this;
            base.ExposeData();

            Scribe_Collections.Look(ref this.ConfigValues, "TA_Expose_Numbers", LookMode.Value, LookMode.Value);
            int isPplDictSaved = 1;

            //LogOutput.WriteLogMessage(Errorlevel.Information, "val:" + isPplDictSaved.ToString());
            Scribe_Values.Look(ref isPplDictSaved, "TA_Expose_People_isSaved", -1, true);
            //LogOutput.WriteLogMessage(Errorlevel.Information, "val:" + isPplDictSaved.ToString());
            if (this.ColonyPeople != null)
            {
                this.ColonyPeople.RemoveAll(x => x.Key == null);
            }
            if (isPplDictSaved == 1)
            {
                Scribe_Collections.Look(ref this.ColonyPeople, "TA_Expose_People", LookMode.Reference, LookMode.Reference);
                //LogOutput.WriteLogMessage(Errorlevel.Information, "Read TA_ExposePeople");
            }
            TechAdvancing_Config_Tab.ExposeData(TA_Expose_Mode.Load);
            if (this.ColonyPeople == null)
            {
                this.ColonyPeople = new Dictionary <Pawn, Faction>();
            }
            LogOutput.WriteLogMessage(Errorlevel.Information, "Loading finished.");

            TA_ResearchManager.FlushCfg();
        }
Exemple #5
0
 /// <summary>
 /// Gets the max techlevel that was generated by any rule. Also takes the faction-min techlevel into account.
 /// </summary>
 /// <returns></returns>
 internal static TechLevel GetRuleTechlevel()
 {
     LogOutput.WriteLogMessage(Errorlevel.Debug, $"A: {RuleA()} | B:{RuleB()}");
     return(Util.GetHighestTechlevel(TechAdvancing_Config_Tab.GetBaseTechlevel(), RuleA(), RuleB()));
 }