diff options
Diffstat (limited to 'src/ecs/component.zig')
-rw-r--r-- | src/ecs/component.zig | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/ecs/component.zig b/src/ecs/component.zig new file mode 100644 index 0000000..4a10172 --- /dev/null +++ b/src/ecs/component.zig @@ -0,0 +1,39 @@ +const std = @import("std"); + +pub const ComponentStub = struct { + pub fn init(args: ComponentStub) ComponentStub { + _ = args; + return .{}; + } + + pub fn deinit(self: *ComponentStub) void { + _ = self; + } +}; + +pub const ComponentType = enum(usize) { + component_stub = 0, +}; + +pub const Component = union(ComponentType) { + component_stub: ComponentStub, + + pub fn init(t: ComponentType, args: anytype) Component { + switch (t) { + ComponentType.component_stub => return Component{ + .component_stub = ComponentStub.init(args), + }, + } + } + + pub fn deinit(self: *Component) void { + switch (self.*) { + .component_stub => |*comp| comp.deinit(), + } + } +}; + +test "stub component" { + var stub = Component.init(ComponentType.component_stub, .{}); + defer stub.deinit(); +} |