Skip to content

Add StaggeredUpdateTracker for tick spreading#6634

Open
Illiux wants to merge 3 commits into
space-wizards:masterfrom
Illiux:staggered-update
Open

Add StaggeredUpdateTracker for tick spreading#6634
Illiux wants to merge 3 commits into
space-wizards:masterfrom
Illiux:staggered-update

Conversation

@Illiux

@Illiux Illiux commented Jun 12, 2026

Copy link
Copy Markdown

Add an entity system helper designed to be used where a component is updated on a regular interval greater than one tick, with updates intended to be spread across multiple ticks. This is intended to replace several places today where content records a next update field on a component, then iterates all entities every tick checking to see if it is time to update that component.

The implementation in this commit efficiently keeps a sorted schedule of updates and allows the entities due to update (and only those entities) to be enumerated in amortized constant time for each. Removed components are handled lazily, and new components are handled via a priority queue. The schedule itself is implemented as a ring buffer.

A limitation of the approach is that the update interval cannot vary across individual instances of tracked components.

Add an entity system helper designed to be used where a component is updated on a regular interval greater than one
tick, with updates intended to be spread across multiple ticks. This is intended to replace several places today where
content records a next update field on a component, then iterates all entities every tick checking to see if it is time
to update that component.

The implementation in this commit efficiently keeps a sorted schedule of updates and allows the entities due to update
(and only those entities) to be enumerated in amortized constant time for each. Removed components are handled lazily,
and new components are handled via a priority queue. The schedule itself is implemented as a ring buffer.

A limitation of the approach is that the update interval cannot vary across individual instances of tracked components.
@Illiux Illiux requested a review from PJB3005 as a code owner June 12, 2026 03:31
@MLGTASTICa

Copy link
Copy Markdown
Contributor

Any chance for a implementation that doesn't register on the MapInitEvent? if this does get merged i'd like to use it but i see that restriction being a issue (unless im wrong and engine/content have split bus events that don't conflict)

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.

2 participants