Exemple #1
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);
        }
        static void Postfix(Verse.ResearchProjectDef __instance, ref float __result, TechLevel researcherTechLevel)
        {
            TechLevel TA_POSTFIXED_techLevel = TechAdvancing_Config_Tab.configCheckboxDisableCostMultiplicatorCap == 1 ? __instance.techLevel : (TechLevel)Mathf.Min((int)__instance.techLevel, 4);

            //TechLevel techLevel = (TechLevel)Mathf.Min((int)__instance.techLevel, 4);
            if ((int)researcherTechLevel >= (int)TA_POSTFIXED_techLevel)
            {
                __result = 1f;
            }
            else
            {
                int num = TA_POSTFIXED_techLevel - researcherTechLevel;
                __result = 1f + (float)num * 0.5f;
            }
        }
        private static void DoPlayLoad()
        {
            DeepProfiler.Start("GraphicDatabase.Clear()");
            try
            {
                GraphicDatabase.Clear();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Load all active mods.");
            try
            {
                LoadedModManager.LoadAllActiveMods();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Load language metadata.");
            try
            {
                LanguageDatabase.InitAllMetadata();
            }
            finally
            {
                DeepProfiler.End();
            }
            LongEventHandler.SetCurrentEventText("LoadingDefs".Translate());
            DeepProfiler.Start("Copy all Defs from mods to global databases.");
            try
            {
                foreach (Type item in typeof(Def).AllSubclasses())
                {
                    GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item, "AddAllInMods");
                }
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Resolve cross-references between non-implied Defs.");
            try
            {
                DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.Silent);
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Rebind defs (early).");
            try
            {
                DefOfHelper.RebindAllDefOfs(earlyTryMode: true);
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("TKeySystem.BuildMappings()");
            try
            {
                TKeySystem.BuildMappings();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Inject selected language data into game data (early pass).");
            try
            {
                LanguageDatabase.activeLanguage.InjectIntoData_BeforeImpliedDefs();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Generate implied Defs (pre-resolve).");
            try
            {
                DefGenerator.GenerateImpliedDefs_PreResolve();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Resolve cross-references between Defs made by the implied defs.");
            try
            {
                DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.LogErrors);
            }
            finally
            {
                DirectXmlCrossRefLoader.Clear();
                DeepProfiler.End();
            }
            DeepProfiler.Start("Rebind DefOfs (final).");
            try
            {
                DefOfHelper.RebindAllDefOfs(earlyTryMode: false);
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Other def binding, resetting and global operations (pre-resolve).");
            try
            {
                PlayerKnowledgeDatabase.ReloadAndRebind();
                LessonAutoActivator.Reset();
                CostListCalculator.Reset();
                Pawn.ResetStaticData();
                PawnApparelGenerator.Reset();
                RestUtility.Reset();
                ThoughtUtility.Reset();
                ThinkTreeKeyAssigner.Reset();
                ThingCategoryNodeDatabase.FinalizeInit();
                TrainableUtility.Reset();
                HaulAIUtility.Reset();
                GenConstruct.Reset();
                MedicalCareUtility.Reset();
                InspectPaneUtility.Reset();
                GraphicDatabaseHeadRecords.Reset();
                DateReadout.Reset();
                ResearchProjectDef.GenerateNonOverlappingCoordinates();
                BaseGen.Reset();
                ResourceCounter.ResetDefs();
                ApparelProperties.ResetStaticData();
                WildPlantSpawner.ResetStaticData();
                PawnGenerator.Reset();
                TunnelHiveSpawner.ResetStaticData();
                Hive.ResetStaticData();
                ExpectationsUtility.Reset();
                WealthWatcher.ResetStaticData();
                SkillUI.Reset();
                QuestNode_GetThingPlayerCanProduce.ResetStaticData();
                Pawn_PsychicEntropyTracker.ResetStaticData();
                ColoredText.ResetStaticData();
                QuestNode_GetRandomNegativeGameCondition.ResetStaticData();
                RoyalTitleUtility.ResetStaticData();
                RewardsGenerator.ResetStaticData();
                WorkGiver_FillFermentingBarrel.ResetStaticData();
                WorkGiver_DoBill.ResetStaticData();
                WorkGiver_InteractAnimal.ResetStaticData();
                WorkGiver_Warden_DoExecution.ResetStaticData();
                WorkGiver_GrowerSow.ResetStaticData();
                WorkGiver_Miner.ResetStaticData();
                WorkGiver_FixBrokenDownBuilding.ResetStaticData();
                WorkGiver_ConstructDeliverResources.ResetStaticData();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Resolve references.");
            try
            {
                DeepProfiler.Start("ThingCategoryDef resolver");
                try
                {
                    DefDatabase <ThingCategoryDef> .ResolveAllReferences();
                }
                finally
                {
                    DeepProfiler.End();
                }
                DeepProfiler.Start("RecipeDef resolver");
                try
                {
                    DeepProfiler.enabled = false;
                    DefDatabase <RecipeDef> .ResolveAllReferences(onlyExactlyMyType : true, parallel : true);

                    DeepProfiler.enabled = true;
                }
                finally
                {
                    DeepProfiler.End();
                }
                DeepProfiler.Start("Static resolver calls");
                try
                {
                    foreach (Type item2 in typeof(Def).AllSubclasses())
                    {
                        if (!(item2 == typeof(ThingDef)) && !(item2 == typeof(ThingCategoryDef)) && !(item2 == typeof(RecipeDef)))
                        {
                            GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item2, "ResolveAllReferences", true, false);
                        }
                    }
                }
                finally
                {
                    DeepProfiler.End();
                }
                DeepProfiler.Start("ThingDef resolver");
                try
                {
                    DefDatabase <ThingDef> .ResolveAllReferences();
                }
                finally
                {
                    DeepProfiler.End();
                }
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Generate implied Defs (post-resolve).");
            try
            {
                DefGenerator.GenerateImpliedDefs_PostResolve();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Other def binding, resetting and global operations (post-resolve).");
            try
            {
                PawnWeaponGenerator.Reset();
                BuildingProperties.FinalizeInit();
                ThingSetMakerUtility.Reset();
            }
            finally
            {
                DeepProfiler.End();
            }
            if (Prefs.DevMode)
            {
                DeepProfiler.Start("Error check all defs.");
                try
                {
                    foreach (Type item3 in typeof(Def).AllSubclasses())
                    {
                        GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item3, "ErrorCheckAllDefs");
                    }
                }
                finally
                {
                    DeepProfiler.End();
                }
            }
            LongEventHandler.SetCurrentEventText("Initializing".Translate());
            DeepProfiler.Start("Load keyboard preferences.");
            try
            {
                KeyPrefs.Init();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Short hash giving.");
            try
            {
                ShortHashGiver.GiveAllShortHashes();
            }
            finally
            {
                DeepProfiler.End();
            }
            LongEventHandler.ExecuteWhenFinished(delegate
            {
                DeepProfiler.Start("Load backstories.");
                try
                {
                    BackstoryDatabase.ReloadAllBackstories();
                }
                finally
                {
                    DeepProfiler.End();
                }
            });
            LongEventHandler.ExecuteWhenFinished(delegate
            {
                DeepProfiler.Start("Inject selected language data into game data.");
                try
                {
                    LanguageDatabase.activeLanguage.InjectIntoData_AfterImpliedDefs();
                    GenLabel.ClearCache();
                }
                finally
                {
                    DeepProfiler.End();
                }
            });
            LongEventHandler.ExecuteWhenFinished(delegate
            {
                DeepProfiler.Start("Static constructor calls");
                try
                {
                    StaticConstructorOnStartupUtility.CallAll();
                    if (Prefs.DevMode)
                    {
                        StaticConstructorOnStartupUtility.ReportProbablyMissingAttributes();
                    }
                }
                finally
                {
                    DeepProfiler.End();
                }
                DeepProfiler.Start("Garbage Collection");
                try
                {
                    AbstractFilesystem.ClearAllCache();
                    GC.Collect(int.MaxValue, GCCollectionMode.Forced);
                }
                finally
                {
                    DeepProfiler.End();
                }
            });
        }
 private static void DoPlayLoad()
 {
     GraphicDatabase.Clear();
     DeepProfiler.Start("Load all active mods.");
     try
     {
         LoadedModManager.LoadAllActiveMods();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Load language metadata.");
     try
     {
         LanguageDatabase.LoadAllMetadata();
     }
     finally
     {
         DeepProfiler.End();
     }
     LongEventHandler.SetCurrentEventText("LoadingDefs".Translate());
     DeepProfiler.Start("Copy all Defs from mods to global databases.");
     try
     {
         foreach (Type genericParam in typeof(Def).AllSubclasses())
         {
             GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), genericParam, "AddAllInMods");
         }
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Resolve cross-references between non-implied Defs.");
     try
     {
         DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.Silent);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Rebind defs (early).");
     try
     {
         DefOfHelper.RebindAllDefOfs(true);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Inject selected language data into game data (early pass).");
     try
     {
         LanguageDatabase.activeLanguage.InjectIntoData_BeforeImpliedDefs();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Generate implied Defs (pre-resolve).");
     try
     {
         DefGenerator.GenerateImpliedDefs_PreResolve();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Resolve cross-references between Defs made by the implied defs.");
     try
     {
         DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.LogErrors);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Rebind DefOfs (final).");
     try
     {
         DefOfHelper.RebindAllDefOfs(false);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Other def binding, resetting and global operations (pre-resolve).");
     try
     {
         PlayerKnowledgeDatabase.ReloadAndRebind();
         LessonAutoActivator.Reset();
         CostListCalculator.Reset();
         Pawn.ResetStaticData();
         PawnApparelGenerator.Reset();
         RestUtility.Reset();
         ThoughtUtility.Reset();
         PawnWeaponGenerator.Reset();
         ThinkTreeKeyAssigner.Reset();
         ThingCategoryNodeDatabase.FinalizeInit();
         TrainableUtility.Reset();
         HaulAIUtility.Reset();
         GenConstruct.Reset();
         MedicalCareUtility.Reset();
         InspectPaneUtility.Reset();
         GraphicDatabaseHeadRecords.Reset();
         DateReadout.Reset();
         ResearchProjectDef.GenerateNonOverlappingCoordinates();
         BaseGen.Reset();
         ResourceCounter.ResetDefs();
         ApparelProperties.ResetStaticData();
         WildPlantSpawner.ResetStaticData();
         PawnGenerator.Reset();
         TunnelHiveSpawner.ResetStaticData();
         Hive.ResetStaticData();
         ExpectationsUtility.Reset();
         WealthWatcher.ResetStaticData();
         WorkGiver_FillFermentingBarrel.ResetStaticData();
         WorkGiver_DoBill.ResetStaticData();
         WorkGiver_InteractAnimal.ResetStaticData();
         WorkGiver_Warden_DoExecution.ResetStaticData();
         WorkGiver_GrowerSow.ResetStaticData();
         WorkGiver_Miner.ResetStaticData();
         WorkGiver_FixBrokenDownBuilding.ResetStaticData();
         WorkGiver_ConstructDeliverResources.ResetStaticData();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Resolve references.");
     try
     {
         foreach (Type type in typeof(Def).AllSubclasses())
         {
             if (type != typeof(ThingDef))
             {
                 GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), type, "ResolveAllReferences", new object[]
                 {
                     true
                 });
             }
         }
         DefDatabase <ThingDef> .ResolveAllReferences(true);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Generate implied Defs (post-resolve).");
     try
     {
         DefGenerator.GenerateImpliedDefs_PostResolve();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Other def binding, resetting and global operations (post-resolve).");
     try
     {
         BuildingProperties.FinalizeInit();
         ThingSetMakerUtility.Reset();
     }
     finally
     {
         DeepProfiler.End();
     }
     if (Prefs.DevMode)
     {
         DeepProfiler.Start("Error check all defs.");
         try
         {
             foreach (Type genericParam2 in typeof(Def).AllSubclasses())
             {
                 GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), genericParam2, "ErrorCheckAllDefs");
             }
         }
         finally
         {
             DeepProfiler.End();
         }
     }
     LongEventHandler.SetCurrentEventText("Initializing".Translate());
     DeepProfiler.Start("Load keyboard preferences.");
     try
     {
         KeyPrefs.Init();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Short hash giving.");
     try
     {
         ShortHashGiver.GiveAllShortHashes();
     }
     finally
     {
         DeepProfiler.End();
     }
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         DeepProfiler.Start("Load backstories.");
         try
         {
             BackstoryDatabase.ReloadAllBackstories();
         }
         finally
         {
             DeepProfiler.End();
         }
     });
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         DeepProfiler.Start("Inject selected language data into game data.");
         try
         {
             LanguageDatabase.activeLanguage.InjectIntoData_AfterImpliedDefs();
             GenLabel.ClearCache();
         }
         finally
         {
             DeepProfiler.End();
         }
     });
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         StaticConstructorOnStartupUtility.CallAll();
         if (Prefs.DevMode)
         {
             StaticConstructorOnStartupUtility.ReportProbablyMissingAttributes();
         }
     });
 }
Exemple #5
0
        public static void GenerateNonOverlappingCoordinates()
        {
            foreach (ResearchProjectDef item in DefDatabase <ResearchProjectDef> .AllDefsListForReading)
            {
                item.x = item.researchViewX;
                item.y = item.researchViewY;
            }
            int num = 0;

            while (true)
            {
                bool flag = false;
                foreach (ResearchProjectDef item2 in DefDatabase <ResearchProjectDef> .AllDefsListForReading)
                {
                    foreach (ResearchProjectDef item3 in DefDatabase <ResearchProjectDef> .AllDefsListForReading)
                    {
                        if (item2 != item3 && item2.tab == item3.tab)
                        {
                            bool flag2 = Mathf.Abs(item2.x - item3.x) < 0.5;
                            bool flag3 = Mathf.Abs(item2.y - item3.y) < 0.25;
                            if (flag2 && flag3)
                            {
                                flag = true;
                                if (item2.x <= item3.x)
                                {
                                    item2.x -= 0.1f;
                                    item3.x += 0.1f;
                                }
                                else
                                {
                                    item2.x += 0.1f;
                                    item3.x -= 0.1f;
                                }
                                if (item2.y <= item3.y)
                                {
                                    item2.y -= 0.1f;
                                    item3.y += 0.1f;
                                }
                                else
                                {
                                    item2.y += 0.1f;
                                    item3.y -= 0.1f;
                                }
                                item2.x += 0.001f;
                                item2.y += 0.001f;
                                item3.x -= 0.001f;
                                item3.y -= 0.001f;
                                ResearchProjectDef.ClampInCoordinateLimits(item2);
                                ResearchProjectDef.ClampInCoordinateLimits(item3);
                            }
                        }
                    }
                }
                if (flag)
                {
                    num++;
                    if (num > 200)
                    {
                        break;
                    }
                    continue;
                }
                return;
            }
            Log.Error("Couldn't relax research project coordinates apart after " + 200 + " passes.");
        }
        public static void GenerateNonOverlappingCoordinates()
        {
            foreach (ResearchProjectDef current in DefDatabase <ResearchProjectDef> .AllDefsListForReading)
            {
                current.x = current.researchViewX;
                current.y = current.researchViewY;
            }
            int num = 0;

            while (true)
            {
                bool flag = false;
                foreach (ResearchProjectDef current2 in DefDatabase <ResearchProjectDef> .AllDefsListForReading)
                {
                    foreach (ResearchProjectDef current3 in DefDatabase <ResearchProjectDef> .AllDefsListForReading)
                    {
                        if (current2 != current3 && current2.tab == current3.tab)
                        {
                            bool flag2 = Mathf.Abs(current2.x - current3.x) < 0.5f;
                            bool flag3 = Mathf.Abs(current2.y - current3.y) < 0.25f;
                            if (flag2 && flag3)
                            {
                                flag = true;
                                if (current2.x <= current3.x)
                                {
                                    current2.x -= 0.1f;
                                    current3.x += 0.1f;
                                }
                                else
                                {
                                    current2.x += 0.1f;
                                    current3.x -= 0.1f;
                                }
                                if (current2.y <= current3.y)
                                {
                                    current2.y -= 0.1f;
                                    current3.y += 0.1f;
                                }
                                else
                                {
                                    current2.y += 0.1f;
                                    current3.y -= 0.1f;
                                }
                                current2.x += 0.001f;
                                current2.y += 0.001f;
                                current3.x -= 0.001f;
                                current3.y -= 0.001f;
                                ResearchProjectDef.ClampInCoordinateLimits(current2);
                                ResearchProjectDef.ClampInCoordinateLimits(current3);
                            }
                        }
                    }
                }
                if (!flag)
                {
                    break;
                }
                num++;
                if (num > 200)
                {
                    goto Block_4;
                }
            }
            return;

Block_4:
            Log.Error("Couldn't relax research project coordinates apart after " + 200 + " passes.");
        }