Struct EntityScheduler
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§
§impl<T> EntityScheduler<T>where
T: Copy,
impl<T> EntityScheduler<T>where
T: Copy,
pub 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.
pub fn register_extra(&mut self, value: T, bucket: usize) -> usize
pub fn register_extra(&mut self, value: T, bucket: usize) -> usize
pub 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.
pub 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.
pub 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).
pub 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).
pub 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.