Terraria.ModLoader.ItemLoader.DrawAnimatedItem C# (CSharp) Method

DrawAnimatedItem() static private method

static private DrawAnimatedItem ( Item item, int whoAmI, Color color, Color alpha, float rotation, float scale ) : void
item Item
whoAmI int
color Color
alpha Color
rotation float
scale float
return void
        internal static void DrawAnimatedItem(Item item, int whoAmI, Color color, Color alpha, float rotation, float scale)
        {
            int frameCount = Main.itemAnimations[item.type].FrameCount;
            int frameDuration = Main.itemAnimations[item.type].TicksPerFrame;
            Main.itemFrameCounter[whoAmI]++;
            if (Main.itemFrameCounter[whoAmI] >= frameDuration)
            {
                Main.itemFrameCounter[whoAmI] = 0;
                Main.itemFrame[whoAmI]++;
            }
            if (Main.itemFrame[whoAmI] >= frameCount)
            {
                Main.itemFrame[whoAmI] = 0;
            }
            Rectangle frame = Main.itemTexture[item.type].Frame(1, frameCount, 0, Main.itemFrame[whoAmI]);
            float offX = (float)(item.width / 2 - frame.Width / 2);
            float offY = (float)(item.height - frame.Height);
            Main.spriteBatch.Draw(Main.itemTexture[item.type], new Vector2(item.position.X - Main.screenPosition.X + (float)(frame.Width / 2) + offX, item.position.Y - Main.screenPosition.Y + (float)(frame.Height / 2) + offY), new Rectangle?(frame), alpha, rotation, frame.Size() / 2f, scale, SpriteEffects.None, 0f);
            if (item.color != default(Color))
            {
                Main.spriteBatch.Draw(Main.itemTexture[item.type], new Vector2(item.position.X - Main.screenPosition.X + (float)(frame.Width / 2) + offX, item.position.Y - Main.screenPosition.Y + (float)(frame.Height / 2) + offY), new Rectangle?(frame), item.GetColor(color), rotation, frame.Size() / 2f, scale, SpriteEffects.None, 0f);
            }
        }