Expose entity lifecycle events on World #1058
Merged
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.
Description
This pull request exposes entity lifecycle events on the
Worldclass, allowing external systems to react when entities are added, removed, or have their component composition changed. This enables integration between the ECS and other subsystems (such asCollisionComponent) without requiring each system to implement its own entity tracking.The events are raised during the
World.Update()cycle and provide entity IDs to subscribers, who can then perform necessary initialization or cleanup operations.Related Issues/Tickets
Changes Made
Worldclass:EntityAdded: Fires when an entity is added to the world during the update cycleEntityRemoved: Fires when an entity is removed from the world during the update cycle (before destruction)EntityChanged: Fires when an entity's component composition changesWorldconstructor: Subscribes to internalEntityManagerevents to forward them to public subscribersWorld.Dispose(): Unsubscribes fromEntityManagereventsBug Fixed
EntityChangedinvocation inEntityManager: Removed immediate event invocation inOnComponentsChanged()to ensure the event only fires once during the Update() cycle, consistent withEntityAddedandEntityRemovedbehaviorChecklist
Please read and check the following items. Pull requests will not be reviewed if all items are not checked.