summaryrefslogtreecommitdiff
path: root/ecs/src/component.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-12-09 18:16:50 +0100
committerHampusM <hampus@hampusmat.com>2024-12-09 18:16:50 +0100
commita318a32eba91cacd71c8f0cb09b49a10d12e96ca (patch)
treea76848818496a0e22c0f5f061c33ed89ab944999 /ecs/src/component.rs
parent3553a24c86791f6f4501e3d19fb85f267435cf70 (diff)
feat(ecs): add action to despawn entity
Diffstat (limited to 'ecs/src/component.rs')
-rw-r--r--ecs/src/component.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/ecs/src/component.rs b/ecs/src/component.rs
index 0f64695..5da510a 100644
--- a/ecs/src/component.rs
+++ b/ecs/src/component.rs
@@ -5,6 +5,7 @@ use seq_macro::seq;
use crate::event::component::{
Added as ComponentAddedEvent,
+ Kind as ComponentEventKind,
Removed as ComponentRemovedEvent,
};
use crate::lock::{ReadGuard, WriteGuard};
@@ -40,6 +41,9 @@ pub trait Component: SystemInput + Any + TypeName
/// The ID of the component `self`. Returns the same value as [`Component::id`].
fn self_id(&self) -> Uid;
+ /// Returns the component UID of a component event for this component.
+ fn get_event_uid(&self, event_kind: ComponentEventKind) -> Uid;
+
#[doc(hidden)]
fn as_any_mut(&mut self) -> &mut dyn Any;
@@ -115,6 +119,13 @@ where
Self::id()
}
+ fn get_event_uid(&self, event_kind: ComponentEventKind) -> Uid
+ {
+ match event_kind {
+ ComponentEventKind::Removed => ComponentRemovedEvent::<Self>::id(),
+ }
+ }
+
fn as_any_mut(&mut self) -> &mut dyn Any
{
self