Skip to content

Conversation

@AristurtleDev
Copy link
Collaborator

Description

This pull request exposes entity lifecycle events on the World class, 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 as CollisionComponent) 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

  • Added three public events to World class:
    • EntityAdded : Fires when an entity is added to the world during the update cycle
    • EntityRemoved: Fires when an entity is removed from the world during the update cycle (before destruction)
    • EntityChanged: Fires when an entity's component composition changes
  • Event wiring in World constructor: Subscribes to internal EntityManager events to forward them to public subscribers
  • Cleanup in World.Dispose(): Unsubscribes from EntityManager events

Bug Fixed

  • Fixed duplicate EntityChanged invocation in EntityManager: Removed immediate event invocation in OnComponentsChanged() to ensure the event only fires once during the Update() cycle, consistent with EntityAdded and EntityRemoved behavior

Checklist

Please read and check the following items. Pull requests will not be reviewed if all items are not checked.

  • I have verified that there are no existing pull requests that would overlap with this pull request.
  • I have verified that I am following the guidelines as outlined in this project's contribution policy
  • I have verified that this pull request adheres to this project's code of conduct.
  • I have written a descriptive title for this pull request.
  • I have provided appropriate test coverage were applicable.

@AristurtleDev AristurtleDev self-assigned this Nov 6, 2025
@AristurtleDev AristurtleDev merged commit 1618789 into develop Nov 6, 2025
1 check passed
@AristurtleDev AristurtleDev deleted the feature/expose-events-to-entities-1026 branch November 6, 2025 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Expose events to entities being added and removed from an ECS world

2 participants