From 8ff02361da3ff51ea3a108873aa8d094c3f733b2 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Mon, 27 Mar 2023 07:58:52 -0700 Subject: [PATCH] ecs: rename World.remove -> World.removeEntity; provide guidance on event names Signed-off-by: Stephen Gutekanst --- libs/ecs/src/systems.zig | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libs/ecs/src/systems.zig b/libs/ecs/src/systems.zig index b7d2d6af..24fba412 100644 --- a/libs/ecs/src/systems.zig +++ b/libs/ecs/src/systems.zig @@ -310,7 +310,15 @@ pub fn World(comptime modules: anytype) type { world.entities.deinit(); } - /// Broadcasts a state message to all modules that are subscribed to it. + /// Broadcasts an event to all modules that are subscribed to it. + /// + /// The message tag corresponds with the handler method name to be invoked. For example, + /// if `send(.tick)` is invoked, all modules which declare a `pub fn init` will be invoked. + /// + /// Events sent by Mach itself, or the application itself, may be single words. To prevent + /// name conflicts, events sent by modules provided by a library should prefix their events + /// with their module name. For example, a module named `.ziglibs_imgui` should use event + /// names like `.ziglibsImguiClick`, `.ziglibsImguiFoobar`. pub fn send(world: *Self, comptime msg_tag: anytype) !void { inline for (std.meta.fields(@TypeOf(modules))) |module_field| { const module = @field(modules, module_field.name); @@ -327,8 +335,8 @@ pub fn World(comptime modules: anytype) type { } /// Removes an entity. - pub inline fn remove(world: *Self, entity: EntityID) !void { - try world.entities.remove(entity); + pub inline fn removeEntity(world: *Self, entity: EntityID) !void { + try world.entities.removeEntity(entity); } }; }