mirror of
https://github.com/lisk77/comet.git
synced 2025-10-24 13:58:49 +00:00
fix: changed second type in the archetype hashmap
This commit is contained in:
parent
05249f2a6d
commit
7d351ced62
2 changed files with 319 additions and 6 deletions
|
|
@ -1,9 +1,9 @@
|
|||
use std::collections::HashMap;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use comet_structs::ComponentSet;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Archetypes {
|
||||
archetypes: HashMap<ComponentSet, Vec<u32>>
|
||||
archetypes: HashMap<ComponentSet, HashSet<u32>>
|
||||
}
|
||||
|
||||
impl Archetypes {
|
||||
|
|
@ -18,20 +18,20 @@ impl Archetypes {
|
|||
}
|
||||
|
||||
pub fn create_archetype(&mut self, components: ComponentSet) {
|
||||
self.archetypes.insert(components, Vec::new());
|
||||
self.archetypes.insert(components, HashSet::new());
|
||||
}
|
||||
|
||||
pub fn get_archetype(&self, components: &ComponentSet) -> Option<&Vec<u32>> {
|
||||
pub fn get_archetype(&self, components: &ComponentSet) -> Option<&HashSet<u32>> {
|
||||
self.archetypes.get(components)
|
||||
}
|
||||
|
||||
pub fn get_archetype_mut(&mut self, components: &ComponentSet) -> Option<&mut Vec<u32>> {
|
||||
pub fn get_archetype_mut(&mut self, components: &ComponentSet) -> Option<&mut HashSet<u32>> {
|
||||
self.archetypes.get_mut(components)
|
||||
}
|
||||
|
||||
pub fn add_entity_to_archetype(&mut self, components: &ComponentSet, entity: u32) {
|
||||
if let Some(archetype) = self.archetypes.get_mut(components) {
|
||||
archetype.push(entity);
|
||||
archetype.insert(entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue