diff --git a/fyrox-impl/src/scene/node/mod.rs b/fyrox-impl/src/scene/node/mod.rs index 70deb7511..04d6a1728 100644 --- a/fyrox-impl/src/scene/node/mod.rs +++ b/fyrox-impl/src/scene/node/mod.rs @@ -63,7 +63,6 @@ use crate::{ }, }; use fyrox_core::{define_as_any_trait, pool::ObjectOrVariantHelper}; -use std::any::type_name; use std::{ any::TypeId, fmt::Debug, @@ -359,8 +358,8 @@ impl ObjectOrVariantHelper for PhantomData { /// Such implementation of property inheritance has its drawbacks, major one is: each instance still holds its own copy of /// of every field, even those inheritable variables which are non-modified. Which means that there's no benefits of RAM /// consumption, only disk space usage is reduced. -#[derive(Debug)] -pub struct Node(pub(crate) Box); +#[derive(Debug, Reflect)] +pub struct Node(#[reflect(deref, display_name = "Node")] pub(crate) Box); impl From for Node { fn from(value: T) -> Self { @@ -578,84 +577,6 @@ impl Visit for Node { } } -static CONTENT_METADATA: FieldMetadata = FieldMetadata { - name: "Content", - display_name: "Content", - tag: "", - read_only: false, - immutable_collection: false, - min_value: None, - max_value: None, - step: None, - precision: None, - doc: "", -}; - -impl Reflect for Node { - fn type_info() -> TypeInfo { - TypeInfo { - source_path: file!(), - type_name: type_name::(), - assembly_name: env!("CARGO_PKG_NAME"), - doc_comment: "", - derived_types: &[], - } - } - - fn type_info_ref(&self) -> TypeInfo { - Self::type_info() - } - - fn fields_ref(&self, func: &mut dyn FnMut(&[FieldRef])) { - func(&[{ - FieldRef { - metadata: &CONTENT_METADATA, - value: &*self.0, - } - }]) - } - - fn fields_mut(&mut self, func: &mut dyn FnMut(&mut [FieldMut])) { - func(&mut [{ - FieldMut { - metadata: &CONTENT_METADATA, - value: &mut *self.0, - } - }]) - } - - fn set(&mut self, value: Box) -> Result, Box> { - let this = std::mem::replace(self, value.take()?); - Ok(Box::new(this)) - } - - fn try_clone_box(&self) -> Option> { - Some(Box::new(self.clone())) - } - - fn field_direct_ref(&self, index: usize) -> Option { - if index == 0 { - Some(FieldRef { - metadata: &CONTENT_METADATA, - value: &*self.0, - }) - } else { - None - } - } - - fn field_direct_mut(&mut self, index: usize) -> Option { - if index == 0 { - Some(FieldMut { - metadata: &CONTENT_METADATA, - value: &mut *self.0, - }) - } else { - None - } - } -} - #[cfg(test)] mod test { use crate::{ diff --git a/fyrox-impl/src/script/mod.rs b/fyrox-impl/src/script/mod.rs index 5a7c23fad..201c85a13 100644 --- a/fyrox-impl/src/script/mod.rs +++ b/fyrox-impl/src/script/mod.rs @@ -43,7 +43,6 @@ use fyrox_core::pool::ObjectOrVariant; use fyrox_core::reflect::{FieldMetadata, TypeInfo}; pub use fyrox_core_derive::ScriptMessagePayload; use fyrox_graph::SceneGraph; -use std::any::type_name; use std::{ any::Any, fmt::{Debug, Formatter}, @@ -711,10 +710,13 @@ pub trait ScriptTrait: BaseScript { } /// A wrapper for actual script instance internals, it used by the engine. -#[derive(Debug)] +#[derive(Debug, Reflect)] pub struct Script { + #[reflect(deref, display_name = "Script")] instance: Box, + #[reflect(hidden)] pub(crate) initialized: bool, + #[reflect(hidden)] pub(crate) started: bool, } @@ -724,84 +726,6 @@ impl TypeUuidProvider for Script { } } -static CONTENT_METADATA: FieldMetadata = FieldMetadata { - name: "Content", - display_name: "Content", - tag: "", - read_only: false, - immutable_collection: false, - min_value: None, - max_value: None, - step: None, - precision: None, - doc: "", -}; - -impl Reflect for Script { - fn type_info() -> TypeInfo { - TypeInfo { - source_path: file!(), - type_name: type_name::(), - assembly_name: env!("CARGO_PKG_NAME"), - doc_comment: "", - derived_types: &[], - } - } - - fn type_info_ref(&self) -> TypeInfo { - Self::type_info() - } - - fn fields_ref(&self, func: &mut dyn FnMut(&[FieldRef])) { - func(&[{ - FieldRef { - metadata: &CONTENT_METADATA, - value: &*self.instance, - } - }]) - } - - fn fields_mut(&mut self, func: &mut dyn FnMut(&mut [FieldMut])) { - func(&mut [{ - FieldMut { - metadata: &CONTENT_METADATA, - value: &mut *self.instance, - } - }]) - } - - fn set(&mut self, value: Box) -> Result, Box> { - let this = std::mem::replace(self, value.take()?); - Ok(Box::new(this)) - } - - fn try_clone_box(&self) -> Option> { - Some(Box::new(self.clone())) - } - - fn field_direct_ref(&self, index: usize) -> Option { - if index == 0 { - Some(FieldRef { - metadata: &CONTENT_METADATA, - value: &*self.instance, - }) - } else { - None - } - } - - fn field_direct_mut(&mut self, index: usize) -> Option { - if index == 0 { - Some(FieldMut { - metadata: &CONTENT_METADATA, - value: &mut *self.instance, - }) - } else { - None - } - } -} - impl Deref for Script { type Target = dyn ScriptTrait;