summaryrefslogtreecommitdiff
path: root/src/ecs/entities.zig
diff options
context:
space:
mode:
authorLorenzo Torres <torres@sideros.org>2025-03-20 23:54:19 +0100
committerLorenzo Torres <torres@sideros.org>2025-03-20 23:54:19 +0100
commite1f1441a38ebd648765d7c3d8771413ccd08a8af (patch)
tree0111731e87033597755c00ae5580691215f86824 /src/ecs/entities.zig
parent7ce5902ec94376837a1a287878bcc2caa678dcbc (diff)
added fixme message to ecs
Diffstat (limited to 'src/ecs/entities.zig')
-rw-r--r--src/ecs/entities.zig23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/ecs/entities.zig b/src/ecs/entities.zig
index 6d091e2..d8b0ea4 100644
--- a/src/ecs/entities.zig
+++ b/src/ecs/entities.zig
@@ -6,6 +6,8 @@ const sparse = @import("sparse.zig");
const System = *const fn (Pool) void;
const SystemGroup = std.ArrayList(System);
+//FIXME: for some reason this thing has very weird issues with
+//hash maps
pub const Pool = struct {
// Components
position: sparse.SparseSet(components.Position),
@@ -18,27 +20,28 @@ pub const Pool = struct {
last_entity: usize,
free_ids: std.ArrayList(usize),
- component_flags: std.AutoHashMap(usize, usize),
+ component_flags: std.AutoHashMap(u32, usize),
pub fn init(allocator: Allocator) !@This() {
- var thread_pool: std.Thread.Pool = undefined;
- try thread_pool.init(.{
- .allocator = allocator,
- .n_jobs = 4,
- });
-
- return @This(){
+ var pool = @This(){
.position = sparse.SparseSet(components.Position).init(allocator),
.speed = sparse.SparseSet(components.Speed).init(allocator),
.system_groups = std.ArrayList(SystemGroup).init(allocator),
- .thread_pool = thread_pool,
+ .thread_pool = undefined,
.wait_group = .{},
.mutex = .{},
.last_entity = 0,
.free_ids = std.ArrayList(usize).init(allocator),
- .component_flags = std.AutoHashMap(usize, usize).init(allocator),
+ .component_flags = std.AutoHashMap(u32, usize).init(allocator),
};
+
+ try pool.thread_pool.init(.{
+ .allocator = allocator,
+ .n_jobs = 4,
+ });
+
+ return pool;
}
pub fn tick(self: *@This()) void {