From 567c422f8cd42eba2437f9a8c2522716a1649be7 Mon Sep 17 00:00:00 2001 From: hazel Date: Mon, 26 Jan 2026 22:04:39 +0100 Subject: celesteia archive, last updated april 9th 2024 Signed-off-by: hazel --- source/game/systems/EntityDebugSystem.cs | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 source/game/systems/EntityDebugSystem.cs (limited to 'source/game/systems/EntityDebugSystem.cs') diff --git a/source/game/systems/EntityDebugSystem.cs b/source/game/systems/EntityDebugSystem.cs new file mode 100644 index 0000000..9b7914a --- /dev/null +++ b/source/game/systems/EntityDebugSystem.cs @@ -0,0 +1,44 @@ +using Celesteia.Graphics; +using Celesteia.Resources; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using MonoGame.Extended; +using MonoGame.Extended.Entities; +using MonoGame.Extended.Entities.Systems; + +namespace Celesteia.Game.Systems { + public class EntityDebugSystem : EntityDrawSystem + { + private readonly Camera2D _camera; + private readonly SpriteBatch _spriteBatch; + + private ComponentMapper transformMapper; + + private SpriteFont _font; + + public EntityDebugSystem(Camera2D camera, SpriteBatch spriteBatch) : base(Aspect.All(typeof(Transform2))) { + _camera = camera; + _spriteBatch = spriteBatch; + } + + public override void Initialize(IComponentMapperService mapperService) + { + transformMapper = mapperService.GetMapper(); + + _font = ResourceManager.Fonts.GetFontType("Hobo").Font; + } + + public override void Draw(GameTime gameTime) + { + _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, null, null, null, _camera.GetViewMatrix()); + + foreach (int entityId in ActiveEntities) { + Transform2 transform = transformMapper.Get(entityId); + + _spriteBatch.DrawString(_font, transform.Position.ToString(), transform.Position, Color.White, 0f, new Vector2(0.5f, 0.5f), .12f, SpriteEffects.None, 0f); + } + + _spriteBatch.End(); + } + } +} \ No newline at end of file -- cgit v1.2.3