[][src]Struct amethyst_test::AmethystApplication

pub struct AmethystApplication<T, E, R> where
    E: Send + Sync + 'static, 
{ /* fields omitted */ }

Builder for an Amethyst application.

This provides varying levels of setup so that users do not have to register common bundles.

Type Parameters

  • T: Game data type that holds the common dispatcher.
  • E: Custom event type shared between states.

Methods

impl AmethystApplication<GameData<'static, 'static>, StateEvent, StateEventReader>[src]

pub fn blank(
) -> AmethystApplication<GameData<'static, 'static>, StateEvent, StateEventReader>
[src]

Returns an Amethyst application without any bundles.

pub fn ui_base<AX, AC>(
) -> AmethystApplication<GameData<'static, 'static>, StateEvent, StateEventReader> where
    AX: Hash + Eq + Clone + Send + Sync + 'static,
    AC: Hash + Eq + Clone + Send + Sync + 'static, 
[src]

Returns an application with the Transform, Input, and UI bundles.

This also adds a ScreenDimensions resource to the World so that UI calculations can be done.

pub fn render_base<'name, N>(
    test_name: N,
    visibility: bool
) -> AmethystApplication<GameData<'static, 'static>, StateEvent, StateEventReader> where
    N: Into<&'name str>, 
[src]

Returns an application with the Animation, Transform, and Render bundles.

If you requite InputBundle and UiBundle, you can call the with_ui_bundles::<AX, AC>() method.

Parameters

  • test_name: Name of the test, used to populate the window title.
  • visibility: Whether the window should be visible.

pub fn assets_dir() -> String[src]

Returns a String to <crate_dir>/assets.

impl<E, R> AmethystApplication<GameData<'static, 'static>, E, R> where
    E: Clone + Send + Sync + 'static,
    R: Default
[src]

pub fn build(
    self
) -> Result<CoreApplication<'static, GameData<'static, 'static>, E, R>> where
    R: EventReader<'b, Event = E>, 
[src]

Returns the built Application.

If you are intending to call .run() on the Application in a test, be aware that on Linux, this will cause a segfault when RenderBundle is added and GL is using software rendering, such as when using Xvfb or when the following environmental variable is set: LIBGL_ALWAYS_SOFTWARE=1.

To avoid this, please call .run() instead of this method, which runs the application in a separate thread and waits for it to end before returning.

See https://users.rust-lang.org/t/trouble-identifying-cause-of-segfault/18096

pub fn run(self) -> Result<()> where
    R: EventReader<'b, Event = E>, 
[src]

Runs the application and returns Ok(()) if nothing went wrong.

This method should be called instead of the .build() method if the application is to be run, as this avoids a segfault on Linux when using the GL software renderer.

impl<T, E, R> AmethystApplication<T, E, R> where
    T: GameUpdate,
    E: Send + Sync + 'static, 
[src]

pub fn with_custom_event_type<Evt, Rdr>(
    self
) -> AmethystApplication<T, Evt, Rdr> where
    Evt: Send + Sync + 'static,
    Rdr: EventReader<'b, Event = Evt>, 
[src]

Use the specified custom event type instead of ().

This must be invoked before any of the .with_*() function calls as the custom event type parameter is changed, so we are unable to bring any of the existing parameters across.

Type Parameters

  • Evt: Type used for state events.
  • Rdr: Event reader of the state events.

pub fn with_bundle<B>(self, bundle: B) -> Self where
    B: SystemBundle<'static, 'static> + Send + 'static, 
[src]

Adds a bundle to the list of bundles.

Note: If you are adding the RenderBundle, you need to use .with_bundle_fn(F) as the Pipeline type used by the bundle is !Send. Furthermore, you must also invoke .mark_render() to avoid a race condition that causes render tests to fail.

Parameters

  • bundle: Bundle to add.

pub fn with_bundle_fn<FnBundle, B>(self, bundle_function: FnBundle) -> Self where
    FnBundle: FnOnce() -> B + Send + 'static,
    B: SystemBundle<'static, 'static> + 'static, 
[src]

Adds a bundle to the list of bundles.

This provides an alternative to .with_bundle(B) where B is !Send. The function that instantiates the bundle must be Send.

Note: If you are adding the RenderBundle, you must also invoke .mark_render() to avoid a race condition that causes render tests to fail.

Note: There is a .with_render_bundle() convenience function if you just need the RenderBundle with predefined parameters.

Parameters

  • bundle_function: Function to instantiate the Bundle.

pub fn with_ui_bundles<AX, AC>(self) -> Self where
    AX: Hash + Eq + Clone + Send + Sync + 'static,
    AC: Hash + Eq + Clone + Send + Sync + 'static, 
[src]

Registers InputBundle and UiBundle with this application.

This method is provided to avoid [stringly-typed][stringly] parameters for the Input and UI bundles. We recommended that you use strong types instead of <String, String>.

Type Parameters

  • AX: Type representing the movement axis.
  • AC: Type representing actions.

pub fn with_render_bundle<'name, N>(self, title: N, visibility: bool) -> Self where
    N: Into<&'name str>, 
[src]

Registers the RenderBundle with this application.

This is a convenience function that registers the RenderBundle using the predefined display_config and pipeline.

Parameters

  • title: Window title.
  • visibility: Whether the window should be visible.

pub fn with_resource<Res>(self, resource: Res) -> Self where
    Res: Resource, 
[src]

Adds a resource to the World.

Parameters

  • resource: Bundle to add.

pub fn with_state<S, FnStateLocal>(self, state_fn: FnStateLocal) -> Self where
    S: State<T, E> + 'static,
    FnStateLocal: FnOnce() -> S + Send + Sync + 'static, 
[src]

Adds a state to run in the Amethyst application.

Parameters

  • state_fn: State to use.

pub fn with_system<N, Sys>(self, system: Sys, name: N, deps: &[N]) -> Self where
    N: Into<String> + Clone,
    Sys: for<'sys_local> System<'sys_local> + Send + 'static, 
[src]

Registers a System into this application's GameData.

Parameters

  • system: The System to register.
  • name: Name to register the system with, used for dependency ordering.
  • deps: Names of systems that must run before this system.

pub fn with_system_single<N, Sys>(
    self,
    system: Sys,
    name: N,
    deps: &[N]
) -> Self where
    N: Into<String> + Clone,
    Sys: for<'sys_local> System<'sys_local> + Send + Sync + 'static, 
[src]

Registers a System to run in a CustomDispatcherState.

This will run the system once in a dedicated State, allowing you to inspect the effects of the system after setting up the world to a desired state.

Parameters

  • system: The System to register.
  • name: Name to register the system with, used for dependency ordering.
  • deps: Names of systems that must run before this system.

pub fn with_fn<F>(self, func: F) -> Self where
    F: Fn(&mut World) + Send + Sync + 'static, 
[src]

Registers a function to run in the World.

Parameters

  • func: Function to execute.

pub fn with_setup<F>(self, setup_fn: F) -> Self where
    F: Fn(&mut World) + Send + Sync + 'static, 
[src]

Registers a function that sets up the World.

This is an alias to .with_fn(F).

Parameters

  • setup_fn: Function to execute.

pub fn with_effect<F>(self, effect_fn: F) -> Self where
    F: Fn(&mut World) + Send + Sync + 'static, 
[src]

Registers a function that executes a desired effect.

This is an alias to .with_fn(F).

Parameters

  • effect_fn: Function that executes an effect.

pub fn with_assertion<F>(self, assertion_fn: F) -> Self where
    F: Fn(&mut World) + Send + Sync + 'static, 
[src]

Registers a function to assert an expected outcome.

This is an alias to .with_fn(F).

Parameters

  • assertion_fn: Function that asserts the expected state.

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

Marks that this application uses the RenderBundle.

Note: There is a .with_render_bundle() convenience function if you just need the RenderBundle with predefined parameters.

This is used to avoid a window initialization race condition that causes tests to fail. See https://github.com/tomaka/glutin/issues/1038.

pub fn display_config(title: String, visibility: bool) -> DisplayConfig[src]

Convenience function that returns a DisplayConfig.

The configuration uses the following parameters:

  • title: As provided.
  • fullscreen: false
  • dimensions: Some((800, 600))
  • min_dimensions: Some((400, 300))
  • max_dimensions: None
  • vsync: true
  • multisampling: 0 (disabled)
  • visibility: As provided.

This is exposed to allow external crates a convenient way of obtaining display configuration.

Parameters

  • title: Window title.
  • visibility: Whether the window should be visible.

pub fn pipeline(
) -> PipelineBuilder<Queue<(Queue<()>, StageBuilder<Queue<(Queue<(Queue<()>, DrawFlat2D)>, DrawUi)>>)>>
[src]

Convenience function that returns a PipelineBuilder.

The pipeline is built from the following:

  • Black clear target.
  • DrawFlat2D pass with transparency.
  • DrawUi pass.

This is exposed to allow external crates a convenient way of obtaining a render pipeline.

Trait Implementations

impl<T: Default, E: Default, R: Default> Default for AmethystApplication<T, E, R> where
    E: Send + Sync + 'static, 
[src]

impl<T, E, R> Debug for AmethystApplication<T, E, R> where
    E: Send + Sync + 'static, 
[src]

Auto Trait Implementations

impl<T, E, R> Send for AmethystApplication<T, E, R> where
    R: Send,
    T: Send

impl<T, E, R> !Sync for AmethystApplication<T, E, R>

Blanket Implementations

impl<T> From for T[src]

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

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Same for T

type Output = T

Should always be Self

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

impl<T> Erased for T

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