More state driven entity disabling components
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## What problem does this solve or what need does it fill?
Addendum to #24142, as suggested by @chescock on the [bevy discord](https://discord.com/channels/691052431525675048/749335865876021248/1501592135525208201)
> Oh, that looks like a nice pattern! I see it's already merged, but I had a thought: The example there has both EnableOnEnter(GameState::InGame) and DisableOnExit(GameState::InGame). Do we expect those to always be paired? If so, it might be more convenient to have a single EnabledIn(GameState::InGame) component that handles both adding and removing Disabled (along with DisabledIn(S) and EnabledWhen(impl Fn(S) -> bool) for the other cases).
I would prefer to keep the previous components if we're doing this for more fine grained control, but otherwise I agree with the convenience of the proposed components.
## What solution would you like?
Add
- `EnabledIn`
Entity will only be enabled when in the given state
- `DisabledIn`
Entity will be disabled when in the given state, and re-enabled when it's left
- `EnabledWhen`
Same as `EnabledIn` but uses a predicate
- `DisabledWhen`
Same as `DisabledIn` but uses a predicate
I'm not totally sold on the names as semantically they aren't far enough away from the existing components to denote their purpose, so bikeshedding welcome.
## What alternative(s) have you considered?
Keep as is and advice users to combine the previous components
Contributor guide
Research direction
Start by reading issue #24142 and the existing EnableOnEnter and DisableOnExit components it introduced. Clarify the names and intended state-transition behavior for EnabledIn, DisabledIn, EnabledWhen, and DisabledWhen, then verify that the paired enable/disable and predicate semantics are covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100