Exemple #1
0
        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);
        }
Exemple #2
0
 private void SetupStatusEffects()
 {
     ObjectDBHelper.Add(new CustomStatusEffect(ScriptableObject.CreateInstance <StatusEffects.SE_Encumbrance>(), true));
     ObjectDBHelper.Add(new CustomStatusEffect(ScriptableObject.CreateInstance <StatusEffects.SE_Exhausted>(), true));
     ObjectDBHelper.Add(new CustomStatusEffect(ScriptableObject.CreateInstance <StatusEffects.SE_Pushing>(), true));
     ObjectDBHelper.Add(new CustomStatusEffect(ScriptableObject.CreateInstance <StatusEffects.SE_Warmed>(), true));
     Log.LogInfo("Status effects injected");
 }
        private void InitStatusEffects()
        {
            var effect = ScriptableObject.CreateInstance <SE_SurtlingEquippedEffect>();

            effect.m_icon    = AssetHelper.Icon;
            effect.m_name    = Language.LanguageData.EffectValue;
            effect.name      = Language.LanguageData.EffectValue;
            effect.m_tooltip = Language.LanguageData.SurtlingTooltipName;
            ObjectDBHelper.Add(new CustomStatusEffect(effect, true));
        }
Exemple #4
0
    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 registerPrefabs()
        {
            foreach (string foodName in affectedFood)
            {
                // we skip default value(0)
                for (int index = 1; index < qualityPrefixes.Length; index++)
                {
                    // check for base prefab existance
                    ItemDrop basePrefab = Prefab.Cache.GetPrefab <ItemDrop>(foodName);
                    if (basePrefab == null)
                    {
                        Log.LogInfo($"No prefab registered for meal: {foodName}");
                        continue;
                    }

                    string qualityPrefix = qualityPrefixes[index];

                    // skipping default quality mostly, cuz those items are already exists,
                    // but modyfing to match the rest
                    string qualifiedPrefabName = foodName + "_" + qualityPrefix;
                    Log.LogInfo($"trying to make clone named: {qualifiedPrefabName}");

                    // create new quality items
                    GameObject clonedBasePrefabObject = basePrefab.gameObject.InstantiateClone(qualifiedPrefabName);
                    CustomItem newMealItem            = new CustomItem(clonedBasePrefabObject, fixReference: true);

                    newMealItem.ItemDrop.m_itemData.m_shared.m_name = $"${qualifiedPrefabName}";
                    Log.LogInfo($"newMealItem named: {newMealItem.ItemDrop.m_itemData.m_shared.m_name}");

                    // setting quality representation for food
                    newMealItem.ItemDrop.m_itemData.m_quality             = index;
                    newMealItem.ItemDrop.m_itemData.m_shared.m_maxQuality = qualityPrefixes.Length;

                    // increase/decrease stats
                    float baseFoodHealth = newMealItem.ItemDrop.m_itemData.m_shared.m_food;
                    newMealItem.ItemDrop.m_itemData.m_shared.m_food =
                        (int)Math.Round(baseFoodHealth * ((100f + (index * JustAnotherCookingSkill.foodIncreasePerQuality.Value) - 20) / 100f));

                    float baseFoodStamina = newMealItem.ItemDrop.m_itemData.m_shared.m_foodStamina;
                    newMealItem.ItemDrop.m_itemData.m_shared.m_foodStamina =
                        (int)Math.Round(baseFoodStamina * ((100f + (index * JustAnotherCookingSkill.foodIncreasePerQuality.Value) - 20) / 100f));

                    // increase regen for better quality items
                    if (index > 2)
                    {
                        newMealItem.ItemDrop.m_itemData.m_shared.m_foodRegen += index - 2;
                    }

                    ObjectDBHelper.Add(newMealItem);
                }
            }
        }
Exemple #6
0
        public static void AddCustomItem(GameObject prefab, Items.RecipesConfig recipes)
        {
            CustomItem customItem = new CustomItem(prefab, fixReference: true);

            ObjectDBHelper.Add(customItem);

            foreach (var rec in recipes.recipes)
            {
                if (rec.name == prefab.name)
                {
                    AddCustomToken(rec.tokenName, rec.tokenValue, rec.tokenDescription, rec.tokenDescriptionValue);
                }
            }
        }
Exemple #7
0
        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);
        }
Exemple #8
0
        /*
         * 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);
        }
Exemple #9
0
        private static void AddCustomItem()
        {
            CustomItem = new CustomItem(MeadPewterPrefab, fixReference: true);

            ObjectDBHelper.Add(CustomItem);
        }
Exemple #10
0
        private static void AddCustomItem()
        {
            CustomItem = new CustomItem(AssetHelper.LeadPrefab, true);

            ObjectDBHelper.Add(CustomItem);
        }