// Disconnect the still connected device from the removed device. private void OnConnectionRemoved(PoweredUnit removedConnection, IOSocket removedSocket) { switch (removedSocket.GetSocketType()) { case IOSocket.SocketType.Input: if (!this.cableEndA.HasConnection() && this.cableEndB.HasConnection()) { removedConnection.RemoveInput(this.cableEndB.GetConnection()); } else if (!this.cableEndB.HasConnection() && this.cableEndA.HasConnection()) { removedConnection.RemoveInput(this.cableEndA.GetConnection()); } break; case IOSocket.SocketType.Output: if (!this.cableEndA.HasConnection() && this.cableEndB.HasConnection()) { this.cableEndB.GetConnection().RemoveInput(removedConnection); } else if (!this.cableEndB.HasConnection() && this.cableEndA.HasConnection()) { this.cableEndA.GetConnection().RemoveInput(removedConnection); } break; } }
private void OnConnectionMade(PoweredUnit connection, IOSocket connectedSocket) { this.connection = connection; this.connectedSocket = connectedSocket; if (this.connectionMadeCallback != null) { this.connectionMadeCallback.Invoke(); } }
public void SetConnection(PoweredUnit connection, IOSocket connectedSocket) { if (connection != null && connectedSocket != null) { this.OnConnectionMade(connection, connectedSocket); } else { this.OnConnectionRemoved(); } }
private void OnConnectionRemoved() { /* Temp variables are required as the callback will require * the connection to be null and at the same time the original * connection (before removal) must be passed into the callback. */ PoweredUnit tempConnection = this.connection; IOSocket tempSocket = this.connectedSocket; this.connection = null; this.connectedSocket = null; if (tempConnection != null && tempSocket != null) { if (this.connectionRemovedCallback != null) { this.connectionRemovedCallback.Invoke(tempConnection, tempSocket); } } }
public virtual void RemoveOutput(PoweredUnit input) { }
public virtual void AddOutput(PoweredUnit input) { }
public override void RemoveInput(PoweredUnit input) { base.RemoveInput(input); this.inputs.Remove(input); }
public override void AddInput(PoweredUnit input) { base.AddInput(input); this.inputs.Add(input); }