forked from nonsensical-dev/zenyx-engine
improve error handling
This commit is contained in:
parent
ff7ff5fb79
commit
2dd2398809
5 changed files with 112 additions and 54 deletions
|
@ -81,7 +81,8 @@ impl Entity for EntityImpl {
|
|||
fn get_component<C: Component>(&self) -> Option<&C> {
|
||||
let type_id = TypeId::of::<C>();
|
||||
if let Some(&bit) = COMPONENT_REGISTRY.lock().unwrap().get(&type_id) {
|
||||
self.components.get(&bit)
|
||||
self.components
|
||||
.get(&bit)
|
||||
.and_then(|boxed| boxed.as_any().downcast_ref::<C>())
|
||||
} else {
|
||||
None
|
||||
|
@ -107,7 +108,6 @@ impl Entity for EntityImpl {
|
|||
components: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub struct ECS {
|
||||
|
@ -167,4 +167,4 @@ impl ECS {
|
|||
}
|
||||
self.next_entity_id = count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue