Show component in error message when sync modification fails because it does not exist

This commit is contained in:
Imbris 2020-04-24 04:19:08 -04:00
parent 8aa88b22a5
commit 48a5001392

View File

@ -22,18 +22,18 @@ pub trait CompPacket: Clone + Debug + Send + 'static {
/// Useful for implementing CompPacket trait
pub fn handle_insert<C: Component>(comp: C, entity: Entity, world: &World) {
if let Err(err) = world.write_storage::<C>().insert(entity, comp) {
error!("Error inserting component: {:?}", err);
error!("Error inserting : {:?}", err);
}
}
/// Useful for implementing CompPacket trait
pub fn handle_modify<C: Component>(comp: C, entity: Entity, world: &World) {
if world
.write_storage::<C>()
.get_mut(entity)
.map(|c| *c = comp)
.is_none()
{
error!("Error modifying synced component, it doesn't seem to exist");
pub fn handle_modify<C: Component + Debug>(comp: C, entity: Entity, world: &World) {
if let Some(c) = world.write_storage::<C>().get_mut(entity) {
*c = comp
} else {
error!(
"Error modifying synced component: {:?}, it doesn't seem to exist",
comp
);
}
}
/// Useful for implementing CompPacket trait