Closed kenjinp closed 3 years ago
When you say the change is not visible, do you mean the component itself is not updated? Or is the entity not synchronized as expected via @javelin/net
?
Sorry, I mean changing a components data after it has been synced from the server on the client. With a system I can see that the component has taken on the new data but not outside of it (referencing the world directly).
I see. This may depend on how the MessageHandler
system is registered. messageHandler.push()
enqueues the message, which lets messageHandler.system
apply the operations contained within the messages during the next tick.
Are you expecting push()
to update the component immediately/synchronously? e.g.
world.addSystem(messageHandler.system)
connection.subscribe(message => {
messageHandler.push(message) // message has insert(player, Position)
world.tryGet(player, Position) // null
world.tick()
world.tryGet(player, Position) // { x: 0, ... }
});
Sorry for the lack of documentation around the networking stuff.
I'm finding inconsistent behaviors when changing or fetching component data using
world.tryGet
. In some cases, it seems to work just find, but in others, the update seems to work only in the context of a system and the change is not visible outside of a system context.