You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using another physics library and have a component to act as an "in between" with the ECS system.
But, when I destroy the parent entity or component I don't have an easy way to reference the component to destroy the partner physics body.
I don't see any significant downsides to implementing this change.
Somethings to consider would be if an OnDelete handler calls Delete() again on the same component, the component would be set to null during handler execution. Subsequent handlers in the chain would see null and likely throw. This is user error and would fail fast, putting the responsibility on users to avoid duplicating delete calls. If a handler throws an exception, the component will not be be removed and the composition changed event will not fire, leaving the entity in an inconsistent state. This is standard event handler behavior, however, and would be the user's responsibility to handle.
An alternative approach could be to split this into two events; OnBeforeDelete (invoked before removal, as you're proposing) and keep the existing OnDelete (invoked after removal). This would provide flexibility for different use cases while maintaining backward compatibility.
However, I think moving OnDelete to before the removal is the better choice since the current timing provides no benefit and it enables important cleanup scenarios like your physics body example
Activity
AristurtleDev commentedon Nov 9, 2025
I don't see any significant downsides to implementing this change.
Somethings to consider would be if an
OnDeletehandler callsDelete()again on the same component, the component would be set tonullduring handler execution. Subsequent handlers in the chain would seenulland likely throw. This is user error and would fail fast, putting the responsibility on users to avoid duplicating delete calls. If a handler throws an exception, the component will not be be removed and the composition changed event will not fire, leaving the entity in an inconsistent state. This is standard event handler behavior, however, and would be the user's responsibility to handle.An alternative approach could be to split this into two events;
OnBeforeDelete(invoked before removal, as you're proposing) and keep the existingOnDelete(invoked after removal). This would provide flexibility for different use cases while maintaining backward compatibility.However, I think moving
OnDeleteto before the removal is the better choice since the current timing provides no benefit and it enables important cleanup scenarios like your physics body example