Struct amethyst::GameDataBuilder[][src]

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

Builder for default game data

Methods

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

Create new builder

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", &[]);

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, "", &[]);

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

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.

Create a basic renderer with a single given Pass, and optional support for the DrawUi pass.

Will set the clear color to black.

Parameters:

  • path: Path to the DisplayConfig configuration file
  • pass: The single pass in the render graph
  • with_ui: If set to true, will add the UI render pass

Trait Implementations

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

Returns the "default value" for a type. Read more

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

Build game data

Auto Trait Implementations

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

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