summaryrefslogtreecommitdiff
path: root/ecs/src/lib.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-06-06 12:21:34 +0200
committerHampusM <hampus@hampusmat.com>2024-06-06 12:21:34 +0200
commit989bffa8ec39bf7421801129fb5b116c47ce8a35 (patch)
treef0f244049230e5be449a9e2a857fa3b72dddc190 /ecs/src/lib.rs
parentc962b8721aaaaf001e9599fac17596bef71e433d (diff)
chore(ecs): remove support for specifying component to be dropped last
Diffstat (limited to 'ecs/src/lib.rs')
-rw-r--r--ecs/src/lib.rs74
1 files changed, 9 insertions, 65 deletions
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs
index 0bc7aa6..f76d1ae 100644
--- a/ecs/src/lib.rs
+++ b/ecs/src/lib.rs
@@ -40,7 +40,7 @@ pub use crate::query::Query;
#[derive(Debug, Default)]
struct Entity
{
- components: Vec<ManuallyDrop<EntityComponent>>,
+ components: Vec<EntityComponent>,
}
#[derive(Debug)]
@@ -50,7 +50,6 @@ pub struct EntityComponent
pub id: TypeId,
pub name: &'static str,
pub component: Lock<Box<dyn Component>>,
- pub drop_last: bool,
}
#[derive(Debug, Default)]
@@ -86,15 +85,10 @@ impl World
components: components
.into_vec()
.into_iter()
- .map(|component| {
- let drop_last = component.drop_last();
-
- ManuallyDrop::new(EntityComponent {
- id: (*component).type_id(),
- name: component.type_name(),
- component: Lock::new(component),
- drop_last,
- })
+ .map(|component| EntityComponent {
+ id: (*component).type_id(),
+ name: component.type_name(),
+ component: Lock::new(component),
})
.collect(),
});
@@ -184,15 +178,10 @@ impl World
.push(Entity {
components: components
.into_iter()
- .map(|component| {
- let drop_last = component.drop_last();
-
- ManuallyDrop::new(EntityComponent {
- id: (*component).type_id(),
- name: component.type_name(),
- component: Lock::new(component),
- drop_last,
- })
+ .map(|component| EntityComponent {
+ id: (*component).type_id(),
+ name: component.type_name(),
+ component: Lock::new(component),
})
.collect(),
});
@@ -326,51 +315,6 @@ impl TypeName for ComponentStorage
}
}
-impl Drop for ComponentStorage
-{
- fn drop(&mut self)
- {
- let mut components_to_drop_last = Vec::new();
-
- for entity in &mut self.entities {
- for component in &mut entity.components {
- if component.drop_last {
- #[cfg(feature = "debug")]
- tracing::debug!(
- "Component {} pushed to dropping last queue",
- component.component.read_nonblock().unwrap().type_name()
- );
-
- components_to_drop_last.push(component);
- continue;
- }
-
- #[cfg(feature = "debug")]
- tracing::debug!(
- "Dropping component {}",
- component.component.read_nonblock().unwrap().type_name()
- );
-
- unsafe {
- ManuallyDrop::drop(component);
- }
- }
- }
-
- for component in &mut components_to_drop_last {
- #[cfg(feature = "debug")]
- tracing::debug!(
- "Dropping component {} last",
- component.component.read_nonblock().unwrap().type_name()
- );
-
- unsafe {
- ManuallyDrop::drop(component);
- }
- }
- }
-}
-
#[derive(Debug, thiserror::Error)]
#[error("Sole {0} already exists")]
pub struct SoleAlreadyExistsError(pub &'static str);