{"id":17545825,"url":"https://github.com/devwckd/wecs","last_synced_at":"2025-04-24T00:09:29.420Z","repository":{"id":177979625,"uuid":"661183058","full_name":"devwckd/wecs","owner":"devwckd","description":"wecs (wckd-ecs) is a simple ECS library suitable for general use.","archived":false,"fork":false,"pushed_at":"2024-09-12T01:43:13.000Z","size":24,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-24T00:09:22.287Z","etag":null,"topics":["ecs","game","game-dev","game-development","game-engine","gamedev","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devwckd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-02T03:50:51.000Z","updated_at":"2024-09-12T01:43:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"6d6e4f90-46ac-4495-9b83-2463b01ec973","html_url":"https://github.com/devwckd/wecs","commit_stats":null,"previous_names":["devwckd/wecs"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwckd%2Fwecs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwckd%2Fwecs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwckd%2Fwecs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwckd%2Fwecs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devwckd","download_url":"https://codeload.github.com/devwckd/wecs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250535102,"owners_count":21446508,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ecs","game","game-dev","game-development","game-engine","gamedev","rust"],"created_at":"2024-10-21T01:25:05.513Z","updated_at":"2025-04-24T00:09:29.399Z","avatar_url":"https://github.com/devwckd.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wecs\n\nwecs (wckd-ecs) is a simple ECS library heavily based on [bevy_ecs](https://github.com/bevyengine/bevy/blob/main/crates/bevy_ecs/README.md).\n\n### Motivation\n\n As part of my \"Road to Rust GameDev\" journey, I wanted to learn how stuff worked behind the scenes, so I started with the foundation of many game engines, the Entity-Component-System. I did it by devouring [bevy_ecs](https://github.com/bevyengine/bevy/blob/main/crates/bevy_ecs/README.md) and creating my own version of it, with similar inner workings and identical syntax, without all the optimization that I am yet to learn. I'll be using it on my personal projects and hopefully be incrementing on its features.  \n  \n### Code Example\n\n#### - \"Gravity\" sim\n\n```rust\nuse wecs::{query::Query, resource::Res, schedule::Schedule, world::World};\n\n#[derive(Resource, Default)]\npub struct GravityManager {\n    gravity: f32,\n}\n\n#[derive(Debug, Component)]\npub struct Position {\n    x: f32,\n    y: f32,\n    z: f32,\n}\n\nfn main() {\n    let mut world = World::new();\n    world.insert_resource(GravityManager { gravity: 10.0 });\n    world.spawn_entity(Position {\n        x: 0.0,\n        y: 50.0,\n        z: 0.0,\n    });\n\n    let mut schedule = Schedule::new()\n        .with_system(update_system)\n        .with_system(print_system);\n\n    loop {\n        schedule.run(\u0026mut world);\n        std::thread::sleep(Duration::from_secs(1));\n    }\n}\n\nfn update_system(query: Query\u003c\u0026mut Position\u003e, manager: Res\u003cGravityManager\u003e) {\n    for position in query {\n        position.y -= manager.gravity;\n    }\n}\n\nfn print_system(query: Query\u003c\u0026Position\u003e) {\n    for position in query {\n        let Position {x, y, z} = position;\n        println!(\"entity position is {x},{y},{z}\");\n    }\n}\n```\n\noutput:  \n\u003e entity position is 0,40,0  \n\u003e entity position is 0,30,0  \n\u003e entity position is 0,20,0  \n\u003e entity position is 0,10,0  \n\u003e entity position is 0,0,0  \n\u003e entity position is 0,-10,0  \n\u003e entity position is 0,-20,0  \n\u003e ...\n\n#### - Events\n\n```rust\nuse wecs::{schedule::Schedule, world::World, EventManager, EventReader, EventWriter};\n\nstruct CoolEvent {\n    pub num: u32,\n}\n\nfn main() {\n    let mut world = World::new();\n    world.init_resource::\u003cEventManager\u003cCoolEvent\u003e\u003e();\n\n    let mut schedule = Schedule::new();\n    schedule.add_system(publish_events);\n    schedule.add_system(consume_events);\n    schedule.add_system(EventManager::\u003cCoolEvent\u003e::clear);\n\n    schedule.run(\u0026mut world);\n}\n\nfn publish_events(mut writer: EventWriter\u003cCoolEvent\u003e) {\n    writer.dispatch_one(CoolEvent { num: 0 });\n}\n\nfn consume_events(reader: EventReader\u003cCoolEvent\u003e) {\n    for event in reader {\n        println!(\"CoolEvent's num is {}\", event.num);\n    }\n}\n```\noutput:\n\u003e CoolEvent's num is 0\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevwckd%2Fwecs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevwckd%2Fwecs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevwckd%2Fwecs/lists"}