diff options
| author | HampusM <hampus@hampusmat.com> | 2026-10-30 05:24:39 +0100 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-10-30 05:52:42 +0100 |
| commit | 723f48d8e008d216978b8ed7d70499c972cc5a1c (patch) | |
| tree | cdb997249bb0188c35c92c0a68a7c8d91ac222fd /engine-ecs/src/sole.rs | |
| parent | 5828e00dbe274391a05772380910f82996908b7d (diff) | |
refactor(engine-ecs): replace uid::WithUid* traits with new component traits
Diffstat (limited to 'engine-ecs/src/sole.rs')
| -rw-r--r-- | engine-ecs/src/sole.rs | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/engine-ecs/src/sole.rs b/engine-ecs/src/sole.rs index 4047b48..9168414 100644 --- a/engine-ecs/src/sole.rs +++ b/engine-ecs/src/sole.rs @@ -4,18 +4,14 @@ use std::fmt::Debug; use crate::component::{ HandleMut as ComponentHandleMut, IntoParts as IntoComponentParts, + WithAssociatedId as ComponentWithAssociatedId, }; use crate::system::{Metadata as SystemMetadata, Param as SystemParam}; -use crate::uid::Uid; use crate::World; /// A component which has a single instance in the [`World`]. -pub trait Sole: Any + IntoComponentParts +pub trait Sole: Any + IntoComponentParts + ComponentWithAssociatedId { - fn id() -> Uid - where - Self: Sized; - fn type_reflection() -> Option<&'static crate::reflection::Type> where Self: Sized; @@ -24,32 +20,6 @@ pub trait Sole: Any + IntoComponentParts fn name(&self) -> &'static str; } -impl dyn Sole -{ - pub fn downcast_mut<Real: 'static>(&mut self) -> Option<&mut Real> - { - (self as &mut dyn Any).downcast_mut() - } - - pub fn downcast_ref<Real: 'static>(&self) -> Option<&Real> - { - (self as &dyn Any).downcast_ref() - } - - pub fn is<Other: 'static>(&self) -> bool - { - (self as &dyn Any).is::<Other>() - } -} - -impl Debug for dyn Sole -{ - fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result - { - formatter.debug_struct("Sole").finish_non_exhaustive() - } -} - /// Holds a reference to a singleton component. #[derive(Debug)] pub struct Single<'world, SoleT: Sole> |
