Untitled

mail@pastecode.io avatar
unknown
csharp
2 years ago
1.6 kB
6
Indexable
Never
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;

namespace WithBroomBetter.Common
{
    public class DrawLayer : PlayerDrawLayer
    {
        public override Position GetDefaultPosition() => new BeforeParent(PlayerDrawLayers.Pulley);

        public override bool GetDefaultVisibility(PlayerDrawSet drawInfo)
        {
            return drawInfo.drawPlayer.GetModPlayer<CustomPlayer>().purityShieldMount == true;
        }

        //For drawing Purity mount
        protected override void Draw(ref PlayerDrawSet drawInfo)
        {
            Texture2D texture = (Texture2D)ModContent.Request<Texture2D>("WithBroomBetter/Mounts/PurityShieldMount");
            int drawX = (int)(drawInfo.Position.X + drawInfo.drawPlayer.width / 2f - Main.screenPosition.X);
            int drawY = (int)(drawInfo.Position.Y + drawInfo.drawPlayer.height / 2f - Main.screenPosition.Y);
            float strength = (drawInfo.drawPlayer.miscTimer % 30f) / 15f;
            if (strength > 1f)
            {
                strength = 2f - strength;
            }
            strength = 0.4f + strength * 0.2f;
            DrawData data = new DrawData(texture, new Vector2(drawX, drawY), null, Color.White * strength, 0f, new Vector2(texture.Width / 2f, texture.Height / 2f), 1f, SpriteEffects.None, 0);
            data.shader = drawInfo.drawPlayer.miscDyes[3].dye;
            drawInfo.DrawDataCache.Add(data);

        }
    }
}