Crates.io | rantz_proto |
lib.rs | rantz_proto |
version | 1.1.0 |
source | src |
created_at | 2024-07-08 21:29:50.792361 |
updated_at | 2024-07-12 20:04:51.872169 |
description | An opinionated rust library for transforming on-disk assets into Entities in Bevy. |
homepage | https://github.com/BobG1983/rantz_suite |
repository | https://github.com/BobG1983/rantz_suite |
max_upload_size | |
id | 1296417 |
size | 36,853 |
An opinionated rust library for transforming on-disk assets into Entities in Bevy.
Manifests are stored on disk in one of many different formats (see 'Cargo.toml'). They are loaded and transformed into a struct that implements the Manifest trait. These structs are then further transformed into Prototypes and stored in a PrototypeLibrary.
Prototypes are structs that implement the Prototype trait. They are stored in a PrototypeLibrary resource. The trait has two primary functions, name() and build(). name() is used to generate the unique name which is used to retrieve the prototype from the library. build() is responsible for turning a prototype into an entity. The trait has an optional third function, rebuild(), a default implementation is provided that does nothing.
Note A single struct can implement both Manifest and Prototype and just return Self in the manifest trait.
Note: Requires 'hot_reloading' (on by default)
If an underlying asset is changed the manifests are reloaded and reprocessed into prototypes, then each entity that was built with a given prototype is passed to rebuild() to allow for "on-the-fly" changes.
Basically, if you use a prototype rebuild() will let you change any live entities to match the changes.
In order for a manifest to be loaded and processed it must be registered. This is done as part of app building by calling 'app.add_prototype()'
Note: Requires 'progress_tracking' (on by default)
This crate provides support for iyes_progress for tracking loading progress. If you wish to control when loading happens it is possible to use configure_set with 'ProtoSchedule::Loading' to control when loading happens.
Extensions to 'Commands', 'World' and 'CommandQueue' are provided that introduce 'spawn_prototype' and 'spawn_prototype_async' that allow for easy spawning of prototypes.
I didn't want to be specific about how locations were handled, so this is left up to you. My recommendation is to add a position to your prototypes, and edit that position before calling spawn_prototype.
Add the ProtoPlugin to your app. Register your manifests using app.add_manifest() then spawn entities with commands.spawn_prototype().
If you want to control when load happens, use app.configure_sets() on the ProtoSchedule::Loading schedule.