So I need to be able to tell whether or not an Entity is on another RigidBody. This is only for Entities in the PhysicsAppState.
To do this I’ve created a GroundCheckComponent simply hold a Boolean. This component is updated in the PhysicsAppState regularly. So now I can check whether or not a component is “grounded” by checking this component.
I’m using it in AppStates that require the entity to be on the ground. For example, in my CharacterActionAppState: the player should only be able to jump if he is grounded. However, to do this I need access to the PhysicsState to ray test. So it seems proper to add a component that the PhysicsState handles.
Also on A side note. Is it okay to just re-set the same component(versus creating a new one, like in the examples) to trigger a “change” in an entity
Well it is changed. As in the PositionComponent. I just update and entity.set(samePositionComponent). instead of creating a new PositionComponnet with the updated data.
It might. But what it definitely does is change the ‘view’ an EntitySet has without it every calling applyChanges().
Normally, Zay-ES is 100% thread safe. When you start modifying components directly then you destroy that or you have to handle multithreading in your component yourself. It’s just not worth it.
Make your components immutable unless there is really good reason not to. “It feels wrong” is not really a good reason.
It’s a false optimization because all of the stuff going on under the covers is already making temporary garbage. Unless you are on Android then the generational GC makes these short-lived objects nearly free to GC. (And I guess Android is getting better.)