Struct topaz::Universe [] [src]

pub struct Universe<T, S> {
    pub entities: Vec<Rc<T>>,
    pub systems: Vec<Rc<System<T, S>>>,
    pub special: S,
    pub events: Vec<Vec<usize>>,
    pub time_delta: f64,
    pub frames: usize,
    // some fields omitted
}

The Universe contains all the meta-data neccessary for the game engine.

  • T: The type of entities.
  • S: A singleton used to contain things that don't fit comfortably elsewhere.

Fields

Entities in the universe.

Systems in the universe.

An instance of the Special type, meant to store data that doesn't fit comfortably elsewhere.

List of possible events, and their subscribers.

Amount of time in seconds since the last frame.

Number of frames the universe has run so far.

Methods

impl<T: HasComponents, S> Universe<T, S>
[src]

[src]

Create a new Universe. Takes one instance of the Special type. (See the field documentation.)

[src]

Run the universe. Returns when EVENT_QUIT is triggered.

[src]

Stop the universe. Using EVENT_QUIT is favored, since it allows subscribed systems to save and shutdown safely.

[src]

Allocate a new event.

[src]

Install a system.

[src]

Subscribe an installed system to an event.

[src]

Install a system and subscribe it to as many events as needed.

[src]

Queue an event. The event will be triggered after all the systems subscribed to the currently running event have been run.

[src]

Allocate space for a new entity.

Componentless entities are considered un-allocated and consequently can be overwritten. Keep this in mind when implementing HasComponents.

[src]

Queue an entity for destruction. The entity will be destroyed after the system is finished running.

[src]

Immediately destroy an entity.

[src]

Set an index to an entity.

[src]

Combines alloc and set. Allocates space for a new entity and installs it.