mach: prepare to handle ECS init via modules

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2023-03-26 11:17:25 -07:00 committed by Stephen Gutekanst
parent 2879ad58b0
commit 15e6f81df8

View file

@ -17,12 +17,8 @@ pub const module = ecs.Module(.{
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
pub fn App(
comptime modules: anytype,
comptime app_init: anytype, // fn (engine: *ecs.World(modules)) !void
) type {
pub fn App(comptime modules: anytype) type {
// TODO: validate modules.mach is the expected type.
// TODO: validate init has the right function signature
return struct {
engine: ecs.World(modules),
@ -36,7 +32,7 @@ pub fn App(
};
app.engine.set(.mach, .core, &app.core);
app.engine.set(.mach, .device, app.core.device());
try app_init(&app.engine);
app.engine.send(.init);
}
pub fn deinit(app: *@This()) void {