Zay-es net / sim-eth-es getComponent

Hello,

I am wondering what the best way to get entity component data from the entity data system on the client would be. For example if you have a health component and you want to update your game clients health bar. What would the best way to get that information out of the entity system?

The reason I am asking this question is because I just started doing some network testing at about 90ms pingtime, the way I was using getComponent and getEntity stalled the render thread because I was using those functions in the update loop of a appstate. This is obviously not the correct way. From what i can tell it would be best to get that kind of information in something like the sharedobjectupdater().

Any advice would be appreciated.

Thank you.

You add/update components (ex : health) on entity in server side, and in client side if you have an EntitySet which is listening to those components, it will automatically receive them from server and you can check if it received updates by calling entitySet.applyChanges() then you can get them as usual with entity.get(type); or ed.getComponent(entity.getId(), type)

The proper way to watch the player entity is by using a WatchedEntity. It’s like an EntitySet that only ever contains one entity and can be missing components.

http://jmonkeyengine-contributions.github.io/zay-es/javadoc/zay-es/com/simsilica/es/EntityData.html#watchEntity(com.simsilica.es.EntityId,%20java.lang.Class...)

You call applyChanges() on it just like you would for an entity set and then you can grab its latest components.