pub struct EntityScheduler<T> {
pub time: i64,
/* private fields */
}Expand description
The entity manager’s buckets: which entities are visited in each simulation iteration, and
the time each one has had since its last visit. T is the caller’s value for an entity.
Fields§
§time: i64The current game time.
Implementations§
Source§impl<T: Copy> EntityScheduler<T>
impl<T: Copy> EntityScheduler<T>
Sourcepub fn register(&mut self, value: T, bucket: usize) -> usize
pub fn register(&mut self, value: T, bucket: usize) -> usize
Register an entity in a bucket, at the end, with its last visit set to now. Returns its handle. Bucket 6 means “not scheduled”: the entity is registered but never visited.
Original: FUN_1400c9d70.
Sourcepub fn register_extra(&mut self, value: T, bucket: usize) -> usize
pub fn register_extra(&mut self, value: T, bucket: usize) -> usize
Sourcepub fn cursor(&self, bucket: usize) -> usize
pub fn cursor(&self, bucket: usize) -> usize
A bucket’s cursor, the slot its next visit starts at.
Sourcepub fn schedule(&self, handle: usize) -> (usize, i64)
pub fn schedule(&self, handle: usize) -> (usize, i64)
An entity’s bucket (6: none) and last visit time.
Sourcepub fn restore(
&mut self,
order: &[Vec<usize>; 5],
cursors: [usize; 5],
saved: &[(usize, usize, i64)],
)
pub fn restore( &mut self, order: &[Vec<usize>; 5], cursors: [usize; 5], saved: &[(usize, usize, i64)], )
A saved game’s bucket lists, cursors and schedules: order lists each bucket’s handles
in its saved order, saved each saved entity’s bucket (6: none) and last visit time.
Registered entities the save does not know keep their bucket and follow its listed ones.
Sourcepub fn take_visits(&mut self) -> Vec<(T, i64)>
pub fn take_visits(&mut self) -> Vec<(T, i64)>
The values visited since the last call, each with the time since its previous visit, in visiting order (the bucket pass’s scheduled components run for these).
Sourcepub fn advance(&mut self, dt: f32)
pub fn advance(&mut self, dt: f32)
Advance the clock by dt seconds. Then the caller visits each bucket, then removes the
entities that were deleted.
Original: FUN_1400c9560 (the clock).
Sourcepub fn visit_bucket(&mut self, bucket: usize) -> Vec<(usize, T, i64)>
pub fn visit_bucket(&mut self, bucket: usize) -> Vec<(usize, T, i64)>
Visit one bucket: from its cursor, at most its quota of entities or one full round. Each visit gives the entity’s handle, value and the time since its own last visit. Entities registered during the visits wait until the next iteration.
Original: FUN_1400c9560.