public static void AddCustomRecipe(GameObject prefab, Items.RecipesConfig recipes, bool craftingMode) { var recipe = ScriptableObject.CreateInstance <Recipe>(); recipe.m_item = prefab.GetComponent <ItemDrop>(); var neededResources = new List <Piece.Requirement>(); foreach (var rec in recipes.recipes) { if (rec.name == prefab.name) { foreach (var component in rec.resources) { neededResources.Add(MockRequirement.Create(component.item, component.amount)); } if (rec.craftingStation != null && craftingMode != true) { recipe.m_craftingStation = Mock <CraftingStation> .Create(rec.craftingStation); } if (rec.repairStation != null) { recipe.m_repairStation = Mock <CraftingStation> .Create(rec.repairStation); } recipe.m_amount = rec.amount; recipe.m_minStationLevel = rec.minStationLevel; recipe.m_resources = neededResources.ToArray(); } } CustomRecipe newRecipe = new CustomRecipe(recipe, fixReference: true, true); ObjectDBHelper.Add(newRecipe); }
public BlueprintRunePrefab(AssetBundle assetBundle) { PieceManager.Instance.AddPieceTable(assetBundle.LoadAsset <GameObject>(PieceTableName)); runeprefab = assetBundle.LoadAsset <GameObject>(BlueprintRuneName); CustomItem rune = new CustomItem(runeprefab, fixReference: false); ItemManager.Instance.AddItem(rune); BlueprintRuneItemName = rune.ItemDrop.m_itemData.m_shared.m_name; rune.ItemDrop.m_itemData.m_shared.m_buildPieces = PieceManager.Instance.GetPieceTable(PlanPiecePrefab.PlanHammerPieceTableName); CustomRecipe runeRecipe = new CustomRecipe(new RecipeConfig() { Item = BlueprintRuneName, Amount = 1, Requirements = new RequirementConfig[] { new RequirementConfig { Item = "Stone", Amount = 1 } } }); ItemManager.Instance.AddRecipe(runeRecipe); GameObject makebp_prefab = assetBundle.LoadAsset <GameObject>(MakeBlueprintName); PrefabManager.Instance.AddPrefab(makebp_prefab); GameObject placebp_prefab = assetBundle.LoadAsset <GameObject>(Blueprint.BlueprintPrefabName); PrefabManager.Instance.AddPrefab(placebp_prefab); PrefabManager.Instance.AddPrefab(assetBundle.LoadAsset <GameObject>(BlueprintSnapPointName)); PrefabManager.Instance.AddPrefab(assetBundle.LoadAsset <GameObject>(BlueprintCenterPointName)); PrefabManager.Instance.AddPrefab(assetBundle.LoadAsset <GameObject>(UndoBlueprintName)); PrefabManager.Instance.AddPrefab(assetBundle.LoadAsset <GameObject>(DeletePlansName)); }
public OverclockEfficiencyCorePrefabConfig() : base(SurtlingCoreOverclocking.oldEfficiencyCoreKey, "SurtlingCore") { Texture2D texture = AssetUtils.LoadTexture(SurtlingCoreOverclockingMod.GetAssetPath("icons/efficiency_core.png")); sprite = Sprite.Create(texture, new Rect(0f, 0f, texture.width, texture.height), Vector2.zero); Recipe = new CustomRecipe(new RecipeConfig() { Item = SurtlingCoreOverclocking.oldEfficiencyCoreKey, CraftingStation = "forge", Requirements = new RequirementConfig[] { new RequirementConfig() { Item = "SurtlingCore", Amount = 1 }, new RequirementConfig() { Item = "Guck", Amount = 1 }, new RequirementConfig() { Item = "Ruby", Amount = 1 } } }); }
public OverclockCoreSlotPrefabConfig() : base(SurtlingCoreOverclocking.oldCoreSlotKey, "SurtlingCore") { Texture2D texture = AssetUtils.LoadTexture(SurtlingCoreOverclockingMod.GetAssetPath("icons/core_slot.png")); sprite = Sprite.Create(texture, new Rect(0f, 0f, texture.width, texture.height), Vector2.zero); Recipe = new CustomRecipe(new RecipeConfig() { Item = SurtlingCoreOverclocking.oldCoreSlotKey, CraftingStation = "piece_artisanstation", Requirements = new RequirementConfig[] { new RequirementConfig() { Item = "SurtlingCore", Amount = 1 }, new RequirementConfig() { Item = "YmirRemains", Amount = 1 }, new RequirementConfig() { Item = "Crystal", Amount = 1 } } }); }
private static void AddRecipe() { var frRecipe = ScriptableObject.CreateInstance <Recipe>(); var irRecipe = ScriptableObject.CreateInstance <Recipe>(); var bmRecipe = ScriptableObject.CreateInstance <Recipe>(); frRecipe.m_item = AssetHelper.FolcbrandPrefab.GetComponent <ItemDrop>(); irRecipe.m_item = AssetHelper.GreatswordIronPrefab.GetComponent <ItemDrop>(); bmRecipe.m_item = AssetHelper.GreatswordBlackmetalPrefab.GetComponent <ItemDrop>(); UtilityFunctions.GetRecipe(ref frRecipe, balance["GreatswordFolcbrand"]); UtilityFunctions.GetRecipe(ref irRecipe, balance["GreatswordIron"]); UtilityFunctions.GetRecipe(ref bmRecipe, balance["GreatswordBlackmetal"]); folcbrandRecipe = new CustomRecipe(frRecipe, true, true); ironRecipe = new CustomRecipe(irRecipe, true, true); blackmetalRecipe = new CustomRecipe(bmRecipe, true, true); if ((bool)balance["GreatswordFolcbrand"]["enabled"]) { ItemManager.Instance.AddRecipe(folcbrandRecipe); } if ((bool)balance["GreatswordIron"]["enabled"]) { ItemManager.Instance.AddRecipe(ironRecipe); } if ((bool)balance["GreatswordBlackmetal"]["enabled"]) { ItemManager.Instance.AddRecipe(blackmetalRecipe); } }
public OverclockSpeedCorePrefabConfig() : base(SurtlingCoreOverclocking.oldSpeedCoreKey, "SurtlingCore") { Texture2D texture = AssetUtils.LoadTexture(SurtlingCoreOverclockingMod.GetAssetPath("icons/speed_core.png")); sprite = Sprite.Create(texture, new Rect(0f, 0f, texture.width, texture.height), Vector2.zero); Recipe = new CustomRecipe(new RecipeConfig() { Item = SurtlingCoreOverclocking.oldSpeedCoreKey, CraftingStation = "forge", Requirements = new RequirementConfig[] { new RequirementConfig() { Item = "SurtlingCore", Amount = 1 }, new RequirementConfig() { Item = "Chain", Amount = 1 }, new RequirementConfig() { Item = "DeerHide", Amount = 1 }, new RequirementConfig() { Item = "Wood", Amount = 2 } } }); }
// Implementation of assets via using manual recipe creation and prefab cache's private void RecipeEvilSword(ItemDrop itemDrop) { // Create and add a recipe for the copied item Recipe recipe = ScriptableObject.CreateInstance <Recipe>(); recipe.name = "Recipe_EvilSword"; recipe.m_item = itemDrop; recipe.m_craftingStation = PrefabManager.Cache.GetPrefab <CraftingStation>("piece_workbench"); recipe.m_resources = new Piece.Requirement[] { new Piece.Requirement() { m_resItem = PrefabManager.Cache.GetPrefab <ItemDrop>("Stone"), m_amount = 1 }, new Piece.Requirement() { m_resItem = PrefabManager.Cache.GetPrefab <ItemDrop>("CustomWood"), m_amount = 1 } }; CustomRecipe CR = new CustomRecipe(recipe, false, false); ItemManager.Instance.AddRecipe(CR); }
// Implementation of assets using mocks, adding recipe's manually without the config abstraction private void AddMockedItems() { if (!backpackPrefab) { Jotunn.Logger.LogWarning($"Failed to load asset from bundle: {embeddedResourceBundle}"); } else { // Create and add a custom item CustomItem CI = new CustomItem(backpackPrefab, true); ItemManager.Instance.AddItem(CI); //Create and add a custom recipe Recipe recipe = ScriptableObject.CreateInstance <Recipe>(); recipe.m_item = backpackPrefab.GetComponent <ItemDrop>(); recipe.m_craftingStation = Mock <CraftingStation> .Create("piece_workbench"); var ingredients = new List <Piece.Requirement> { MockRequirement.Create("LeatherScraps", 10), MockRequirement.Create("DeerHide", 2), MockRequirement.Create("Iron", 4), }; recipe.m_resources = ingredients.ToArray(); CustomRecipe CR = new CustomRecipe(recipe, true, true); ItemManager.Instance.AddRecipe(CR); //Enable BoneReorder BoneReorder.ApplyOnEquipmentChanged(); } embeddedResourceBundle.Unload(false); }
private void RecipeHearthStone(ItemDrop itemDrop) { Recipe recipe = ScriptableObject.CreateInstance <Recipe>(); recipe.name = "Recipe_Hearthstone"; recipe.m_item = itemDrop; recipe.m_craftingStation = PrefabManager.Cache.GetPrefab <CraftingStation>("piece_workbench"); recipe.m_resources = new Piece.Requirement[] { new Piece.Requirement() { m_resItem = PrefabManager.Cache.GetPrefab <ItemDrop>(item1.Value), m_amount = itemCost1.Value }, new Piece.Requirement() { m_resItem = PrefabManager.Cache.GetPrefab <ItemDrop>(item2.Value), m_amount = itemCost2.Value }, new Piece.Requirement() { m_resItem = PrefabManager.Cache.GetPrefab <ItemDrop>(item3.Value), m_amount = itemCost3.Value } }; CustomRecipe CR = new CustomRecipe(recipe, fixReference: false, fixRequirementReferences: false); ItemManager.Instance.AddRecipe(CR); }
private static void AddRecipe() { var recipeFire = ScriptableObject.CreateInstance <Recipe>(); var recipeFrost = ScriptableObject.CreateInstance <Recipe>(); var recipeLightning = ScriptableObject.CreateInstance <Recipe>(); recipeFire.m_item = AssetHelper.BombFirePrefab.GetComponent <ItemDrop>(); recipeFrost.m_item = AssetHelper.BombFrostPrefab.GetComponent <ItemDrop>(); recipeLightning.m_item = AssetHelper.BombLightningPrefab.GetComponent <ItemDrop>(); var itemReqsFire = new List <Piece.Requirement> { MockRequirement.Create("Coal", 10), MockRequirement.Create("Ooze", 5), MockRequirement.Create("LeatherScraps", 5), }; recipeFire.m_amount = 5; recipeFire.name = "Recipe_BombFire"; var itemReqsFrost = new List <Piece.Requirement> { MockRequirement.Create("FreezeGland", 5), MockRequirement.Create("Ooze", 5), MockRequirement.Create("LeatherScraps", 5), }; recipeFrost.m_amount = 5; recipeFrost.name = "Recipe_BombFrost"; var itemReqsLightning = new List <Piece.Requirement> { MockRequirement.Create("HardAntler", 1), MockRequirement.Create("Ooze", 5), MockRequirement.Create("LeatherScraps", 5), }; recipeLightning.m_amount = 5; recipeLightning.name = "Recipe_BombLightning"; recipeFire.m_resources = itemReqsFire.ToArray(); recipeFrost.m_resources = itemReqsFrost.ToArray(); recipeLightning.m_resources = itemReqsLightning.ToArray(); recipeFire.m_craftingStation = Mock <CraftingStation> .Create(CraftingStationPrefabName); recipeFrost.m_craftingStation = Mock <CraftingStation> .Create(CraftingStationPrefabName); recipeLightning.m_craftingStation = Mock <CraftingStation> .Create(CraftingStationPrefabName); customRecipeFire = new CustomRecipe(recipeFire, true, true); customRecipeFrost = new CustomRecipe(recipeFrost, true, true); customRecipeLightning = new CustomRecipe(recipeLightning, true, true); ItemManager.Instance.AddRecipe(customRecipeFire); ItemManager.Instance.AddRecipe(customRecipeFrost); ItemManager.Instance.AddRecipe(customRecipeLightning); }
/// <summary> /// Remove a custom recipe by its ref. Removes it from the manager and the <see cref="ObjectDB"/>, if instantiated. /// </summary> /// <param name="recipe"><see cref="CustomRecipe"/> to remove.</param> public void RemoveRecipe(CustomRecipe recipe) { Recipes.Remove(recipe); if (recipe.Recipe != null && ObjectDB.instance != null && ObjectDB.instance.m_recipes.Contains(recipe.Recipe)) { ObjectDB.instance.m_recipes.Remove(recipe.Recipe); } }
private static void AddCustomItems() { //Create a clone of existing game asset helmet troll leather for our Surtling Helm var mock = Mock<ItemDrop>.Create("HelmetTrollLeather"); var cloned = Prefab.GetRealPrefabFromMock<ItemDrop>(mock).gameObject.InstantiateClone($"{LanguageData.TokenValue}", true); cloned.name = LanguageData.TokenValue; //Set the new data on the ItemDrop component of our new helm var newItemPrefab = cloned; var helm = new CustomItem(cloned, fixReference: true); var item = helm.ItemDrop; item.m_itemData.m_dropPrefab = newItemPrefab; item.m_itemData.m_shared.m_name = LanguageData.TokenName; item.m_itemData.m_shared.m_description = LanguageData.TokenDescriptionName; item.m_itemData.m_shared.m_icons = new Sprite[] { AssetHelper.Icon }; item.m_itemData.m_shared.m_setName = string.Empty; item.m_itemData.m_shared.m_setSize = 0; item.m_itemData.m_shared.m_setStatusEffect = null; item.m_itemData.m_shared.m_equipStatusEffect = Prefab.Cache.GetPrefab<SE_SurtlingEquippedEffect>(LanguageData.EffectValue); item.m_itemData.m_shared.m_backstabBonus = 1; //Tweak the material to make the helmet purple var meshRenderer = newItemPrefab.transform.GetComponentInChildren<MeshRenderer>(); var colorTarget = new Color(255f / 255f, 0f, 194f / 255f, 255f / 255f); meshRenderer.material.color = colorTarget; var skinnedRenderer = newItemPrefab.transform.Find("attach_skin/hood").GetComponent<SkinnedMeshRenderer>(); skinnedRenderer.material.color = colorTarget; //Add to the object db, along with our new network-synced prefabs ObjectDBHelper.Add(helm); Prefab.NetworkRegister(AssetHelper.EyeGlowPrefab); Prefab.NetworkRegister(AssetHelper.EyeBeamPrefab); Prefab.NetworkRegister(AssetHelper.EyeHitPrefab); //Create a recipe to craft the helm var recipe = ScriptableObject.CreateInstance<Recipe>(); recipe.name = "Recipe_SurtlingHelm"; recipe.m_item = helm.ItemDrop; recipe.m_enabled = true; recipe.m_minStationLevel = Math.Max(Math.Min(SH.WorkbenchLevelRequired.Value, 5), 0); recipe.m_craftingStation = Mock<CraftingStation>.Create("piece_workbench"); var req = new List<Piece.Requirement>(); //Add required items list to recipe if (SH.SurtlingRequired.Value > 0) req.Add(MR.Create("SurtlingCore", SH.SurtlingRequired.Value)); if (SH.TrollHideRequired.Value > 0) req.Add(MR.Create("TrollHide", SH.TrollHideRequired.Value)); if (SH.LinenThreadRequired.Value > 0) req.Add(MR.Create("LinenThread", SH.LinenThreadRequired.Value)); if (SH.SurtlingTrophyRequired.Value > 0) req.Add(MR.Create("TrophySurtling", SH.SurtlingTrophyRequired.Value)); if (req.Count == 0) req.Add(MR.Create("Wood", 1)); recipe.m_resources = req.ToArray(); var helmRecipe = new CustomRecipe(recipe, true, true); ObjectDBHelper.Add(helmRecipe); }
private static void AddRecipe() { var recipe = ScriptableObject.CreateInstance <Recipe>(); recipe.m_item = AssetHelper.ParryingDaggerPrefab.GetComponent <ItemDrop>(); UtilityFunctions.GetRecipe(ref recipe, balance["ParryingDagger"]); customRecipe = new CustomRecipe(recipe, true, true); ItemManager.Instance.AddRecipe(customRecipe); }
private static void AddRecipe() { var recipe = ScriptableObject.CreateInstance <Recipe>(); recipe.m_item = AssetHelper.AxeForstascaPrefab.GetComponent <ItemDrop>(); UtilityFunctions.GetRecipe(ref recipe, balance["AxeForstasca"]); customRecipe = new CustomRecipe(recipe, true, true); if ((bool)balance["AxeForstasca"]["enabled"]) { ItemManager.Instance.AddRecipe(customRecipe); } }
private void AddInvalidItems() { CustomItem CI = new CustomItem("item_faulty", false); if (CI != null) { CI.ItemDrop.m_itemData.m_shared.m_icons = new Sprite[] { testSprite }; ItemManager.Instance.AddItem(CI); CustomRecipe CR = new CustomRecipe(new RecipeConfig { Item = "item_faulty", Requirements = new RequirementConfig[] { new RequirementConfig { Item = "NotReallyThereResource", Amount = 99 } } }); ItemManager.Instance.AddRecipe(CR); } CustomPiece CP = new CustomPiece("piece_fukup", "Hammer"); if (CP != null) { var piece = CP.Piece; piece.m_icon = testSprite; var prefab = CP.PiecePrefab; // Test faulty resource, do it manually cause there is no config on empty pieces atm var cfg = new PieceConfig { Requirements = new RequirementConfig[] { new RequirementConfig { Item = "StillNotThereResource", Amount = 99 } } }; cfg.Apply(prefab); CP.FixReference = true; PieceManager.Instance.AddPiece(CP); } }
//Add custom recipe to the customRecipes table and returns true/false on success/failure public async Task <bool> AddCustomRecipe(CustomRecipe customRecipe) { try { await _context.CustomRecipes.AddAsync(customRecipe); _context.SaveChanges(); return(true); } catch (Exception ex) { Console.WriteLine(ex); return(false); } }
private static void AddRecipe() { var recipe = ScriptableObject.CreateInstance <Recipe>(); var recipeBronze = ScriptableObject.CreateInstance <Recipe>(); var recipeIron = ScriptableObject.CreateInstance <Recipe>(); var recipeSilver = ScriptableObject.CreateInstance <Recipe>(); var recipeBlackmetal = ScriptableObject.CreateInstance <Recipe>(); recipe.m_item = AssetHelper.ThrowingAxeFlintPrefab.GetComponent <ItemDrop>(); recipeBronze.m_item = AssetHelper.ThrowingAxeBronzePrefab.GetComponent <ItemDrop>(); recipeIron.m_item = AssetHelper.ThrowingAxeIronPrefab.GetComponent <ItemDrop>(); recipeSilver.m_item = AssetHelper.ThrowingAxeSilverPrefab.GetComponent <ItemDrop>(); recipeBlackmetal.m_item = AssetHelper.ThrowingAxeBlackmetalPrefab.GetComponent <ItemDrop>(); UtilityFunctions.GetRecipe(ref recipe, balance["ThrowingAxeFlint"]); UtilityFunctions.GetRecipe(ref recipeBronze, balance["ThrowingAxeBronze"]); UtilityFunctions.GetRecipe(ref recipeIron, balance["ThrowingAxeIron"]); UtilityFunctions.GetRecipe(ref recipeSilver, balance["ThrowingAxeSilver"]); UtilityFunctions.GetRecipe(ref recipeBlackmetal, balance["ThrowingAxeBlackmetal"]); customRecipeFlint = new CustomRecipe(recipe, true, true); customRecipeBronze = new CustomRecipe(recipeBronze, true, true); customRecipeIron = new CustomRecipe(recipeIron, true, true); customRecipeSilver = new CustomRecipe(recipeSilver, true, true); customRecipeBlackmetal = new CustomRecipe(recipeBlackmetal, true, true); if ((bool)balance["ThrowingAxeFlint"]["enabled"]) { ItemManager.Instance.AddRecipe(customRecipeFlint); } if ((bool)balance["ThrowingAxeBronze"]["enabled"]) { ItemManager.Instance.AddRecipe(customRecipeBronze); } if ((bool)balance["ThrowingAxeIron"]["enabled"]) { ItemManager.Instance.AddRecipe(customRecipeIron); } if ((bool)balance["ThrowingAxeSilver"]["enabled"]) { ItemManager.Instance.AddRecipe(customRecipeSilver); } if ((bool)balance["ThrowingAxeBlackmetal"]["enabled"]) { ItemManager.Instance.AddRecipe(customRecipeBlackmetal); } }
/// <summary> /// Add a <see cref="CustomRecipe"/> to the game.<br /> /// Checks if the custom recipe is unique and adds it to the list of custom recipes.<br /> /// Custom recipes are added to the current <see cref="ObjectDB"/> on every <see cref="ObjectDB.Awake"/>. /// </summary> /// <param name="customRecipe">The custom recipe to add.</param> /// <returns>true if the custom recipe was added to the manager.</returns> public bool AddRecipe(CustomRecipe customRecipe) { if (!customRecipe.IsValid()) { Logger.LogWarning($"Custom recipe {customRecipe} is not valid"); return(false); } if (Recipes.Contains(customRecipe)) { Logger.LogWarning($"Custom recipe {customRecipe} already added"); return(false); } Recipes.Add(customRecipe); return(true); }
// Add new items with mocked prefabs private void AddMockedItems() { // Load assets from resources var assetstream = typeof(TestMod).Assembly.GetManifestResourceStream("TestMod.AssetsEmbedded.capeironbackpack"); if (assetstream == null) { Jotunn.Logger.LogWarning("Requested asset stream could not be found."); } else { var assetBundle = AssetBundle.LoadFromStream(assetstream); var prefab = assetBundle.LoadAsset <GameObject>("Assets/Evie/CapeIronBackpack.prefab"); if (!prefab) { Jotunn.Logger.LogWarning($"Failed to load asset from bundle: {assetBundle}"); } else { // Create and add a custom item var CI = new CustomItem(prefab, fixReference: true); // Mocked refs in prefabs need to be fixed ItemManager.Instance.AddItem(CI); // Create and add a custom recipe var recipe = ScriptableObject.CreateInstance <Recipe>(); recipe.name = "Recipe_Backpack"; recipe.m_item = prefab.GetComponent <ItemDrop>(); recipe.m_craftingStation = Mock <CraftingStation> .Create("piece_workbench"); var ingredients = new List <Piece.Requirement> { MockRequirement.Create("LeatherScraps", 10), MockRequirement.Create("DeerHide", 2), MockRequirement.Create("Iron", 4) }; recipe.m_resources = ingredients.ToArray(); var CR = new CustomRecipe(recipe, fixReference: true, fixRequirementReferences: true); // Mocked main and requirement refs need to be fixed ItemManager.Instance.AddRecipe(CR); // Enable BoneReorder BoneReorder.ApplyOnEquipmentChanged(); } assetBundle.Unload(false); } }
private static void AddCustomRecipe() { var recipe = ScriptableObject.CreateInstance <Recipe>(); recipe.m_item = AssetHelper.LeadPrefab.GetComponent <ItemDrop>(); var neededResources = new List <Piece.Requirement> { MockRequirement.Create("Ooze", 4), MockRequirement.Create("DeerHide", 2), }; recipe.m_resources = neededResources.ToArray(); CustomRecipe = new CustomRecipe(recipe, false, true); ObjectDBHelper.Add(CustomRecipe); }
private void LoadCraftedItem(GameObject prefab, List <Piece.Requirement> ingredients, string craftingStation = "piece_workbench") { if (prefab) { var CI = new CustomItem(prefab, true); var recipe = ScriptableObject.CreateInstance <Recipe>(); recipe.name = prefab.name; recipe.m_item = prefab.GetComponent <ItemDrop>(); recipe.m_craftingStation = Mock <CraftingStation> .Create(craftingStation); recipe.m_resources = ingredients.ToArray(); var CR = new CustomRecipe(recipe, true, true); ItemManager.Instance.AddItem(CI); ItemManager.Instance.AddRecipe(CR); Main.log.LogDebug($"Successfully loaded new CraftedItem {prefab.name} for {craftingStation}."); } }
private static void AddRecipe() { var recipe = ScriptableObject.CreateInstance <Recipe>(); var recipeBronze = ScriptableObject.CreateInstance <Recipe>(); recipe.m_item = AssetHelper.JavelinFlintPrefab.GetComponent <ItemDrop>(); recipeBronze.m_item = AssetHelper.JavelinBronzePrefab.GetComponent <ItemDrop>(); UtilityFunctions.GetRecipe(ref recipe, balance["JavelinFlint"]); UtilityFunctions.GetRecipe(ref recipeBronze, balance["JavelinBronze"]); customRecipeFlint = new CustomRecipe(recipe, true, true); customRecipeBronze = new CustomRecipe(recipeBronze, true, true); ItemManager.Instance.AddRecipe(customRecipeFlint); ItemManager.Instance.AddRecipe(customRecipeBronze); }
/* * Private Methods */ private static void AddCustomRecipe() { var recipe = ScriptableObject.CreateInstance <Recipe>(); recipe.m_item = MeadPewterPrefab.GetComponent <ItemDrop>(); recipe.m_amount = 10; var neededResources = new List <Piece.Requirement> { MockRequirement.Create("Pewter", 1), MockRequirement.Create("MeadTasty", 2), }; recipe.m_resources = neededResources.ToArray(); recipe.m_craftingStation = Mock <CraftingStation> .Create(CraftingStationPrefabName); CustomRecipe = new CustomRecipe(recipe, fixReference: true, true); ObjectDBHelper.Add(CustomRecipe); }
//Update custom recipe for customRecipes table and returns true/false on success/failure public async Task <bool> UpdateRecipe(CustomRecipe customRecipe) { try { var recipe = await _context.CustomRecipes.SingleOrDefaultAsync(r => r.Id == customRecipe.Id); recipe.RecipeName = customRecipe.RecipeName; recipe.Ingredients = customRecipe.Ingredients; recipe.Directions = customRecipe.Directions; recipe.Notes = customRecipe.Notes; _context.SaveChanges(); return(true); } catch (Exception ex) { Console.WriteLine(ex); return(false); } }
private static void AddRecipe() { var recipe = ScriptableObject.CreateInstance <Recipe>(); var recipeBR = ScriptableObject.CreateInstance <Recipe>(); var recipeBM = ScriptableObject.CreateInstance <Recipe>(); var recipeSil = ScriptableObject.CreateInstance <Recipe>(); recipe.m_item = AssetHelper.BattleaxeBlackmetalPrefab.GetComponent <ItemDrop>(); recipeBR.m_item = AssetHelper.BattleaxeBronzePrefab.GetComponent <ItemDrop>(); recipeBM.m_item = AssetHelper.GreateaxeBlackmetalPrefab.GetComponent <ItemDrop>(); recipeSil.m_item = AssetHelper.BattleaxeSilverPrefab.GetComponent <ItemDrop>(); UtilityFunctions.GetRecipe(ref recipe, balance["AxehammerBlackmetal"]); UtilityFunctions.GetRecipe(ref recipeBM, balance["BattleaxeBlackmetal"]); UtilityFunctions.GetRecipe(ref recipeBR, balance["BattleaxeBronze"]); UtilityFunctions.GetRecipe(ref recipeSil, balance["BattleaxeSilver"]); customRecipe = new CustomRecipe(recipe, true, true); customRecipeBronze = new CustomRecipe(recipeBR, true, true); customRecipeBM = new CustomRecipe(recipeBM, true, true); customRecipeSil = new CustomRecipe(recipeSil, true, true); if ((bool)balance["BattleaxeBronze"]["enabled"]) { ItemManager.Instance.AddRecipe(customRecipe); } if ((bool)balance["BattleaxeBlackmetal"]["enabled"]) { ItemManager.Instance.AddRecipe(customRecipeBronze); } if ((bool)balance["BattleaxeSilver"]["enabled"]) { ItemManager.Instance.AddRecipe(customRecipeBM); } if ((bool)balance["AxehammerBlackmetal"]["enabled"]) { ItemManager.Instance.AddRecipe(customRecipeSil); } }
public PlanCrystalPrefabConfig() : base(prefabName, "Ruby") { Recipe = new CustomRecipe(new RecipeConfig() { Item = prefabName, Name = "$item_" + localizationName, CraftingStation = "piece_workbench", Requirements = new RequirementConfig[] { new RequirementConfig() { Item = "Ruby", Amount = 1 }, new RequirementConfig() { Item = "GreydwarfEye", Amount = 1 } } }); }
private void LoadAssets() { AssetBundle assetBundle = AssetUtils.LoadAssetBundleFromResources("blueprints", typeof(VeilheimPlugin).Assembly); PieceManager.Instance.AddPieceTable(assetBundle.LoadAsset <GameObject>("_BlueprintPieceTable")); GameObject runeprefab = assetBundle.LoadAsset <GameObject>("BlueprintRune"); CustomItem rune = new CustomItem(runeprefab, fixReference: false); ItemManager.Instance.AddItem(rune); CustomRecipe runeRecipe = new CustomRecipe(new RecipeConfig() { Item = "BlueprintRune", Amount = 1, Requirements = new RequirementConfig[] { new RequirementConfig { Item = "Stone", Amount = 1 } } }); ItemManager.Instance.AddRecipe(runeRecipe); GameObject makebp_prefab = assetBundle.LoadAsset <GameObject>("make_blueprint"); PrefabManager.Instance.AddPrefab(makebp_prefab); GameObject placebp_prefab = assetBundle.LoadAsset <GameObject>("piece_blueprint"); PrefabManager.Instance.AddPrefab(placebp_prefab); TextAsset[] textAssets = assetBundle.LoadAllAssets <TextAsset>(); foreach (var textAsset in textAssets) { var lang = textAsset.name.Replace(".json", null); LocalizationManager.Instance.AddJson(lang, textAsset.ToString()); } assetBundle.Unload(false); }
//Adds custom recipe to the database, then redirects to the saved recipe view public async Task <IActionResult> CreateRecipe(string recipeName, string ingredients, string directions, string notes, int?id) { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); if (string.IsNullOrEmpty(recipeName)) { TempData["Error"] = "You cannot have a blank name for recipe. Please try again."; return(RedirectToAction("Error", "Home")); } var customRecipe = new CustomRecipe() { UserId = userId, RecipeName = recipeName, Ingredients = string.IsNullOrEmpty(ingredients) ? string.Empty : ingredients, Directions = string.IsNullOrEmpty(directions) ? string.Empty : directions, Notes = string.IsNullOrEmpty(notes) ? string.Empty : notes }; var isRecipeSaved = false; if (id == null) { isRecipeSaved = await _repositoryClient.AddCustomRecipe(customRecipe); } else { customRecipe.Id = id.Value; isRecipeSaved = await _repositoryClient.UpdateRecipe(customRecipe); } if (isRecipeSaved) { return(RedirectToAction("SavedRecipeList", "Recipe")); } else { return(RedirectToAction("Error", "Home")); } }
private static void AddRecipe() { var recipe = ScriptableObject.CreateInstance <Recipe>(); recipe.m_item = AssetHelper.TorchOlympiaPrefab.GetComponent <ItemDrop>(); var itemReqs = new List <Piece.Requirement> { MockRequirement.Create("HelmetYule", 1), MockRequirement.Create("Flametal", 70), MockRequirement.Create("YagluthDrop", 100), MockRequirement.Create("YmirRemains", 20), }; recipe.name = "Recipe_Secret"; recipe.m_resources = itemReqs.ToArray(); recipe.m_craftingStation = Mock <CraftingStation> .Create(CraftingStationPrefabName); customRecipe = new CustomRecipe(recipe, true, true); if ((bool)balance["TorchOlympia"]["enabled"]) { ItemManager.Instance.AddRecipe(customRecipe); } }
// Implementation of assets using mocks, adding recipe's manually without the config abstraction private void AddMockedItems() { Jotunn.Logger.LogInfo("test items"); if (!slappingFish) { Jotunn.Logger.LogWarning($"Failed to load asset from bundle: {slappingFishBundle}"); } else { Jotunn.Logger.LogInfo("test items 2"); // Create and add a custom item CustomItem CI = new CustomItem(slappingFish, true); CI.ItemDrop.m_itemData.m_shared.m_attackStatusEffect = challengedEffect.StatusEffect; CI.ItemDrop.m_itemData.m_shared.m_damages.m_slash = 0; CI.ItemDrop.m_itemData.m_shared.m_damages.m_pierce = 0; ItemManager.Instance.AddItem(CI); //Create and add a custom recipe Recipe recipe = ScriptableObject.CreateInstance <Recipe>(); recipe.name = "Recipe_SlappingFish"; recipe.m_item = slappingFish.GetComponent <ItemDrop>(); recipe.m_craftingStation = Mock <CraftingStation> .Create("piece_workbench"); var ingredients = new List <Piece.Requirement> { MockRequirement.Create("Wood", 1), }; recipe.m_resources = ingredients.ToArray(); CustomRecipe CR = new CustomRecipe(recipe, true, true); ItemManager.Instance.AddRecipe(CR); //Enable BoneReorder BoneReorder.ApplyOnEquipmentChanged(); } slappingFishBundle.Unload(false); }