// Transmit the unit on this node toward the relevant connexion's node bool SendUnit(Connexion relevantConnexion) { // Check if there is a unit to send if (_unitOnNode == null) { // Otherwise, // Return that it couldn't succesfully send the inexisting unit Debug.Log("Error - " + this + " : SendUnit() called with no unit to send."); return(false); } // Check if the unit can start traveling to the relevant node if (!_unitOnNode.IsReadyToExecuteOrder()) { // Otherwise, // Return that it couldn't succesfully send the inexisting unit Debug.Log("Error - " + this + " : SendUnit() called but the unit isnt't ready to travel to it's new destination."); return(false); } // Transmit the unit on this node to the target node system if (!relevantConnexion._connectedNode.RecieveUnit(_unitOnNode)) { // If the target node couldn't recive the unit, // Return that it couldn't succesfully send the unit Debug.Log("Error - " + this + " : SendUnit() called but couldn't successfully transmit the unit to it's destination node."); return(false); } // Make the unit travel to it's relevant node _unitOnNode.RecieveOrder(relevantConnexion._path); // Set the target node on unit _unitOnNode._currentNode = relevantConnexion._connectedNode; // Set the last node on unit _unitOnNode._lastNode = this; // Check if the unit has a child if (_unitOnNode._childCount > 0) { // If it does, spawn it on this node _unitOnNode._childCount--; _unitOnNode = SpawnUnitOnNode(); // Calculate relevant destination _relevantConnexionFound = CalculateRelevantConnexion(ref _relevantConnexion); } else { // Otherwise, remove the stored unit from this node if it was sucessfully sent _unitOnNode = null; // Reset relevant connexion _relevantConnexionFound = false; } // Return that it succesfully send the unit return(true); }