sillyecs
A silly little compile-time generated archetype ECS in Rust.
Installation
sillyecs is a build-time dependency. To use it, add this to your Cargo.toml:
[]
= "0.0.2"
Usage
Use sillyecs in your build.rs:
use EcsCode;
use File;
use BufReader;
Define your ECS components and systems in a YAML file:
# ecs.yaml
states:
- name: Render
description: The render state
components:
- name: Position
- name: Velocity
- name: Health
- name: Collider
archetypes:
- name: Particle
description: A particle system particle.
components:
- Position
- Velocity
- name: Player
components:
- Position
- Velocity
- Health
- name: ForegroundObject
components:
- Position
- Collider
promotions:
- BackgroundObject
- name: BackgroundObject
components:
- Position
promotions:
- ForegroundObject
phases:
- name: Startup
- name: FixedUpdate
fixed: 60 Hz # or "0.01666 s"
- name: Update
- name: Render
systems:
- name: Physics
phase: FixedUpdate
context: true
run_after: # optional
inputs:
- Velocity
outputs:
- Position
- name: Render
phase: Render
states:
- use: Render
write: false # optional
inputs:
- Position
worlds:
- name: Main
archetypes:
- Particle
- Player
- ForegroundObject
- BackgroundObject
Include the compile-time generated files:
include!;
include!;
include!;
include!;
The compiler will tell you which traits and functions to implement.
Command Queue
You will have to implement a command queue. Below is an example for a queue based on
crossbeam-channel: