Ejemplo n.º 1
0
        //in Terraria.Main.DrawPlayers after armor combinations setting flags call
        //  ItemLoader.ArmorSetShadows(player, ref flag, ref flag2, ref flag3, ref flag4);
        internal static void ArmorSetShadows(Player player, ref bool longTrail, ref bool smallPulse, ref bool largePulse, ref bool shortTrail)
        {
            EquipTexture headTexture = EquipLoader.GetEquipTexture(EquipType.Head, player.head);
            EquipTexture bodyTexture = EquipLoader.GetEquipTexture(EquipType.Body, player.body);
            EquipTexture legTexture  = EquipLoader.GetEquipTexture(EquipType.Legs, player.legs);

            if (headTexture != null && headTexture.IsVanitySet(player.head, player.body, player.legs))
            {
                headTexture.ArmorSetShadows(player, ref longTrail, ref smallPulse, ref largePulse, ref shortTrail);
            }
            if (bodyTexture != null && bodyTexture.IsVanitySet(player.head, player.body, player.legs))
            {
                bodyTexture.ArmorSetShadows(player, ref longTrail, ref smallPulse, ref largePulse, ref shortTrail);
            }
            if (legTexture != null && legTexture.IsVanitySet(player.head, player.body, player.legs))
            {
                legTexture.ArmorSetShadows(player, ref longTrail, ref smallPulse, ref largePulse, ref shortTrail);
            }
            foreach (GlobalItem globalItem in globalItems)
            {
                string set = globalItem.IsVanitySet(player.head, player.body, player.legs);
                if (set.Length > 0)
                {
                    globalItem.ArmorSetShadows(player, set, ref longTrail, ref smallPulse, ref largePulse, ref shortTrail);
                }
            }
        }
Ejemplo n.º 2
0
        public int AddEquipTexture(EquipTexture equipTexture, ModItem item, EquipType type, string name, string texture,
                                   string armTexture = "", string femaleTexture = "")
        {
            int slot = EquipLoader.ReserveEquipID(type);

            equipTexture.Texture = texture;
            equipTexture.mod     = this;
            equipTexture.Name    = name;
            equipTexture.Type    = type;
            equipTexture.Slot    = slot;
            equipTexture.item    = item;
            EquipLoader.equipTextures[type][slot] = equipTexture;
            ModLoader.GetTexture(texture);
            if (type == EquipType.Body)
            {
                EquipLoader.armTextures[slot]    = armTexture;
                EquipLoader.femaleTextures[slot] = femaleTexture.Length > 0 ? femaleTexture : texture;
                ModLoader.GetTexture(armTexture);
                ModLoader.GetTexture(femaleTexture);
            }
            if (item != null && (type == EquipType.Head || type == EquipType.Body || type == EquipType.Legs))
            {
                EquipLoader.slotToId[type][slot] = item.item.type;
            }
            return(slot);
        }
Ejemplo n.º 3
0
        //in Terraria.Player.PlayerFrame after armor sets creating dust call this
        internal static void UpdateVanitySet(Player player)
        {
            EquipTexture headTexture = EquipLoader.GetEquipTexture(EquipType.Head, player.head);
            EquipTexture bodyTexture = EquipLoader.GetEquipTexture(EquipType.Body, player.body);
            EquipTexture legTexture  = EquipLoader.GetEquipTexture(EquipType.Legs, player.legs);

            if (headTexture != null && headTexture.IsVanitySet(player.head, player.body, player.legs))
            {
                headTexture.UpdateVanitySet(player);
            }
            if (bodyTexture != null && bodyTexture.IsVanitySet(player.head, player.body, player.legs))
            {
                bodyTexture.UpdateVanitySet(player);
            }
            if (legTexture != null && legTexture.IsVanitySet(player.head, player.body, player.legs))
            {
                legTexture.UpdateVanitySet(player);
            }
            foreach (GlobalItem globalItem in globalItems)
            {
                string set = globalItem.IsVanitySet(player.head, player.body, player.legs);
                if (set.Length > 0)
                {
                    globalItem.UpdateVanitySet(player, set);
                }
            }
        }
Ejemplo n.º 4
0
        internal static void ResizeAndFillArrays()
        {
            Array.Resize(ref TextureAssets.ArmorHead, nextEquip[EquipType.Head]);
            Array.Resize(ref TextureAssets.ArmorBody, nextEquip[EquipType.Body]);
            Array.Resize(ref TextureAssets.FemaleBody, nextEquip[EquipType.Body]);
            Array.Resize(ref TextureAssets.ArmorArm, nextEquip[EquipType.Body]);
            Array.Resize(ref TextureAssets.ArmorLeg, nextEquip[EquipType.Legs]);
            Array.Resize(ref TextureAssets.AccHandsOn, nextEquip[EquipType.HandsOn]);
            Array.Resize(ref TextureAssets.AccHandsOff, nextEquip[EquipType.HandsOff]);
            Array.Resize(ref TextureAssets.AccBack, nextEquip[EquipType.Back]);
            Array.Resize(ref TextureAssets.AccFront, nextEquip[EquipType.Front]);
            Array.Resize(ref TextureAssets.AccShoes, nextEquip[EquipType.Shoes]);
            Array.Resize(ref TextureAssets.AccWaist, nextEquip[EquipType.Waist]);
            Array.Resize(ref TextureAssets.Wings, nextEquip[EquipType.Wings]);
            Array.Resize(ref TextureAssets.AccShield, nextEquip[EquipType.Shield]);
            Array.Resize(ref TextureAssets.AccNeck, nextEquip[EquipType.Neck]);
            Array.Resize(ref TextureAssets.AccFace, nextEquip[EquipType.Face]);
            Array.Resize(ref TextureAssets.AccBalloon, nextEquip[EquipType.Balloon]);
            Array.Resize(ref ArmorIDs.Wing.Sets.Stats, nextEquip[EquipType.Wings]);

            foreach (EquipType type in EquipTypes)
            {
                foreach (var entry in equipTextures[type])
                {
                    int          slot    = entry.Key;
                    EquipTexture texture = entry.Value;

                    GetTextureArray(type)[slot] = ModContent.GetTexture(texture.Texture);

                    if (type == EquipType.Body)
                    {
                        TextureAssets.FemaleBody[slot] = ModContent.GetTexture(femaleTextures[slot]);
                        TextureAssets.ArmorArm[slot]   = ModContent.GetTexture(armTextures[slot]);
                    }
                }
            }

            Array.Resize(ref Item.headType, nextEquip[EquipType.Head]);

            foreach (var entry in slotToId[EquipType.Head])
            {
                Item.headType[entry.Key] = entry.Value;
            }

            Array.Resize(ref Item.bodyType, nextEquip[EquipType.Body]);

            foreach (var entry in slotToId[EquipType.Body])
            {
                Item.bodyType[entry.Key] = entry.Value;
            }

            Array.Resize(ref Item.legType, nextEquip[EquipType.Legs]);

            foreach (var entry in slotToId[EquipType.Legs])
            {
                Item.legType[entry.Key] = entry.Value;
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Hook Player.PlayerFrame
 /// Calls each of the item's equipment texture's UpdateVanity hook.
 /// </summary>
 public static void EquipFrameEffects(Player player)
 {
     foreach (EquipType type in EquipTypes)
     {
         int          slot    = GetPlayerEquip(player, type);
         EquipTexture texture = GetEquipTexture(type, slot);
         texture?.FrameEffects(player, type);
     }
 }
Ejemplo n.º 6
0
        public int GetEquipSlot(string name)
        {
            EquipTexture texture = GetEquipTexture(name);

            if (texture == null)
            {
                return(-1);
            }
            return(texture.Slot);
        }
Ejemplo n.º 7
0
 internal static void UpdateVanity(Player player)
 {
     foreach (EquipType type in Enum.GetValues(typeof(EquipType)))
     {
         int          slot    = EquipLoader.GetPlayerEquip(player, type);
         EquipTexture texture = EquipLoader.GetEquipTexture(type, slot);
         if (texture != null)
         {
             texture.UpdateVanity(player, type);
         }
     }
 }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
 internal static void ResizeAndFillArrays()
 {
     Array.Resize(ref Main.armorHeadLoaded, nextEquip[EquipType.Head]);
     Array.Resize(ref Main.armorBodyLoaded, nextEquip[EquipType.Body]);
     Array.Resize(ref Main.armorLegsLoaded, nextEquip[EquipType.Legs]);
     Array.Resize(ref Main.accHandsOnLoaded, nextEquip[EquipType.HandsOn]);
     Array.Resize(ref Main.accHandsOffLoaded, nextEquip[EquipType.HandsOff]);
     Array.Resize(ref Main.accBackLoaded, nextEquip[EquipType.Back]);
     Array.Resize(ref Main.accFrontLoaded, nextEquip[EquipType.Front]);
     Array.Resize(ref Main.accShoesLoaded, nextEquip[EquipType.Shoes]);
     Array.Resize(ref Main.accWaistLoaded, nextEquip[EquipType.Waist]);
     Array.Resize(ref Main.wingsLoaded, nextEquip[EquipType.Wings]);
     Array.Resize(ref Main.accShieldLoaded, nextEquip[EquipType.Shield]);
     Array.Resize(ref Main.accNeckLoaded, nextEquip[EquipType.Neck]);
     Array.Resize(ref Main.accFaceLoaded, nextEquip[EquipType.Face]);
     Array.Resize(ref Main.accballoonLoaded, nextEquip[EquipType.Balloon]);
     foreach (EquipType type in EquipTypes)
     {
         for (int k = GetNumVanilla(type); k < nextEquip[type]; k++)
         {
             GetLoadedArray(type)[k] = true;
         }
     }
     Array.Resize(ref Main.armorHeadTexture, nextEquip[EquipType.Head]);
     Array.Resize(ref Main.armorBodyTexture, nextEquip[EquipType.Body]);
     Array.Resize(ref Main.femaleBodyTexture, nextEquip[EquipType.Body]);
     Array.Resize(ref Main.armorArmTexture, nextEquip[EquipType.Body]);
     Array.Resize(ref Main.armorLegTexture, nextEquip[EquipType.Legs]);
     Array.Resize(ref Main.accHandsOnTexture, nextEquip[EquipType.HandsOn]);
     Array.Resize(ref Main.accHandsOffTexture, nextEquip[EquipType.HandsOff]);
     Array.Resize(ref Main.accBackTexture, nextEquip[EquipType.Back]);
     Array.Resize(ref Main.accFrontTexture, nextEquip[EquipType.Front]);
     Array.Resize(ref Main.accShoesTexture, nextEquip[EquipType.Shoes]);
     Array.Resize(ref Main.accWaistTexture, nextEquip[EquipType.Waist]);
     Array.Resize(ref Main.wingsTexture, nextEquip[EquipType.Wings]);
     Array.Resize(ref Main.accShieldTexture, nextEquip[EquipType.Shield]);
     Array.Resize(ref Main.accNeckTexture, nextEquip[EquipType.Neck]);
     Array.Resize(ref Main.accFaceTexture, nextEquip[EquipType.Face]);
     Array.Resize(ref Main.accBalloonTexture, nextEquip[EquipType.Balloon]);
     foreach (EquipType type in EquipTypes)
     {
         foreach (var entry in equipTextures[type])
         {
             int          slot    = entry.Key;
             EquipTexture texture = entry.Value;
             GetTextureArray(type)[slot] = ModContent.GetTexture(texture.Texture);
             if (type == EquipType.Body)
             {
                 Main.femaleBodyTexture[slot] = ModContent.GetTexture(femaleTextures[slot]);
                 Main.armorArmTexture[slot]   = ModContent.GetTexture(armTextures[slot]);
             }
         }
     }
     Array.Resize(ref Item.headType, nextEquip[EquipType.Head]);
     foreach (var entry in slotToId[EquipType.Head])
     {
         Item.headType[entry.Key] = entry.Value;
     }
     Array.Resize(ref Item.bodyType, nextEquip[EquipType.Body]);
     foreach (var entry in slotToId[EquipType.Body])
     {
         Item.bodyType[entry.Key] = entry.Value;
     }
     Array.Resize(ref Item.legType, nextEquip[EquipType.Legs]);
     foreach (var entry in slotToId[EquipType.Legs])
     {
         Item.legType[entry.Key] = entry.Value;
     }
 }
Ejemplo n.º 10
0
 internal static void ResizeAndFillArrays()
 {
     Array.Resize(ref Main.armorHeadLoaded, nextEquip[EquipType.Head]);
     Array.Resize(ref Main.armorBodyLoaded, nextEquip[EquipType.Body]);
     Array.Resize(ref Main.armorLegsLoaded, nextEquip[EquipType.Legs]);
     Array.Resize(ref Main.accHandsOnLoaded, nextEquip[EquipType.HandsOn]);
     Array.Resize(ref Main.accHandsOffLoaded, nextEquip[EquipType.HandsOff]);
     Array.Resize(ref Main.accBackLoaded, nextEquip[EquipType.Back]);
     Array.Resize(ref Main.accFrontLoaded, nextEquip[EquipType.Front]);
     Array.Resize(ref Main.accShoesLoaded, nextEquip[EquipType.Shoes]);
     Array.Resize(ref Main.accWaistLoaded, nextEquip[EquipType.Waist]);
     Array.Resize(ref Main.wingsLoaded, nextEquip[EquipType.Wings]);
     Array.Resize(ref Main.accShieldLoaded, nextEquip[EquipType.Shield]);
     Array.Resize(ref Main.accNeckLoaded, nextEquip[EquipType.Neck]);
     Array.Resize(ref Main.accFaceLoaded, nextEquip[EquipType.Face]);
     Array.Resize(ref Main.accballoonLoaded, nextEquip[EquipType.Balloon]);
     foreach (EquipType type in Enum.GetValues(typeof(EquipType)))
     {
         for (int k = GetNumVanilla(type); k < nextEquip[type]; k++)
         {
             GetLoadedArray(type)[k] = true;
         }
     }
     Array.Resize(ref Main.armorHeadTexture, nextEquip[EquipType.Head]);
     Array.Resize(ref Main.armorBodyTexture, nextEquip[EquipType.Body]);
     Array.Resize(ref Main.femaleBodyTexture, nextEquip[EquipType.Body]);
     Array.Resize(ref Main.armorArmTexture, nextEquip[EquipType.Body]);
     Array.Resize(ref Main.armorLegTexture, nextEquip[EquipType.Legs]);
     Array.Resize(ref Main.accHandsOnTexture, nextEquip[EquipType.HandsOn]);
     Array.Resize(ref Main.accHandsOffTexture, nextEquip[EquipType.HandsOff]);
     Array.Resize(ref Main.accBackTexture, nextEquip[EquipType.Back]);
     Array.Resize(ref Main.accFrontTexture, nextEquip[EquipType.Front]);
     Array.Resize(ref Main.accShoesTexture, nextEquip[EquipType.Shoes]);
     Array.Resize(ref Main.accWaistTexture, nextEquip[EquipType.Waist]);
     Array.Resize(ref Main.wingsTexture, nextEquip[EquipType.Wings]);
     Array.Resize(ref Main.accShieldTexture, nextEquip[EquipType.Shield]);
     Array.Resize(ref Main.accNeckTexture, nextEquip[EquipType.Neck]);
     Array.Resize(ref Main.accFaceTexture, nextEquip[EquipType.Face]);
     Array.Resize(ref Main.accBalloonTexture, nextEquip[EquipType.Balloon]);
     foreach (EquipType type in Enum.GetValues(typeof(EquipType)))
     {
         foreach (int slot in equipTextures[type].Keys)
         {
             EquipTexture texture = GetEquipTexture(type, slot);
             GetTextureArray(type)[slot] = ModLoader.GetTexture(texture.Texture);
             if (type == EquipType.Body)
             {
                 if (femaleTextures.ContainsKey(slot))
                 {
                     Main.femaleBodyTexture[slot] = ModLoader.GetTexture(femaleTextures[slot]);
                 }
                 else
                 {
                     Main.femaleBodyTexture[slot] = Main.armorBodyTexture[slot];
                 }
                 Main.armorArmTexture[slot] = ModLoader.GetTexture(armTextures[slot]);
             }
         }
     }
     Array.Resize(ref Item.headType, nextEquip[EquipType.Head]);
     foreach (int slot in slotToId[EquipType.Head].Keys)
     {
         Item.headType[slot] = slotToId[EquipType.Head][slot];
     }
     Array.Resize(ref Item.bodyType, nextEquip[EquipType.Body]);
     foreach (int slot in slotToId[EquipType.Body].Keys)
     {
         Item.bodyType[slot] = slotToId[EquipType.Body][slot];
     }
     Array.Resize(ref Item.legType, nextEquip[EquipType.Legs]);
     foreach (int slot in slotToId[EquipType.Legs].Keys)
     {
         Item.legType[slot] = slotToId[EquipType.Legs][slot];
     }
 }
Ejemplo n.º 11
0
		public int AddEquipTexture(EquipTexture equipTexture, ModItem item, EquipType type, string name, string texture,
			string armTexture = "", string femaleTexture = "")
		{
			int slot = EquipLoader.ReserveEquipID(type);
			equipTexture.Texture = texture;
			equipTexture.mod = this;
			equipTexture.Name = name;
			equipTexture.Type = type;
			equipTexture.Slot = slot;
			equipTexture.item = item;
			EquipLoader.equipTextures[type][slot] = equipTexture;
			ModLoader.GetTexture(texture);
			if (type == EquipType.Body)
			{
				EquipLoader.armTextures[slot] = armTexture;
				EquipLoader.femaleTextures[slot] = femaleTexture.Length > 0 ? femaleTexture : texture;
				ModLoader.GetTexture(armTexture);
				ModLoader.GetTexture(femaleTexture);
			}
			if (item != null && (type == EquipType.Head || type == EquipType.Body || type == EquipType.Legs))
			{
				EquipLoader.slotToId[type][slot] = item.item.type;
			}
			return slot;
		}