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
878 stars 58 forks source link

Make 'scope' non-persistent #122

Closed cBournhonesque closed 1 year ago

cBournhonesque commented 1 year ago

Currently, scope is persistent between each network tick. If you add new entities to the scope, you need to remove them manually before the same network tick.

This is useful in some cases (for example, the player enters a 'Cave', and we add all the entities in the cave to the scope only one time), but in other cases it prevents some useful optimizations. An example is if you want to add in the scope only entities that are 'close' the player character.

Instead of just finding entities that are close to the user (using a R-tree structure or other optimized data structures), right now we need to loop through all entities in the previous scope to remove the ones that are not close to the user anymore.

There could be a flag to 'reset' the scope between every network tick.

(Maybe this is not needed and users can just manually reset the scope between each server tick!)

connorcarpenter commented 1 year ago

Closed by https://github.com/naia-lib/naia/pull/130, thank you!