internal static bool AddRecipeToList_Pre(Player player, Recipe recipe, ItemDrop.ItemData item, ref bool canCraft)
 {
     if (!player.NoCostCheat() && SkillRequirement.skillRequirements.ContainsKey(recipe.name))
     {
         canCraft = SkillRequirement.GoodEnough(player, recipe);
     }
     return(true);
 }
Ejemplo n.º 2
0
 internal static bool AddKnownRecipe_Pre(ref Player __instance, Recipe recipe)
 {
     if (!SkillRequirement.skillRequirements.ContainsKey(recipe.name) || SkillRequirement.GoodEnough(__instance, recipe))
     {
         return(true);
     }
     return(false);
 }
        internal static void UpdateRecipe_Post(ref InventoryGui __instance, Player player)
        {
            Recipe selectedRecipe = ((KeyValuePair <Recipe, ItemDrop.ItemData>)AccessTools.Field(typeof(InventoryGui), "m_selectedRecipe").GetValue(__instance)).Key;

            if (selectedRecipe && SkillRequirement.skillRequirements.ContainsKey(selectedRecipe.name))
            {
                SkillRequirement skillRecipe = SkillRequirement.skillRequirements[selectedRecipe.name];
                Dictionary <Skills.SkillType, Skills.Skill> m_skillData = AccessTools.Field(typeof(Skills), "m_skillData").GetValue(player.GetSkills()) as Dictionary <Skills.SkillType, Skills.Skill>;
                if (m_skillData.ContainsKey(skillRecipe.m_skill))
                {
                    string message = $"Requires Lvl {skillRecipe.m_requiredLevel} in {SkillRequirement.GetSkillName(skillRecipe.m_skill)}";
                    __instance.m_recipeDecription.text += Localization.instance.Localize($"\n\n{message}\n");
                    if (__instance.m_craftButton.interactable && !SkillRequirement.GoodEnough(player, selectedRecipe))
                    {
                        __instance.m_craftButton.GetComponent <UITooltip>().m_text = message;
                        __instance.m_craftButton.interactable = false;
                    }
                }
            }
        }
Ejemplo n.º 4
0
 internal static bool PlayerAttackInput_Pre(ref Player __instance, float dt)
 {
     if (__instance)
     {
         ItemDrop.ItemData currentWeapon = __instance.GetCurrentWeapon();
         if (currentWeapon != null)
         {
             if (ObjectDB.instance)
             {
                 List <Recipe> recipes = ObjectDB.instance.m_recipes;
                 if (recipes != null)
                 {
                     Recipe recipe = recipes
                                     .Where(r => r.m_item != null &&
                                            r.m_item.m_itemData != null &&
                                            r.m_item.m_itemData.m_shared != null &&
                                            r.m_item.m_itemData.m_shared.m_name.Equals(currentWeapon.m_shared.m_name))
                                     .FirstOrDefault();
                     if (recipe && !SkillRequirement.GoodEnough(__instance, recipe))
                     {
                         SkillRequirement skillRequirement = SkillRequirement.skillRequirements[recipe.name];
                         string           message          = $"Need level {skillRequirement.m_requiredLevel} in {SkillRequirement.GetSkillName(skillRequirement.m_skill)} to use {currentWeapon.m_shared.m_name}";
                         MessageHud.instance.ShowMessage(MessageHud.MessageType.TopLeft, message);
                         if (!lastCurrentWeapon.Equals(currentWeapon.m_shared.m_name))
                         {
                             MessageHud.instance.ShowMessage(MessageHud.MessageType.Center, message);
                             lastCurrentWeapon = currentWeapon.m_shared.m_name;
                         }
                         return(false);
                     }
                 }
             }
             lastCurrentWeapon = currentWeapon.m_shared.m_name;
         }
     }
     return(true);
 }