Пример #1
0
        internal static void AddBossBar(ModBossBar bossBar)
        {
            bossBar.index = bossBars.Count;
            bossBars.Add(bossBar);
            ModTypeLookup <ModBossBar> .Register(bossBar);

            //Texture is optional
            if (ModContent.TextureExists(bossBar.Texture))
            {
                bossBarTextures[bossBar.index] = ModContent.GetTexture(bossBar.Texture);
            }
        }
Пример #2
0
        /// <summary>
        /// Adds an equipment texture of the specified type, internal name, and associated item to your mod.
        /// This method is different from the other AddEquipTexture in that you can specify the class of the equipment texture, thus allowing you to override EquipmentTexture's hooks.
        /// All other parameters are the same as the other AddEquipTexture.
        /// </summary>
        /// <param name="equipTexture">The equip texture.</param>
        /// <param name="item">The item.</param>
        /// <param name="type">The type.</param>
        /// <param name="name">The name.</param>
        /// <param name="texture">The texture.</param>
        /// <param name="armTexture">The arm texture (for body slots).</param>
        /// <param name="femaleTexture">The female texture (for body slots), if missing the regular body texture is used.</param>
        /// <returns></returns>
        public int AddEquipTexture(EquipTexture equipTexture, ModItem item, EquipType type, string texture)
        {
            if (!loading)
            {
                throw new Exception("AddEquipTexture can only be called from Mod.Load or Mod.Autoload");
            }

            ModContent.GetTexture(texture);             //ensure texture exists

            equipTexture.Texture = texture;
            equipTexture.Mod     = this;
            equipTexture.Name    = item.Name;
            equipTexture.Type    = type;
            equipTexture.Item    = item;
            int slot = equipTexture.Slot = EquipLoader.ReserveEquipID(type);

            EquipLoader.equipTextures[type][slot]        = equipTexture;
            equipTextures[Tuple.Create(item.Name, type)] = equipTexture;

            if (type == EquipType.Body)
            {
                if (!ModContent.TextureExists(item.FemaleTexture))
                {
                    EquipLoader.femaleTextures[slot] = texture;
                }
                else
                {
                    EquipLoader.femaleTextures[slot] = item.FemaleTexture;
                }
                ModContent.GetTexture(item.ArmTexture);                 //ensure texture exists
                EquipLoader.armTextures[slot] = item.ArmTexture;
            }

            if (!EquipLoader.idToSlot.TryGetValue(item.Type, out IDictionary <EquipType, int> slots))
            {
                EquipLoader.idToSlot[item.Type] = slots = new Dictionary <EquipType, int>();
            }

            slots[type] = slot;
            if (type == EquipType.Head || type == EquipType.Body || type == EquipType.Legs)
            {
                EquipLoader.slotToId[type][slot] = item.Type;
            }

            return(slot);
        }