summaryrefslogtreecommitdiff
path: root/ecs/src/actions.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-11-11 00:11:22 +0100
committerHampusM <hampus@hampusmat.com>2024-11-11 00:11:22 +0100
commitdaf0bc236df25c0e9f44bc3e30839c16cda3f638 (patch)
tree7475e4e58686dd34366e641ec32f5a9374d66533 /ecs/src/actions.rs
parent17f63d9859e1c82a30c07bf110cf2b9872e2427e (diff)
refactor(ecs): use same ID for entities & components
Diffstat (limited to 'ecs/src/actions.rs')
-rw-r--r--ecs/src/actions.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/ecs/src/actions.rs b/ecs/src/actions.rs
index 5cd7b00..72cc95d 100644
--- a/ecs/src/actions.rs
+++ b/ecs/src/actions.rs
@@ -7,8 +7,8 @@ use crate::component::{
Metadata as ComponentMetadata,
Sequence as ComponentSequence,
};
-use crate::entity::Uid as EntityUid;
use crate::system::{NoInitParamFlag, Param as SystemParam, System};
+use crate::uid::{Kind as UidKind, Uid};
use crate::{ActionQueue, World};
/// Used to to queue up actions for a [`World`] to perform.
@@ -28,19 +28,23 @@ impl<'world> Actions<'world>
}
/// Adds component(s) to a entity.
- pub fn add_components<Comps>(&mut self, entity_uid: EntityUid, components: Comps)
+ pub fn add_components<Comps>(&mut self, entity_uid: Uid, components: Comps)
where
Comps: ComponentSequence,
{
+ debug_assert_eq!(entity_uid.kind(), UidKind::Entity);
+
self.action_queue
.push(Action::AddComponents(entity_uid, components.into_vec()));
}
/// Removes component(s) from a entity.
- pub fn remove_components<Comps>(&mut self, entity_uid: EntityUid)
+ pub fn remove_components<Comps>(&mut self, entity_uid: Uid)
where
Comps: ComponentSequence,
{
+ debug_assert_eq!(entity_uid.kind(), UidKind::Entity);
+
self.action_queue
.push(Action::RemoveComponents(entity_uid, Comps::metadata()));
}
@@ -149,8 +153,8 @@ impl<'weak_ref> Ref<'weak_ref>
pub(crate) enum Action
{
Spawn(Vec<Box<dyn Component>>),
- AddComponents(EntityUid, Vec<Box<dyn Component>>),
- RemoveComponents(EntityUid, Vec<ComponentMetadata>),
+ AddComponents(Uid, Vec<Box<dyn Component>>),
+ RemoveComponents(Uid, Vec<ComponentMetadata>),
Stop,
}