ecs: make [set/remove/get]Component globally type safe
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
1f7ea529f4
commit
25afe5ccf4
2 changed files with 51 additions and 28 deletions
|
|
@ -46,7 +46,10 @@ test "inclusion" {
|
|||
test "example" {
|
||||
const allocator = testing.allocator;
|
||||
|
||||
const all_components = .{};
|
||||
const all_components = .{
|
||||
.physics = u16,
|
||||
.geometry = u16,
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Create a world.
|
||||
|
|
@ -56,11 +59,11 @@ test "example" {
|
|||
const player1 = try world.entities.new();
|
||||
const player2 = try world.entities.new();
|
||||
const player3 = try world.entities.new();
|
||||
try world.entities.setComponent(player1, "physics", @as(u16, 1234));
|
||||
try world.entities.setComponent(player1, "geometry", @as(u16, 1234));
|
||||
try world.entities.setComponent(player1, .physics, 1234);
|
||||
try world.entities.setComponent(player1, .geometry, 1234);
|
||||
|
||||
try world.entities.setComponent(player2, "physics", @as(u16, 1234));
|
||||
try world.entities.setComponent(player3, "physics", @as(u16, 1234));
|
||||
try world.entities.setComponent(player2, .physics, 1234);
|
||||
try world.entities.setComponent(player3, .physics, 1234);
|
||||
|
||||
const physics = (struct {
|
||||
pub fn physics(adapter: *Adapter(all_components)) void {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue