Beispiel #1
0
        protected override List <DefinitionOptionElement <PrefixDefinition> > GetPassedOptionElements()
        {
            var passed = new List <DefinitionOptionElement <PrefixDefinition> >();

            foreach (var option in options)
            {
                // Should this be the localized Prefix name?
                if (Lang.prefix[option.type].Value.IndexOf(chooserFilter.CurrentString, StringComparison.OrdinalIgnoreCase) == -1)
                {
                    continue;
                }

                string modname = option.definition.mod;

                if (option.type > PrefixID.Count)
                {
                    modname = PrefixLoader.GetPrefix((byte)option.type).Mod.DisplayName;                     // or internal name?
                }
                if (modname.IndexOf(chooserFilterMod.CurrentString, StringComparison.OrdinalIgnoreCase) == -1)
                {
                    continue;
                }

                passed.Add(option);
            }

            return(passed);
        }
Beispiel #2
0
        public static TagCompound Save(Item item)
        {
            var tag = new TagCompound();

            if (item.type <= 0)
            {
                return(tag);
            }

            if (item.ModItem == null)
            {
                tag.Set("mod", "Terraria");
                tag.Set("id", item.netID);
            }
            else
            {
                tag.Set("mod", item.ModItem.Mod.Name);
                tag.Set("name", item.ModItem.Name);
                tag.Set("data", item.ModItem.Save());
            }

            if (item.prefix != 0 && item.prefix < PrefixID.Count)
            {
                tag.Set("prefix", item.prefix);
            }

            if (item.prefix >= PrefixID.Count)
            {
                ModPrefix modPrefix = PrefixLoader.GetPrefix(item.prefix);

                if (modPrefix != null)
                {
                    tag.Set("modPrefixMod", modPrefix.Mod.Name);
                    tag.Set("modPrefixName", modPrefix.Name);
                }
            }

            if (item.stack > 1)
            {
                tag.Set("stack", item.stack);
            }

            if (item.favorited)
            {
                tag.Set("fav", true);
            }

            tag.Set("globalData", SaveGlobals(item));

            return(tag);
        }