diff --git a/src/EntitySystem.zig b/src/EntitySystem.zig index c26e81c..e369b3c 100644 --- a/src/EntitySystem.zig +++ b/src/EntitySystem.zig @@ -40,8 +40,22 @@ pub fn GetSignature(entity: Etyp.entity) Etyp.signature { return Signatures[entity]; } -//Component Manager +//Component Manager variables -pub fn RegisterComponent() void { - +const ComponentTypeList: std.StringArrayHashMap(Etyp.Component) = std.StringArrayHashMap(Etyp.Component); + +const ComponentArrays: std.StringArrayHashMap(Etyp.ComponentArray) = std.StringArrayHashMap(Etyp.ComponentArray); + +var NextComponent: Etyp.Component = 0; + +//component manager + +pub fn RegisterComponent(in: type) void { + var name = @typeName(in); + ComponentTypeList.put(name, NextComponent); + ComponentArrays.put(name, ComponentArrays{}); +} + +fn GetComponentArray(in: type) Etyp.ComponentArray { + return ComponentArrays[@typeName(in)]; } \ No newline at end of file diff --git a/src/EntitySystemTypes.zig b/src/EntitySystemTypes.zig index a212abf..ee99e91 100644 --- a/src/EntitySystemTypes.zig +++ b/src/EntitySystemTypes.zig @@ -16,7 +16,7 @@ pub const Signature = std.bit_set.IntegerBitSet(MAXComponents); //Component array type -const ComponentArray = struct { +pub const ComponentArray = struct { Components: [MAXEntitys]type, Entity2Array: [usize]Entity, Array2Entity: [Entity]usize,