public void haltDocking(string reason = "unknown", bool sendSignal = true) { if (Communication.currentNode.playerCommand == "recall") { Display.printDebug("Cannot halt docking, drones are recalled."); return; } Display.printDebug("[INFO] Halting docking, reason: " + reason); this.dockingInProgress = false; this.hasDockingPermission = false; this.enableLock = false; this.dockingStart = 0; this.connectionStart = 0; this.dockingStep = 2; if (this.myConnector != null) { if (this.myConnector.block != null && this.myConnector.block.Status == MyShipConnectorStatus.Connected) { this.myConnector.block.Disconnect(); } if (this.myConnector.connectorId != null) { AnchoredConnector.setConnectorState(this.myConnector.connectorId, false); if (this.myConnector.piston != null) { this.myConnector.piston.setPistonState(false); } } } if (this.dockingWithDrone != 0 && sendSignal) { // Send halt dock signal. this.navHandle.commHandle.sendStopDocking(reason, this.dockingWithDrone); this.dockingWithDrone = 0; } if (Communication.masterDrone != null && Communication.masterDrone.masterConnectorId != 0) { Communication.masterDrone.masterConnectorId = 0; } if (Communication.currentNode.navHandle.activeDockingProcedure != null) { Communication.currentNode.navHandle.activeDockingProcedure = null; } // Remove from active procedure list for (int i = 0; i < Docking.activeDockingProcedures.Count; i++) { if (Docking.activeDockingProcedures[i] == this) { Docking.activeDockingProcedures.RemoveAt(i); } } }
public void handleIdleConnectors() { for (int i = 0; i < AnchoredConnector.anchoredConnectors.Count; i++) { if (AnchoredConnector.anchoredConnectors[i].inUse == false) { AnchoredConnector.setConnectorState(AnchoredConnector.anchoredConnectors[i].connectorId, false); if (AnchoredConnector.anchoredConnectors[i].piston != null) { AnchoredConnector.anchoredConnectors[i].piston.setPistonState(false); } } } }
public void handleFinalStep(DockingProcedure procedure) { Communication.currentNode.status = "docking-step-final"; this.navHandle.setAutopilotStatus(false); if (procedure.connectionStart > 0) { this.handleDockedStep(procedure); } else { AnchoredConnector connector = procedure.myConnector; if (connector != null) { if (connector.block.Status != MyShipConnectorStatus.Connected) { if (connector.block.Status == MyShipConnectorStatus.Connectable) { this.navHandle.gyroHandle.disableOverride(); connector.block.Connect(); this.navHandle.thrusterStatus(false); } else { Vector3D targetPos = this.getDockingPosition(1, procedure); double distance = this.getDistanceFrom(this.navHandle.getShipPosition(), targetPos); if (distance > 3) { this.navHandle.setAutopilotStatus(true); this.navHandle.move(targetPos, "docking-realign"); this.navHandle.setCollisionStatus(false); } else { this.navHandle.setAutopilotStatus(false); AnchoredConnector.setConnectorState(connector.connectorId, true); this.navHandle.commHandle.sendDockingLockRequest(1); this.navHandle.gyroHandle.rotateShip(2); // Rotate near connector. } } } else { this.navHandle.thrusterStatus(false); procedure.connectionStart = Communication.getTimestamp(); Communication.currentNode.status = "docking-step-connected"; } } else { Display.printDebug("No connectors found, total connectors: " + AnchoredConnector.anchoredConnectors.Count); Communication.currentNode.status = "error-connector-not-found"; } } }
public void initDocking() { this.dockingInProgress = true; this.enableLock = true; this.hasDockingPermission = false; this.dockingStep = 2; this.queuePos = 0; this.procedureId = Core.generateRandomId(); this.connectionStart = 0; this.dockingStart = Communication.getTimestamp(); if (this.myConnector == null) { this.myConnector = AnchoredConnector.getAvailableConnector(); } if (this.myConnector != null) { AnchoredConnector.setConnectorState(this.myConnector.connectorId, true); } else { Display.printDebug("[ERROR] No available connector found for docking."); } }
public void handleDockLockRequest(string data) { if (Communication.currentNode.type != "mothership") { return; // Motherships handle docking requests } string[] dataSplitted = data.Split('_'); if (dataSplitted.Count() == 3) { int id = int.Parse(dataSplitted[0]); if (Communication.currentNode.id != id) { return; // If not my id } int status = int.Parse(dataSplitted[1]); int slaveId = int.Parse(dataSplitted[2]); DockingProcedure procedure = Docking.getDroneDockingProcedure(slaveId); if (procedure != null) { if (procedure.myConnector != null) { if (procedure.myConnector.piston != null) { Display.printDebug("[INFO] Changing piston state to " + (bool)(status == 1) + ", ConnectorID: " + procedure.myConnector.connectorId + "."); procedure.myConnector.piston.setPistonState((bool)(status == 1)); } Display.printDebug("[INFO] Changing connector state to " + (bool)(status == 1) + ", ConnectorID: " + procedure.myConnector.connectorId + "."); AnchoredConnector.setConnectorState(procedure.myConnector.connectorId, (bool)(status == 1)); } } else { Display.printDebug("[WARN] Docking procedure not found."); } } }