Exemplo n.º 1
0
        /// <summary>Triggers a transition to a new state via a specified link.</summary>
        /// <param name="node">The state node to transition to.</param>
        /// <param name="link">The link which triggered this new state.</param>
        public void Transition(StateMachineNode node, StateMachineLink link)
        {
            var e = new TransitionEventArgs(this.currentNode, node, link);

            nodeTime         = 0f;
            this.currentNode = node;
            OnTransition?.Invoke(this, e);
        }
Exemplo n.º 2
0
        /// <summary>Link two states together with a simple test function.</summary>
        /// <param name="a">The state to transition from.</param>
        /// <param name="b">The linked state to transition to.</param>
        /// <param name="test"></param>
        public void LinkNodes(StateMachineNode a, StateMachineNode b, StateMachineLink.TestDelegate test)
        {
            if (a == b)
            {
                throw new NotSupportedException("Cannot link a node to itself.");
            }
            if (!Nodes.Contains(a) || !Nodes.Contains(b))
            {
                throw new NotSupportedException("Cannot link nodes that are not contained within the state machine.");
            }
            var link = new StateMachineLink(b, test);

            a.Links.Add((b, link));
        }
Exemplo n.º 3
0
 public TransitionEventArgs(StateMachineNode from, StateMachineNode to, StateMachineLink link) : base()
 {
     this.from = from;
     this.to   = to;
     this.link = link;
 }
Exemplo n.º 4
0
 /// <summary>Add a link to a state.</summary>
 /// <param name="a">The state to transition from.</param>
 /// <param name="link">The link defining the transition.</param>
 public void LinkNodes(StateMachineNode a, StateMachineLink link)
 {
     LinkNodes(a, link.Target, link);
 }