diff options
author | Lorenzo Torres <torres@sideros.org> | 2025-03-27 21:42:46 +0100 |
---|---|---|
committer | Lorenzo Torres <torres@sideros.org> | 2025-03-27 21:42:46 +0100 |
commit | 1730f1e2980bfa2819c541d9b8a3bc0301b8334e (patch) | |
tree | b4acfaf7fbd7d6f3344155c251c1d1b1d6f7a431 /src/ecs | |
parent | 09691ec4d93cda6ab31d28d6e478257209fe625e (diff) |
Made Renderer a separate module
Diffstat (limited to 'src/ecs')
-rw-r--r-- | src/ecs/ecs.zig | 1 | ||||
-rw-r--r-- | src/ecs/entities.zig | 12 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/ecs/ecs.zig b/src/ecs/ecs.zig index 278915b..9efc044 100644 --- a/src/ecs/ecs.zig +++ b/src/ecs/ecs.zig @@ -2,5 +2,6 @@ pub const components = @import("components.zig"); const entities = @import("entities.zig"); pub const Pool = entities.Pool; +pub const Resources = entities.Resources; pub const System = *const fn (*Pool) void; pub const SystemGroup = []const System; diff --git a/src/ecs/entities.zig b/src/ecs/entities.zig index 149c9ff..9337d6b 100644 --- a/src/ecs/entities.zig +++ b/src/ecs/entities.zig @@ -2,15 +2,21 @@ const std = @import("std"); const Allocator = std.mem.Allocator; const components = @import("components.zig"); const sparse = @import("sparse.zig"); +const Renderer = @import("renderer"); pub const System = *const fn (*Pool) void; pub const SystemGroup = []const System; +pub const Resources = struct { + window: Renderer.Window, + renderer: Renderer, +}; + pub const Pool = struct { // Components position: sparse.SparseSet(components.Position), speed: sparse.SparseSet(components.Speed), - + resources: Resources, system_groups: std.ArrayList(SystemGroup), thread_pool: *std.Thread.Pool, wait_group: std.Thread.WaitGroup, @@ -20,11 +26,11 @@ pub const Pool = struct { component_flags: std.AutoHashMap(usize, usize), - pub fn init(allocator: Allocator) !@This() { + pub fn init(allocator: Allocator, resources: Resources) !@This() { var pool = @This(){ .position = sparse.SparseSet(components.Position).init(allocator), .speed = sparse.SparseSet(components.Speed).init(allocator), - + .resources = resources, .system_groups = std.ArrayList(SystemGroup).init(allocator), .thread_pool = try allocator.create(std.Thread.Pool), .wait_group = .{}, |