Exemple #1
0
    // Create a connection between two physical connection points.
    public void MakeConnection(ConnectionPoint src, ConnectionPoint dest)
    {
        Debug.Log("Submitting new connection to server: " + src.GetComponentInParent <CircuitDevice>().associatedGuid + ", " + dest.GetComponentInParent <CircuitDevice>().associatedGuid);
        Guid netGuid = circuitSimObject.Connect(src.GetComponentInParent <CircuitDevice>().associatedGuid, src.connectionIndex,
                                                dest.GetComponentInParent <CircuitDevice>().associatedGuid, dest.connectionIndex);

        PopulateWire(netGuid);
    }
Exemple #2
0
    // Returns true if a connection is possible.
    public bool CanMakeConnection(ConnectionPoint src, ConnectionPoint dest)
    {
        if (src == null || dest == null)
        {
            return(false);
        }

        if (src.connectionType == ConnectionPoint.ConnectionType.Input || dest.connectionType == ConnectionPoint.ConnectionType.Output)
        {
            return(false);
        }

        if (src.connectionType == dest.connectionType)
        {
            return(false);
        }

        CircuitDevice dest_cd = dest.GetComponentInParent <CircuitDevice>();

        // If we're trying to connect to a port that already has something connected to it, fail
        if (circuitSimObject.gates[dest_cd.associatedGuid].inputs[dest.connectionIndex] != null)
        {
            return(false);
        }

        return(true);
    }