summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-12-09 18:17:32 +0100
committerHampusM <hampus@hampusmat.com>2024-12-09 18:17:32 +0100
commite26e548f5730e401797149d5d3254437e68e660e (patch)
tree53737d0f3d271cc4995640134af01ddff7121a32
parenta318a32eba91cacd71c8f0cb09b49a10d12e96ca (diff)
feat(ecs-macros): make Component macro implement get_event_uid fn
-rw-r--r--ecs-macros/src/lib.rs16
1 files changed, 16 insertions, 0 deletions
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::<Self>::id(),
+ _ => {
+ panic!(
+ "Support for event kind {event_kind:?} not implemented!"
+ );
+ }
+ }
+ }
+
fn as_any_mut(&mut self) -> &mut dyn Any
{
self