Repository navigation
[Architecture] Scene and Serialization register themselves in the composition - #128
Merged
Merged
Conversation
…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
There was a problem hiding this comment.
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
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
WorldManagerand simplifiesGameEngine. - 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
…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
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
AddHEngineSystem<T>(priority, enabled)to ECS: it registers the system and anISystemRegistration, andWorldManageradds every registered system to itself on construction. The new constructor parameter is optional, so directnew WorldManager(new SystemManager())callers are unchanged.AddHEngineScene()(free camera 10, transform hierarchy 9, frustum culling 8) and call it andAddHEngineSerialization()fromAddHEngineRuntime.TransformHierarchySystemandFrustumCullingSystemnow tick from theSystemManagerthe game loop drives, andSceneSerializer/ComponentSerializerRegistryresolve from the container.FreeCameraSystemand itsICameraInputProviderconstructor dependency fromGameEngine; the system's defaults already matched the values the host set.Part of #127. The
HEngine.Assetsregistration andMeshAssetLoadingSystemwiring follow in a second PR that closes it.Known risk, not addressed here:
FrustumCullingSystemadds and removesCulledwhile iterating its query. The demo has noBoundingBoxentities, so it is never exercised in the running host.Test plan
dotnet build HEngine.slnx -c Debug— 0 warnings, 0 errorsdotnet test HEngine.slnx— all projects green, includingHEngine.Architecture.TestsAddHEngineScene(systems present, tick order, act on the world viaSystemManager.Update, missing input provider fails validation),CompositionTests(scene systems in the production world, serialization services resolve)master: both reach the game loop, render 47 meshes, and log the same lines apart from FPS values and paths; stderr emptyBoundingBoxorMeshAssetentities, so the newly ticking systems have nothing to act on