pub fn apply_scope_to_target(instance_index: usize, data: &mut GameData) {
    if let Some(target_index) = data.instances[instance_index].target_instance_index {
        if let Some(target) = data.scopes[instance_index].get_value::<InstanceVariables>("target") {
            if let Some(behavior) = data.behaviors.get_mut(&data.instances[target_index].behavior_id) {
                for (_index, node) in &behavior.data.nodes {
                    if node.behavior_type == BehaviorNodeType::VariableNumber {

                        let o = data.scopes[target_index].get_value::<f64>(node.name.as_str());
                        let n = target.numbers.get(&node.name);

                        if n.is_some() && o.is_some() && o.unwrap() != *n.unwrap() {
                            let value = n.unwrap().clone();
                            data.scopes[target_index].set_value(node.name.clone(), value);
                            data.changed_variables.push((target_index, behavior.data.id, node.id, value));
                        }
                    }
                }
            }
        }
    }
}
/// Read out the target variables and if changed apply them
Read out the target variables and if changed apply them
Read out the target variables and if changed apply them
pub fn apply_scope_to_target(instance_index: usize, data: &mut GameData) {
    if let Some(target_index) = data.instances[instance_index].target_instance_index {
        if let Some(target) = data.scopes[instance_index].get_value::<InstanceVariables>("target") {
            if let Some(behavior) = data.behaviors.get_mut(&data.instances[target_index].behavior_id) {
                for (_index, node) in &behavior.data.nodes {
                    if node.behavior_type == BehaviorNodeType::VariableNumber {
                        let o = data.scopes[target_index].get_value::<f64>(node.name.as_str());
                        let n = target.numbers.get(&node.name);
                        if n.is_some() && o.is_some() && o.unwrap() != *n.unwrap() {
                            let value = n.unwrap().clone();
                            data.scopes[target_index].set_value(node.name.clone(), value);
                            data.changed_variables.push((target_index, behavior.data.id, node.id, value));
                        }
                    }
                }
            }
        }
    }
}
pub fn apply_scope_to_target ( instance_index : usize , data : & mut GameData ) { if let Some ( target_index ) = data . instances [ instance_index ] . target_instance_index { if let Some ( target ) = data . scopes [ instance_index ] . get_value :: < InstanceVariables > ( " " ) { if let Some ( behavior ) = data . behaviors . get_mut ( & data . instances [ target_index ] . behavior_id ) { for ( _index , node ) in & behavior . data . nodes { if node . behavior_type == BehaviorNodeType :: VariableNumber { let o = data . scopes [ target_index ] . get_value :: < f64 > ( node . name . as_str ( ) ) ; let n = target . numbers . get ( & node . name ) ; if n . is_some ( ) && o . is_some ( ) && o . unwrap ( ) != * n . unwrap ( ) { let value = n . unwrap ( ) . clone ( ) ; data . scopes [ target_index ] . set_value ( node . name . clone ( ) , value ) ; data . changed_variables . push ( ( target_index , behavior . data . id , node . id , value ) ) ; } } } } } } }
Read out the target variables and if changed apply them
Read out the target variables and if changed apply them
instance_index
usize
data
&mut GameData
instance_index
usize
data
&mut GameData