From 1b6dec8f5abaa4f34413a3b5f70453df41055b77 Mon Sep 17 00:00:00 2001 From: DasLixou Date: Wed, 21 Aug 2024 14:09:14 +0200 Subject: [PATCH] fix downcast --- crates/blenvy/src/components/patch_entity.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/crates/blenvy/src/components/patch_entity.rs b/crates/blenvy/src/components/patch_entity.rs index f9e763e..5dac92c 100644 --- a/crates/blenvy/src/components/patch_entity.rs +++ b/crates/blenvy/src/components/patch_entity.rs @@ -1,18 +1,13 @@ use bevy::{ log::{info, warn}, prelude::Entity, - reflect::Reflect, + reflect::{FromReflect, Reflect}, }; use super::{fake_entity, reflect_ext}; pub fn patch_reflect_entity(reflect: &mut dyn Reflect) -> Option { - // We can put here either `fake_entity::Entity` or `bevy::ecs::entity::Entity`, but the latter would result in a false downcast. - let maybe_fake = reflect - .downcast_mut::() // TODO: doesn't work yet, seems like it doesnt work when it's a dynamic type - .map(|fake| fake.name.clone()); - - info!("{}", reflect.reflect_type_ident().unwrap()); + let maybe_fake = fake_entity::Entity::from_reflect(reflect).map(|fake| fake.name.clone()); if let Some(reference) = maybe_fake { let entity = if let Some(name) = reference {