module: rename MComponents -> MComponentTypes
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
a83f9d5be8
commit
f55aee4b50
1 changed files with 5 additions and 5 deletions
|
|
@ -15,7 +15,7 @@ fn ModuleInterface(comptime M: type) type {
|
||||||
if (!@hasDecl(M, "events")) @compileError(prefix ++ "must have `pub const events = .{};`");
|
if (!@hasDecl(M, "events")) @compileError(prefix ++ "must have `pub const events = .{};`");
|
||||||
// TODO: re-enable this validation once module event handler arguments would not pose a type dependency loop
|
// TODO: re-enable this validation once module event handler arguments would not pose a type dependency loop
|
||||||
// validateEvents("mach: module ." ++ @tagName(M.name) ++ " ", M.events);
|
// validateEvents("mach: module ." ++ @tagName(M.name) ++ " ", M.events);
|
||||||
_ = MComponents(M);
|
_ = MComponentTypes(M);
|
||||||
return M;
|
return M;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -375,7 +375,7 @@ pub fn Module(
|
||||||
) type {
|
) type {
|
||||||
const module_tag = M.name;
|
const module_tag = M.name;
|
||||||
const State = @TypeOf(@field(@as(StateT, undefined), @tagName(module_tag)));
|
const State = @TypeOf(@field(@as(StateT, undefined), @tagName(module_tag)));
|
||||||
const components = MComponents(M){};
|
const components = MComponentTypes(M){};
|
||||||
return struct {
|
return struct {
|
||||||
state: State,
|
state: State,
|
||||||
entities: *Entities(NSComponents{}),
|
entities: *Entities(NSComponents{}),
|
||||||
|
|
@ -701,7 +701,7 @@ fn validateEvents(comptime error_prefix: anytype, comptime events: anytype) void
|
||||||
pub fn ComponentTypesByName(comptime modules: anytype) type {
|
pub fn ComponentTypesByName(comptime modules: anytype) type {
|
||||||
var fields: []const std.builtin.Type.StructField = &[0]std.builtin.Type.StructField{};
|
var fields: []const std.builtin.Type.StructField = &[0]std.builtin.Type.StructField{};
|
||||||
inline for (modules) |M| {
|
inline for (modules) |M| {
|
||||||
const MC = MComponents(M);
|
const MC = MComponentTypes(M);
|
||||||
fields = fields ++ [_]std.builtin.Type.StructField{.{
|
fields = fields ++ [_]std.builtin.Type.StructField{.{
|
||||||
.name = @tagName(M.name),
|
.name = @tagName(M.name),
|
||||||
.type = MC,
|
.type = MC,
|
||||||
|
|
@ -713,7 +713,7 @@ pub fn ComponentTypesByName(comptime modules: anytype) type {
|
||||||
|
|
||||||
// Builtin components
|
// Builtin components
|
||||||
// TODO: better method of injecting builtin module?
|
// TODO: better method of injecting builtin module?
|
||||||
const BuiltinMC = MComponents(struct {
|
const BuiltinMC = MComponentTypes(struct {
|
||||||
pub const name = .builtin;
|
pub const name = .builtin;
|
||||||
pub const components = .{
|
pub const components = .{
|
||||||
.{ .name = .id, .type = EntityID, .description = "Entity ID" },
|
.{ .name = .id, .type = EntityID, .description = "Entity ID" },
|
||||||
|
|
@ -746,7 +746,7 @@ pub fn ComponentTypesByName(comptime modules: anytype) type {
|
||||||
/// rotation: @TypeOf() = .{ .type = Vec2, .description = "rotation component" },
|
/// rotation: @TypeOf() = .{ .type = Vec2, .description = "rotation component" },
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn MComponents(comptime M: anytype) type {
|
fn MComponentTypes(comptime M: anytype) type {
|
||||||
const error_prefix = "mach: module ." ++ @tagName(M.name) ++ " .components ";
|
const error_prefix = "mach: module ." ++ @tagName(M.name) ++ " .components ";
|
||||||
if (!@hasDecl(M, "components")) {
|
if (!@hasDecl(M, "components")) {
|
||||||
return struct {};
|
return struct {};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue