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
|
|
@ -753,7 +753,6 @@ test "example" {
|
|||
const all_components = ComponentTypesByName(.{
|
||||
struct {
|
||||
pub const name = .game;
|
||||
pub const events = .{};
|
||||
pub const components = .{
|
||||
.{ .name = .name, .type = []const u8 },
|
||||
.{ .name = .location, .type = Location },
|
||||
|
|
@ -858,7 +857,6 @@ test "many entities" {
|
|||
const all_components = ComponentTypesByName(.{
|
||||
struct {
|
||||
pub const name = .game;
|
||||
pub const events = .{};
|
||||
pub const components = .{
|
||||
.{ .name = .name, .type = []const u8 },
|
||||
.{ .name = .location, .type = Location },
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ test "example" {
|
|||
pub const components = .{
|
||||
.{ .name = .id, .type = u32 },
|
||||
};
|
||||
pub const events = .{
|
||||
.{ .global = .tick, .handler = tick },
|
||||
pub const global_events = .{
|
||||
.tick = .{ .handler = tick },
|
||||
};
|
||||
|
||||
fn tick(physics: *Modules(modules).Mod(Physics)) void {
|
||||
|
|
@ -63,8 +63,8 @@ test "example" {
|
|||
pub const components = .{
|
||||
.{ .name = .id, .type = u16 },
|
||||
};
|
||||
pub const events = .{
|
||||
.{ .global = .tick, .handler = tick },
|
||||
pub const global_events = .{
|
||||
.tick = .{ .handler = tick },
|
||||
};
|
||||
|
||||
fn tick(
|
||||
|
|
|
|||
|
|
@ -73,14 +73,12 @@ test "query" {
|
|||
const all_components = ComponentTypesByName(.{
|
||||
struct {
|
||||
pub const name = .game;
|
||||
pub const events = .{};
|
||||
pub const components = .{
|
||||
.{ .name = .name, .type = []const u8 },
|
||||
};
|
||||
},
|
||||
struct {
|
||||
pub const name = .physics;
|
||||
pub const events = .{};
|
||||
pub const components = .{
|
||||
.{ .name = .location, .type = Location },
|
||||
.{ .name = .rotation, .type = Rotation },
|
||||
|
|
@ -88,7 +86,6 @@ test "query" {
|
|||
},
|
||||
struct {
|
||||
pub const name = .renderer;
|
||||
pub const events = .{};
|
||||
},
|
||||
}){};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue