mirror of
https://github.com/lisk77/comet.git
synced 2025-12-12 17:18:50 +00:00
fix(ecs): entity deletion is now type correct
This commit is contained in:
parent
607bf94f1e
commit
2a37205c22
4 changed files with 77 additions and 3 deletions
|
|
@ -272,6 +272,17 @@ impl Column {
|
|||
}
|
||||
}
|
||||
|
||||
/// Remove an element without knowing its concrete type. Drops in place.
|
||||
pub fn remove_any(&mut self, index: usize) {
|
||||
if index >= self.data.len() {
|
||||
return;
|
||||
}
|
||||
unsafe {
|
||||
let ptr = self.data.swap_remove_and_forget_unchecked(index);
|
||||
(self.data.drop)(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/// Overwrites an existing element in place, dropping the previous value.
|
||||
pub fn set<T: 'static>(&mut self, index: usize, item: T) -> Option<()> {
|
||||
assert_eq!(TypeId::of::<T>(), TypeId::of::<T>(), "Type mismatch");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue