From 5feeaf154a8b729873c729b4488f28536cf4ae24 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 21 Dec 2024 14:43:53 +0100 Subject: feat(ecs): add support for entities without components --- ecs/src/component.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'ecs/src/component.rs') diff --git a/ecs/src/component.rs b/ecs/src/component.rs index 85c556f..1fde5b4 100644 --- a/ecs/src/component.rs +++ b/ecs/src/component.rs @@ -351,3 +351,51 @@ macro_rules! inner { seq!(C in 0..=64 { inner!(C); }); + +impl Sequence for () +{ + type MutRefs<'component> = (); + type Refs<'component> = (); + + fn into_vec(self) -> Vec> + { + Vec::new() + } + + fn metadata() -> Vec + { + Vec::new() + } + + fn added_event_ids() -> Vec + { + Vec::new() + } + + fn removed_event_ids() -> Vec + { + Vec::new() + } + + #[inline] + fn from_components_mut<'component>( + _components: &'component [EntityComponent], + _component_index_lookup: impl Fn(Uid) -> Option, + _world: &'component World, + _lock_component: fn(&EntityComponent) -> WriteGuard<'_, Box>, + ) -> Self::MutRefs<'component> + { + () + } + + #[inline] + fn from_components<'component>( + _components: &'component [EntityComponent], + _component_index_lookup: impl Fn(Uid) -> Option, + _world: &'component World, + _lock_component: fn(&EntityComponent) -> ReadGuard<'_, Box>, + ) -> Self::Refs<'component> + { + () + } +} -- cgit v1.2.3-18-g5258