You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was considering using SparseSet backed components as markers for the current player state, in a way that different marker components could be added and removed as often as the player state changes.
As far as I understand, SparseSet storage is specifically useful for instances where you want to add/remove the component frequently because it doesn't change the entity's archetype ( or something like that ).
The motivation is because I want to have different systems that operate on the player depending on which state component is on the player.
For instance while idling, the Idling component will be on the player and the idle system will have a query that operates on all idling players. But as soon as the player moves, the Idling component will be removed and a Moving component added. Then the move system which has a query including players with the Moving component will kick in.
Is there a performance disadvantage do you think to this model as opposed to, for instance, having a State enum with variants for each state and having each system execute based on the condition of the State enum?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I was considering using
SparseSet
backed components as markers for the current player state, in a way that different marker components could be added and removed as often as the player state changes.As far as I understand,
SparseSet
storage is specifically useful for instances where you want to add/remove the component frequently because it doesn't change the entity's archetype ( or something like that ).The motivation is because I want to have different systems that operate on the player depending on which state component is on the player.
For instance while idling, the
Idling
component will be on the player and theidle
system will have a query that operates on all idling players. But as soon as the player moves, theIdling
component will be removed and aMoving
component added. Then themove
system which has a query including players with theMoving
component will kick in.Is there a performance disadvantage do you think to this model as opposed to, for instance, having a
State
enum with variants for each state and having each system execute based on the condition of theState
enum?Beta Was this translation helpful? Give feedback.
All reactions