No description
| src | ||
| .gitignore | ||
| build.zig | ||
| build.zig.zon | ||
| Jenkinsfile | ||
| LICENSE | ||
| README.md | ||
Zig System Dispatcher
This is the executing part of an entity-component-system. Aka, this is what runs the systems.
Systems are functions that take any number of pointers to resources as their arguments. For example:
fn bananaRipener(timer: *const Timer, banana_container: *Container(Banana)) void {
for (banana_container.items) |*banana| {
banana.ripe(timer.delta_time);
}
}
To execute this system, you need to provide a pointer to the struct that contains all of these (Timer, Container) things. For example a struct like this:
const World = struct {
bananas: Container(Banana),
timer: Timer,
};
And finally you can execute the system like so:
var world = World.init(...);
// List as many systems as you want.
const dispatcher = Dispatcher(.{bananaRipener});
// One system at a time only...
dispatcher.runSeq(&world);
// ... or run systems in parallel where rules allow.
try dispatcher.runPar(&world);