Exemplo n.º 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 (!string.IsNullOrEmpty(borderTexture))
                {
                    try
                    {
                        var probe = ModContent.GetTexture(borderTexture);
                        if (!ClickerWeaponBorderTexture.ContainsKey(type))
                        {
                            ClickerWeaponBorderTexture.Add(type, borderTexture);
                        }
                    }
                    catch
                    {
                    }
                }
            }

            if (modItem.Tooltip.GetDefault() == null)
            {
                modItem.Tooltip.SetDefault("{$Mods.ClickerClass.Common.Tooltips.Clicker}");
            }
        }
Exemplo n.º 2
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}");
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Returns the border texture of the item of this type
 /// </summary>
 /// <param name="type">The item type</param>
 /// <returns>The path to the border texture, null if not found</returns>
 public static string GetPathToBorderTexture(int type)
 {
     if (ClickerWeaponBorderTexture.TryGetValue(type, out string borderTexture))
     {
         return(borderTexture);
     }
     return(null);
 }
Exemplo n.º 4
0
 internal static void Unload()
 {
     ClickerItems = null;
     ClickerWeaponBorderTexture?.Clear();
     ClickerWeaponBorderTexture = null;
     ClickerWeapons             = null;
     ClickerProjectiles         = null;
     ClickEffectsByName?.Clear();
     ClickEffectsByName = null;
 }