public void BeginClickConnect(NodeGfx node, NodePortGfx port) { if (prevNode == null) { prevPort = port; prevNode = node; } else if (prevPort == port) { prevNode = null; prevPort.ClickConnectDone(); prevPort = null; } else { if (RecipeSet.ConnectAdapters(prevPort.myAdapterGroup, port.myAdapterGroup)) { prevNode = null; prevPort = null; ReDrawAllNodes(); } else { port.ClickConnectDone(); bool isDeletion = false; if (prevPort) { prevPort.ClickConnectDone(); if (prevNode == node) { //If we have selected another port on the same node, delete the port if its not the last port if (port.myConnection != null) { myRecipeSet.RemoveConnection(port.myAdapterGroup, port.myConnection); } isDeletion = true; } } if (!isDeletion) { prevPort = port; prevNode = node; prevPort.BeginClickConnect(); } else { prevPort = null; prevNode = null; ReDrawAllNodes(); } } } }
public override void BeginClickConnect(NodeGfx node, NodePortGfx port) { port.ClickConnectDone(); }
public override void BeginClickConnect(NodeGfx node, NodePortGfx port) { if (prevNode == null) { prevPort = port; prevNode = node; } else if (prevPort == port) { prevNode = null; prevPort.ClickConnectDone(); prevPort = null; } else { bool canConnect = false; switch (port.myType) { case NodePortGfx.PortType.craftInput: if (prevPort.myType == NodePortGfx.PortType.itemOutput) { canConnect = true; } break; case NodePortGfx.PortType.craftOutput: if (prevPort.myType == NodePortGfx.PortType.itemInput) { canConnect = true; } break; case NodePortGfx.PortType.itemInput: if (prevPort.myType == NodePortGfx.PortType.craftOutput) { canConnect = true; } break; case NodePortGfx.PortType.itemOutput: if (prevPort.myType == NodePortGfx.PortType.craftInput) { canConnect = true; } break; } if (canConnect) { CraftingNode craft; ItemNode item; bool isInput; // Figure out what port is which, and whether we are dealing with an input or not if (prevNode is CraftingNodeGfx) { craft = prevNode.myNode as CraftingNode; item = node.myNode as ItemNode; if (prevPort.myType == NodePortGfx.PortType.craftInput) { isInput = true; } else { isInput = false; } } else { craft = node.myNode as CraftingNode; item = prevNode.myNode as ItemNode; if (port.myType == NodePortGfx.PortType.craftInput) { isInput = true; } else { isInput = false; } } bool isPrevConnected = prevPort.myConnection != null; bool isThisConnected = port.myConnection != null; // Actually add the input/ outputs as necessary. ConnectPorts(prevPort, port); if (prevNode is CraftingNodeGfx) { if (!isPrevConnected) { (prevNode as CraftingNodeGfx).AddPort(isInput); } if (!isThisConnected) { (node as ItemNodeGfx).AddPort(isInput); } } else { if (!isThisConnected) { (node as CraftingNodeGfx).AddPort(isInput); } if (!isPrevConnected) { (prevNode as ItemNodeGfx).AddPort(isInput); } } if (isInput) { craft.inputs.Add(new CountedItemNode(item, 1)); item.outputs.Add(craft); } else { craft.outputs.Add(new CountedItemNode(item, 1)); item.inputs.Add(craft); } if (prevNode is CraftingNodeGfx) { (prevNode as CraftingNodeGfx).UpdateVisuals(); } else { (node as CraftingNodeGfx).UpdateVisuals(); } prevNode = null; prevPort = null; } else { port.ClickConnectDone(); bool isDeletion = false; if (prevPort) { prevPort.ClickConnectDone(); if (prevNode = node) { //If we have selected another port on the same node, delete the port if its not the last port if (prevPort.transform.GetSiblingIndex() + 1 < prevPort.transform.parent.childCount) { prevPort.RemoveConnections(); prevPort.DeleteSelf(); isDeletion = true; } } } if (!isDeletion) { prevPort = port; prevNode = node; prevPort.BeginClickConnect(); } else { prevPort = null; prevNode = null; } } } }