From e26e548f5730e401797149d5d3254437e68e660e Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 9 Dec 2024 18:17:32 +0100 Subject: feat(ecs-macros): make Component macro implement get_event_uid fn --- ecs-macros/src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ecs-macros/src/lib.rs b/ecs-macros/src/lib.rs index 8bef0b6..b178022 100644 --- a/ecs-macros/src/lib.rs +++ b/ecs-macros/src/lib.rs @@ -110,6 +110,10 @@ pub fn component_derive(input: TokenStream) -> TokenStream use ::std::collections::HashMap; use #ecs_path::component::Component; + use #ecs_path::event::component::{ + Removed as ComponentRemovedEvent, + Kind as ComponentEventKind, + }; use #ecs_path::system::ComponentRefMut; use #ecs_path::system::ComponentRef; use #ecs_path::uid::{Uid, Kind as UidKind}; @@ -138,6 +142,18 @@ pub fn component_derive(input: TokenStream) -> TokenStream Self::id() } + fn get_event_uid(&self, event_kind: ComponentEventKind) -> Uid + { + match event_kind { + ComponentEventKind::Removed => ComponentRemovedEvent::::id(), + _ => { + panic!( + "Support for event kind {event_kind:?} not implemented!" + ); + } + } + } + fn as_any_mut(&mut self) -> &mut dyn Any { self -- cgit v1.2.3-18-g5258