added register and get
This commit is contained in:
parent
b93bc32d44
commit
c5ca08a610
@ -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)];
|
||||
}
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user