public void handleDockingRequest(string data) { if (Communication.currentNode.type != "mothership") { return; // Motherships handle docking requests } string[] dataSplitted = data.Split('_'); if (dataSplitted.Count() == 2) { int id = int.Parse(dataSplitted[0]); if (Communication.currentNode.id != id) { return; // If not my id } int slaveId = int.Parse(dataSplitted[1]); int nodeIndex = this.getNodeIndexById(slaveId); if (nodeIndex == -1) { Communication.connectedNodes.Add(slaveId); Drone node = new Drone(slaveId); node.initNavigation(this.myGrid); Communication.connectedNodesData.Add(node); nodeIndex = this.getNodeIndexById(slaveId); } AnchoredConnector available = AnchoredConnector.getAvailableAnchoredConnector(); if (available == null) { Display.print("Docking request denied (Connectors full)."); } else { if (Docking.dockingWithDrone(slaveId)) { Display.print("Already accepted, continue on docking."); this.sendDockingAccepted(slaveId); this.sendConnectorData(slaveId); } else { Display.print("Assigning a proper connector."); DockingProcedure dock = new DockingProcedure(slaveId); dock.setNavHandle(Communication.currentNode.navHandle); dock.myConnector = available; dock.initDocking(); Docking.activeDockingProcedures.Add(dock); this.sendDockingAccepted(slaveId); this.sendConnectorData(slaveId); } } } else { Display.print("[ERROR] Docking request invalid. (" + data + ")"); } }