mirror of
https://github.com/lisk77/comet.git
synced 2025-10-23 21:38:50 +00:00
fix: the ecs will now create all the archetypes for any combination of components that entities have on them
This commit is contained in:
parent
7d351ced62
commit
c1d41323f9
4 changed files with 55 additions and 12 deletions
|
|
@ -20,6 +20,24 @@ impl ComponentSet {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn powerset(ids: Vec<TypeId>) -> Vec<HashSet<TypeId>> {
|
||||
let n = ids.len();
|
||||
let mut subsets: Vec<HashSet<TypeId>> = Vec::with_capacity(1 << n);
|
||||
|
||||
for mask in 0..(1 << n) {
|
||||
let mut subset = HashSet::new();
|
||||
for i in 0..n {
|
||||
if (mask & (1 << i)) != 0 {
|
||||
subset.insert(ids[i].clone());
|
||||
}
|
||||
}
|
||||
subsets.push(subset);
|
||||
}
|
||||
subsets.remove(0);
|
||||
|
||||
subsets
|
||||
}
|
||||
|
||||
pub fn is_subset(&self, other: &ComponentSet) -> bool {
|
||||
self.set.is_subset(&other.set)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue