pub fn add_target_to_scope(instance_index: usize, data: &mut GameData) {
    if let Some(target_index) = data.instances[instance_index].target_instance_index {
        data.engine.register_type::<InstanceVariables>()
            .register_fn("new_instance", InstanceVariables::new)
            .register_indexer_get(InstanceVariables::get_number)
            .register_indexer_set(InstanceVariables::set_number);


        let original_target = data.scopes[target_index].clone();
        let mut target = InstanceVariables::new();

        if let Some(behavior) = data.get_mut_behavior(data.instances[target_index].behavior_id, BehaviorType::Behaviors) {
            for (_index, node) in &behavior.data.nodes {
                if node.behavior_type == BehaviorNodeType::VariableNumber {

                    if let Some(v) = original_target.get_value::<f64>(node.name.as_str()) {
                        target.numbers.insert(node.name.clone(), v);
                    }
                }
            }
        }

        data.scopes[instance_index].set_value("target", target);
    }
}
/// Adds the given target variables to the scope
Adds the given target variables to the scope
Adds the given target variables to the scope
pub fn add_target_to_scope(instance_index: usize, data: &mut GameData) {
    if let Some(target_index) = data.instances[instance_index].target_instance_index {
        data.engine.register_type::<InstanceVariables>()
            .register_fn("new_instance", InstanceVariables::new)
            .register_indexer_get(InstanceVariables::get_number)
            .register_indexer_set(InstanceVariables::set_number);
        let original_target = data.scopes[target_index].clone();
        let mut target = InstanceVariables::new();
        if let Some(behavior) = data.get_mut_behavior(data.instances[target_index].behavior_id, BehaviorType::Behaviors) {
            for (_index, node) in &behavior.data.nodes {
                if node.behavior_type == BehaviorNodeType::VariableNumber {
                    if let Some(v) = original_target.get_value::<f64>(node.name.as_str()) {
                        target.numbers.insert(node.name.clone(), v);
                    }
                }
            }
        }
        data.scopes[instance_index].set_value("target", target);
    }
}
pub fn add_target_to_scope ( instance_index : usize , data : & mut GameData ) { if let Some ( target_index ) = data . instances [ instance_index ] . target_instance_index { data . engine . register_type :: < InstanceVariables > ( ) . register_fn ( " " , InstanceVariables :: new ) . register_indexer_get ( InstanceVariables :: get_number ) . register_indexer_set ( InstanceVariables :: set_number ) ; let original_target = data . scopes [ target_index ] . clone ( ) ; let mut target = InstanceVariables :: new ( ) ; if let Some ( behavior ) = data . get_mut_behavior ( data . instances [ target_index ] . behavior_id , BehaviorType :: Behaviors ) { for ( _index , node ) in & behavior . data . nodes { if node . behavior_type == BehaviorNodeType :: VariableNumber { if let Some ( v ) = original_target . get_value :: < f64 > ( node . name . as_str ( ) ) { target . numbers . insert ( node . name . clone ( ) , v ) ; } } } } data . scopes [ instance_index ] . set_value ( " " , target ) ; } }
Adds the given target variables to the scope
Adds the given target variables to the scope
instance_index
usize
data
&mut GameData
instance_index
usize
data
&mut GameData