public GameObject GetIntegratedCircuitObj(IntegratedCircuit circuit) { GameObject obj = GetIntegratedCircuitObj(circuit.ModelName); circuit.AssignObjRef(obj); obj.name = circuit.SetBreadBoard(breadBoard).ToString(); Text text = obj.GetComponentInChildren <Text>(); if (text != null && circuit.OverwriteObjText) { text.text = circuit.GetType().Name.Split('_')[0]; } return(obj); }
public GameObject PlaceIntegratedCircuit(IntegratedCircuit ic, string nodeIdA, int indexA, string nodeIdB, int indexB, bool skipUpdate) { // Debug.Log("Placing: " + IcName); GameObject obj = Instantiate(GetIntegratedCircuitObj(ic), new Vector3(0, 0, 0), Quaternion.identity) as GameObject; obj.transform.parent = parent; ic.AssignObjRef(obj); obj.name = ic.SetBreadBoard(breadBoard).ToString(); bool rotated = Helper.CircuitHelper.IsNodeRotated(nodeIdA); switch (ic.IcType) { case ICType.solo: breadBoard.SetNodeConnection(false, nodeIdA, indexA, 0, ic.GetId().ToString()); ic.SetPinIndex(0, indexA); ic.SetPinNode(0, nodeIdA); break; case ICType.dual: breadBoard.SetNodeConnection(false, nodeIdA, indexA, 0, ic.GetId().ToString()); ic.SetPinIndex(0, indexA); ic.SetPinNode(0, nodeIdA); breadBoard.SetNodeConnection(false, nodeIdB, indexB, 1, ic.GetId().ToString()); ic.SetPinIndex(1, indexB); ic.SetPinNode(1, nodeIdB); break; case ICType.wire: ic.SetPinNode(0, nodeIdA); ic.SetPinIndex(0, indexA); ic.SetPinNode(1, nodeIdB); ic.SetPinIndex(1, indexB); break; case ICType.ic6: case ICType.ic4: string[] id = nodeIdA.Split('x'); int a = int.Parse(id[0]); int b = int.Parse(id[1]); int c = int.Parse(id[2]); int d = int.Parse(id[3]); for (int i = 0; i < 2; i++) { for (int j = 0; j < ic.Pins / 2; j++) { string nodeId; if (rotated) { nodeId = $"{a + i}x{b + (i * 7)}x{c}x{d + j}x{id[4]}"; } else { nodeId = $"{a + i}x{b}x{c + (i * 7)}x{d + j}x{id[4]}"; } int index = i == 0 ? 4 : 0; if (ic.IcType == ICType.ic6) { index = i == 0 ? indexA : indexA - 1; } int pinIndex = i == 0 ? j : (ic.Pins - 1) - j; if (ic.WriteToNodes) { breadBoard.SetNodeConnection(false, nodeId, index, pinIndex, ic.GetId().ToString()); } ic.SetPinIndex(pinIndex, index); ic.SetPinNode(pinIndex, nodeId); } } break; default: return(null); } breadBoard.components.Add(ic.GetId(), ic); if (!skipUpdate) { ic.Update(); } return(obj); }