No description
Find a file
2025-09-12 23:54:04 -04:00
src init 2025-09-12 23:26:54 -04:00
.gitignore init 2025-09-12 23:26:54 -04:00
build.zig init 2025-09-12 23:26:54 -04:00
build.zig.zon bump version 2025-09-12 23:54:04 -04:00
Jenkinsfile add jenkinsfile 2025-09-12 23:34:55 -04:00
LICENSE init 2025-09-12 23:26:54 -04:00
README.md init 2025-09-12 23:26:54 -04:00

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);