mirror of
https://github.com/lisk77/comet.git
synced 2025-12-15 02:08:49 +00:00
chore(all): fix warnings
This commit is contained in:
parent
c7f0412eff
commit
81bc1cb790
14 changed files with 471 additions and 513 deletions
|
|
@ -1,59 +1,47 @@
|
|||
use std::collections::{HashMap, HashSet};
|
||||
use comet_structs::ComponentSet;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Archetypes {
|
||||
archetypes: HashMap<ComponentSet, HashSet<u32>>
|
||||
archetypes: HashMap<ComponentSet, HashSet<u32>>,
|
||||
}
|
||||
|
||||
impl Archetypes {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
archetypes: HashMap::new()
|
||||
}
|
||||
}
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
archetypes: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn component_sets(&self) -> Vec<ComponentSet> {
|
||||
self.archetypes.keys().cloned().collect()
|
||||
}
|
||||
pub fn component_sets(&self) -> Vec<ComponentSet> {
|
||||
self.archetypes.keys().cloned().collect()
|
||||
}
|
||||
|
||||
pub fn create_archetype(&mut self, components: ComponentSet) {
|
||||
self.archetypes.insert(components, HashSet::new());
|
||||
}
|
||||
pub fn create_archetype(&mut self, components: ComponentSet) {
|
||||
self.archetypes.insert(components, HashSet::new());
|
||||
}
|
||||
|
||||
pub fn get_archetype(&self, components: &ComponentSet) -> Option<&HashSet<u32>> {
|
||||
self.archetypes.get(components)
|
||||
}
|
||||
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 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.insert(entity);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_entity_to_archetype(&mut self, components: &ComponentSet, entity: u32) {
|
||||
if let Some(archetype) = self.archetypes.get_mut(components) {
|
||||
archetype.insert(entity);
|
||||
}
|
||||
}
|
||||
pub fn remove_entity_from_archetype(&mut self, components: &ComponentSet, entity: u32) {
|
||||
if let Some(archetype) = self.archetypes.get_mut(components) {
|
||||
archetype.retain(|&id| id != entity);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_entity_from_archetype(&mut self, components: &ComponentSet, entity: u32) {
|
||||
if let Some(archetype) = self.archetypes.get_mut(components) {
|
||||
archetype.retain(|&id| id != entity);
|
||||
}
|
||||
}
|
||||
pub fn remove_archetype(&mut self, components: &ComponentSet) {
|
||||
self.archetypes.remove(components);
|
||||
}
|
||||
|
||||
pub fn remove_archetype(&mut self, components: &ComponentSet) {
|
||||
self.archetypes.remove(components);
|
||||
}
|
||||
|
||||
pub fn contains_archetype(&self, components: &ComponentSet) -> bool {
|
||||
self.archetypes.contains_key(components)
|
||||
}
|
||||
|
||||
pub fn archetype_contains_entity(&self, entity_id: u32, components: &ComponentSet) -> bool {
|
||||
if self.contains_archetype(components) {
|
||||
let archetype = self.get_archetype(components).unwrap();
|
||||
return archetype.contains(&entity_id);
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
pub fn contains_archetype(&self, components: &ComponentSet) -> bool {
|
||||
self.archetypes.contains_key(components)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue