I’m evaluating Amethyst for an up coming project and I have a n00b question: How would you create entities specified in a config file?
Every example of working with entities (not just for Amethyst but other Rust engines I’ve looked at) looks like this:
world.spawn_entity((tuple, of, components))
This is fine for toy projects, but I’d like to dynamically load entities from some file format so I don’t need to re-compile the game every time I’m tweaking the game.
In principle I could do something like
// Pseudocode!
let entity_description: Vec<Component> = deserialize_entity_file("001.entity")
let mut entity = world.spawn_entity(())
for component in entity_description {
entity.add_component(component_from_file)
}
but many ECS frameworks (including Legion) require the 'static
trait on Components which makes this difficult since my components (created at runtime) don’t (can’t ?) have the 'static
lifetime. I don’t fully grok the 'static
lifetime though so feel free to correct me.
TLDR Has anybody seen dynamic entity-loading in the wild or have a description of how to make it work?