Ludeon Forums

RimWorld => Mods => Help => Topic started by: henryheyhey123 on August 24, 2015, 05:21:05 PM

Title: Researchable recipes help
Post by: henryheyhey123 on August 24, 2015, 05:21:05 PM
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!  :) :)
Title: Re: Researchable recipes help
Post by: 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 (https://ludeon.com/forums/index.php?topic=14172.0).
Title: Re: Researchable recipes help
Post by: henryheyhey123 on August 24, 2015, 05:29:31 PM
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 (https://ludeon.com/forums/index.php?topic=14172.0).

Ahhhh ok  :) I had absolutely no idea this was finally a thing  :o Thanks for the info
Title: Re: Researchable recipes help
Post by: Ykara on August 26, 2015, 05:35:34 PM
Wow, I didn't notice that! That makes things a lot less complicate!
Title: Re: Researchable recipes help
Post by: Orion on October 04, 2015, 04:04:11 PM
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?