public ShipDockingStation(IMyShipConnector shipConnector) { if (shipConnector == null) { throw new ArgumentNullException(nameof(shipConnector)); } this.shipConnector = shipConnector; lastShipConnectorStatus = ShipConnectionStatus; }
public void AddMockConnector(MyShipConnectorStatus status) { var mockConnector = new Mock <IMyShipConnector>(); mockConnector .Setup(x => x.Status) .Returns(status); _mockConnectors.Add(mockConnector); _connectors.Add(mockConnector.Object); }
public void Update() { MyShipConnectorStatus ship_connector_status = shipConnector.Status; if (lastShipConnectorStatus != ship_connector_status) { switch (ship_connector_status) { case MyShipConnectorStatus.Unconnected: case MyShipConnectorStatus.Connectable: if (lastShipConnectorStatus == MyShipConnectorStatus.Connected) { if (registeredShipIGC == null) { OnForeignGridDisconnected?.Invoke(lastConnectedEntityID); } else if (lastConnectedEntityID == registeredShipIGC.ShipID) { OnRegisteredShipDisconnected?.Invoke(registeredShipIGC); } else { OnForeignGridDisconnected?.Invoke(lastConnectedEntityID); } } break; case MyShipConnectorStatus.Connected: lastConnectedEntityID = shipConnector.OtherConnector.CubeGrid.EntityId; if (registeredShipIGC == null) { shipConnector.Disconnect(); OnForeignGridConnected?.Invoke(lastConnectedEntityID); } else if (shipConnector.OtherConnector.CubeGrid.EntityId == registeredShipIGC.ShipID) { OnRegisteredShipConnected?.Invoke(registeredShipIGC); } else { shipConnector.Disconnect(); OnForeignGridConnected?.Invoke(lastConnectedEntityID); } break; } lastShipConnectorStatus = ship_connector_status; } }