This commit is contained in:
peterino2 2026-01-19 21:40:05 -08:00
parent bae150305d
commit 2d59109994
5 changed files with 25 additions and 16 deletions

View File

@ -191,7 +191,7 @@ pub const Program = struct {
} }
if (self.opts.static_build) { if (self.opts.static_build) {
exe.root_module.addImport().addImport("staticShaderLoader", self.generateStaticShaders()); exe.root_module.addImport("staticShaderLoader", self.generateStaticShaders());
} }
const gameModule = self.makeGameModule(); const gameModule = self.makeGameModule();

View File

@ -299,9 +299,6 @@ pub fn start_module_(map: *SpecVariantMap, args: anytype, allocator: std.mem.All
gEngine.* = try Engine.init(allocator); gEngine.* = try Engine.init(allocator);
staticsInitialized = true; staticsInitialized = true;
_ = try createObject(ModuleLoader, .{});
try console.start();
const engineName = try std.fmt.allocPrint(allocator, "{s}Engine.ini", .{name}); const engineName = try std.fmt.allocPrint(allocator, "{s}Engine.ini", .{name});
defer allocator.free(engineName); 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 logging.setupLogging(gEngine);
} }
try ecs.setup(allocator);
_ = try gEngine.createObject(scene.SceneSystem, .{ .can_tick = true });
try algorithm.string_pool.setup(allocator); try algorithm.string_pool.setup(allocator);
gEngine.stringContext = algorithm.string_pool.gStringContext; 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 createObject(GameObjectSystem, .{ .can_tick = true });
_ = try inputs.initInputStack(); _ = try createObject(inputs.InputStack, .{});
_ = try createObject(console.Console, .{});
// components define // components define
try ecs.defineComponentList(ComponentList, allocator); 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 { pub fn modulePreamble(p_allocator: *anyopaque, p_a: ?*anyopaque) !std.mem.Allocator {
const args = startup_getArgs(p_a.?); const args = startup_getArgs(p_a.?);
const allocator = startup_getAllocator(p_allocator); const allocator = startup_getAllocator(p_allocator);
try setupFromModule(args);
if (comptime !BuildOption("static_build")) {
try setupFromModule(args);
}
return allocator; return allocator;
} }

View File

@ -279,9 +279,11 @@ pub const EcsRegistry = struct {
} }
pub fn deinit(self: *@This()) void { pub fn deinit(self: *@This()) void {
for (self.containers.items) |ref| { // this should never work... wtf?
ref.vtable.evictFromRegistry(ref.ptr); // for (self.containers.items) |ref| {
} // ref.vtable.evictFromRegistry(ref.ptr);
// }
for (self.systems.items) |ref| { for (self.systems.items) |ref| {
ref.vtable.destroy(ref.ptr); ref.vtable.destroy(ref.ptr);
} }

View File

@ -42,6 +42,8 @@ pub fn SparseMultiSetAdvanced(comptime T: type, comptime SparseSize: u32) type {
return struct { return struct {
pub const SetType = std.MultiArrayList(T); pub const SetType = std.MultiArrayList(T);
pub const InnerType = T;
allocator: std.mem.Allocator, allocator: std.mem.Allocator,
denseIndices: ArrayListUnmanaged(SetHandle), denseIndices: ArrayListUnmanaged(SetHandle),
dense: SetType, dense: SetType,
@ -311,6 +313,7 @@ pub fn SparseSetAdvanced(comptime T: type, comptime SparseSize: u32) type {
opCount: u32 = 0, opCount: u32 = 0,
pub const StableReferences = false; pub const StableReferences = false;
pub const InnerType = T;
pub fn getStateCount(self: @This()) u32 { pub fn getStateCount(self: @This()) u32 {
return self.opCount; return self.opCount;
@ -596,6 +599,7 @@ pub fn SparseMap(comptime T: type) type {
containerListener: ?ContainerListener = null, containerListener: ?ContainerListener = null,
opCount: u32 = 0, opCount: u32 = 0,
pub const InnerType = T;
pub const StableReferences = true; pub const StableReferences = true;
pub fn create(backingAllocator: std.mem.Allocator) !*@This() { pub fn create(backingAllocator: std.mem.Allocator) !*@This() {
@ -720,6 +724,7 @@ const interface = @import("interface.zig");
pub const EcsContainerInterface = interface.MakeInterface("EcsContainerInterfaceVTable", struct { pub const EcsContainerInterface = interface.MakeInterface("EcsContainerInterfaceVTable", struct {
containerTypeName: []const u8, containerTypeName: []const u8,
componentName: []const u8,
handleExists: *const fn (*const anyopaque, SetHandle) bool, handleExists: *const fn (*const anyopaque, SetHandle) bool,
get: *const fn (*const anyopaque, SetHandle) ?*anyopaque, get: *const fn (*const anyopaque, SetHandle) ?*anyopaque,
createWithHandle: *const fn (*anyopaque, SetHandle) *anyopaque, createWithHandle: *const fn (*anyopaque, SetHandle) *anyopaque,
@ -787,6 +792,7 @@ pub const EcsContainerInterface = interface.MakeInterface("EcsContainerInterface
return .{ return .{
.containerTypeName = TargetType.ContainerTypeName, .containerTypeName = TargetType.ContainerTypeName,
.componentName = @typeName(TargetType.InnerType),
.handleExists = Wrap.handleExists, .handleExists = Wrap.handleExists,
.get = Wrap.get, .get = Wrap.get,
.createWithHandle = Wrap.createWithHandle, .createWithHandle = Wrap.createWithHandle,

View File

@ -166,11 +166,11 @@ pub const PackerFS = struct {
const self: *@This() = @ptrCast(@alignCast(ctx)); const self: *@This() = @ptrCast(@alignCast(ctx));
for (self.fileWatchCallbacks.items) |*watch| { 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))) { if (std.mem.eql(u8, watch.path, std.mem.span(path))) {
watch.call(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| { 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 { 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; const pakMountIndex = self.pakMountings.items.len;
try self.pakMountings.append(self.allocator, .{ try self.pakMountings.append(self.allocator, .{