move mach.ecs.Module -> mach.Module
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
279290bbf2
commit
56fc29743f
4 changed files with 13 additions and 12 deletions
|
|
@ -12,14 +12,13 @@
|
|||
//!
|
||||
|
||||
const std = @import("std");
|
||||
const mach = @import("../main.zig");
|
||||
const testing = std.testing;
|
||||
|
||||
pub const EntityID = @import("entities.zig").EntityID;
|
||||
pub const Entities = @import("entities.zig").Entities;
|
||||
pub const Archetype = @import("Archetype.zig");
|
||||
|
||||
pub const Module = @import("modules.zig").Module;
|
||||
pub const Modules = @import("modules.zig").Modules;
|
||||
pub const World = @import("systems.zig").World;
|
||||
|
||||
// TODO:
|
||||
|
|
@ -36,7 +35,6 @@ test "inclusion" {
|
|||
std.testing.refAllDeclsRecursive(@import("query.zig"));
|
||||
std.testing.refAllDeclsRecursive(@import("StringTable.zig"));
|
||||
std.testing.refAllDeclsRecursive(@import("systems.zig"));
|
||||
std.testing.refAllDeclsRecursive(@import("modules.zig"));
|
||||
}
|
||||
|
||||
test "example" {
|
||||
|
|
@ -44,7 +42,7 @@ test "example" {
|
|||
|
||||
comptime var Renderer = type;
|
||||
comptime var Physics = type;
|
||||
Physics = Module(struct {
|
||||
Physics = mach.Module(struct {
|
||||
pointer: u8,
|
||||
|
||||
pub const name = .physics;
|
||||
|
|
@ -57,7 +55,7 @@ test "example" {
|
|||
}
|
||||
});
|
||||
|
||||
Renderer = Module(struct {
|
||||
Renderer = mach.Module(struct {
|
||||
pub const name = .renderer;
|
||||
pub const components = struct {
|
||||
pub const id = u16;
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ const std = @import("std");
|
|||
const mem = std.mem;
|
||||
const StructField = std.builtin.Type.StructField;
|
||||
|
||||
const mach = @import("../main.zig");
|
||||
const Entities = @import("entities.zig").Entities;
|
||||
const Modules = @import("modules.zig").Modules;
|
||||
const EntityID = @import("entities.zig").EntityID;
|
||||
const comp = @import("comptime.zig");
|
||||
|
||||
pub fn World(comptime mods: anytype) type {
|
||||
const modules = Modules(mods);
|
||||
const modules = mach.Modules(mods);
|
||||
|
||||
return struct {
|
||||
allocator: mem.Allocator,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ pub const testing = @import("testing.zig");
|
|||
pub const sysaudio = if (build_options.want_sysaudio) @import("sysaudio/main.zig") else struct {};
|
||||
pub const sysgpu = if (build_options.want_sysgpu) @import("sysgpu/main.zig") else struct {};
|
||||
|
||||
pub const Module = @import("module.zig").Module;
|
||||
pub const Modules = @import("module.zig").Modules;
|
||||
|
||||
// Engine exports
|
||||
pub const App = @import("engine.zig").App;
|
||||
pub const Engine = @import("engine.zig").Engine;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
const std = @import("std");
|
||||
const testing = std.testing;
|
||||
const StructField = std.builtin.Type.StructField;
|
||||
|
||||
const EntityID = @import("entities.zig").EntityID;
|
||||
// TODO: eliminate dependency on ECS here.
|
||||
const EntityID = @import("ecs/entities.zig").EntityID;
|
||||
|
||||
/// Verifies that T matches the expected layout of an ECS module
|
||||
/// Verifies that T matches the basic layout of a mach.Module
|
||||
pub fn Module(comptime T: type) type {
|
||||
if (@typeInfo(T) != .Struct) @compileError("Module must be a struct type. Found:" ++ @typeName(T));
|
||||
if (!@hasDecl(T, "name")) @compileError("Module must have `pub const name = .foobar;`");
|
||||
|
|
@ -16,7 +16,7 @@ pub fn Module(comptime T: type) type {
|
|||
}
|
||||
|
||||
fn NamespacedComponents(comptime modules: anytype) type {
|
||||
var fields: []const StructField = &[0]StructField{};
|
||||
var fields: []const std.builtin.Type.StructField = &[0]std.builtin.Type.StructField{};
|
||||
inline for (modules) |M| {
|
||||
const components = if (@hasDecl(M, "components")) M.components else struct {};
|
||||
fields = fields ++ [_]std.builtin.Type.StructField{.{
|
||||
|
|
@ -51,7 +51,7 @@ fn NamespacedComponents(comptime modules: anytype) type {
|
|||
}
|
||||
|
||||
fn NamespacedState(comptime modules: anytype) type {
|
||||
var fields: []const StructField = &[0]StructField{};
|
||||
var fields: []const std.builtin.Type.StructField = &[0]std.builtin.Type.StructField{};
|
||||
inline for (modules) |M| {
|
||||
const state_fields = std.meta.fields(M);
|
||||
const State = if (state_fields.len > 0) @Type(.{
|
||||
Loading…
Add table
Add a link
Reference in a new issue