module: sending global event requires sender module awareness

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-03-25 11:06:54 -07:00 committed by Stephen Gutekanst
parent 9eac721f24
commit 3661cb8721
4 changed files with 39 additions and 31 deletions

View file

@ -122,6 +122,6 @@ test "example" {
//-------------------------------------------------------------------------
// Send events to modules
world.modules.send(.tick, .{});
world.mod.renderer.sendGlobal(.tick, .{});
try world.dispatch();
}

View file

@ -77,7 +77,7 @@ pub fn World(comptime mods: anytype) type {
pub inline fn sendGlobal(m: *@This(), comptime event_name: Modules.GlobalEvent, args: anytype) void {
const mod_ptr: *Mods = @alignCast(@fieldParentPtr(Mods, @tagName(module_tag), m));
const world = @fieldParentPtr(WorldT, "mod", mod_ptr);
world.modules.send(event_name, args);
world.modules.sendGlobal(module_tag, event_name, args);
}
pub fn dispatchNoError(m: *@This()) void {