protected void Connection(Event e) { if (!(e.type == EventType.MouseDown && e.button == 0)) { return; } if (!IsConnecting()) { foreach (var node in nodes) { if (!node.Window.Contains(mousePos)) { continue; } var kvp = node.GetNodeOption(mousePos); if (kvp.Value != null) { CreateActiveConnection(node, kvp); } else { Rect endRect = node.endRect; endRect.y += node.Window.y; endRect.x += node.Window.x; if (endRect.Contains(mousePos)) { CreateActiveConnection(node); } } return; } } else { foreach (var node in nodes) { if (!node.Window.Contains(mousePos)) { continue; } if (activeConnection.Key.entity.id == node.entity.id) { if (node.AbsoluteEndRect.Contains(mousePos)) { ExtendDialogue(node); BreakConnection(); return; } else { return; } } if (activeConnection.Value == null) { CurrentTree.RelateDialogue(activeConnection.Key.entity.id, node.entity.id); } else { CurrentTree.RelateOption(activeConnection.Value.id, node.entity.id); } BreakConnection(); return; } // create dialogue CreateDialogue(activeConnection); BreakConnection(); } }