internal void CreateTransition(TransitionOutPoint from, EditorStateNode to) { var trans = new EditorTransition(from, to, this); Transitions.Add(trans); changed = true; }
public TransitionOutPoint(EditorStateNode node, NodeLayout layout, TransitionRequest requestType, float buttonSize = 5f) { this.layout = layout; this.Node = node ?? throw new ArgumentNullException(nameof(node)); Transition = null; Type = requestType; this.buttonSize = buttonSize; var info = Type.GetInfo(); toolTip = info != null ? info.DisplayName : Type.GetType().Name; }
public bool SetNodeSelected(EditorStateNode node) { if (transitionCreationHelper.IsMakingTransition) { transitionCreationHelper.OnNodeClicked(node); return(false); } else { SelectedNode = node; } return(true); }
public EditorTransition(Transition t, MovementStateMachineEditor editor) { this.editor = editor; this.Transition = t; fromID = t.StateBelongingToID; toID = t.NextStateID; fromNodeOutPoint = editor.GetStateByID(fromID).GetTransitionOutPoint(t.Type); fromNodeOutPoint.Transition = this; toNode = editor.GetStateByID(toID); causeFoldOut = false; }
public EditorTransition(TransitionOutPoint fromNodeOutPoint, EditorStateNode toNode, MovementStateMachineEditor editor) { this.editor = editor ?? throw new ArgumentNullException(nameof(editor)); this.fromNodeOutPoint = fromNodeOutPoint ?? throw new ArgumentNullException(nameof(fromNodeOutPoint)); this.toNode = toNode ?? throw new ArgumentNullException(nameof(toNode)); fromID = fromNodeOutPoint.Node.ID; toID = toNode.ID; Transition = new Transition(fromNodeOutPoint.Type, toID, fromNodeOutPoint.Node.State); fromNodeOutPoint.Node.State.AddTransition(Transition); fromNodeOutPoint.Transition = this; causeFoldOut = false; }
private void CreateEditorNode(MovementState state, Vector2 pos) { EditorStateNode newNode = new EditorStateNode(this, state, pos, style); nodes.Add(newNode); newNode.OnRightClick -= OnNodeRightClicked; newNode.OnRightClick += OnNodeRightClicked; newNode.OnDestroyed -= RemoveNode; newNode.OnDestroyed += RemoveNode; newNode.SelectNode(); }
private void OnNodeRightClicked(EditorStateNode obj) { GenericMenu nodeMenu = new GenericMenu(); if (obj.IsInitialState) { nodeMenu.AddItem(new GUIContent("Unmakr As Initial"), false, () => obj.SetInitialState(false)); } else { nodeMenu.AddItem(new GUIContent("Mark As Initial"), false, () => { obj.SetInitialState(true); InformOfIntialMark(obj.State); }); } nodeMenu.AddItem(new GUIContent("Destroy"), false, () => obj.Destroy()); nodeMenu.ShowAsContext(); }
internal void RemoveTransitionsForNodeOfType(EditorStateNode editorStateNode, Type[] types) { TransitionRequest[] requestTypes = new TransitionRequest[types.Length]; for (int i = 0; i < types.Length; i++) { requestTypes[i] = TransitionRequest.Factory.BuildRequest(types[i]); } for (int i = Transitions.Count - 1; i >= 0; i--) { var tran = transitions[i].Transition; if (tran.StateBelongingToID == editorStateNode.ID) { //this transition belongs to this node //check if we have a type in our list same as this transition if (requestTypes.Any(t => t.IsSameRequest(tran.Type))) { transitions.RemoveAt(i); } } } }
void OnNodeSelected(EditorStateNode node) { CurrentObjectDisplayed = node; }
public void Reset() { from = null; to = null; }
public void OnNodeClicked(EditorStateNode n) { to = n; TryFinishTransition(); }
public void RemoveNode(EditorStateNode n, MovementState state) { entityInfoEditor.RemoveState(state); nodes.Remove(n); }
public NodeLayout(EditorStateNode node) { this.node = node ?? throw new ArgumentNullException(nameof(node)); outPoints = new List <TransitionOutPoint>(); UpdateLayout(); }
public static void DrawTransitionLine(Vector2 from, Vector2 to, float arrowSize, Color col, EditorStateNode toNode = null) { Vector2 toPoint = to; Bounds b; if (toNode != null) { b = new Bounds(toNode.Rect.center, toNode.Rect.size); } else { b = new Bounds(to, Vector2.one * 5); } Ray r = new Ray(b.center, -(from - toPoint).normalized); float dist; b.IntersectRay(r, out dist); toPoint = r.origin + r.direction * dist; Vector2 lineVec = (from - toPoint); Vector2 arrowDir = lineVec.normalized; var dirP1 = Rotate(arrowDir, 45f); var dirp2 = Rotate(arrowDir, -45f); var p1 = toPoint + dirP1 * arrowSize; var p2 = toPoint + dirp2 * arrowSize; Color c = Handles.color; Handles.color = col; Handles.DrawPolyLine(from, toPoint, p1, p2, toPoint); Handles.color = c; }