コード例 #1
0
    public void sendConnectorData(int slaveId)
    {
        Display.printDebug("Sending connector info.");
        DockingProcedure procedure = Docking.getDroneDockingProcedure(slaveId);

        if (procedure != null)
        {
            AnchoredConnector connector = procedure.myConnector;
            if (connector != null && connector.isAnchored)
            {
                procedure.lastConnectorPing = Communication.getTimestamp();
                Vector3D pos;
                this.dataStructure.newPackage();
                this.dataStructure.addRawData("drone-connector-data");
                this.dataStructure.addData("id", Communication.currentNode.id.ToString());
                this.dataStructure.addData("slaveId", slaveId.ToString());
                this.dataStructure.addData("masterConnectorId", connector.connectorId.ToString());
                pos = connector.anchorTop.block.GetPosition();
                this.dataStructure.addData("connectorAnchorTopX", pos.X.ToString());
                this.dataStructure.addData("connectorAnchorTopY", pos.Y.ToString());
                this.dataStructure.addData("connectorAnchorTopZ", pos.Z.ToString());
                pos = connector.anchorBottom.block.GetPosition();
                this.dataStructure.addData("connectorAnchorBottomX", pos.X.ToString());
                this.dataStructure.addData("connectorAnchorBottomY", pos.Y.ToString());
                this.dataStructure.addData("connectorAnchorBottomZ", pos.Z.ToString());
                this.broadcastMessage(this.dataStructure.generateOutput());
                procedure.approveDocking();
            }
            else
            {
                Display.printDebug("[Error] No working connectors found. (Connectors: " + AnchoredConnector.anchoredConnectors.Count + ")");
            }
        }
        else
        {
            Display.printDebug("[Error] No docking procedure found.");
        }
    }
コード例 #2
0
 public void handleDockingAccepted(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 masterId  = int.Parse(dataSplitted[1]);
         int nodeIndex = this.getNodeIndexById(masterId);
         if (nodeIndex == -1)
         {
             Communication.connectedNodes.Add(masterId);
             Drone node = new Drone(masterId);
             node.initNavigation(this.myGrid);
             Communication.connectedNodesData.Add(node);
             nodeIndex = this.getNodeIndexById(masterId);
         }
         if (Docking.dockingWithDrone(masterId))
         {
             DockingProcedure procedure = Docking.getDroneDockingProcedure(masterId);
             procedure.haltDocking("docking-already-in-progress");
         }
         DockingProcedure dock = new DockingProcedure(masterId);
         dock.initDocking();
         dock.approveDocking();
         dock.setNavHandle(Communication.currentNode.navHandle);
         Docking.activeDockingProcedures.Add(dock);
         Communication.currentNode.navHandle.activeDockingProcedure = dock;
     }
 }