module: rename events -> systems, remove 'event arguments'

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-05-08 13:18:39 -07:00 committed by Stephen Gutekanst
parent 83d436ffa4
commit 22ac26b57e
19 changed files with 287 additions and 320 deletions

View file

@ -18,7 +18,7 @@ var gpa = std.heap.GeneralPurposeAllocator(.{}){};
pub const name = .app;
pub const Mod = mach.Mod(@This());
pub const events = .{
pub const systems = .{
.init = .{ .handler = init },
.after_init = .{ .handler = afterInit },
.deinit = .{ .handler = deinit },
@ -38,8 +38,8 @@ fn init(
audio: *mach.Audio.Mod,
app: *Mod,
) !void {
audio.send(.init, .{});
app.send(.after_init, .{});
audio.schedule(.init);
app.schedule(.after_init);
const bgm_fbs = std.io.fixedBufferStream(assets.bgm.bit_bit_loop);
const sfx_fbs = std.io.fixedBufferStream(assets.sfx.sword1);
@ -65,18 +65,18 @@ fn init(
std.debug.print("[arrow up] increase volume 10%\n", .{});
std.debug.print("[arrow down] decrease volume 10%\n", .{});
core.send(.start, .{});
core.schedule(.start);
}
fn afterInit(audio: *mach.Audio.Mod, app: *Mod) void {
// Configure the audio module to send our app's .audio_state_change event when an entity's sound
// finishes playing.
audio.state().on_state_change = app.event(.audio_state_change);
audio.state().on_state_change = app.system(.audio_state_change);
}
fn deinit(core: *mach.Core.Mod, audio: *mach.Audio.Mod) void {
audio.send(.deinit, .{});
core.send(.deinit, .{});
audio.schedule(.deinit);
core.schedule(.deinit);
}
fn audioStateChange(
@ -135,7 +135,7 @@ fn tick(
try audio.set(e, .playing, true);
},
},
.close => core.send(.exit, .{}),
.close => core.schedule(.exit),
else => {},
}
}
@ -175,5 +175,5 @@ fn tick(
core.state().queue.submit(&[_]*gpu.CommandBuffer{command});
// Present the frame
core.send(.present_frame, .{});
core.schedule(.present_frame);
}