Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CustomRecipesFramework
- {
- public static bool AreRecipesLoaded = false;
- private static void CreateRecipe(string recipeName, int obtaintedItemID, int[] ingredientIDs, int[] howManyXIngredient, CraftingRecipe.Type type, int howManyObtained = 1, WeaponMod weaponMod = null)
- {
- if (ingredientIDs.Length != howManyXIngredient.Length)
- return;
- int howManyIngredients = ingredientIDs.Length;
- CraftingRecipe craftingRecipe = new CraftingRecipe();
- //ResultingItem resultingItem = new ResultingItem();
- Il2CppSystem.Collections.Generic.List<ResultingItem> resultingItems = new Il2CppSystem.Collections.Generic.List<ResultingItem>();
- // name of recipe
- craftingRecipe.name = recipeName;
- // the obtained item ID
- //resultingItem.Id = obtaintedItemID;
- // adding the item/s to the obtained item list & setting it to the recipe
- for (int i = 0; i < howManyObtained; i++)
- {
- ResultingItem resultingItem = new ResultingItem();
- resultingItem.Id = obtaintedItemID;
- resultingItems.Add(resultingItem);
- }
- craftingRecipe._resultingItems = resultingItems;
- // setting recipe parameters
- craftingRecipe._recipeType = type;
- craftingRecipe._forceNewItemInstance = false;
- craftingRecipe._weaponMod = weaponMod;
- Il2CppSystem.Collections.Generic.List<CraftingIngredient> ingredients = new Il2CppSystem.Collections.Generic.List<CraftingIngredient>();
- int currentPointedIngredient = 0;
- for (int i = 0; i < howManyIngredients; i++)
- {
- CraftingIngredient craftingIngredient = new CraftingIngredient();
- craftingIngredient.Count = howManyXIngredient.ElementAt(currentPointedIngredient);
- craftingIngredient.ItemId = ingredientIDs.ElementAt(currentPointedIngredient);
- craftingIngredient.IsReusable = false;
- ingredients.Add(craftingIngredient);
- currentPointedIngredient++;
- }
- // adding ingredients to the final recipe
- craftingRecipe._ingredients = ingredients;
- // Adding to game database
- CraftingSystem instance = CraftingSystem.Instance;
- if (!instance)
- return;
- CraftingRecipeDatabase database = instance._recipeDatabase;
- database._recipes.Add(craftingRecipe);
- }
- public static void CreateNewRecipes()
- {
- CreateRecipe("RockRecipe", (int)ItemIDs.ItemID.Rock,
- new int[] { (int)ItemIDs.ItemID.SmallRocks },
- new int[] { 4 }, CraftingRecipe.Type.CraftNewItem);
- CreateRecipe("BatteryRecipe", (int)ItemIDs.ItemID.Batteries,
- new int[] { (int)ItemIDs.ItemID.Coins, (int)ItemIDs.ItemID.CircuitBoard },
- new int[] { 5, 1 }, CraftingRecipe.Type.CraftNewItem);
- CreateRecipe("C4BrickRecipe", (int)ItemIDs.ItemID.C4Brick,
- new int[] { (int)ItemIDs.ItemID.Coins, (int)ItemIDs.ItemID.PistolAmmo },
- new int[] { 20, 25 }, CraftingRecipe.Type.CraftNewItem);
- CreateRecipe("CanOpenerRecipe", (int)ItemIDs.ItemID.CanOpener,
- new int[] { (int)ItemIDs.ItemID.Coins, (int)ItemIDs.ItemID.DuctTape, (int)ItemIDs.ItemID.Watch },
- new int[] { 15, 1, 2 }, CraftingRecipe.Type.CraftNewItem);
- // better to create atleast 2 of them at time
- CreateRecipe("ClothRecipe", (int)ItemIDs.ItemID.Cloth,
- new int[] { (int)ItemIDs.ItemID.Cash, (int)ItemIDs.ItemID.Wire },
- new int[] { 5, 1 }, CraftingRecipe.Type.CraftNewItem);
- CreateRecipe("DuctTapeRecipe", (int)ItemIDs.ItemID.DuctTape,
- new int[] { (int)ItemIDs.ItemID.Cash, (int)ItemIDs.ItemID.Rope },
- new int[] { 5, 1 }, CraftingRecipe.Type.CraftNewItem);
- CreateRecipe("FragGrenade", (int)ItemIDs.ItemID.FragGrenade,
- new int[] { (int)ItemIDs.ItemID.Coins, (int)ItemIDs.ItemID.ShotgunSlugAmmo },
- new int[] { 30, 15 }, CraftingRecipe.Type.CraftNewItem);
- CreateRecipe("MedsRecipe", (int)ItemIDs.ItemID.Meds,
- new int[] { (int)ItemIDs.ItemID.AloeVera },
- new int[] { 3 }, CraftingRecipe.Type.CraftNewItem);
- MelonLogger.Msg("Custom recipes loaded");
- AreRecipesLoaded = true;
- }
- }
Add Comment
Please, Sign In to add comment