public SecuenceNode Update(float deltaT) { if (_currentTransition == null) { foreach (var tr in _transitions) { if (tr.IsTriggered()) { _currentTransition = tr; } } } SecuenceNode next = null; if (_currentTransition != null) { //it's in transition if (!_currentTransition.Blend(deltaT)) { //the transition has ended //move to the next state next = _currentTransition.DestNode; _currentTransition = null; } } else { OnBeforeUpdate(deltaT); //its playing the state and there aren't any transitions triggered UpdateAnimations(deltaT, _animations.Count == 1 ? -1 : 1, 1); OnAfterUpdate(deltaT); } return(next); }
public SecuenceNode TransitionTo(SecuenceTransition transition) { _transitions.AddLast(transition); return(this); }
public bool RemoveTransition(SecuenceTransition transition) { return(_transitions.Remove(transition)); }
public void AddTransition(SecuenceTransition transition) { transition.SourceNode = this; _transitions.AddLast(transition); }
public SecuenceStateMachine WithTransition(string sourceNode, string destNode, SecuenceTransition transition) { transition.SourceNode = _nodes[sourceNode]; transition.DestNode = _nodes[destNode]; transition.Name = sourceNode + "->" + destNode; transition.SourceNode.AddTransition(transition); return(this); }