[][src]Struct amethyst::GameDataBuilder

pub struct GameDataBuilder<'a, 'b> { /* fields omitted */ }

Builder for default game data

Methods

impl<'a, 'b> GameDataBuilder<'a, 'b>[src]

pub fn new() -> Self[src]

Create new builder

pub fn with_barrier(self) -> Self[src]

Inserts a barrier which assures that all systems added before the barrier are executed before the ones after this barrier.

Does nothing if there were no systems added since the last call to with_barrier(). Thread-local systems are not affected by barriers; they're always executed at the end.

Returns

This function returns GameDataBuilder after it has modified it.

Examples

use amethyst::prelude::*;
use amethyst::ecs::prelude::System;

struct NopSystem;
impl<'a> System<'a> for NopSystem {
    type SystemData = ();
    fn run(&mut self, (): Self::SystemData) {}
}

// Three systems are added in this example. The "tabby cat" & "tom cat"
// systems will both run in parallel. Only after both cat systems have
// run is the "doggo" system permitted to run them.
GameDataBuilder::default()
    .with(NopSystem, "tabby cat", &[])
    .with(NopSystem, "tom cat", &[])
    .with_barrier()
    .with(NopSystem, "doggo", &[]);

pub fn with<S>(self, system: S, name: &str, dependencies: &[&str]) -> Self where
    S: System<'c> + Send + 'a, 
[src]

Adds a given system.

Note: all dependencies must be added before you add the system.

Parameters

  • system: The system that is to be added to the game loop.
  • name: A unique string to identify the system by. This is used for dependency tracking. This name may be empty "" string in which case it cannot be referenced as a dependency.
  • dependencies: A list of named system that must have completed running before this system is permitted to run. This may be an empty list if there is no dependencies.

Returns

This function returns GameDataBuilder after it has modified it.

Type Parameters

  • S: A type that implements the System trait.

Panics

If two system are added that share an identical name, this function will panic. Empty names are permitted, and this function will not panic if more then two are added.

If a dependency is referenced (by name), but has not previously been added this function will panic.

Examples

use amethyst::prelude::*;
use amethyst::ecs::prelude::System;

struct NopSystem;
impl<'a> System<'a> for NopSystem {
    type SystemData = ();
    fn run(&mut self, _: Self::SystemData) {}
}

GameDataBuilder::default()
    // This will add the "foo" system to the game loop, in this case
    // the "foo" system will not depend on any systems.
    .with(NopSystem, "foo", &[])
    // The "bar" system will only run after the "foo" system has completed
    .with(NopSystem, "bar", &["foo"])
    // It is legal to register a system with an empty name
    .with(NopSystem, "", &[]);

pub fn with_thread_local<S>(self, system: S) -> Self where
    S: RunNow<'c> + 'b, 
[src]

Add a given thread-local system.

A thread-local system is one that must run on the main thread of the game. A thread-local system would be necessary typically to work around vendor APIs that have thread dependent designs; an example being OpenGL which uses a thread-local state machine to function.

All thread-local systems are executed sequentially after all non-thread-local systems.

Parameters

  • system: The system that is to be added to the game loop.

Returns

This function returns GameDataBuilder after it has modified it.

Type Parameters

  • S: A type that implements the System trait.

Examples

use amethyst::prelude::*;
use amethyst::ecs::prelude::System;

struct NopSystem;
impl<'a> System<'a> for NopSystem {
    type SystemData = ();
    fn run(&mut self, _: Self::SystemData) {}
}

GameDataBuilder::default()
    // the Nop system is registered here
    .with_thread_local(NopSystem);

pub fn with_bundle<B>(self, bundle: B) -> Result<Self, Error> where
    B: SystemBundle<'a, 'b>, 
[src]

Add a given ECS bundle to the game loop.

A bundle is a container for registering a bunch of ECS systems at once.

Parameters

  • bundle: The bundle to add

Returns

This function returns GameDataBuilder after it has modified it, this is wrapped in a Result.

Errors

This function creates systems, which use any number of dependent crates or APIs, which could result in any number of errors. See each individual bundle for a description of the errors it could produce.

Trait Implementations

impl<'a, 'b> DataInit<GameData<'a, 'b>> for GameDataBuilder<'a, 'b>[src]

impl<'a, 'b> Default for GameDataBuilder<'a, 'b>[src]

Auto Trait Implementations

impl<'a, 'b> !Send for GameDataBuilder<'a, 'b>

impl<'a, 'b> !Sync for GameDataBuilder<'a, 'b>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Any for T where
    T: Any

impl<T> TryDefault for T where
    T: Default

fn unwrap_default() -> Self

Calls try_default and panics on an error case.

impl<T> Erased for T

impl<T> Supports<T> for T

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
    D: AdaptFrom<S, Swp, Dwp, T>,
    Dwp: WhitePoint,
    Swp: WhitePoint,
    T: Component + Float
[src]

fn adapt_into(self) -> D[src]

Convert the source color to the destination color using the bradford method by default Read more

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

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

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