pub fn add_node(&mut self, behavior_type: BehaviorNodeType, name: String) -> usize {

        let mut node = BehaviorNode {
            behavior_type: behavior_type.clone(),
            name,
            values: HashMap::new(),
            id: 0,
            position: (250, 50),
        };

        if behavior_type == BehaviorNodeType::BehaviorType {
            node.position = (0, 0);
        }

        let mut has_id_already = true;
        while has_id_already {

            has_id_already = false;
            for (key, _value) in &self.data.nodes {
                if key == &node.id {
                    has_id_already = true;
                }
            }

            if has_id_already {
                node.id += 1;
            }
        }

        // Insert the node
        let id = node.id.clone();
        self.data.nodes.insert(node.id, node);
        id
    }
/// Add a new node of the given type and name
Add a new node of the given type and name
Add a new node of the given type and name
pub fn add_node(&mut self, behavior_type: BehaviorNodeType, name: String) -> usize {
        let mut node = BehaviorNode {
            behavior_type: behavior_type.clone(),
            name,
            values: HashMap::new(),
            id: 0,
            position: (250, 50),
        };
        if behavior_type == BehaviorNodeType::BehaviorType {
            node.position = (0, 0);
        }
        let mut has_id_already = true;
        while has_id_already {
            has_id_already = false;
            for (key, _value) in &self.data.nodes {
                if key == &node.id {
                    has_id_already = true;
                }
            }
            if has_id_already {
                node.id += 1;
            }
        }
        // Insert the node
        let id = node.id.clone();
        self.data.nodes.insert(node.id, node);
        id
    }
pub fn add_node ( & mut self , behavior_type : BehaviorNodeType , name : String ) -> usize { let mut node = BehaviorNode { behavior_type : behavior_type . clone ( ) , name , values : HashMap :: new ( ) , id : 0 , position : ( 250 , 50 ) , } ; if behavior_type == BehaviorNodeType :: BehaviorType { node . position = ( 0 , 0 ) ; } let mut has_id_already = true ; while has_id_already { has_id_already = false ; for ( key , _value ) in & self . data . nodes { if key == & node . id { has_id_already = true ; } } if has_id_already { node . id += 1 ; } } // Insert the node let id = node . id . clone ( ) ; self . data . nodes . insert ( node . id , node ) ; id }
Add a new node of the given type and name
Add a new node of the given type and name
&mut self
behavior_type
BehaviorNodeType
name
String
&mut self
behavior_type
BehaviorNodeType
name
String