Skip to content

Add state-driven entity disabling using a EnabledInState component #19087

Open
@alice-i-cecile

Description

@alice-i-cecile

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

When working with complex states, especially for menus, it can be nice to fully preserve the data of various entities while hiding them from the world.

The "despawn when entering / exiting states" behavior in #18818 is useful for full cleanup, but that's not always desirable.

What solution would you like?

Now that we have a Disabled component, we can do better!

Reuse the StateScoped component name, and cause it to disable and enable entities based on the states.

What alternative(s) have you considered?

This is easy to implement in third-party code, but it's a natural complement and a useful pattern to teach and use internally in first-party tools.

Additional context

Discussed in #18818.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-StatesApp-level states machinesC-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!X-UncontroversialThis work is generally agreed upon

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions