- Notifications
You must be signed in to change notification settings - Fork218
Specs - Parallel ECS
License
Apache-2.0, MIT licenses found
Licenses found
Apache-2.0
LICENSE-APACHEMIT
LICENSE-MITNotificationsYou must be signed in to change notification settings
amethyst/specs
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
SpecsParallelECS
Specs is an Entity-Component System written in Rust.Unlike most other ECS libraries out there, it provides
- easy parallelism
- high flexibility
- contains 5 different storages for components, which can be extended by the user
- its types are mostly not coupled, so you can easily write some part yourself andstill use Specs
System
s may read from and write to components and resources, can depend on eachother and you can use barriers to force several stages in system execution
- high performance for real-world applications
Minimum Rust version: 1.70
use specs::prelude::*;// A component contains data// which is associated with an entity.#[derive(Debug)]structVel(f32);implComponentforVel{typeStorage =VecStorage<Self>;}#[derive(Debug)]structPos(f32);implComponentforPos{typeStorage =VecStorage<Self>;}structSysA;impl<'a>System<'a>forSysA{// These are the resources required for execution.// You can also define a struct and `#[derive(SystemData)]`,// see the `full` example.typeSystemData =(WriteStorage<'a,Pos>,ReadStorage<'a,Vel>);fnrun(&mutself,(mut pos, vel):Self::SystemData){// The `.join()` combines multiple component storages,// so we get access to all entities which have// both a position and a velocity.for(pos, vel)in(&mut pos,&vel).join(){ pos.0 += vel.0;}}}fnmain(){// The `World` is our// container for components// and other resources.letmut world =World::new(); world.register::<Pos>(); world.register::<Vel>();// An entity may or may not contain some component. world.create_entity().with(Vel(2.0)).with(Pos(0.0)).build(); world.create_entity().with(Vel(4.0)).with(Pos(1.6)).build(); world.create_entity().with(Vel(1.5)).with(Pos(5.4)).build();// This entity does not have `Vel`, so it won't be dispatched. world.create_entity().with(Pos(2.0)).build();// This builds a dispatcher.// The third parameter of `with` specifies// logical dependencies on other systems.// Since we only have one, we don't depend on anything.// See the `full` example for dependencies.letmut dispatcher =DispatcherBuilder::new().with(SysA,"sys_a",&[]).build();// This will call the `setup` function of every system.// In this example this has no effect since we already registered our components. dispatcher.setup(&mut world);// This dispatches all the systems in parallel (but blocking). dispatcher.dispatch(&mut world);}
Please look intothe examples directory for more.
crate | version |
---|---|
hibitset | |
rayon | |
shred | |
shrev |
Contribution is very welcome! If you didn't contribute before,just filter for issues with "easy" or "good first issue" label.Please note that your contributions are assumed to be dual-licensed under Apache-2.0/MIT.
About
Specs - Parallel ECS
Topics
Resources
License
Apache-2.0, MIT licenses found
Licenses found
Apache-2.0
LICENSE-APACHEMIT
LICENSE-MITCode of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published