public Edge FindClosestEdge() { Edge result = null; float num = float.PositiveInfinity; Vector3 vector = Event.current.mousePosition; foreach (Edge current in this.host.graph.edges) { Vector3[] edgePoints = EdgeGUI.GetEdgePoints(current); float num2; if (edgePoints[0] == edgePoints[1]) { num2 = Vector3.Distance(EdgeGUI.edgeToSelfOffsetVector + edgePoints[0], vector); } else { num2 = HandleUtility.DistancePointLine(vector, edgePoints[0], edgePoints[1]); } if (num2 < num && num2 < 10f) { num = num2; result = current; } } return(result); }
private static Vector3 GetEdgeEndPosition(Edge edge) { if (!EdgeGUI.IsEdgeBeingDragged(edge)) { return(EdgeGUI.GetNodeCenterFromSlot(edge.toSlot)); } if (EdgeGUI.s_TargetDraggingSlot != null) { return(EdgeGUI.GetNodeCenterFromSlot(EdgeGUI.s_TargetDraggingSlot)); } return(Event.current.mousePosition); }
private static void DrawArrows(Color color, Vector3 cross, Vector3[] edgePoints, EdgeInfo info, bool isSelf) { Vector3 a = edgePoints[1] - edgePoints[0]; Vector3 normalized = a.normalized; Vector3 a2 = a * 0.5f + edgePoints[0]; a2 -= cross * 0.5f; int num = 1; if (info != null && info.hasMultipleTransitions) { num = 3; } for (int i = 0; i < num; i++) { Color color2 = color; if (info != null) { if (info.debugState == EdgeDebugState.MuteAll) { color2 = Color.red; } else if (info.debugState == EdgeDebugState.SoloAll) { color2 = Color.green; } else if (i == 0) { if (info.debugState == EdgeDebugState.MuteSome || info.debugState == EdgeDebugState.MuteAndSolo) { color2 = Color.red; } if (info.debugState == EdgeDebugState.SoloSome) { color2 = Color.green; } } else if (i == 2 && info.debugState == EdgeDebugState.MuteAndSolo) { color2 = Color.green; } if (i == 1 && info.edgeType == EdgeType.MixedTransition) { color2 = EdgeGUI.selectorTransitionColor; } } Vector3 center = a2 + (float)((num != 1) ? (i - 1) : i) * 13f * ((!isSelf) ? normalized : cross); EdgeGUI.DrawArrow(color2, cross, normalized, center); } }
private static Vector3[] GetEdgePoints(Edge edge, out Vector3 cross) { Vector3[] array = new Vector3[] { EdgeGUI.GetEdgeStartPosition(edge), EdgeGUI.GetEdgeEndPosition(edge) }; cross = Vector3.Cross((array[0] - array[1]).normalized, Vector3.forward); array[0] += cross * 5f; if (!EdgeGUI.IsEdgeBeingDragged(edge)) { array[1] += cross * 5f; } return(array); }
private void DrawEdge(Edge edge, Texture2D tex, Color color, EdgeInfo info) { Vector3 cross; Vector3[] edgePoints = EdgeGUI.GetEdgePoints(edge, out cross); Handles.color = color; if (edgePoints[0] == edgePoints[1]) { EdgeGUI.DrawArrows(color, -Vector3.right, new Vector3[] { edgePoints[0] + new Vector3(0f, 31f, 0f), edgePoints[0] + new Vector3(0f, 30f, 0f) }, info, true); } else { Handles.DrawAAPolyLine(tex, 5f, new Vector3[] { edgePoints[0], edgePoints[1] }); EdgeGUI.DrawArrows(color, cross, edgePoints, info, false); if (info != null) { bool flag = this.smHost.liveLinkInfo.srcNode == edge.fromSlot.node; bool flag2 = this.smHost.liveLinkInfo.dstNode == edge.toSlot.node; if ((flag && flag2) || (flag2 && this.smHost.liveLinkInfo.transitionInfo.entry && edge.fromSlot.node is EntryNode) || (flag && this.smHost.liveLinkInfo.transitionInfo.exit && edge.toSlot.node is ExitNode) || (flag2 && this.smHost.liveLinkInfo.transitionInfo.anyState && edge.fromSlot.node is AnyStateNode)) { float num = this.smHost.liveLinkInfo.transitionInfo.normalizedTime; if (this.smHost.liveLinkInfo.currentStateMachine != this.smHost.liveLinkInfo.nextStateMachine) { num = num % 0.5f / 0.5f; } Handles.color = EdgeGUI.selectedEdgeColor; Handles.DrawAAPolyLine(10f, new Vector3[] { edgePoints[0], edgePoints[1] * num + edgePoints[0] * (1f - num) }); } } } }
private static Vector3 GetEdgeStartPosition(Edge edge) { return(EdgeGUI.GetNodeCenterFromSlot(edge.fromSlot)); }
private static Vector3[] GetEdgePoints(Edge edge) { Vector3 vector; return(EdgeGUI.GetEdgePoints(edge, out vector)); }