# NYXApp Low cortisol **General Purpose App** # App ```zig // --- APP --- var app: App = .init(std.testing.allocator); defer app.deinit(); // --- ADD PLUGINS --- try app.plugins.addMany(&.{ window_plugin, }); try app.plugins.build(&app); ``` # Plugin ```zig pub const window_plugin: Plugin = .{ .name = "Window", .description = "SDL3 Window", .build = build, }; fn build( self: *Plugin, _: *App, ) !void { std.debug.print( "[WINDOW_PLUGIN] {s} - {s}\n", .{ self.name, self.description, }, ); } ``` # Schedules **addMany** ```zig try app.schedules.addMany(stage.init, &.{ ensureStuff, otherSystem, }); ``` **runMany** ```zig try app.schedules.runMany( &.{ App.stage.init, App.stage.deinit, }, &app, ); ``` # Resources **set** ```zig const Window = struct { raw: u32 }; try app.resources.set(Window{ .raw = 0 }); ``` **get** ```zig if (app.resources.getPtr(Window)) |win| { std.debug.print("[WINDOW] {}\n", .{win.raw}); } ``` **getMany** ```zig const res = try app.resources.getMany(struct { window: *Window, renderer: ?*Renderer, }); if (res.renderer) |ren| { std.debug.print("[RENDERER] {}\n", .{ren.raw}); } ``` # Events **send** ```zig try app.events.send( AppExit{ .reason = "Why Not?", }, ); ``` **consume** ```zig if (app.events.consume(AppExit)) |app_exit| { std.debug.print("[APP_EXIT] {s}\n", .{app_exit.reason}); } ``` # Default Stages ```zig pub const stage = struct { // --- LIFETIME --- pub const init = struct {}; pub const deinit = struct {}; // --- FRAME --- pub const begin_frame = struct {}; pub const end_frame = struct {}; // --- CORE --- pub const inputs = struct {}; pub const fixed_update = struct {}; pub const update = struct {}; pub const draw = struct {}; }; ```