ecs: add support for module global values

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-06-25 13:43:42 -07:00 committed by Stephen Gutekanst
parent 3fddb687bc
commit f74faf90df
2 changed files with 94 additions and 0 deletions

View file

@ -53,6 +53,9 @@ test "example" {
.components = .{
.id = u16,
},
.globals = struct{
pointer: u8,
},
}),
.geometry = Module(.{
.components = .{
@ -66,6 +69,10 @@ test "example" {
var world = try World(modules).init(allocator);
defer world.deinit();
// Initialize globals.
world.set(.physics, .pointer, 123);
_ = world.get(.physics, .pointer); // == 123
const player1 = try world.entities.new();
const player2 = try world.entities.new();
const player3 = try world.entities.new();