Skip to main content

EntityScheduler

Struct EntityScheduler 

Source
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: i64

The current game time.

Implementations§

Source§

impl<T: Copy> EntityScheduler<T>

Source

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.

Source

pub fn register_extra(&mut self, value: T, bucket: usize) -> usize

register in the extra handle space (from EXTRA): the same buckets, cursors and timing, without taking a placed entity’s index.

Source

pub fn contains(&self, handle: usize) -> bool

Whether handle was registered.

Source

pub fn bucket(&self, bucket: usize) -> &[usize]

A bucket’s handles in visiting order.

Source

pub fn cursor(&self, bucket: usize) -> usize

A bucket’s cursor, the slot its next visit starts at.

Source

pub fn schedule(&self, handle: usize) -> (usize, i64)

An entity’s bucket (6: none) and last visit time.

Source

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.

Source

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).

Source

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).

Source

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.

Source

pub fn remove(&mut self, id: usize)

Remove an entity: it swaps places with the last entity of its bucket, and the cursor does not move. Call it after all visits of the iteration, as the original deletes late.

Original: FUN_1400c8db0.

Trait Implementations§

Source§

impl<T: Copy> Default for EntityScheduler<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for EntityScheduler<T>

§

impl<T> RefUnwindSafe for EntityScheduler<T>
where T: RefUnwindSafe,

§

impl<T> Send for EntityScheduler<T>
where T: Send,

§

impl<T> Sync for EntityScheduler<T>
where T: Sync,

§

impl<T> Unpin for EntityScheduler<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for EntityScheduler<T>

§

impl<T> UnwindSafe for EntityScheduler<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.