// recalculates the clusters for each input and output in the cluster, based on all the connections in the cluster public static void RecalculateCluster(WireCluster cluster) { if (cluster == null) { return; } RecalculateClustersFromInputs(cluster.GetConnectedInputs()); Object.Destroy(cluster.gameObject); }
// merge two clusters public static void JoinClusters(WireCluster cluster1, WireCluster cluster2) { // stick inputs & outputs of cluster2 into cluster1 foreach (CircuitInput ConnectedInput in cluster2.GetConnectedInputs()) { cluster1.ConnectInput(ConnectedInput); } foreach (CircuitOutput ConnectedOutput in cluster2.GetConnectedOutputs()) { cluster1.ConnectOutput(ConnectedOutput); } Object.Destroy(cluster2.gameObject); }
// todo: rethink this... public static Transform ProperClusterParent(WireCluster cluster) { int ShallowestDepthInHeirarchy = 1000000000; Transform ProperParent = cluster.transform; foreach (CircuitInput input in cluster.GetConnectedInputs()) { int ThisDepthInHeirarchy = DepthInHeirarchy(input.transform); if (ShallowestDepthInHeirarchy > ThisDepthInHeirarchy) { ProperParent = input.transform.parent; ShallowestDepthInHeirarchy = ThisDepthInHeirarchy; } } return(ProperParent); }