-
-
Notifications
You must be signed in to change notification settings - Fork 145
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
world time implementation #370
Conversation
… if the speed is 0
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.
Looks good. Just a few nitpicks.
WorldTime day and time getter will no longer produce negative values
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.
One problem I see here is that the LinearTimeTicking
and LinearWorldAging
components do not mix well with the ChangeTrackingTimeBroadcast
component, since it constantly triggers change detection and spams the client with world time packets. This is problematic for WorldTimeBundle
.
I might have to redesign the API a bit. I will create a Broadcaster kind of a mix of the 2 current broadcasters. struct ScheduledBroadcaster {
pub next_tick: i64;
pub interval: u64;
} And a prebuilt query to provide some API sugarily. I want to separate struct TimeControllingQuery {
pub time: &mut 'static WorldTime,
pub schedule: &mut 'static ScheduledBroadcaster
}
impl TimeControllingQuery {
pub set_time(&mut self, time: i64) { ... }
pub set_time_defered(&mut self, time: i64) { ... }
} to change the time we can do: let mut query: TimeControllingQuery = ...;
// Update immediately
query.set_time(10);
// Scheduled
for i in 11..20 {
query.set_time_defered(i);
} What do you think about this API? |
Description
Implementation of world time for instance. Support sets the time explicitly, advances the time and adjusts the frequency that the server sends
WorldTimeUpdateS2c
packet to clients.Playground:
example:
cargo run --package valence --example time_travel
tests:
cargo test --package valence --lib -- tests::world_time
Related
part of #210