From daf0bc236df25c0e9f44bc3e30839c16cda3f638 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 11 Nov 2024 00:11:22 +0100 Subject: refactor(ecs): use same ID for entities & components --- ecs/src/actions.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'ecs/src/actions.rs') 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(&mut self, entity_uid: EntityUid, components: Comps) + pub fn add_components(&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(&mut self, entity_uid: EntityUid) + pub fn remove_components(&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>), - AddComponents(EntityUid, Vec>), - RemoveComponents(EntityUid, Vec), + AddComponents(Uid, Vec>), + RemoveComponents(Uid, Vec), Stop, } -- cgit v1.2.3-18-g5258