Lowered cortisol levels by about 69% | Boilerplate be GONE (context)
This commit is contained in:
parent
55411d8fa7
commit
ff3a273416
11 changed files with 131 additions and 74 deletions
32
src/app.zig
32
src/app.zig
|
|
@ -1,3 +1,6 @@
|
||||||
|
//! ----------------------------------------------------
|
||||||
|
//! ----------------------------------------------------
|
||||||
|
|
||||||
// --- LIBS ---
|
// --- LIBS ---
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const root = @import("root");
|
const root = @import("root");
|
||||||
|
|
@ -110,24 +113,23 @@ test "Main" {
|
||||||
});
|
});
|
||||||
|
|
||||||
// --- BUILD PLUGINS ---
|
// --- BUILD PLUGINS ---
|
||||||
try app.plugins.build(.{
|
try app.plugins.build(&app);
|
||||||
.app = &app,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // SYSTEMS
|
{ // SYSTEMS
|
||||||
try app.schedules.runAll(.{
|
// try app.schedules.runAll(&app);
|
||||||
.app = &app,
|
|
||||||
});
|
|
||||||
|
|
||||||
// try app.schedules.runMany(&.{
|
try app.schedules.runMany(&.{
|
||||||
// example.simple.stage.Init,
|
example.simple.stage.Init,
|
||||||
// example.simple.stage.Inputs,
|
example.simple.stage.Inputs,
|
||||||
// example.simple.stage.Update,
|
example.simple.stage.Update,
|
||||||
// example.simple.stage.Draw,
|
example.simple.stage.Draw,
|
||||||
// example.simple.stage.Deinit,
|
example.simple.stage.Deinit,
|
||||||
// }, .{
|
}, &app);
|
||||||
// .app = &app,
|
|
||||||
// });
|
try app.schedules.runReversed(
|
||||||
|
example.simple.stage.Deinit,
|
||||||
|
&app,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ pub const plugin: App.plugin.Plugin = .{
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
fn build(
|
fn build(
|
||||||
self: *App.plugin.Plugin,
|
self: *App.plugin.Plugin,
|
||||||
ctx: App.plugin.Context,
|
app: *App,
|
||||||
) !void {
|
) !void {
|
||||||
// --- DEBUG ---
|
// --- DEBUG ---
|
||||||
std.debug.print(
|
std.debug.print(
|
||||||
|
|
@ -32,11 +32,40 @@ fn build(
|
||||||
);
|
);
|
||||||
|
|
||||||
// --- ADD SYSTEMS ---
|
// --- ADD SYSTEMS ---
|
||||||
try ctx.app.schedules.addMany(stage.Init, &.{
|
try app.schedules.addMany(stage.Init, &.{
|
||||||
system.test_resources,
|
system.test_resources,
|
||||||
system.test_events,
|
system.test_events,
|
||||||
system.test_ecs,
|
system.test_ecs,
|
||||||
});
|
});
|
||||||
|
|
||||||
try ctx.app.schedules.addBefore(stage.Init, stage.Init, system.draw);
|
// --- RUN BEFORE ---
|
||||||
|
try app.schedules.addBefore(
|
||||||
|
stage.Init,
|
||||||
|
stage.Init,
|
||||||
|
system.draw,
|
||||||
|
);
|
||||||
|
|
||||||
|
try app.schedules.addMany(stage.Deinit, &.{
|
||||||
|
deinit_one,
|
||||||
|
deinit_two,
|
||||||
|
deinit_three,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ----------------------------------------------------
|
||||||
|
/// ----------------------------------------------------
|
||||||
|
fn deinit_one(_: *App) !void {
|
||||||
|
std.debug.print("---> One\n", .{});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ----------------------------------------------------
|
||||||
|
/// ----------------------------------------------------
|
||||||
|
fn deinit_two(_: *App) !void {
|
||||||
|
std.debug.print("---> Two\n", .{});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ----------------------------------------------------
|
||||||
|
/// ----------------------------------------------------
|
||||||
|
fn deinit_three(_: *App) !void {
|
||||||
|
std.debug.print("---> Three\n", .{});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,11 @@ const component = @import("component.zig");
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
pub fn test_resources(
|
pub fn test_resources(
|
||||||
ctx: App.scheduler.Context,
|
app: *App,
|
||||||
) !void {
|
) !void {
|
||||||
// --- SET NEW ---
|
// --- SET NEW ---
|
||||||
try ctx.app.resources.set(resource.Server{});
|
try app.resources.set(resource.Server{});
|
||||||
try ctx.app.resources.set(resource.Client{});
|
try app.resources.set(resource.Client{});
|
||||||
|
|
||||||
// --- CONTAINS DEBUG ---
|
// --- CONTAINS DEBUG ---
|
||||||
std.debug.print(
|
std.debug.print(
|
||||||
|
|
@ -22,13 +22,13 @@ pub fn test_resources(
|
||||||
\\
|
\\
|
||||||
,
|
,
|
||||||
.{
|
.{
|
||||||
ctx.app.resources.contains(resource.Server),
|
app.resources.contains(resource.Server),
|
||||||
ctx.app.resources.contains(resource.Client),
|
app.resources.contains(resource.Client),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// --- GET READONLY RESOURCES ---
|
// --- GET READONLY RESOURCES ---
|
||||||
_ = try ctx.app.resources.getMany(struct {
|
_ = try app.resources.getMany(struct {
|
||||||
server: ?*const resource.Server,
|
server: ?*const resource.Server,
|
||||||
client: ?*const resource.Client,
|
client: ?*const resource.Client,
|
||||||
});
|
});
|
||||||
|
|
@ -43,7 +43,7 @@ const User = struct {
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
pub fn test_events(
|
pub fn test_events(
|
||||||
ctx: App.scheduler.Context,
|
app: *App,
|
||||||
) !void {
|
) !void {
|
||||||
// --- DEBUG ---
|
// --- DEBUG ---
|
||||||
std.debug.print(
|
std.debug.print(
|
||||||
|
|
@ -52,25 +52,25 @@ pub fn test_events(
|
||||||
);
|
);
|
||||||
|
|
||||||
// --- CLEAR EVENTS ---
|
// --- CLEAR EVENTS ---
|
||||||
defer ctx.app.events.clear();
|
defer app.events.clear();
|
||||||
|
|
||||||
// --- USER LIST ---
|
// --- USER LIST ---
|
||||||
var users: std.ArrayList(User) = .empty;
|
var users: std.ArrayList(User) = .empty;
|
||||||
defer users.deinit(ctx.app.alloc);
|
defer users.deinit(app.alloc);
|
||||||
|
|
||||||
// --- ID`S ---
|
// --- ID`S ---
|
||||||
var next_register_id: u32 = 0;
|
var next_register_id: u32 = 0;
|
||||||
var next_connected_id: u32 = 0;
|
var next_connected_id: u32 = 0;
|
||||||
|
|
||||||
// --- ADD ADMIN USER ---
|
// --- ADD ADMIN USER ---
|
||||||
try users.append(ctx.app.alloc, .{
|
try users.append(app.alloc, .{
|
||||||
.id = next_register_id,
|
.id = next_register_id,
|
||||||
.username = "admin",
|
.username = "admin",
|
||||||
.password = "1234",
|
.password = "1234",
|
||||||
});
|
});
|
||||||
|
|
||||||
{ // NEW USER
|
{ // NEW USER
|
||||||
try ctx.app.events.sendMany(.{
|
try app.events.sendMany(.{
|
||||||
event.Register{
|
event.Register{
|
||||||
.username = "abux",
|
.username = "abux",
|
||||||
.password = "qwerty",
|
.password = "qwerty",
|
||||||
|
|
@ -83,10 +83,10 @@ pub fn test_events(
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- REGISTER LOOP ---
|
// --- REGISTER LOOP ---
|
||||||
if (ctx.app.events.get(event.Register)) |queue| {
|
if (app.events.get(event.Register)) |queue| {
|
||||||
for (queue.items()) |reg| {
|
for (queue.items()) |reg| {
|
||||||
next_register_id += 1;
|
next_register_id += 1;
|
||||||
try users.append(ctx.app.alloc, .{
|
try users.append(app.alloc, .{
|
||||||
.id = next_register_id,
|
.id = next_register_id,
|
||||||
.username = reg.username,
|
.username = reg.username,
|
||||||
.password = reg.password,
|
.password = reg.password,
|
||||||
|
|
@ -96,7 +96,7 @@ pub fn test_events(
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- LOGIN LOOP ---
|
// --- LOGIN LOOP ---
|
||||||
if (ctx.app.events.get(event.Login)) |queue| {
|
if (app.events.get(event.Login)) |queue| {
|
||||||
for (queue.items()) |login| {
|
for (queue.items()) |login| {
|
||||||
for (users.items) |user| {
|
for (users.items) |user| {
|
||||||
// --- CHECK CREDS ---
|
// --- CHECK CREDS ---
|
||||||
|
|
@ -105,7 +105,7 @@ pub fn test_events(
|
||||||
|
|
||||||
// --- SEND ACCEPTED CONNECTION ---
|
// --- SEND ACCEPTED CONNECTION ---
|
||||||
next_connected_id += 1;
|
next_connected_id += 1;
|
||||||
try ctx.app.events.send(event.ConnectionAccepted{
|
try app.events.send(event.ConnectionAccepted{
|
||||||
.id = next_connected_id,
|
.id = next_connected_id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -114,7 +114,7 @@ pub fn test_events(
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- CONNECTED ---
|
// --- CONNECTED ---
|
||||||
if (ctx.app.events.consume(event.ConnectionAccepted)) |ca| {
|
if (app.events.consume(event.ConnectionAccepted)) |ca| {
|
||||||
std.debug.print(
|
std.debug.print(
|
||||||
\\ | Connected:
|
\\ | Connected:
|
||||||
\\ | ID: {}
|
\\ | ID: {}
|
||||||
|
|
@ -150,15 +150,15 @@ pub fn test_events(
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
pub fn test_ecs(
|
pub fn test_ecs(
|
||||||
ctx: App.scheduler.Context,
|
app: *App,
|
||||||
) !void {
|
) !void {
|
||||||
// --- SPAWN ENTITY ---
|
// --- SPAWN ENTITY ---
|
||||||
const player = try ctx.app.world.spawnEntity(.{
|
const player = try app.world.spawnEntity(.{
|
||||||
component.Player{ .name = "abux" },
|
component.Player{ .name = "abux" },
|
||||||
component.Material{},
|
component.Material{},
|
||||||
component.Transform{},
|
component.Transform{},
|
||||||
});
|
});
|
||||||
try ctx.app.world.spawn(.{
|
try app.world.spawn(.{
|
||||||
component.Material{},
|
component.Material{},
|
||||||
component.Transform{},
|
component.Transform{},
|
||||||
});
|
});
|
||||||
|
|
@ -170,7 +170,7 @@ pub fn test_ecs(
|
||||||
);
|
);
|
||||||
|
|
||||||
// --- QUERY ---
|
// --- QUERY ---
|
||||||
var query = ctx.app.world.query(struct {
|
var query = app.world.query(struct {
|
||||||
player: ?*component.Player,
|
player: ?*component.Player,
|
||||||
material: *component.Material,
|
material: *component.Material,
|
||||||
transform: *component.Transform,
|
transform: *component.Transform,
|
||||||
|
|
@ -205,16 +205,16 @@ pub fn test_ecs(
|
||||||
std.debug.print("\x1b[0m", .{});
|
std.debug.print("\x1b[0m", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx.app.world.getComponent(component.Dead, player)) |_| {
|
if (app.world.getComponent(component.Dead, player)) |_| {
|
||||||
std.debug.print("------------------>\n", .{});
|
std.debug.print("------------------>\n", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
// try ctx.app.world.addComponents(player, .{component.Dead{}});
|
// try app.world.addComponents(player, .{component.Dead{}});
|
||||||
try ctx.app.world.addComponents(player, .{
|
try app.world.addComponents(player, .{
|
||||||
component.Dead{},
|
component.Dead{},
|
||||||
});
|
});
|
||||||
|
|
||||||
const cmps = try ctx.app.world.getComponents(struct {
|
const cmps = try app.world.getComponents(struct {
|
||||||
mat: *component.Material,
|
mat: *component.Material,
|
||||||
dead: ?*component.Dead,
|
dead: ?*component.Dead,
|
||||||
}, player);
|
}, player);
|
||||||
|
|
@ -225,17 +225,17 @@ pub fn test_ecs(
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
pub fn draw(
|
pub fn draw(
|
||||||
ctx: App.scheduler.Context,
|
app: *App,
|
||||||
) !void {
|
) !void {
|
||||||
_ = ctx;
|
_ = app;
|
||||||
std.debug.print("----> DRAW\n", .{});
|
std.debug.print("----> DRAW\n", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
pub fn mainPass(
|
pub fn mainPass(
|
||||||
ctx: App.scheduler.Context,
|
app: *App,
|
||||||
) !void {
|
) !void {
|
||||||
_ = ctx;
|
_ = app;
|
||||||
std.debug.print("----> MAIN_PASS\n", .{});
|
std.debug.print("----> MAIN_PASS\n", .{});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
const App = @import("../app.zig");
|
|
||||||
|
|
||||||
app: *App,
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const Context = @import("context.zig");
|
const App = @import("../app.zig");
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -12,4 +12,4 @@ description: []const u8 = "",
|
||||||
version: [3]u8 = .{ 0, 0, 0 },
|
version: [3]u8 = .{ 0, 0, 0 },
|
||||||
|
|
||||||
// --- CALLBACKS ---
|
// --- CALLBACKS ---
|
||||||
build: *const fn (*Self, Context) anyerror!void,
|
build: *const fn (*Self, *App) anyerror!void,
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,2 @@
|
||||||
pub const Plugin = @import("plugin.zig");
|
pub const Plugin = @import("plugin.zig");
|
||||||
pub const Storage = @import("storage.zig");
|
pub const Storage = @import("storage.zig");
|
||||||
pub const Context = @import("context.zig");
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// --- LIBS ---
|
// --- LIBS ---
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const App = @import("../app.zig");
|
||||||
const Plugin = @import("plugin.zig");
|
const Plugin = @import("plugin.zig");
|
||||||
const Context = @import("context.zig");
|
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -53,7 +53,7 @@ pub fn addMany(
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
pub fn build(
|
pub fn build(
|
||||||
self: *Self,
|
self: *Self,
|
||||||
ctx: Context,
|
app: *App,
|
||||||
) !void {
|
) !void {
|
||||||
// --- # ---
|
// --- # ---
|
||||||
var built: std.StringHashMap(void) = .init(self.alloc);
|
var built: std.StringHashMap(void) = .init(self.alloc);
|
||||||
|
|
@ -79,7 +79,7 @@ pub fn build(
|
||||||
|
|
||||||
// --- IF YE, BUILD ---
|
// --- IF YE, BUILD ---
|
||||||
if (ready) {
|
if (ready) {
|
||||||
try plugin.build(plugin, ctx);
|
try plugin.build(plugin, app);
|
||||||
try built.put(plugin.name, {});
|
try built.put(plugin.name, {});
|
||||||
progress = true;
|
progress = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
const App = @import("../app.zig");
|
|
||||||
|
|
||||||
app: *App,
|
|
||||||
|
|
@ -1,3 +1,2 @@
|
||||||
pub const System = @import("system.zig");
|
pub const System = @import("system.zig");
|
||||||
pub const Storage = @import("storage.zig");
|
pub const Storage = @import("storage.zig");
|
||||||
pub const Context = @import("context.zig");
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// --- LIBS ---
|
// --- LIBS ---
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const App = @import("../app.zig");
|
||||||
const System = @import("system.zig");
|
const System = @import("system.zig");
|
||||||
const Context = @import("context.zig");
|
|
||||||
const TypeID = @import("../template/type_id.zig").of;
|
const TypeID = @import("../template/type_id.zig").of;
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ pub fn deinit(self: *Self) void {
|
||||||
pub fn add(
|
pub fn add(
|
||||||
self: *Self,
|
self: *Self,
|
||||||
comptime T: type,
|
comptime T: type,
|
||||||
execute: *const fn (Context) anyerror!void,
|
execute: *const fn (*App) anyerror!void,
|
||||||
) !void {
|
) !void {
|
||||||
// --- GET ID ---
|
// --- GET ID ---
|
||||||
const stage_id = TypeID(T);
|
const stage_id = TypeID(T);
|
||||||
|
|
@ -50,7 +50,7 @@ pub fn add(
|
||||||
pub fn addMany(
|
pub fn addMany(
|
||||||
self: *Self,
|
self: *Self,
|
||||||
comptime T: type,
|
comptime T: type,
|
||||||
values: []const *const fn (Context) anyerror!void,
|
values: []const *const fn (*App) anyerror!void,
|
||||||
) !void {
|
) !void {
|
||||||
for (values) |exe| {
|
for (values) |exe| {
|
||||||
try self.add(T, exe);
|
try self.add(T, exe);
|
||||||
|
|
@ -63,7 +63,7 @@ pub fn addBefore(
|
||||||
self: *Self,
|
self: *Self,
|
||||||
comptime Stage: type,
|
comptime Stage: type,
|
||||||
comptime Before: type,
|
comptime Before: type,
|
||||||
execute: *const fn (Context) anyerror!void,
|
execute: *const fn (*App) anyerror!void,
|
||||||
) !void {
|
) !void {
|
||||||
const stage_id = TypeID(Stage);
|
const stage_id = TypeID(Stage);
|
||||||
const insert_idx = self.firstStageIndex(TypeID(Before));
|
const insert_idx = self.firstStageIndex(TypeID(Before));
|
||||||
|
|
@ -81,7 +81,7 @@ pub fn addManyBefore(
|
||||||
self: *Self,
|
self: *Self,
|
||||||
comptime Stage: type,
|
comptime Stage: type,
|
||||||
comptime Before: type,
|
comptime Before: type,
|
||||||
values: []const *const fn (Context) anyerror!void,
|
values: []const *const fn (*App) anyerror!void,
|
||||||
) !void {
|
) !void {
|
||||||
const stage_id = TypeID(Stage);
|
const stage_id = TypeID(Stage);
|
||||||
var insert_idx = self.firstStageIndex(TypeID(Before));
|
var insert_idx = self.firstStageIndex(TypeID(Before));
|
||||||
|
|
@ -101,7 +101,7 @@ pub fn addAfter(
|
||||||
self: *Self,
|
self: *Self,
|
||||||
comptime Stage: type,
|
comptime Stage: type,
|
||||||
comptime After: type,
|
comptime After: type,
|
||||||
execute: *const fn (Context) anyerror!void,
|
execute: *const fn (*App) anyerror!void,
|
||||||
) !void {
|
) !void {
|
||||||
const stage_id = TypeID(Stage);
|
const stage_id = TypeID(Stage);
|
||||||
const insert_idx = self.lastStageIndex(TypeID(After));
|
const insert_idx = self.lastStageIndex(TypeID(After));
|
||||||
|
|
@ -119,7 +119,7 @@ pub fn addManyAfter(
|
||||||
self: *Self,
|
self: *Self,
|
||||||
comptime Stage: type,
|
comptime Stage: type,
|
||||||
comptime After: type,
|
comptime After: type,
|
||||||
values: []const *const fn (Context) anyerror!void,
|
values: []const *const fn (*App) anyerror!void,
|
||||||
) !void {
|
) !void {
|
||||||
const stage_id = TypeID(Stage);
|
const stage_id = TypeID(Stage);
|
||||||
var insert_idx = self.lastStageIndex(TypeID(After));
|
var insert_idx = self.lastStageIndex(TypeID(After));
|
||||||
|
|
@ -137,10 +137,10 @@ pub fn addManyAfter(
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
pub fn runAll(
|
pub fn runAll(
|
||||||
self: *Self,
|
self: *Self,
|
||||||
ctx: Context,
|
app: *App,
|
||||||
) !void {
|
) !void {
|
||||||
for (self.data.items) |sys| {
|
for (self.data.items) |sys| {
|
||||||
try sys.execute(ctx);
|
try sys.execute(app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,7 +149,7 @@ pub fn runAll(
|
||||||
pub fn run(
|
pub fn run(
|
||||||
self: *Self,
|
self: *Self,
|
||||||
comptime T: type,
|
comptime T: type,
|
||||||
ctx: Context,
|
app: *App,
|
||||||
) !void {
|
) !void {
|
||||||
// --- GET ID ---
|
// --- GET ID ---
|
||||||
const stage_id = TypeID(T);
|
const stage_id = TypeID(T);
|
||||||
|
|
@ -157,7 +157,7 @@ pub fn run(
|
||||||
// --- RUN ---
|
// --- RUN ---
|
||||||
for (self.data.items) |sys| {
|
for (self.data.items) |sys| {
|
||||||
if (sys.stage_id != stage_id) continue;
|
if (sys.stage_id != stage_id) continue;
|
||||||
try sys.execute(ctx);
|
try sys.execute(app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -166,10 +166,44 @@ pub fn run(
|
||||||
pub fn runMany(
|
pub fn runMany(
|
||||||
self: *Self,
|
self: *Self,
|
||||||
comptime Ts: []const type,
|
comptime Ts: []const type,
|
||||||
ctx: Context,
|
app: *App,
|
||||||
) !void {
|
) !void {
|
||||||
inline for (Ts) |T| {
|
inline for (Ts) |T| {
|
||||||
try self.run(T, ctx);
|
try self.run(T, app);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ----------------------------------------------------
|
||||||
|
/// ----------------------------------------------------
|
||||||
|
pub fn runReversed(
|
||||||
|
self: *Self,
|
||||||
|
comptime T: type,
|
||||||
|
app: *App,
|
||||||
|
) !void {
|
||||||
|
// --- GET ID ---
|
||||||
|
const stage_id = TypeID(T);
|
||||||
|
|
||||||
|
// --- RUN ---
|
||||||
|
var i: usize = self.data.items.len;
|
||||||
|
while (i > 0) {
|
||||||
|
i -= 1;
|
||||||
|
|
||||||
|
const sys = self.data.items[i];
|
||||||
|
if (sys.stage_id != stage_id) continue;
|
||||||
|
|
||||||
|
try sys.execute(app);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ----------------------------------------------------
|
||||||
|
/// ----------------------------------------------------
|
||||||
|
pub fn runManyReversed(
|
||||||
|
self: *Self,
|
||||||
|
comptime Ts: []const type,
|
||||||
|
app: *App,
|
||||||
|
) !void {
|
||||||
|
inline for (Ts) |T| {
|
||||||
|
try self.runReversed(T, app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const Context = @import("context.zig");
|
const App = @import("../app.zig");
|
||||||
|
|
||||||
stage_id: u64,
|
stage_id: u64,
|
||||||
execute: *const fn (ctx: Context) anyerror!void,
|
execute: *const fn (*App) anyerror!void,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue