Exemplo n.º 1
0
        /// <summary>
        /// Gets the id of an item, projectile, or buff.
        /// </summary>
        public static List <int> GetIdFromInput(this TShockAPI.Utils util, string input, string name)
        {
            if (input == DbConsts.ItemTable)
            {
                var itemsFound = util.GetItemByName(name);
                return(itemsFound.Select(c => c.netID).ToList());
            }
            else if (input == DbConsts.ProjectileTable)
            {
                return(util.GetProjectileByName(name));
            }
            else if (input == DbConsts.BuffTable)
            {
                return(util.GetBuffByName(name));
            }

            return(default(List <int>));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the id of an item, projectile, or buff.
        /// </summary>
        public static List <int> GetIdFromInput(this Utils util, string section, string name)
        {
            if (section == DbTables.ItemTable)
            {
                var itemsFound = util.GetItemByName(name);
                return(itemsFound.Select(c => c.netID).ToList());
            }

            if (section == DbTables.ProjectileTable)
            {
                return(util.GetProjectileByName(name));
            }

            if (section == DbTables.BuffTable)
            {
                return(util.GetBuffByName(name));
            }

            return(default(List <int>));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets a list of projectiles based off the given Name query.
        /// </summary>
        public static List <int> GetProjectileByName(this TShockAPI.Utils util, string name)
        {
            string nameLower = name.ToLower();
            var    found     = new List <int>();

            for (int i = 1; i < Main.maxProjectileTypes; i++)
            {
                string projectileName = Lang.GetProjectileName(i).ToString();
                if (!String.IsNullOrWhiteSpace(projectileName) && projectileName.ToLower() == nameLower)
                {
                    return new List <int> {
                               i
                    }
                }
                ;
                if (!String.IsNullOrWhiteSpace(projectileName) && projectileName.ToLower().StartsWith(nameLower))
                {
                    found.Add(i);
                }
            }
            return(found);
        }