Caution
This Repository is no longer maintained, as the associated PR has been closed. It's archived to prevent breaking dependent projects, but should not be used.
This crate is an implementation of the State Pattern Matching - Alternative PR as a third party crate, to provide access to test out the feature in 0.12
before it gets merged in for, hopefully, 0.13
.
NOTE: much of the code is directly copied and pasted from the Bevy repository, and while I implemented the changes in the PR - there are many others who were involved in creating the original code. As such, despite this being a 3rd party repository, I'd consider all the code here to be Bevy's rather than mine - I'm just providing early access to this API.
Due to being a 3rd party crate, there are some added limitations on what we can do, which result in some API differences:
- we can't auto-implement
IntoSystem
for state matchers. As a result, we have opted to add arun_in<S: States, Sm: StateMatcher<S>>(Sm)
to all implementors ofIntoSystem
- that way it'll just be a search and replace when migrating to0.13
- assuming the API remains intact. In addition, I added anand_then
function toStateMatcher<S>
directly, but it won't support conditions - only other matchers. If you want both state matchers and other conditions, you will have to chainrun_in
andrun_if
commands. - we can't replace existing types with the same name - so the enum version of
NextState
has been renamedNextMatchableState
- we can't replace the existing
add_state
with one that triggers theEntering
&Exiting
states when states change, or uses the updatedNextMatchableState
implementation, so we added anadd_matchable_state
method for that purpose.
To install, you currently need to specify the github repo in Cargo.toml
:
[dependencies]
bevy = "0.12",
bevy_state_matching_prototype = { git = "https://github.com/lee-orr/bevy-state-match-prototype" }