Example #1
0
        private static void GameHistoryDataPostPatch(GameHistoryData __instance)
        {
            ProtoRegister.Logger.LogInfo("GameHistoryDataPatch.Postfix invoked.");

            ProtoRegister.AddRecipeProtos
            .Where(proto => proto.preTech != null && __instance.TechState(proto.preTech.ID).unlocked&& !__instance.RecipeUnlocked(proto.ID))
            .ForEach(proto => __instance.UnlockRecipe(proto.ID));
        }
Example #2
0
        private static void UnlockTechRecursive(int techId, GameHistoryData history)
        {
            TechState state = history.TechState(techId);
            TechProto proto = LDB.techs.Select(techId);

            foreach (var techReq in proto.PreTechs)
            {
                if (!history.TechState(techReq).unlocked)
                {
                    UnlockTechRecursive(techReq, history);
                }
            }
            foreach (var techReq in proto.PreTechsImplicit)
            {
                if (!history.TechState(techReq).unlocked)
                {
                    UnlockTechRecursive(techReq, history);
                }
            }
            foreach (var itemReq in proto.itemArray)
            {
                if (itemReq.preTech is not null && !history.TechState(itemReq.preTech.ID).unlocked)
                {
                    UnlockTechRecursive(itemReq.preTech.ID, history);
                }
            }

            int current = state.curLevel;

            for (; current < state.maxLevel; current++)
            {
                for (int j = 0; j < proto.UnlockFunctions.Length; j++)
                {
                    history.UnlockTechFunction(proto.UnlockFunctions[j], proto.UnlockValues[j], current);
                }
            }

            history.UnlockTech(techId);
        }
Example #3
0
 private static void HistoryPatch(GameHistoryData __instance)
 {
     foreach (var proto in TotalDict[ProtoType.Recipe])
     {
         var recipe = proto as RecipeProto;
         if (recipe.preTech != null)
         {
             if (__instance.TechState(recipe.preTech.ID).unlocked)
             {
                 if (!__instance.RecipeUnlocked(recipe.ID))
                 {
                     __instance.UnlockRecipe(recipe.ID);
                 }
             }
         }
     }
 }