Exemple #1
0
        private static void DrawLayer(PlayerDrawInfo drawInfo)
        {
            if (Main.netMode == NetmodeID.Server)
            {
                return;
            }

            DBTPlayer dbtPlayer = drawInfo.drawPlayer.GetModPlayer <DBTPlayer>();

            AuraAppearance aura = dbtPlayer.GetAura();

            if (aura == null)
            {
                return;
            }

            int auraHeight = aura.Information.GetHeight(dbtPlayer);

            Texture2D auraTexture   = aura.Information.GetTexture(dbtPlayer);
            Rectangle auraRectangle = new Rectangle(0, auraHeight * dbtPlayer.AuraFrameIndex, auraTexture.Width, auraHeight);

            float scale = aura.Information.GetAuraScale(dbtPlayer);
            Tuple <float, Vector2> rotationAndPosition = aura.Information.GetRotationAndPosition(dbtPlayer);

            SamplerState samplerState = dbtPlayer.GetPlayerSamplerState();

            aura.Information.BlendState.SetSpriteBatchForPlayerLayerCustomDraw(samplerState);

            Main.spriteBatch.Draw(auraTexture, rotationAndPosition.Item2 - Main.screenPosition, auraRectangle, Color.White, rotationAndPosition.Item1,
                                  new Vector2(aura.Information.GetWidth(dbtPlayer), aura.Information.GetHeight(dbtPlayer)) * 0.5f, scale, SpriteEffects.None, 0f);

            samplerState.ResetSpriteBatchForPlayerDrawLayers();
        }
Exemple #2
0
        public static void DrawAura(this DBTPlayer modPlayer, AuraAnimationInformation aura)
        {
            Player    player           = modPlayer.player;
            Texture2D texture          = aura.GetTexture(modPlayer);
            Rectangle textureRectangle = new Rectangle(0, aura.GetHeight(modPlayer) * aura.FramesCount, texture.Width, aura.GetHeight(modPlayer));
            float     scale            = aura.GetAuraScale(modPlayer);
            Tuple <float, Vector2> rotationAndPosition = aura.GetRotationAndPosition(modPlayer);
            float   rotation = rotationAndPosition.Item1;
            Vector2 position = rotationAndPosition.Item2;

            SpriteBatchExtensions.SetSpriteBatchForPlayerLayerCustomDraw(aura.BlendState, modPlayer.GetPlayerSamplerState());

            // custom draw routine
            Main.spriteBatch.Draw(texture, position - Main.screenPosition, textureRectangle, Color.White, rotation, new Vector2(aura.GetWidth(modPlayer), aura.GetHeight(modPlayer)) * 0.5f, scale, SpriteEffects.None, 0f);

            SpriteBatchExtensions.ResetSpriteBatchForPlayerDrawLayers(modPlayer.GetPlayerSamplerState());
        }