-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clients visibility #174
Clients visibility #174
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Efficiency and code clarity comments. I think this direction is promising, I will work on a Rooms design that can be layered on top.
Necessary to make fields private.
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #174 +/- ##
==========================================
- Coverage 89.81% 89.30% -0.51%
==========================================
Files 19 20 +1
Lines 1247 1412 +165
==========================================
+ Hits 1120 1261 +141
- Misses 127 151 +24 ☔ View full report in Codecov by Sentry. |
src/server/clients_info.rs
Outdated
} | ||
} | ||
|
||
/// Returns reference to connected client info. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we should rename it into ClientState
and the parent struct into ClientsState
.
But I think it's better to do as part of a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe: ClientCache
for the parent struct, then ClientState
for the per-client struct. ClientsState
is pretty awkward.
Split into simpler tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me a while to figure out you were handling the 'lost visibility' vs 'don't have visibility' distinction separate from EntityState
.
Co-authored-by: UkoeHB <37489173+UkoeHB@users.noreply.github.com>
Co-authored-by: UkoeHB <37489173+UkoeHB@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making progress :)
On the other hand, I have not much progress on the Rooms abstraction if you want to give it a try. I think it can be done with one custom SystemParam (instead of an entity component) called RepliconRooms
with this core API:
rooms.join(client id, room id)
rooms.leave(client id, room id)
rooms.add_entity(entity, room id)
rooms.remove_entity(entity, room id)
I'm not sure how to integrate it with events. Maybe a bespoke solution is required (a distinct events API that wraps bevy_replicon
, like RoomWriter
or some such).
Co-authored-by: UkoeHB <37489173+UkoeHB@users.noreply.github.com>
Unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting closer :)
Co-authored-by: UkoeHB <37489173+UkoeHB@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work! I think it's ok to merge this, but let's wait to release it until a Rooms implementation is solidified.
Okay! |
Description
It's a prototype of my recent idea about visibility management. Please note, that it's a quick and dirty prototype, I just wanted to showcase the idea.
The idea is simple. When you configure server plugin, you set visibility policy based on your game. Then you can control visibility using
ClientVisibility
struct obtainable fromClientInfo
.ClientVisibility
is an enum with fields based on policy:ClientVisibility::All
: stores only single boolean to check if client just connected.ClientVisibility::Whitelist
/ClientVisibility::Blacklist
:When we collect changes, we also check if an entity visible or just became visible for specific client (can be optimized, see below).
When we collect removals, we additionally iterate over just hidden entities.
TODO:
Advantages
Disadvantages
Optimizations