Skip to content

Support removing a removed Component's required components #15580

@cart

Description

@cart

What problem does this solve or what need does it fill?

Sometimes it is desirable to remove not just a specific component, but also its required components: #15572 (comment).

What solution would you like?

Add an entity.remove_with_requires::<SomeComponent>() API that removes all required components brought in by SomeComponent (recursively).

What alternative(s) have you considered?

  • This should not be the default behavior of entity.remove::<SomeComponent>(), as in many cases this could remove components that are required by other components. If we want to go this route, we need to consider building some sort of reference counting system to track requires across components. But there are still problems there (ex: what if someone manually added a component ... how do we distinguish between overriding a required component value and inserting a new separate persistent component).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions