all: rename mach.Entity.Mod -> mach.Entities.Mod
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
11ebce62a3
commit
541ce9e7c0
18 changed files with 69 additions and 69 deletions
|
|
@ -290,8 +290,8 @@ pub fn Slicer(comptime modules: anytype) type {
|
|||
@field(component_types_by_name, @tagName(namespace_name)),
|
||||
@tagName(component_name),
|
||||
).type;
|
||||
if (namespace_name == .entity and component_name == .id) {
|
||||
const name_id = slicer.archetype.component_names.index("entity.id").?;
|
||||
if (namespace_name == .entities and component_name == .id) {
|
||||
const name_id = slicer.archetype.component_names.index("entities.id").?;
|
||||
return slicer.archetype.getColumnValues(name_id, Type).?[0..slicer.archetype.len];
|
||||
}
|
||||
const name = @tagName(namespace_name) ++ "." ++ @tagName(component_name);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const StringTable = @import("StringTable.zig");
|
|||
const ComponentTypesByName = @import("module.zig").ComponentTypesByName;
|
||||
const merge = @import("main.zig").merge;
|
||||
const builtin_modules = @import("main.zig").builtin_modules;
|
||||
const Entity = @import("main.zig").Entity;
|
||||
const Entities = @import("main.zig").Entities;
|
||||
const ModuleName = @import("module.zig").ModuleName;
|
||||
const ComponentNameM = @import("module.zig").ComponentNameM;
|
||||
const ComponentName = @import("module.zig").ComponentName;
|
||||
|
|
@ -130,7 +130,7 @@ pub fn Database(comptime modules: anytype) type {
|
|||
.component_names = component_names,
|
||||
.buckets = buckets,
|
||||
};
|
||||
entities.id_name = entities.componentName(Entity.name, .id);
|
||||
entities.id_name = entities.componentName(Entities.name, .id);
|
||||
|
||||
const columns = try allocator.alloc(Archetype.Column, 1);
|
||||
columns[0] = .{
|
||||
|
|
@ -1076,7 +1076,7 @@ test "example" {
|
|||
// Query for all entities that have all of the given components
|
||||
const W = @TypeOf(world);
|
||||
var q = try world.query(.{
|
||||
.ids = W.ComponentQuery{ .read = W.ModuleComponentName{ .module = Entity.name, .component = .id } },
|
||||
.ids = W.ComponentQuery{ .read = W.ModuleComponentName{ .module = Entities.name, .component = .id } },
|
||||
.rotations = W.ComponentQuery{ .write = W.ModuleComponentName{ .module = Game.name, .component = .rotation } },
|
||||
});
|
||||
while (q.next()) |v| {
|
||||
|
|
@ -1090,7 +1090,7 @@ test "example" {
|
|||
// Dynamic queries (e.g. issued from another programming language without comptime)
|
||||
var q2 = try world.queryDynamic(.{
|
||||
.op_and = &.{
|
||||
.{ .read = world.componentName(Entity.name, .id) },
|
||||
.{ .read = world.componentName(Entities.name, .id) },
|
||||
.{ .read = world.componentName(Game.name, .rotation) },
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ pub const AnyEvent = @import("module.zig").AnyEvent;
|
|||
pub const Merge = @import("module.zig").Merge;
|
||||
pub const merge = @import("module.zig").merge;
|
||||
|
||||
pub const builtin_modules = .{Entity};
|
||||
pub const builtin_modules = .{Entities};
|
||||
|
||||
/// Builtin .entity module
|
||||
pub const Entity = struct {
|
||||
pub const name = .entity;
|
||||
/// Builtin .entities module
|
||||
pub const Entities = struct {
|
||||
pub const name = .entities;
|
||||
|
||||
pub const Mod = mach.Mod(@This());
|
||||
|
||||
|
|
@ -82,15 +82,15 @@ test "entities DB" {
|
|||
defer world.deinit(allocator);
|
||||
|
||||
// Initialize module state.
|
||||
var entity = &world.mod.entity;
|
||||
var entities = &world.mod.entities;
|
||||
var physics = &world.mod.physics;
|
||||
var renderer = &world.mod.renderer;
|
||||
physics.init(.{ .pointer = 123 });
|
||||
_ = physics.state().pointer; // == 123
|
||||
|
||||
const player1 = try entity.new();
|
||||
const player2 = try entity.new();
|
||||
const player3 = try entity.new();
|
||||
const player1 = try try entities.new();
|
||||
const player2 = try try entities.new();
|
||||
const player3 = try try entities.new();
|
||||
try physics.set(player1, .id, 1001);
|
||||
try renderer.set(player1, .id, 1001);
|
||||
|
||||
|
|
|
|||
|
|
@ -575,8 +575,8 @@ pub fn ModSet(comptime modules: anytype) type {
|
|||
const module_tag = M.name;
|
||||
const components = ComponentTypesM(M){};
|
||||
|
||||
if (M.name == .entity) {
|
||||
// The .entity module is a special builtin module, with its own unique API.
|
||||
if (M.name == .entities) {
|
||||
// The .entities module is a special builtin module, with its own unique API.
|
||||
return struct {
|
||||
/// Private/internal fields
|
||||
__entities: *Database(modules),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue