Struct amethyst_assets::Prefab

source ·
pub struct Prefab<T> { /* private fields */ }
Expand description

Main Prefab structure, containing all data loaded in a single prefab.

Contains a list prefab data for the entities affected by the prefab. The first entry in the entities list will be applied to the main Entity the Handle is placed on, and all other entries will trigger creation of a new entity. Note that the parent index is ignored for the first entry in the list.

The recommended way of loading resources is to place them on the main Entity.

Example:

If the prefab contains 3 new entities A, B and C, and the main Entity that the Handle is placed on is E, and we want the graph to be A -> E, B -> E, C -> B (parent links), the data will be as follows:

Prefab {
    entities: vec![
        PrefabEntity { parent: None /* not used */, .. },
        PrefabEntity { parent: Some(0), .. },
        PrefabEntity { parent: Some(0), .. },
        PrefabEntity { parent: Some(2), .. },
    ],
}

Type parameters:

  • T: PrefabData

Implementations

Create new empty prefab

Create a prefab with data for only the main Entity

Set main Entity data

Add a new entity to the prefab, with optional data and parent.

Number of entities in the prefab, including the main entity

Create a new entity in the prefab, with no data and no parent

Get mutable access to the PrefabEntity with the given index

Get immutable access to all entities in the prefab

Get mutable access to the data in the PrefabEntity with the given index

If data is None, this will insert a default value for T

Panics

If the given index do not have a PrefabEntity

Check if sub asset loading have been triggered

Get the ProgressCounter for the sub asset loading.

Panics

If sub asset loading has not been triggered.

Trigger sub asset loading for the asset

Trait Implementations

An identifier for this asset used for debugging.
The Data type the asset can be created from.
The ECS storage type to be used. You’ll want to use VecStorage in most cases.
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Checks if self is actually part of its subset T (and can be converted to it).
Use with care! Same as self.to_subset but without any property checks. Always succeeds.
The inclusion map: converts self to the equivalent element of its superset.
Tries to create the default.
Calls try_default and panics on an error case.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.