Crates.io | retaker |
lib.rs | retaker |
version | |
source | src |
created_at | 2024-01-07 07:00:36.804401 |
updated_at | 2024-11-18 00:49:27.411274 |
description | a simple ecs implementation |
homepage | |
repository | https://github.com/jjmartinodev/retaker |
max_upload_size | |
id | 1091526 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Retaker is an ECS(very wip) that aims for simplicity and just enough performance to use ECS.
use retaker::{entity::DefaultEntityIdGenerator, system::Scheduler, world::World};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum SystemGroups {
SomeSystemGroup,
}
pub struct State {
world: World,
generator: DefaultEntityIdGenerator,
}
pub struct MyComponent(String);
pub struct Exclude;
fn system(state: &mut State) {
let entity1 = state.generator.generate();
state.world.insert_component(&entity1, MyComponent(String::from("hi!!!")));
let entity2 = state.generator.generate();
state.world.insert_component(&entity2, MyComponent(String::from("bye!!!")));
let entity3 = state.generator.generate();
state.world.insert_component2(
&entity3,
(MyComponent(String::from("excluded!!!")), Exclude),
);
{
let mut query = state.world.query::<MyComponent>();
query.filter_without::<Exclude>(&state.world);
for entity in query {
let mut string = state.world.mut_component::<MyComponent>(&entity).unwrap();
string.0 = string.0.to_uppercase();
println!("{}", string.0);
}
}
}
fn main() {
let mut state = State {
world: World::new().into(),
generator: DefaultEntityIdGenerator::new().into(),
};
let mut scheduler: Scheduler<SystemGroups, State> = Scheduler::new();
scheduler.add_system(system, SystemGroups::SomeSystemGroup);
scheduler.run_group(&mut state, SystemGroups::SomeSystemGroup);
}