예제 #1
0
        /// <summary>
        /// Call this in <see cref="ModItem.SetStaticDefaults"/> to register this weapon into the "clicker class" category as a "clicker".
        /// You can change the default tooltip BEFORE it.
        /// Do not call <see cref="RegisterClickerItem"/> with it as this method does this already by itself
        /// </summary>
        /// <param name="modItem">The <see cref="ModItem"/> that is to be registered</param>
        /// <param name="borderTexture">The path to the border texture (optional)</param>
        /// <exception cref="InvalidOperationException"/>
        public static void RegisterClickerWeapon(ModItem modItem, string borderTexture = null)
        {
            if (ClickerClass.finalizedRegisterCompat)
            {
                throw new InvalidOperationException("Tried to register a clicker weapon at the wrong time, do so in ModItem.SetStaticDefaults");
            }
            RegisterClickerItem(modItem);
            int type = modItem.Item.type;

            if (!ClickerWeapons.Contains(type))
            {
                ClickerWeapons.Add(type);
                if (borderTexture != null)
                {
                    if (ModContent.HasAsset(borderTexture))
                    {
                        if (!ClickerWeaponBorderTexture.ContainsKey(type))
                        {
                            ClickerWeaponBorderTexture.Add(type, borderTexture);
                        }
                    }
                    else
                    {
                        ClickerClass.mod.Logger.Info($"Border texture for {modItem.Name} not found: {borderTexture}");
                    }
                }
            }

            if (modItem.Tooltip.GetDefault() == null)
            {
                modItem.Tooltip.SetDefault("{$Mods.ClickerClass.Common.Tooltips.Clicker}");
            }
        }