fix downcast

This commit is contained in:
DasLixou 2024-08-21 14:09:14 +02:00
parent 0ad9f13f1d
commit 1b6dec8f5a
1 changed files with 2 additions and 7 deletions

View File

@ -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<Entity> {
// 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::<fake_entity::Entity>() // 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 {