Skip to content

[Architecture] Scene and Serialization register themselves in the composition - #128

Merged
eXoz00rd merged 3 commits into
masterfrom
fix/127-module-registration-points
Sep 29, 2026
Merged

eXoz00rd merged 3 commits into
masterfrom
fix/127-module-registration-points

Conversation

@eXoz00rd

Copy link
Copy Markdown
Owner

Summary

  • Add AddHEngineSystem<T>(priority, enabled) to ECS: it registers the system and an ISystemRegistration, and WorldManager adds every registered system to itself on construction. The new constructor parameter is optional, so direct new WorldManager(new SystemManager()) callers are unchanged.
  • Add AddHEngineScene() (free camera 10, transform hierarchy 9, frustum culling 8) and call it and AddHEngineSerialization() from AddHEngineRuntime. TransformHierarchySystem and FrustumCullingSystem now tick from the SystemManager the game loop drives, and SceneSerializer / ComponentSerializerRegistry resolve from the container.
  • Remove the hand-built FreeCameraSystem and its ICameraInputProvider constructor dependency from GameEngine; the system's defaults already matched the values the host set.

Part of #127. The HEngine.Assets registration and MeshAssetLoadingSystem wiring follow in a second PR that closes it.

Known risk, not addressed here: FrustumCullingSystem adds and removes Culled while iterating its query. The demo has no BoundingBox entities, so it is never exercised in the running host.

Test plan

  • dotnet build HEngine.slnx -c Debug — 0 warnings, 0 errors
  • dotnet test HEngine.slnx — all projects green, including HEngine.Architecture.Tests
  • New tests: ECS registration (added to world, priority order, disabled, missing dependency fails validation), AddHEngineScene (systems present, tick order, act on the world via SystemManager.Update, missing input provider fails validation), CompositionTests (scene systems in the production world, serialization services resolve)
  • Ran the demo host for 12 s next to a build of master: both reach the game loop, render 47 meshes, and log the same lines apart from FPS values and paths; stderr empty
  • Window contents were not visually compared; the demo has no BoundingBox or MeshAsset entities, so the newly ticking systems have nothing to act on

Copilot AI lite review requested due to automatic review settings September 24, 2026 21:22
…position

- Add AddHEngineSystem<T> to ECS; WorldManager adds registered systems on construction
- Add AddHEngineScene registering the free camera, transform hierarchy and frustum culling systems
- Call AddHEngineScene and AddHEngineSerialization from AddHEngineRuntime
- Drop the hand-built FreeCameraSystem and its input dependency from GameEngine
- Cover registration, tick order and the production composition with tests

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical lifecycle and API compatibility issues, plus a culling iteration bug, remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity · 1 Medium severity

Open (3)
What changed in this PR

This PR adds module-owned Scene and Serialization registration, wires ECS systems into the runtime composition, and removes manual camera setup.

Changes:

  • Adds prioritized, optionally enabled ECS system registration.
  • Registers Scene and Serialization through runtime composition.
  • Updates WorldManager and simplifies GameEngine.
  • Adds composition and registration tests.
File Description
Tests/​HEngine.Scene.Tests/​Extensions/​ServiceCollectionExtensionsTests.cs Tests Scene registration and execution.
Tests/​HEngine.Rendering.D3D12.Tests/​CompositionTests.cs Tests production composition.
Tests/​HEngine.ECS.Tests/​Extensions/​ServiceCollectionExtensionsTests.cs Tests ECS registration behavior.
Src/​Runtime/​HEngine.Runtime/​HEngine.Runtime.csproj Adds Scene and Serialization references.
Src/​Runtime/​HEngine.Runtime/​Extensions/​ServiceCollectionExtensions.cs Composes Scene and Serialization modules.
Src/​Core/​HEngine.Scene/​HEngine.Scene.csproj Adds dependency injection support.
Src/​Core/​HEngine.Scene/​Extensions/​ServiceCollectionExtensions.cs Registers Scene systems.
Src/​Core/​HEngine.ECS/​Managers/​WorldManager.cs Installs registered systems.
Src/​Core/​HEngine.ECS/​Extensions/​ServiceCollectionExtensions.cs Adds generic system registration.
Src/​Core/​HEngine.ECS/​Contracts/​ISystemRegistration.cs Defines the registration contract.
HEngine/​GameEngine.cs Removes manual camera-system setup.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

…iteration

- AddHEngineSystem<T> builds the system via ActivatorUtilities instead of
  registering it as its own DI singleton, so SystemManager is the sole
  owner of its disposal (it was previously disposed by both the container
  and SystemManager)
- Restore an explicit one-argument WorldManager(SystemManager) constructor
  instead of an optional parameter, preserving the existing public
  constructor signature
- FrustumCullingSystem now snapshots the query's entities before mutating
  Culled, so adding/removing the component mid-frame no longer truncates
  the frame's remaining entities
- Cover disposal ownership, non-resolvability from the container, and
  multi-entity culling with tests

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved lifecycle, initialization-order, and per-frame allocation concerns remain.

Review effort: Lite
Findings: 1 High severity · 1 Medium severity

Open (2)
Resolved since last review (3)

Copilot AI review requested due to automatic review settings September 29, 2026 12:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…llocation

- GameLoop now depends on WorldManager instead of reaching past it to the
  shared SystemManager, so resolving or running the loop always forces
  the world (and its registered systems) to be constructed first
- FrustumCullingSystem collects culling changes into a reused instance
  list instead of copying the query's entities every frame, so it no
  longer allocates on frames where nothing needs to change
- Cover both fixes with tests
@eXoz00rd
eXoz00rd requested a lite review from Copilot September 29, 2026 12:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@eXoz00rd
eXoz00rd requested a lite review from Copilot September 29, 2026 17:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@eXoz00rd
eXoz00rd merged commit 4eb6523 into master Sep 29, 2026
1 check passed
@eXoz00rd
eXoz00rd deleted the fix/127-module-registration-points branch September 29, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants