{mach,ecs}: pass World to ECS event handlers

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2023-03-26 12:34:23 -07:00 committed by Stephen Gutekanst
parent 15e6f81df8
commit f153133c30
3 changed files with 6 additions and 6 deletions

View file

@ -269,12 +269,11 @@ pub fn World(comptime modules: anytype) type {
}
/// Broadcasts a global message to all modules that are subscribed to it.
pub fn send(world: *Self, comptime msg_tag: anytype) void {
_ = world;
pub fn send(world: *Self, comptime msg_tag: anytype) !void {
inline for (std.meta.fields(@TypeOf(modules))) |module_field| {
const module = @field(modules, module_field.name);
if (@hasField(@TypeOf(module), "messages")) {
if (@hasField(module.messages, @tagName(msg_tag))) module.update(msg_tag);
if (@hasField(module.messages, @tagName(msg_tag))) try module.update(world, msg_tag);
}
}
}