3 个版本 (稳定版)

1.0.1 2021年9月17日
0.1.0 2021年9月17日

#1240 in 游戏开发

自定义许可

21KB
462

Jelly ECS

简单但功能齐全的ECS。它主要用于游戏开发,但也适用于其他项目。
如果遇到错误,请随时提交问题,甚至可以贡献代码。

示例用法

use jelly_ecs::World;

struct Position(pub f32, pub f32);
struct Health(pub u32);

fn main() -> Result<()> {
    let mut world = World::new();
    world.register_component::<Position>();
    world.register_component::<Health>();
    
    world.create_entity()
        .with_component(Position(10.0, 20.0))?
        .with_component(Health(100))?;
        
    let query = world
        .query()
        .with_component::<Position>()?
        .with_component::<Health>()?
        .run();
        
    let player = &query.1[0];
}

依赖项

~0.4–1MB
~19K SLoC