Mewo
Driving the Car
// For single threaded use cases.
// let galaxy = Galaxy::new();
let galaxy = new;
// Although you can do this, you should prefer the built-in runner functions.
//
// // Game Loop
// loop {
// let galaxy = galaxy.write();
// system_one(&galaxy);
// system_two(&galaxy);
// if galaxy.update().is_none() {
// // Game Over
// return;
// }
// }
run_spawn.join.unwrap;
Defining Components
Components are pieces of data that are attached to entities.
There are two types of components: CheapComponent and UniqueComponent.
;
;
CheapComponent is for components that are cheap to copy.
UniqueComponent is for components that either don't implement copy or shouldn't be copied too
often.
Defining Resources
Resources are pieces of data that just exist and can be accessed with some value.
;
;
Here, PlayerEntity is a single resource which can be accessed using
PlayerEntity::single_resource().
There is only one PlayerEntity.
However, there can be multiple of Window.
You can access each window later using literally any value.
Systems
Systems are just functions that take a galaxy.
Spawning an Entity
let player = galaxy
.insert_entity
.insert
.insert
.insert
.get_entity;
This creates an entity, however, this entity is not accessible until the next update.
Queries
// With Entity
for in g..eiter
// Without Entity
for in g..iter
Getting a Specific Entity
let entity_getter = galaxy.get_entity.unwrap;
entity_getter
.insert
.insert
.remove;
// I don't see when you would use this.
let entity = entity_getter.get_entity;
Once again, both inserted and removed components don't show until the next update.
Spawning a Resource
// For single resources.
galaxy.insert_resource;
// For (generic) resources.
// This associates the new window with the string `"My Window"`.
galaxy.insert_resource;
Resources that are created are instantly available unlike with components.
Accessing a Resource
galaxy
.
.unwrap
galaxy
.
.unwrap
Removing Stuff
galaxy.remove_entity;
galaxy.;
galaxy.;
Events
galaxy.insert_event;
for event in galaxy.get_events
Similar to components, inserted events don't appear until the next update.
Game Over
galaxy.set_exit;