36 lines
1016 B
C#
36 lines
1016 B
C#
using Encompass;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using PongFE.Components;
|
|
using PongFE.Extensions;
|
|
using SpriteFontPlus;
|
|
|
|
namespace PongFE.Renderers
|
|
{
|
|
public class UITextRenderer : GeneralRenderer
|
|
{
|
|
private SpriteBatch SpriteBatch { get; }
|
|
|
|
public UITextRenderer(SpriteBatch spriteBatch)
|
|
{
|
|
SpriteBatch = spriteBatch;
|
|
}
|
|
|
|
public override void Render()
|
|
{
|
|
foreach (ref readonly var entity in ReadEntities<UITextComponent>())
|
|
{
|
|
ref readonly var uiTextComponent = ref GetComponent<UITextComponent>(entity);
|
|
ref readonly var positionComponent = ref GetComponent<PositionComponent>(entity);
|
|
|
|
SpriteBatch.DrawString(
|
|
uiTextComponent.Font,
|
|
uiTextComponent.Text,
|
|
positionComponent.Position.ToXNAVector(),
|
|
Color.White
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|