Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
book: how to interact between states and systems using resources #1154
I promised folks during an Amethyst presentation I did in Gothenburg to improve documentation around the pain points I encountered while building a test game in Amethyst.
This adds concrete documentation for how to actually implement the state transitions hinted at during the
I'm also actively working on trying to improve the ergonomics around this approach, so far the only relevant issue is: #1146 - but in general I'm trying to create a stronger association between a group of states and systems. If this becomes relevant, I'll update the documentation to reflect it :).
The other approach I'm aware of to handle this would be to set up event channels. But that section doesn't really talk about how to set up readers in states (it probably should!). Event channels is however a bit more complicates since the reader needs to be setup.
Add concrete documentation for input handling - I mention adding an action called
jojolepro left a comment
Thanks, but the content isn't actually true. I explained the proper way to handle state transitions in the following comments.
Note that there's a secret
This is the reason it isn't mentioned in the book. If you do want to mention it, it should be in an "advanced" section with a big disclaimer.
Thanks for checking this out :)
azriel91 left a comment
Hiya! Thanks for writing an example on how to use resources to communicate with states.
The writing style is good; the example has a number of things that can be improved:
Let's see what the others think about the code example.
Must end this with a great work!
I renamed the
Right now I want to make sure we capture some status quo in the book that allows people to use the engine more independently. As it evolves, we either find or build better ways to do this, the documentation should be updated to reflect that.
Thank you for the review! <3
I made a "pretty" drawing of how I mentally think about the ECS.
Of course, you can have Systems that are aware of the
Also, you wouldn't want a system doing a State
I hope I was able to explain that correctly.
I'll reiterate some things that were discussed over Discord. Sorry if I miss things.
It's important to emphasize that this PR is not the do-all, end-all way to trigger state transitions.
I do believe that triggering state transitions through resources is actually not that bad all things considered.
There is probably a better way to trigger state transitions
There was concerns raised about coupling systems to states
That would be the
We do maintain the value of the
Moxinilian left a comment
azriel91 left a comment
Happy with the wording, I did change the code around to use an
Essentially I just changed the boolean flags with an enum, I guess manually upholding the state invariant felt like a footgun