rename mach.Module -> mach.Engine; parameter injection
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
8cea2c9f7d
commit
fd5d347f3e
2 changed files with 21 additions and 20 deletions
|
|
@ -7,53 +7,53 @@ var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||||
const allocator = gpa.allocator();
|
const allocator = gpa.allocator();
|
||||||
|
|
||||||
/// The main Mach engine ECS module.
|
/// The main Mach engine ECS module.
|
||||||
pub const Module = struct {
|
pub const Engine = struct {
|
||||||
device: *gpu.Device,
|
device: *gpu.Device,
|
||||||
exit: bool,
|
exit: bool,
|
||||||
|
|
||||||
pub const name = .mach;
|
pub const name = .engine;
|
||||||
|
|
||||||
pub fn machInit(eng: *Engine) !void {
|
pub fn engineInit(world: *World) !void {
|
||||||
core.allocator = allocator;
|
core.allocator = allocator;
|
||||||
try core.init(.{});
|
try core.init(.{});
|
||||||
eng.mod.mach.state.device = core.device;
|
world.mod.engine.state.device = core.device;
|
||||||
eng.mod.mach.state.exit = false;
|
world.mod.engine.state.exit = false;
|
||||||
|
|
||||||
try eng.send(.init);
|
try world.send(.init);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn machDeinit(eng: *Engine) !void {
|
pub fn engineDeinit(world: *World) !void {
|
||||||
try eng.send(.deinit);
|
try world.send(.deinit);
|
||||||
core.deinit();
|
core.deinit();
|
||||||
eng.deinit();
|
world.deinit();
|
||||||
_ = gpa.deinit();
|
_ = gpa.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn machExit(eng: *Engine) !void {
|
pub fn engineExit(world: *World) !void {
|
||||||
try eng.send(.exit);
|
try world.send(.exit);
|
||||||
eng.mod.mach.state.exit = true;
|
world.mod.engine.state.exit = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const App = struct {
|
pub const App = struct {
|
||||||
engine: Engine,
|
world: World,
|
||||||
|
|
||||||
pub fn init(app: *@This()) !void {
|
pub fn init(app: *@This()) !void {
|
||||||
app.* = .{ .engine = try Engine.init(allocator) };
|
app.* = .{ .world = try World.init(allocator) };
|
||||||
try app.engine.send(.machInit);
|
try app.world.send(.engineInit);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(app: *@This()) void {
|
pub fn deinit(app: *@This()) void {
|
||||||
try app.engine.send(.machDeinit);
|
try app.world.send(.engineDeinit);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(app: *@This()) !bool {
|
pub fn update(app: *@This()) !bool {
|
||||||
try app.engine.send(.tick);
|
try app.world.send(.tick);
|
||||||
return app.engine.mod.mach.state.exit;
|
return app.world.mod.engine.state.exit;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Engine = ecs.World(modules());
|
pub const World = ecs.World(modules());
|
||||||
|
|
||||||
fn Modules() type {
|
fn Modules() type {
|
||||||
if (!@hasDecl(@import("root"), "modules")) {
|
if (!@hasDecl(@import("root"), "modules")) {
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,9 @@ pub const Atlas = @import("atlas/Atlas.zig");
|
||||||
|
|
||||||
// Engine exports
|
// Engine exports
|
||||||
pub const App = @import("engine.zig").App;
|
pub const App = @import("engine.zig").App;
|
||||||
pub const Module = @import("engine.zig").Module;
|
|
||||||
pub const Engine = @import("engine.zig").Engine;
|
pub const Engine = @import("engine.zig").Engine;
|
||||||
|
pub const World = @import("engine.zig").World;
|
||||||
|
pub const Mod = World.Mod;
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue