Ejemplo n.º 1
0
        // 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);
        }
Ejemplo n.º 2
0
 public void Start()
 {
     //Configs.genSettings = Config;
     Hooks.Init();
     ModAssets.Instance.Init();
     BoneReorder.ApplyOnEquipmentChanged();
 }
Ejemplo n.º 3
0
        // 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);
            }
        }
Ejemplo n.º 4
0
        // 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);
        }