-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
261 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace MonoDreams.Examples.Component; | ||
|
||
public class PlayerState | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
using DefaultEcs; | ||
using DefaultEcs.System; | ||
using ImGuiNET; | ||
using Microsoft.Xna.Framework; | ||
using Microsoft.Xna.Framework.Graphics; | ||
using MonoDreams.Component; | ||
using MonoDreams.Component.Debug; | ||
using MonoDreams.Examples.Component; | ||
using MonoDreams.LegacyComponents; | ||
using MonoDreams.Message; | ||
using MonoDreams.State; | ||
using MonoGame.ImGuiNet; | ||
using Position = MonoDreams.Component.Position; | ||
|
||
namespace MonoDreams.Examples.System.InGameDebug; | ||
|
||
public class DebugSystem : AComponentSystem<GameState, DebugUI> | ||
{ | ||
private readonly ImGuiRenderer _guiRenderer; | ||
private List<CollisionMessage> _collisions = []; | ||
// private List<PlayerTouchMessage> _touches = []; | ||
private readonly World _world; | ||
private readonly Game _game; | ||
private readonly SpriteBatch _batch; | ||
|
||
public DebugSystem(World world, Game game, SpriteBatch batch) : base(world) | ||
{ | ||
_world = world; | ||
_game = game; | ||
_batch = batch; | ||
_guiRenderer = new ImGuiRenderer(game); | ||
_world.Subscribe(this); | ||
} | ||
|
||
[Subscribe] | ||
private void On(in CollisionMessage message) => _collisions.Add(message); | ||
|
||
// [Subscribe] | ||
// private void On(in PlayerTouchMessage message) => _touches.Add(message); | ||
|
||
protected override void Update(GameState state, ref DebugUI debugUI) | ||
{ | ||
_guiRenderer.RebuildFontAtlas(); | ||
_batch.GraphicsDevice.SetRenderTarget(debugUI.DebugRenderTarget); | ||
_batch.GraphicsDevice.Clear(Color.Transparent); | ||
_guiRenderer.BeforeLayout(state.GameTime.current); | ||
|
||
_game.IsMouseVisible = true; | ||
|
||
var player = _world.GetEntities().With<PlayerState>().AsEnumerable().First(); | ||
ImGui.Begin("PlayerState", ImGuiWindowFlags.Modal); | ||
|
||
ImGui.Text($"Position: {player.Get<Position>().Current}"); | ||
// ImGui.Text($"Bounds: {player.Get<Collidable>().Bounds}"); | ||
|
||
// ImGui.SetNextItemOpen(true); | ||
// if (ImGui.TreeNode("State")) | ||
// { | ||
// var playerState = player.Get<PlayerState>(); | ||
// ImGui.Text($"Movement: {playerState.Movement}"); | ||
// ImGui.Text($"Grabbing: {playerState.Grabbing}"); | ||
// ImGui.Text($"Riding: {playerState.Riding}"); | ||
// ImGui.TreePop(); | ||
// } | ||
// | ||
// ImGui.SetNextItemOpen(true); | ||
// if (ImGui.TreeNode("Dynamic Body")) | ||
// { | ||
// var dynamicBody = player.Get<DynamicBody>(); | ||
// ImGui.Text($"Gravity: {dynamicBody.Gravity}"); | ||
// ImGui.Text($"IsJumping: {dynamicBody.IsJumping}"); | ||
// ImGui.Text($"IsRiding: {dynamicBody.IsRiding}"); | ||
// ImGui.Text($"IsSliding: {dynamicBody.IsSliding}"); | ||
// ImGui.TreePop(); | ||
// } | ||
// | ||
// ImGui.SetNextItemOpen(true); | ||
// if (ImGui.TreeNode("Movement Controller")) | ||
// { | ||
// var movementController = player.Get<MovementController>(); | ||
// ImGui.Text($"Velocity: {movementController.Velocity}"); | ||
// ImGui.TreePop(); | ||
// } | ||
|
||
ImGui.End(); | ||
|
||
ImGui.Begin("Collision Messages", ImGuiWindowFlags.Modal); | ||
foreach (var collision in _collisions) | ||
{ | ||
ImGui.SetNextItemOpen(true); | ||
if (ImGui.TreeNode("Collision")) | ||
{ | ||
ImGui.Text($"Base Entity: {collision.BaseEntity}"); | ||
ImGui.Text($"Colliding Entity: {collision.CollidingEntity}"); | ||
ImGui.Text($"Contact Time: {collision.ContactTime}"); | ||
ImGui.TreePop(); | ||
} | ||
} | ||
ImGui.End(); | ||
|
||
// ImGui.Begin("PlayerTouch Messages", ImGuiWindowFlags.Modal); | ||
// foreach (var touch in _touches) | ||
// { | ||
// ImGui.SetNextItemOpen(true); | ||
// if (ImGui.TreeNode("Touch")) | ||
// { | ||
// ImGui.Text($"TouchingEntity: {touch.TouchingEntity}"); | ||
// ImGui.Text($"Side: {touch.Side}"); | ||
// ImGui.TreePop(); | ||
// } | ||
// } | ||
// ImGui.End(); | ||
|
||
_guiRenderer.AfterLayout(); | ||
_batch.GraphicsDevice.SetRenderTarget(null); | ||
_collisions.Clear(); | ||
// _touches.Clear(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using DefaultEcs; | ||
using DefaultEcs.System; | ||
using Microsoft.Xna.Framework; | ||
using Microsoft.Xna.Framework.Graphics; | ||
using MonoDreams.Component.Debug; | ||
using MonoDreams.Renderer; | ||
using MonoDreams.State; | ||
|
||
namespace MonoDreams.Examples.System.InGameDebug; | ||
|
||
public class DrawDebugSystem(World world, SpriteBatch batch, ResolutionIndependentRenderer renderer) : AComponentSystem<GameState, DebugUI>(world) | ||
{ | ||
protected override void Update(GameState state, ref DebugUI debugUI) | ||
{ | ||
batch.Begin( | ||
SpriteSortMode.Deferred, | ||
BlendState.AlphaBlend, | ||
SamplerState.PointClamp, | ||
DepthStencilState.None, | ||
RasterizerState.CullNone); | ||
batch.Draw(debugUI.DebugRenderTarget, Vector2.Zero, new Rectangle(0, 0, renderer.ScreenWidth, renderer.ScreenHeight), Color.White); | ||
batch.End(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using DefaultEcs; | ||
using Microsoft.Xna.Framework.Graphics; | ||
using MonoDreams.Component.Debug; | ||
using MonoDreams.Renderer; | ||
|
||
namespace MonoDreams.Objects; | ||
|
||
public class InGameDebug | ||
{ | ||
public static Entity Create(World world, SpriteBatch batch, ResolutionIndependentRenderer renderer) | ||
{ | ||
var entity = world.CreateEntity(); | ||
entity.Set(new DebugUI(new RenderTarget2D(batch.GraphicsDevice, renderer.ScreenWidth, renderer.ScreenHeight))); | ||
return entity; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.