Skip to content
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

Valence tick #377

Closed
wants to merge 7 commits into from
Closed

Valence tick #377

wants to merge 7 commits into from

Conversation

AviiNL
Copy link
Contributor

@AviiNL AviiNL commented Jun 19, 2023

Description

Describe the changes you've made. Link to any issues this PR fixes or addresses.

Adapted the bevy_time implementation to be used with Ticks as usize instead of Time as Instant/Duration, allows you to run systems with a fixed tick interval.

Quick note: This does (still) use CoreSchedule::FixedUpdate and I am not sure that it should, I looked briefly in how to add a custom Schedule thing, but that went way over my head.
What I am missing, (also from bevy itself) is how to make multiple FixedTick to run separate systems, I don't think it's possible, I would prefer to assign a system to a schedule, where you can have systems run at different intervals without needing to resort to something like https://github.com/valence-rs/valence/pull/377/files#diff-50197256120b6495759f6a7d5ff7276b9716bc0deddc48b62e174c0762e4ac00R68
But that might just be a bevy generic limitation from what I can tell.

.add_system(despawn_disconnected_clients)
.add_system(run_every_20_ticks.in_schedule(CoreSchedule::FixedUpdate))
.add_system(manual_tick_interval)
.insert_resource(FixedTick::new(20))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean this only allows for one timer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionally it works the same as bevy_timer, so yeah, i think so, which is why I added the other example, or want to run it on a seperate scheduler, or maybe even make it some form of dynamic scheduler if thats possible?

@Bafbi
Copy link
Contributor

Bafbi commented Aug 9, 2023

Could be useful for #440

@dyc3
Copy link
Collaborator

dyc3 commented Aug 9, 2023

@Bafbi I don't think so. The behavior we'd want for rate limiting is more dynamic than just "send x packets every n ticks"

@Bafbi
Copy link
Contributor

Bafbi commented Aug 9, 2023

@Bafbi I don't think so. The behavior we'd want for rate limiting is more dynamic than just "send x packets every n ticks"

@dyc3 What do you mean? we would just not be able to the delay per entity (which is not really an indispensable feature) but would get the behavior wanted .
I would like to know what do you mean by dynamic ?

@dyc3
Copy link
Collaborator

dyc3 commented Aug 9, 2023

This is getting off topic for this PR, I'll respond in #440 ah, sorry nevermind, I thought #440 was a different issue.

@dyc3
Copy link
Collaborator

dyc3 commented Aug 9, 2023

Regardless in this PR's current state, it's only possible to have one FixedTick. Ideally, we'd have something that allows for more than 1 time interval to run systems at.

@rj00a
Copy link
Member

rj00a commented Aug 15, 2023

With systems already running once per game tick and with only one FixedTick resource, I don't see this having much use. Perhaps what you're looking for is something analogous to bevy's Timer?

@rj00a rj00a closed this Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants