fn execute_area_node(&mut self, area_index: usize, node_id: usize) -> Option<BehaviorNodeConnector> {

        let mut connectors : Vec<BehaviorNodeConnector> = vec![];
        let mut connected_node_ids : Vec<usize> = vec![];

        let mut rc : Option<BehaviorNodeConnector> = None;

        // Call the node and get the resulting BehaviorNodeConnector
        if let Some(region) = self.regions.get_mut(&self.curr_region_id) {
            if let Some(node) = region.behaviors[area_index].data.nodes.get_mut(&node_id) {

                if let Some(node_call) = self.nodes.get_mut(&node.behavior_type) {
                    let connector = node_call(region.behaviors[area_index].data.id, (area_index, node_id), self, BehaviorType::Regions);
                    rc = Some(connector);
                    connectors.push(connector);
                } else {
                    connectors.push(BehaviorNodeConnector::Bottom);
                }
            }
        }

        // Search the connections to check if we can find an ongoing node connection
        for connector in connectors {
            if let Some(region) = self.regions.get_mut(&self.curr_region_id) {
                for c in &region.behaviors[area_index].data.connections {
                    if c.0 == node_id && c.1 == connector {
                        connected_node_ids.push(c.2);
                        self.executed_connections.push((BehaviorType::Regions, c.0, c.1));
                    }
                }
            }
        }

        // And if yes execute it
        for (_index, connected_node_id) in connected_node_ids.iter().enumerate() {
            self.execute_area_node(area_index, *connected_node_id);
        }
        rc
    }
/// Executes the given node and follows the connection chain
Executes the given node and follows the connection chain
Executes the given node and follows the connection chain
fn execute_area_node(&mut self, area_index: usize, node_id: usize) -> Option<BehaviorNodeConnector> {
        let mut connectors : Vec<BehaviorNodeConnector> = vec![];
        let mut connected_node_ids : Vec<usize> = vec![];
        let mut rc : Option<BehaviorNodeConnector> = None;
        // Call the node and get the resulting BehaviorNodeConnector
        if let Some(region) = self.regions.get_mut(&self.curr_region_id) {
            if let Some(node) = region.behaviors[area_index].data.nodes.get_mut(&node_id) {
                if let Some(node_call) = self.nodes.get_mut(&node.behavior_type) {
                    let connector = node_call(region.behaviors[area_index].data.id, (area_index, node_id), self, BehaviorType::Regions);
                    rc = Some(connector);
                    connectors.push(connector);
                } else {
                    connectors.push(BehaviorNodeConnector::Bottom);
                }
            }
        }
        // Search the connections to check if we can find an ongoing node connection
        for connector in connectors {
            if let Some(region) = self.regions.get_mut(&self.curr_region_id) {
                for c in &region.behaviors[area_index].data.connections {
                    if c.0 == node_id && c.1 == connector {
                        connected_node_ids.push(c.2);
                        self.executed_connections.push((BehaviorType::Regions, c.0, c.1));
                    }
                }
            }
        }
        // And if yes execute it
        for (_index, connected_node_id) in connected_node_ids.iter().enumerate() {
            self.execute_area_node(area_index, *connected_node_id);
        }
        rc
    }
fn execute_area_node ( & mut self , area_index : usize , node_id : usize ) -> Option < BehaviorNodeConnector > { let mut connectors : Vec < BehaviorNodeConnector > = vec ! [ ] ; let mut connected_node_ids : Vec < usize > = vec ! [ ] ; let mut rc : Option < BehaviorNodeConnector > = None ; // Call the node and get the resulting BehaviorNodeConnector if let Some ( region ) = self . regions . get_mut ( & self . curr_region_id ) { if let Some ( node ) = region . behaviors [ area_index ] . data . nodes . get_mut ( & node_id ) { if let Some ( node_call ) = self . nodes . get_mut ( & node . behavior_type ) { let connector = node_call ( region . behaviors [ area_index ] . data . id , ( area_index , node_id ) , self , BehaviorType :: Regions ) ; rc = Some ( connector ) ; connectors . push ( connector ) ; } else { connectors . push ( BehaviorNodeConnector :: Bottom ) ; } } } // Search the connections to check if we can find an ongoing node connection for connector in connectors { if let Some ( region ) = self . regions . get_mut ( & self . curr_region_id ) { for c in & region . behaviors [ area_index ] . data . connections { if c . 0 == node_id && c . 1 == connector { connected_node_ids . push ( c . 2 ) ; self . executed_connections . push ( ( BehaviorType :: Regions , c . 0 , c . 1 ) ) ; } } } } // And if yes execute it for ( _index , connected_node_id ) in connected_node_ids . iter ( ) . enumerate ( ) { self . execute_area_node ( area_index , * connected_node_id ) ; } rc }
Executes the given node and follows the connection chain
Executes the given node and follows the connection chain
&mut self
area_index
usize
node_id
usize
&mut self
area_index
usize
node_id
usize