mirror of
https://github.com/lisk77/comet.git
synced 2025-10-24 13:58:49 +00:00
initial commit
This commit is contained in:
commit
6154c72b0e
55 changed files with 9481 additions and 0 deletions
35
crates/comet_ecs/src/entity.rs
Normal file
35
crates/comet_ecs/src/entity.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
use bit_set::BitSet;
|
||||
use crate::ComponentSet;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Entity {
|
||||
id: u32,
|
||||
components: BitSet
|
||||
}
|
||||
|
||||
impl Entity {
|
||||
pub fn new(id: u32) -> Self {
|
||||
let mut components = BitSet::new();
|
||||
components.insert(0);
|
||||
Self {
|
||||
id,
|
||||
components
|
||||
}
|
||||
}
|
||||
|
||||
pub fn id(&self) -> &u32 {
|
||||
&self.id
|
||||
}
|
||||
|
||||
pub(crate) fn add_component(&mut self, component_index: usize) {
|
||||
self.components.insert(component_index);
|
||||
}
|
||||
|
||||
pub(crate) fn remove_component(&mut self, component_index: usize) {
|
||||
self.components.remove(component_index);
|
||||
}
|
||||
|
||||
pub(crate) fn get_components(&self) -> &BitSet {
|
||||
&self.components
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue