fishfolk / bones

An easy-to-use game engine for making real games.
https://fishfolk.org/development/bones/introduction/
Other
236 stars 20 forks source link

feat: Added player networking info + preparation for future EventManager work #450

Closed RockasMockas closed 2 months ago

RockasMockas commented 2 months ago

This PR covers the following:

  1. Exposing player networking info from ggrs -> into an accessible resource for anyone to use.
  2. Provide a bunch of helper methods for easily fetching averages/highest/lowest from networking info.
  3. Convert NetworkingInfo struct to SyncingInfo (as discussed previously on discord) which supports both Online/Offline variants and put all fields behind getters. This will allow us to have a standardized interface for implementing EventManager in the future that watches current/last confirmed frame. (Of note this hasn't inserted the offline variant anywhere, as that can wait for the EventManager work itself).
MaxCWhitehead commented 2 months ago

This looks great - one thing that I think may be nice is a is_online() func, right now can check something like this, but not super clear:

let is_online = session
            .world
            .get_resource::<SyncingInfo>()
            .is_some_and(|x| x.socket().is_some());

Or can do this, but not super slick either

let is_online = match session.world.get_resource::<SyncingInfo>().as_deref() {
    Some(SyncingInfo::Online { .. }) => true,
    _ => false,
};
RockasMockas commented 2 months ago

Great point, added.