diff --git a/build/program.zig b/build/program.zig index 5d07fca..38bcd36 100644 --- a/build/program.zig +++ b/build/program.zig @@ -191,7 +191,7 @@ pub const Program = struct { } if (self.opts.static_build) { - exe.root_module.addImport().addImport("staticShaderLoader", self.generateStaticShaders()); + exe.root_module.addImport("staticShaderLoader", self.generateStaticShaders()); } const gameModule = self.makeGameModule(); diff --git a/engine/core/src/core.zig b/engine/core/src/core.zig index 22baa50..2c0cfe6 100644 --- a/engine/core/src/core.zig +++ b/engine/core/src/core.zig @@ -299,9 +299,6 @@ pub fn start_module_(map: *SpecVariantMap, args: anytype, allocator: std.mem.All gEngine.* = try Engine.init(allocator); staticsInitialized = true; - _ = try createObject(ModuleLoader, .{}); - try console.start(); - const engineName = try std.fmt.allocPrint(allocator, "{s}Engine.ini", .{name}); defer allocator.free(engineName); @@ -311,15 +308,15 @@ pub fn start_module_(map: *SpecVariantMap, args: anytype, allocator: std.mem.All try logging.setupLogging(gEngine); } - try ecs.setup(allocator); - - _ = try gEngine.createObject(scene.SceneSystem, .{ .can_tick = true }); - try algorithm.string_pool.setup(allocator); gEngine.stringContext = algorithm.string_pool.gStringContext; + _ = try createObject(ModuleLoader, .{}); + _ = try createObject(ecs.EcsRegistry, .{ .can_tick = true, .isCore = true }); + _ = try createObject(scene.SceneSystem, .{ .can_tick = true }); _ = try createObject(GameObjectSystem, .{ .can_tick = true }); - _ = try inputs.initInputStack(); + _ = try createObject(inputs.InputStack, .{}); + _ = try createObject(console.Console, .{}); // components define try ecs.defineComponentList(ComponentList, allocator); @@ -529,7 +526,11 @@ pub fn startup_getArgs(p_allocator: *anyopaque) ModuleLoaderArgs { pub fn modulePreamble(p_allocator: *anyopaque, p_a: ?*anyopaque) !std.mem.Allocator { const args = startup_getArgs(p_a.?); const allocator = startup_getAllocator(p_allocator); - try setupFromModule(args); + + if (comptime !BuildOption("static_build")) { + try setupFromModule(args); + } + return allocator; } diff --git a/engine/core/src/ecs.zig b/engine/core/src/ecs.zig index e6c410c..469ecf4 100644 --- a/engine/core/src/ecs.zig +++ b/engine/core/src/ecs.zig @@ -279,9 +279,11 @@ pub const EcsRegistry = struct { } pub fn deinit(self: *@This()) void { - for (self.containers.items) |ref| { - ref.vtable.evictFromRegistry(ref.ptr); - } + // this should never work... wtf? + // for (self.containers.items) |ref| { + // ref.vtable.evictFromRegistry(ref.ptr); + // } + for (self.systems.items) |ref| { ref.vtable.destroy(ref.ptr); } diff --git a/lib/p2/src/structures/sparse-set.zig b/lib/p2/src/structures/sparse-set.zig index 0fba59e..f9d6a35 100644 --- a/lib/p2/src/structures/sparse-set.zig +++ b/lib/p2/src/structures/sparse-set.zig @@ -42,6 +42,8 @@ pub fn SparseMultiSetAdvanced(comptime T: type, comptime SparseSize: u32) type { return struct { pub const SetType = std.MultiArrayList(T); + pub const InnerType = T; + allocator: std.mem.Allocator, denseIndices: ArrayListUnmanaged(SetHandle), dense: SetType, @@ -311,6 +313,7 @@ pub fn SparseSetAdvanced(comptime T: type, comptime SparseSize: u32) type { opCount: u32 = 0, pub const StableReferences = false; + pub const InnerType = T; pub fn getStateCount(self: @This()) u32 { return self.opCount; @@ -596,6 +599,7 @@ pub fn SparseMap(comptime T: type) type { containerListener: ?ContainerListener = null, opCount: u32 = 0, + pub const InnerType = T; pub const StableReferences = true; pub fn create(backingAllocator: std.mem.Allocator) !*@This() { @@ -720,6 +724,7 @@ const interface = @import("interface.zig"); pub const EcsContainerInterface = interface.MakeInterface("EcsContainerInterfaceVTable", struct { containerTypeName: []const u8, + componentName: []const u8, handleExists: *const fn (*const anyopaque, SetHandle) bool, get: *const fn (*const anyopaque, SetHandle) ?*anyopaque, createWithHandle: *const fn (*anyopaque, SetHandle) *anyopaque, @@ -787,6 +792,7 @@ pub const EcsContainerInterface = interface.MakeInterface("EcsContainerInterface return .{ .containerTypeName = TargetType.ContainerTypeName, + .componentName = @typeName(TargetType.InnerType), .handleExists = Wrap.handleExists, .get = Wrap.get, .createWithHandle = Wrap.createWithHandle, diff --git a/lib/packer/src/packerfs.zig b/lib/packer/src/packerfs.zig index 96b57e3..eba584f 100644 --- a/lib/packer/src/packerfs.zig +++ b/lib/packer/src/packerfs.zig @@ -166,11 +166,11 @@ pub const PackerFS = struct { const self: *@This() = @ptrCast(@alignCast(ctx)); for (self.fileWatchCallbacks.items) |*watch| { - std.debug.print("checking {s} {s}\n", .{ watch.path, path }); + // std.debug.print("checking {s} {s}\n", .{ watch.path, path }); if (std.mem.eql(u8, watch.path, std.mem.span(path))) { watch.call(std.mem.span(path)); } - std.debug.print("registered callback: {s}\n", .{watch.path}); + // std.debug.print("registered callback: {s}\n", .{watch.path}); } for (self.anyWatchCallbacks.items) |*watch| { @@ -342,7 +342,7 @@ pub const PackerFS = struct { } pub fn installFileBytesMount(self: *@This(), path: []const u8, fileBytes: []align(8) u8, embedded: bool) !?PackerBytesMapping { - std.debug.print("mounting file path {s}\n", .{path}); + // std.debug.print("mounting file path {s}\n", .{path}); const pakMountIndex = self.pakMountings.items.len; try self.pakMountings.append(self.allocator, .{