diff options
author | HampusM <hampus@hampusmat.com> | 2024-11-11 00:11:22 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-11-11 00:11:22 +0100 |
commit | daf0bc236df25c0e9f44bc3e30839c16cda3f638 (patch) | |
tree | 7475e4e58686dd34366e641ec32f5a9374d66533 /ecs/src/system/stateful.rs | |
parent | 17f63d9859e1c82a30c07bf110cf2b9872e2427e (diff) |
refactor(ecs): use same ID for entities & components
Diffstat (limited to 'ecs/src/system/stateful.rs')
-rw-r--r-- | ecs/src/system/stateful.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/ecs/src/system/stateful.rs b/ecs/src/system/stateful.rs index 99b56c1..810a071 100644 --- a/ecs/src/system/stateful.rs +++ b/ecs/src/system/stateful.rs @@ -4,7 +4,7 @@ use std::panic::{RefUnwindSafe, UnwindSafe}; use seq_macro::seq; -use crate::component::{Component, Id as ComponentId}; +use crate::component::Component; use crate::lock::Lock; use crate::system::util::check_params_are_compatible; use crate::system::{ @@ -21,13 +21,14 @@ use crate::tuple::{ TakeOptionElementResult as TupleTakeOptionElementResult, WithOptionElements as TupleWithOptionElements, }; +use crate::uid::Uid; use crate::World; /// A stateful system. pub struct Stateful<Func> { func: Func, - local_components: HashMap<ComponentId, Lock<Box<dyn Component>>>, + local_components: HashMap<Uid, Lock<Box<dyn Component>>>, } macro_rules! impl_system { @@ -125,7 +126,7 @@ macro_rules! impl_system { ) -> Option<ComponentRefMut<LocalComponent>> { let local_component = self.local_components - .get(&ComponentId::of::<LocalComponent>())? + .get(&LocalComponent::id())? .write_nonblock() .expect("Failed to aquire read-write local component lock"); @@ -139,7 +140,7 @@ macro_rules! impl_system { { self.local_components .insert( - ComponentId::of::<LocalComponent>(), + LocalComponent::id(), Lock::new(Box::new(local_component)) ); } |