Пример #1
0
 // destroys an input-output connection
 public static void DestroyIOConnection(InputOutputConnection connection)
 {
     connection.Input.IOConnections.Remove(connection);
     connection.Output.RemoveIOConnection(connection);
     RecalculateCluster(connection.Input.Cluster); // remove the output from the cluster, and destroy the cluster in a lot of cases - whatever, who cares, some other shitty function will deal with it
     Object.Destroy(connection.gameObject);        // destroy the physical connection
 }
Пример #2
0
    // determines which type of connection a wire is and passes it off to the appropriate destroyer
    public static void DestroyWire(GameObject wire)
    {
        InputInputConnection IIConnection = wire.GetComponent <InputInputConnection>();

        if (IIConnection != null)
        {
            DestroyIIConnection(IIConnection);
            return; // just for that teeny tiny completely insignificant amount of extra performance, stop the function here if it's an IIConnection
        }

        InputOutputConnection IOConnection = wire.GetComponent <InputOutputConnection>();

        if (IOConnection != null)
        {
            DestroyIOConnection(IOConnection);
        }
    }
    // joins an output with an input by sticking the output in the cluster of the input
    public static void LinkInputOutput(InputOutputConnection connection)
    {
        CircuitInput  input  = connection.Input;
        CircuitOutput output = connection.Output;

        if (input == null || output == null)
        {
            Debug.LogError("this wire didn't have its input/output set!"); return;
        }

        if (input.Cluster != null)
        {
            input.Cluster.ConnectOutput(output);
        }

        else
        {
            WireCluster NewCluster = Object.Instantiate(Prefabs.Cluster).GetComponent <WireCluster>();
            NewCluster.ConnectInput(input);
            NewCluster.ConnectOutput(output);
            NewCluster.transform.parent = ProperClusterParent(NewCluster); // this is also done the next frame when the cluster recalculates its mesh. The reason it is being done here is because when a board is cloned, it gets new clusters, and those need to be children of the board during the same frame they start existing so that autocombineonstable can be set to false for them by StuffPlacer.NewThingBeingPlaced. My hope is that it doesn't affect performance, but I'm pretty nervous about it...
        }
    }
Пример #4
0
 public void RemoveIOConnection(InputOutputConnection connection)
 {
     IOConnections.Remove(connection);
     QueueMeshRecalculation();
 }
Пример #5
0
    }                                                                               // we do not want to allow other classes to directly modify IOConnections, but in some cases they must access it

    public void AddIOConnection(InputOutputConnection connection)
    {
        IOConnections.Add(connection);
        QueueMeshRecalculation();
    }