Implement the following plan: Rewrite ColliderDebugSystem for per-frame collider…
- User
Implement the following plan:
Rewrite ColliderDebugSystem for per-frame collider visualization
Context
We need visual debug overlays for colliders (BoxCollider + ConvexCollider) to diagnose collision issues at a glance. A
ColliderDebugSystemalready exists but is non-functional: it only fires on component addition (subscription-based), creates static entities that don't follow moving entities, and doesn't setVisible(required for Main render target). It needs a full rewrite.Approach
Rewrite
ColliderDebugSystemusing the ephemeral per-frame pattern fromSpriteDebugSystem: each frame, dispose previous debug entities, query all colliders, and create fresh mesh entities with colored outlines. Reuse the existingLineMeshGeneratorstatic helpers for building mesh vertices.Changes
1. Rewrite
MonoDreams/System/Debug/ColliderDebugSystem.csReplace the entire subscription-based implementation with a per-frame system:
- Query: Use
ColliderTag+Transformentity set (same as collision detection system) - Per frame: Dispose all previous debug entities, then recreate
- BoxCollider: Compute world-space rectangle from
transform.WorldPosition + boxCollider.Bounds.Location, draw 4 line segments as a rectangle outline usingLineMeshGenerator.AddLine - ConvexCollider: Draw polygon edges by iterating
WorldVertices(already in world space, updated by collision system) — connect each vertex to the next with lines - Colors: Red = active, Green = passive, Gray = disabled (same scheme, via existing
IColliderflags) - DrawComponent: Type =
Mesh, Target =Main, LayerDepth =1f(on top). SetVisibleon each debug entity soMasterRenderSystempicks them up - Toggle:
IsEnabledproperty + staticEnabledfield (matchesSpriteDebugSystempattern) - Line thickness: 0.5px — thin enough to not obscure sprites but visible at game scale
Remove dead code (
AddDebugLine,_pixelTexture, NinePatch approach, subscriptions).2. Wire into
MonoDreams.Examples/Screens/LoadLevelExampleGameScreen.cs - Query: Use
Assistant
I'll start by reading the key files needed for this implementation.
Assistant
Now let me read the remaining files I need.
Assistant
Now I have all the context I need. Let me also quickly check how
Visibleis used and how the existing collision detection system queries entities.Assistant
Let me check the MasterRenderSystem query logic more closely.
Assistant
Let me check how CullingSystem adds Visible.
Assistant
Now I have full understanding. Let me implement the rewrite.
Assistant
Now wire it into
LoadLevelExampleGameScreen.cs.Assistant
Now build to verify.
Assistant
Build succeeds with 0 errors. Here's a summary of the changes:
MonoDreams/System/Debug/ColliderDebugSystem.cs— Full rewrite:- Replaced subscription-based approach with per-frame ephemeral entity pattern (matching
SpriteDebugSystem) - Queries entities with
ColliderTag+Transformeach frame - Disposes all previous debug entities, then recreates fresh ones
- BoxCollider: computes world-space corners from
Transform.WorldPosition + Bounds, draws 4 line segments as a rectangle outline viaLineMeshGenerator.AddLine - ConvexCollider: iterates
WorldVertices(already in world space), connects each vertex to the next with lines - Colors: Red = active, Green = passive, Gray = disabled
- Sets
Visibleon debug entities soMasterRenderSystemrenders them on the Main target IsEnabledproperty + staticEnabledfield for toggling- Removed all dead code (
_pixelTexture, NinePatch approach,AddDebugLine, subscriptions, dependency)
- Replaced subscription-based approach with per-frame ephemeral entity pattern (matching
- User
Make a way to enable disable this and other debugging features via the ImGUI debugging UI that exists for tracking entities and their components and shows when you hit F1.
Assistant
Let me start by reading the existing plan and exploring the ImGui debug infrastructure.
Assistant
Excellent exploration results. Now let me read the DebugInspector directly to understand its exact structure and where to add a new panel.
Assistant
Now let me also check if LayoutDebugSystem is wired anywhere and what it looks like.
Assistant
Good. Now I have complete understanding. Let me design the plan with a Plan agent.
Assistant
Now let me write the final plan to the plan file.
- User
[Request interrupted by user for tool use]