use `set_entity_field` function in `define_universal_commands` macro
@@ -102,42 +102,7 @@ macro_rules! define_universal_commands {
fn swap(&mut $self, $ctx_ident: &mut $ctx) {
let entity = $entity_getter;
- let mut components = fyrox::core::reflect::path_to_components(&$self.path);
- if let Some(fyrox::core::reflect::Component::Field(field)) = components.pop() {
- let mut parent_path = String::new();
- for component in components.into_iter() {
- match component {
- fyrox::core::reflect::Component::Field(s) => {
- if !parent_path.is_empty() {
- parent_path.push('.');
- }
- parent_path += s;
- }
- fyrox::core::reflect::Component::Index(s) => {
- parent_path.push('[');
- parent_path += s;
- parent_path.push(']');
- }
- }
- }
-
- let parent_entity = if parent_path.is_empty() {
- entity
- } else {
- match entity.resolve_path_mut(&parent_path) {
- Err(e) => {
- fyrox::utils::log::Log::err(format!(
- "There is no such parent property {}! Reason: {:?}",
- parent_path, e
- ));
-
- return;
- }
- Ok(property) => property,
- }
- };
-
- match parent_entity.set_field(field, $self.value.take().unwrap()) {
+ match crate::command::universal::set_entity_field(entity, &$self.path, $self.value.take().unwrap()) {
Ok(old_value) => {
$self.value = Some(old_value);
}
@@ -149,12 +114,6 @@ macro_rules! define_universal_commands {
))
}
}
- } else {
- fyrox::utils::log::Log::err(format!(
- "Failed to set property {}! Invalid path!",
- $self.path
- ))
- }
}
}
