public override void Execute(FSMBehaviour fsm) { NodePort outPort = GetOutputPort("outState"); if (outPort.ConnectionCount > 0) { NodeBase_State next = (NodeBase_State)outPort.Connection.node; next.SetCurrentState(); } }
private NodeBase_State GetNextState() { NodeBase_State result = null; NodePort outStatePort = OutStatePort; if (outStatePort.ConnectionCount == 0) { return(result); } result = (NodeBase_State)outStatePort.Connection.node; return(result); }
public bool SetRootState(NodeBase_State state) { if (state == _rootState) { return(false); } if (state == null) { return(false); } _rootState = state; return(true); }
private void GoToNextState(bool decisionResult) { if (decisionResult == false) { return; } NodeBase_State nextState = GetNextState(); if (nextState == null) { return; } nextState.SetCurrentState(); }
public void ExecuteDecisions(FSMBehaviour fsm) { if (outputPort.ConnectionCount <= 0) { return; } bool result = GetDecisionResult(fsm); //Transition to other state if (result == false && outputPort.ConnectionCount <= 0) { return; } NodeBase_State state = (NodeBase_State)outputPort.Connection.node; state.SetCurrentState(); }
public void InitGraph(FSMBehaviour fsm) { currentState_elapsedTime = 0; if (RootState == null) { XNode.Node node = nodes.FirstOrDefault(r => r is NodeBase_State); if (node != null) { _rootState = (NodeBase_State)node; _currentState = _rootState; } } if (RootState != null) { _currentState = RootState; } }
private void GoToNextState(bool decisionResult) { if (decisionResult) { NodeBase_State nextTrueState = GetNextTrueState(); if (nextTrueState) { nextTrueState.SetCurrentState(); } } else { NodeBase_State nextFalseState = GetNextFalseState(); if (nextFalseState) { nextFalseState.SetCurrentState(); } } }
/// <summary> /// Força o <seealso cref="CurrentState"/> para o estado do parametro. /// </summary> /// <param name="state">Novo estado para <see cref="CurrentState"/></param> /// <returns>Verdadeiro: Se o <seealso cref="CurrentState"/> foi modificado para um estado diferente do anterior</returns> public bool SetCurrentState(NodeBase_State state) { if (state == _currentState) { return(false); } if (state == null) { return(false); } currentState_elapsedTime = 0; _currentState = state; if (OnStateChangedEvent != null) { OnStateChangedEvent.Invoke(); } return(true); }