From 8022e8998290b067b8aa0cb9cba8ba410826bdab Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 21 May 2026 17:55:20 +0200 Subject: chore: rename ecs* crates to engine-ecs* --- ecs/src/component/local.rs | 104 --------------------------------------------- 1 file changed, 104 deletions(-) delete mode 100644 ecs/src/component/local.rs (limited to 'ecs/src/component/local.rs') diff --git a/ecs/src/component/local.rs b/ecs/src/component/local.rs deleted file mode 100644 index b19a30b..0000000 --- a/ecs/src/component/local.rs +++ /dev/null @@ -1,104 +0,0 @@ -use std::any::type_name; -use std::ops::{Deref, DerefMut}; - -use ecs_macros::Component; - -use crate::component::{ - Component, - HandleMut as ComponentHandleMut, - IntoParts as _, - Parts as ComponentParts, -}; -use crate::pair::Pair; -use crate::system::initializable::Param as InitializableParam; -use crate::system::{Metadata as SystemMetadata, Param as SystemParam}; -use crate::World; - -/// Holds a component which is local to a single system. -#[derive(Debug)] -pub struct Local<'world, LocalComponent: Component> -{ - local_component: ComponentHandleMut<'world, LocalComponent>, -} - -impl<'world, LocalComponent> SystemParam<'world> for Local<'world, LocalComponent> -where - LocalComponent: Component, -{ - type Input = LocalComponent; - - fn new(world: &'world World, system_metadata: &SystemMetadata) -> Self - { - let Some(system_ent) = world.get_entity(system_metadata.ent_id) else { - panic!( - "System entity with ID {} does not exist", - system_metadata.ent_id - ); - }; - - let Some(local_component) = system_ent.get_with_id_mut::( - Pair::builder() - .relation::() - .target::() - .build() - .id(), - ) else { - panic!( - "Local component {} of system with ID {} is uninitialized", - type_name::(), - system_metadata.ent_id - ); - }; - - Self { local_component } - } -} - -impl<'world, LocalComponent, SystemT> InitializableParam<'world, SystemT> - for Local<'world, LocalComponent> -where - LocalComponent: Component, - SystemT: SystemWithLocalComponents, - Self: SystemParam<'world, Input = LocalComponent>, -{ - fn initialize(system: &mut SystemT, input: Self::Input) - { - system.add_local_component( - Pair::builder() - .relation::() - .target_as_data(input) - .build() - .into_parts(), - ); - } -} - -impl Deref for Local<'_, LocalComponent> -where - LocalComponent: Component, -{ - type Target = LocalComponent; - - fn deref(&self) -> &Self::Target - { - &self.local_component - } -} - -impl DerefMut for Local<'_, LocalComponent> -where - LocalComponent: Component, -{ - fn deref_mut(&mut self) -> &mut Self::Target - { - &mut self.local_component - } -} - -pub trait SystemWithLocalComponents -{ - fn add_local_component(&mut self, component_parts: ComponentParts); -} - -#[derive(Component)] -struct IsLocalComponent; -- cgit v1.2.3-18-g5258