I’m curious how folks use AppStates… so I made a poll:
I use one of the AppState base classes like I’m supposed to.
I’m a rebel and just implement the AppState interface directly.
What’s an AppState?
0voters
Reasoning: I would like to add a getId():String method to the AppState interface and then default implementations to the base classes. This would “harm” only those who implement AppState directly.
Adding the method is WAY easier and cleaner than having an interim IdentifiableAppState interface or somesuch.
The idea here is to be able to lookup AppStates by ID instead of just class. Useful when you have something like a ViewPortState and want to get the “rootNode” viewport versus the “guiNode” viewport, for example.
well im not sure why someone would want expand AppState interace since there is AbstractAppState/BaseAppState to make own AppState. (that is anyway low level)
since for example “public class BulletAppState implements AppState” this do not extend Abstract layer, just interface, so you would need add it to multiple Classes. (just dont forget about AbstractAppState/BaseAppState )
By the way, this means we can now have 2 instances of the same AppState class?
I’ve believed that AppStates and Controls are the same thing, except for you can have only 1 instance of AppState, instead you can have multiple Controls (but must be attached to some Spatial). Am I wrong?
Wouldn’t this also require to change the API in the AppStateManager? To return a collection, array or else of AppStates then? And/Or adding a parameter to specify the id.
Is the id then meant to be unique or unique among the same app state class?
I think is going to be really good for adding instances of the same class, but maybe it can be done with something like the ElementId, that way it can be added as a child, and then you can get an array of states of a parent as well as an indivial state.
This is what i imagine how it could be used
I think that’s overly complicated for this. If you want your app state to be ID=“viewport.gui.minimap” then that’s up to you.
Also, because of the way AppStateManager supports multithreaded access, you will likely never see a getStates() method since it would have to copy the data.
Most of my app states are derived from a custom base class NamedAppState, written in 2017. As you might imagine, it includes a per-instance String (for debugging purposes).
Adding a method to the AppState interface will impact me. However, I don’t mind modifying my libraries. So go ahead.