Researchable recipes help

Started by henryheyhey123, August 24, 2015, 05:21:05 PM

Previous topic - Next topic

henryheyhey123

Hiya peeps, I've recently updated a really old mod of mine called Resource Duplexer, which could unlock recipes for the worktable i made for it via research. It used an invisible worktable (called "ResourceDuplexerDummy") to store the recipes which would on the rare tick check if the research is done, then if it was add the recipes and never do so again. This is the code I used in my assembly file:

public class Building_ResourceDuplexer : Building_WorkTable
    {
        private bool ResourceDuplexerMKIII = false;
        private bool ResourceDuplexerMKII = false;
   
        public override void TickRare()
        {
            base.TickRare();

            if ((ResourceDuplexerMKII == false) && (Find.ResearchManager.IsFinished(ResearchProjectDef.Named("Unlock_RDUse1")) == true))
            {
               
                Thing RecipeHolder = ThingMaker.MakeThing(ThingDef.Named("ResourceDuplexerDummy"));
                RecipeDef recipeToAddDefMKII1 = RecipeHolder.def.recipes.Find(myRecipe1 => myRecipe1.defName == "DoubleWoodStack");
               
                def.recipes.Add(recipeToAddDefMKII1);

                ResourceDuplexerMKII = true;
            }
            if ((ResourceDuplexerMKIII == false) && (Find.ResearchManager.IsFinished(ResearchProjectDef.Named("Unlock_RDUse2")) == true))
            {

                Thing RecipeHolder = ThingMaker.MakeThing(ThingDef.Named("ResourceDuplexerDummy"));
                RecipeDef recipeToAddDefMKIII1 = RecipeHolder.def.recipes.Find(myRecipe5 => myRecipe5.defName == "DoubleAICore");
                RecipeDef recipeToAddDefMKIII2 = RecipeHolder.def.recipes.Find(myRecipe7 => myRecipe7.defName == "DoubleUranium");
               
                def.recipes.Add(recipeToAddDefMKIII1);
                def.recipes.Add(recipeToAddDefMKIII2);

                ResourceDuplexerMKIII = true;
            }

            base.TickRare();
        }
    }


Any help on how to adapt to the 6 alpha updates since it was last updated will be greatly appreciated!  :) :)

1000101

That situation has been make obsolete, Alpha 12 added a researchPrerequisite tag to recipes.  For more complex needs, there is the Community Core Library.
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

henryheyhey123

Quote from: 1000101 on August 24, 2015, 05:28:06 PM
That situation has been make obsolete, Alpha 12 added a researchPrerequisite tag to recipes.  For more complex needs, there is the Community Core Library.

Ahhhh ok  :) I had absolutely no idea this was finally a thing  :o Thanks for the info

Ykara

Wow, I didn't notice that! That makes things a lot less complicate!

Orion

Quote from: 1000101 on August 24, 2015, 05:28:06 PM
That situation has been make obsolete, Alpha 12 added a researchPrerequisite tag to recipes.

I'm trying to get the researchPrerequisite tag to work on a recipe, but it seems to just ignore it, as if the research was already done. Did anyone successfully use this? Any tips?