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
|
|
@ -139,7 +139,7 @@ fn audioTick(audio: *Mod) !void {
|
|||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
for (
|
||||
archetype.slice(.entity, .id),
|
||||
archetype.slice(.entities, .id),
|
||||
archetype.slice(.mach_audio, .samples),
|
||||
archetype.slice(.mach_audio, .channels),
|
||||
archetype.slice(.mach_audio, .playing),
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ fn start(core: *Mod) !void {
|
|||
core.state().run_state = .running;
|
||||
}
|
||||
|
||||
fn init(entity: *mach.Entity.Mod, core: *Mod) !void {
|
||||
fn init(entities: *mach.Entities.Mod, core: *Mod) !void {
|
||||
mach.core.allocator = gpa.allocator(); // TODO: banish this global allocator
|
||||
|
||||
// Initialize GPU implementation
|
||||
|
|
@ -116,7 +116,7 @@ fn init(entity: *mach.Entity.Mod, core: *Mod) !void {
|
|||
try mach.core.init(.{});
|
||||
|
||||
// TODO(important): update this information upon framebuffer resize events
|
||||
const main_window = try entity.new();
|
||||
const main_window = try entities.new();
|
||||
try core.set(main_window, .framebuffer_format, mach.core.descriptor.format);
|
||||
try core.set(main_window, .framebuffer_width, mach.core.descriptor.width);
|
||||
try core.set(main_window, .framebuffer_height, mach.core.descriptor.height);
|
||||
|
|
@ -141,7 +141,7 @@ fn update(core: *Mod) !void {
|
|||
var num_windows: usize = 0;
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
for (
|
||||
archetype.slice(.entity, .id),
|
||||
archetype.slice(.entities, .id),
|
||||
archetype.slice(.mach_core, .title),
|
||||
) |window_id, title| {
|
||||
num_windows += 1;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ fn update(core: *mach.Core.Mod, sprite: *Mod, sprite_pipeline: *gfx.SpritePipeli
|
|||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
const ids = archetype.slice(.entity, .id);
|
||||
const ids = archetype.slice(.entities, .id);
|
||||
const built_pipelines = archetype.slice(.mach_gfx_sprite_pipeline, .built);
|
||||
for (ids, built_pipelines) |pipeline_id, *built| {
|
||||
try updatePipeline(core, sprite, sprite_pipeline, pipeline_id, built);
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ fn update(core: *mach.Core.Mod, sprite_pipeline: *Mod) !void {
|
|||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
const ids = archetype.slice(.entity, .id);
|
||||
const ids = archetype.slice(.entities, .id);
|
||||
const textures = archetype.slice(.mach_gfx_sprite_pipeline, .texture);
|
||||
|
||||
for (ids, textures) |pipeline_id, texture| {
|
||||
|
|
@ -373,7 +373,7 @@ fn render(sprite_pipeline: *Mod) !void {
|
|||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
const ids = archetype.slice(.entity, .id);
|
||||
const ids = archetype.slice(.entities, .id);
|
||||
const built_pipelines = archetype.slice(.mach_gfx_sprite_pipeline, .built);
|
||||
for (ids, built_pipelines) |pipeline_id, built| {
|
||||
// Draw the sprite batch
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ fn update(core: *mach.Core.Mod, text: *Mod, text_pipeline: *gfx.TextPipeline.Mod
|
|||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
const ids = archetype.slice(.entity, .id);
|
||||
const ids = archetype.slice(.entities, .id);
|
||||
const built_pipelines = archetype.slice(.mach_gfx_text_pipeline, .built);
|
||||
for (ids, built_pipelines) |pipeline_id, *built| {
|
||||
try updatePipeline(core, text, text_pipeline, pipeline_id, built);
|
||||
|
|
@ -106,7 +106,7 @@ fn updatePipeline(
|
|||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
const ids = archetype.slice(.entity, .id);
|
||||
const ids = archetype.slice(.entities, .id);
|
||||
const transforms = archetype.slice(.mach_gfx_text, .transform);
|
||||
const segment_slices = archetype.slice(.mach_gfx_text, .text);
|
||||
const style_slices = archetype.slice(.mach_gfx_text, .style);
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ fn update(core: *mach.Core.Mod, text_pipeline: *Mod) !void {
|
|||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
const ids = archetype.slice(.entity, .id);
|
||||
const ids = archetype.slice(.entities, .id);
|
||||
for (ids) |pipeline_id| {
|
||||
try buildPipeline(core, text_pipeline, pipeline_id);
|
||||
}
|
||||
|
|
@ -402,7 +402,7 @@ fn render(text_pipeline: *Mod) !void {
|
|||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
const ids = archetype.slice(.entity, .id);
|
||||
const ids = archetype.slice(.entities, .id);
|
||||
const built_pipelines = archetype.slice(.mach_gfx_text_pipeline, .built);
|
||||
for (ids, built_pipelines) |pipeline_id, built| {
|
||||
// Draw the text batch
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ pub const EventID = @import("module/main.zig").EventID;
|
|||
pub const AnyEvent = @import("module/main.zig").AnyEvent;
|
||||
pub const merge = @import("module/main.zig").merge;
|
||||
pub const builtin_modules = @import("module/main.zig").builtin_modules;
|
||||
pub const Entity = @import("module/main.zig").Entity;
|
||||
pub const Entities = @import("module/main.zig").Entities;
|
||||
|
||||
/// To use experimental sysgpu graphics API, you can write this in your main.zig:
|
||||
///
|
||||
|
|
|
|||
|
|
@ -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