-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Rename StateScoped
to DespawnOnExitState
and add DespawnOnEnterState
#18818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…into rename-StateScoped
It looks like your PR is a breaking change, but you didn't provide a migration guide. Please review the instructions for writing migration guides, then expand or revise the content in the migration guides directory to reflect your changes. |
986f57d
to
467ba58
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving a few minor comments on the documentation, but the code looks good and I like the rename.
@benfrankel thanks for the review ❤️. I'll apply the suggestions shortly (no rush due to 0.16 shenanigans). In the meantime, if you have any thoughts on the open questions in the PR description, please feel free to add your opinion |
I think it would be best to keep it to a single Another naming option is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I'm also not interested in DespawnOnEnterState
either, I think the performance cost of enabling both with 1 call is likely negligible as it is only scheduled to run once during transitions, whereas the verbosity of splitting the enabling calls seems cumbersome. It will still be possible to refine it later once more state-scope mechanisms are introduced.
Regarding the naming question for the common enabling call, it seems from the discussions in #16284 that "state scope" could still be used to name the feature (bikeshed: could also introduce something like "Entities Lifetime" which could potentially extend to more usages than just state scopes).
Regarding the internal systems name, I prefer despawn_entities_on_enter_state
rather than apply_despawn_on_enter_state
.
(As a more general note, I feel like it might have been easier to split the work as a straightforward renaming PR from StateScoped to DespawnOnExitState and then have a PR to propose an extension of state scoping mechanisms)
Co-authored-by: Ben Frankel <ben.frankel7@gmail.com>
@Henauxg in case you weren't aware, I adopted this PR and all the work and review was already done, so it probably would have been more effort to start from scratch, even if you're right. |
@benfrankel @Henauxg how about this rename for the First, as a reminder, the goal of the rename (more than just pointless rename churn) is that
Proposal: app.enable_state_scoped_entity_despawning::<GameState>();
app.enable_state_scoped_entity_visibility::<GameState>();
// The visibility one just to show that it _could_ exist, even in userland,
// and also to show how the naming would sit with the despawning version I went back and forth a bit coming up with this. Rationale/thinking:
If we wanted, we could also use the term app.enable_state_bound_entity_despawning::<GameState>();
app.enable_state_bound_entity_visibility::<GameState>(); WDYT? |
I thought that I would prefer Here's my attempt at a more accurate name: app.enable_entities_despawning_on_state_transitions::<GameState>(); The plural does not seem like a bad thing to me. It manages entities, not an entity. We have plural on EDIT: the use of |
I'm pretty sure I have opinions here on what an ideal naming / setup looks like, but I can tackle that during final review. Other maintainers: please let me handle this one? |
FWIW in my own crate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migration guide looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've come around and quite like the current naming. Let's merge this, and then make an entity-disabling form in follow-up.
Objective
StateScoped
toDespawnOnStateExit
and addDespawnOnStateEnter
#16284.StateScoped
toStateExitDespawn
, add the inverse variantStateEntryDespawn
#15849.Solution
StateScoped
toDespawnOnExitState
.clear_state_scoped_entities
todespawn_entities_on_exit_state
.DespawnOnEnterState
anddespawn_entities_on_enter_state
which is theOnEnter
equivalent.Note
Compared to #16284, the main change is that I did the rename in such a way as to keep the terms
OnExit
andOnEnter
together. In my own game, I was addingVisibleOnEnterState
andHiddenOnExitState
and when naming those, I kept theOnExit
andOnEnter
together. When I checked #16284 it stood out to me that the naming was a bit awkward. Putting theState
in the middle and breaking upOnEnter
andOnExit
also breaks searching for those terms.Open questions
enable_state_scoped_entities
into two functions, one for theOnEnter
and one for theOnExit
? I personally have zero need thus far for theOnEnter
version, so I'd be interested in not having this enabled unless I ask for it.Visibility
state components (see below) and name theseapp.enable_despawn_entities_on_enter_state()
andapp.enable_despawn_entities_on_exit_state()
, which IMO says what it does on the tin?Testing
Ran all changed examples.
Side note:
VisibleOnEnterState
andHiddenOnExitState
For reference to anyone else and to help with the open questions, I'm including the code I wrote for controlling entity visibility when a state is entered/exited.
visibility.rs