コード例 #1
0
        public void DrawToSpriteBatch(SpriteBatch batch, bool started = false)
        {
            if (_effectRenderer != null)
            {
                _effectRenderer.DrawBehindTarget(batch, started);
            }

            if (!started)
            {
                batch.Begin();
            }

            SpriteEffects effects = NPC.Direction == EODirection.Left || NPC.Direction == EODirection.Down
                ? SpriteEffects.None
                : SpriteEffects.FlipHorizontally;

            Color col = NPC.Dying ? Color.FromNonPremultiplied(255, 255, 255, _fadeAwayAlpha -= 3) : Color.White;

            batch.Draw(_npcSheet.GetNPCTexture(NPC.Data.Graphic, Frame, NPC.Direction),
                       DrawArea,
                       null,
                       col,
                       0f,
                       Vector2.Zero,
                       effects,
                       1f);

            if (NPC.Dying && _fadeAwayAlpha <= 0)
            {
                NPC.EndDying();
            }

            if (!started)
            {
                batch.End();
            }

            if (_effectRenderer != null)
            {
                _effectRenderer.DrawInFrontOfTarget(batch, started);
            }
        }