Skip to content

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

@greenstack

Description

@greenstack

Purpose

Being able to react to entities being added to and removed from the ECS world would allow us to be able to add or remove entities that interact with multiple APIs or that need to exist in multiple disparate collections or contexts.

Motivation

An entity that exists in both a CollisionComponent from MonoGame.Extended's collision code needs to be removed from both the ECS world and the CollisionComponent when it is destroyed in the ECS. Being able to react to entities being added outside of the ECS would also allow other types of interactions.

While systems can be designed to raise these events themselves, having a single unified place would avoid having to implement this manually and allow multiple systems to remove entities without listeners for such an event having to subscribe to each possibility.

These events already exist in the EntityManager, which each world has. The public-facing events in the entity manager; we could expose these events in the World class and have the add and remove accessors direct to the EntityManager's equivalent events.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions