module: write module events using a struct pattern
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
582a3c07f6
commit
17db5498ee
13 changed files with 245 additions and 203 deletions
|
|
@ -20,9 +20,9 @@ pub const components = .{
|
|||
.{ .name = .follower, .type = void },
|
||||
};
|
||||
|
||||
pub const events = .{
|
||||
.{ .global = .init, .handler = init },
|
||||
.{ .global = .tick, .handler = tick },
|
||||
pub const global_events = .{
|
||||
.init = .{ .handler = init },
|
||||
.tick = .{ .handler = tick },
|
||||
};
|
||||
|
||||
// Each module must have a globally unique name declared, it is impossible to use two modules with
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ pub const components = .{
|
|||
.{ .name = .scale, .type = f32 },
|
||||
};
|
||||
|
||||
pub const events = .{
|
||||
.{ .global = .init, .handler = init },
|
||||
.{ .global = .deinit, .handler = deinit },
|
||||
.{ .global = .tick, .handler = tick },
|
||||
pub const global_events = .{
|
||||
.init = .{ .handler = init },
|
||||
.deinit = .{ .handler = deinit },
|
||||
.tick = .{ .handler = tick },
|
||||
};
|
||||
|
||||
// TODO: this shouldn't be a packed struct, it should be extern.
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@ const d0 = 0.000001;
|
|||
pub const name = .game;
|
||||
pub const Mod = mach.Mod(@This());
|
||||
|
||||
pub const events = .{
|
||||
.{ .global = .init, .handler = init },
|
||||
.{ .global = .tick, .handler = tick },
|
||||
pub const global_events = .{
|
||||
.init = .{ .handler = init },
|
||||
.tick = .{ .handler = tick },
|
||||
};
|
||||
|
||||
pub const Pipeline = enum(u32) {
|
||||
|
|
|
|||
|
|
@ -8,10 +8,13 @@ const assets = @import("assets");
|
|||
pub const name = .game_text;
|
||||
pub const Mod = mach.Mod(@This());
|
||||
|
||||
pub const events = .{
|
||||
.{ .global = .deinit, .handler = deinit },
|
||||
.{ .global = .init, .handler = init },
|
||||
.{ .local = .prepare, .handler = prepare },
|
||||
pub const global_events = .{
|
||||
.deinit = .{ .handler = deinit },
|
||||
.init = .{ .handler = init },
|
||||
};
|
||||
|
||||
pub const local_events = .{
|
||||
.prepare = .{ .handler = prepare },
|
||||
};
|
||||
|
||||
const RegionMap = std.AutoArrayHashMapUnmanaged(u21, mach.gfx.Atlas.Region);
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ const d0 = 0.000001;
|
|||
pub const name = .game;
|
||||
pub const Mod = mach.Mod(@This());
|
||||
|
||||
pub const events = .{
|
||||
.{ .global = .init, .handler = init },
|
||||
.{ .global = .tick, .handler = tick },
|
||||
pub const global_events = .{
|
||||
.init = .{ .handler = init },
|
||||
.tick = .{ .handler = tick },
|
||||
};
|
||||
|
||||
pub const Pipeline = enum(u32) {
|
||||
|
|
|
|||
|
|
@ -44,10 +44,10 @@ const d0 = 0.000001;
|
|||
pub const name = .game;
|
||||
pub const Mod = mach.Mod(@This());
|
||||
|
||||
pub const events = .{
|
||||
.{ .global = .init, .handler = init },
|
||||
.{ .global = .deinit, .handler = deinit },
|
||||
.{ .global = .tick, .handler = tick },
|
||||
pub const global_events = .{
|
||||
.init = .{ .handler = init },
|
||||
.deinit = .{ .handler = deinit },
|
||||
.tick = .{ .handler = tick },
|
||||
};
|
||||
|
||||
pub const Pipeline = enum(u32) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue