naia-lib / naia

a cross-platform (including Wasm!) networking library built in Rust. Intended to make multiplayer game development dead-simple & lightning-fast
Apache License 2.0
911 stars 58 forks source link

Using Bevy entities to store User and Room data #174

Closed Veritius closed 10 months ago

Veritius commented 1 year ago

To re-iterate my points in Discord: Using Bevy entities allows arbitrary data to be associated with, for example, a User or Room, without using many, many associative arrays. This is also much more aligned with the ECS pattern. Bevy already does this with Windows, among other things.

Deleting an Entity associated with a User or Room key would probably disconnect/destroy the relevant object in the server, likely using removal detection.

I am only talking about the Bevy adapter, I'm not yet knowledgable enough about naia to comment on the rest of the crate.

Veritius commented 1 year ago

Thought I'd link my implementation I made in the meantime. https://github.com/Veritius/bevy-net-playground/blob/e6cf7d3dc7e6acab75927b05923adaf854331b3f/server/src/network/entity.rs

This uses a workaround due to #178

connorcarpenter commented 10 months ago

The Bevy adapter depends on naia, not the other way around. naia should be able to work outside a Bevy app. So User and Room will never be stored within a Bevy world like you suggest. Thank you for the suggestions though!