public virtual void OnFixedUpdate() { if (GlobalStateData != null) { GlobalStateData.OnFixedUpdate(); } if (CurStateData != null) { CurStateData.OnFixedUpdate(); } }
public State(GlobalStateData.FSMStateID stateid, List<FSMAction> actions, List<FSMReason> reasons) { this.stateID = stateid; this.actions = actions; this.reasons = reasons; foreach (var reason in reasons) { AddTransition(reason.Transition, reason.GoToState); } }
public State(GlobalStateData.FSMStateID stateid, FSMAction action, List<FSMReason> reasons) { var actionList = new List<FSMAction>(); actionList.Add(action); this.stateID = stateid; this.actions = actionList; this.reasons = reasons; foreach (var reason in reasons) { AddTransition(reason.Transition, reason.GoToState); } }
/// <summary> /// Deletes a transition, stateID pair from the transition map. /// </summary> public void DeleteTransition(GlobalStateData.FSMTransistion transition) { // Ensures valid transition. if (transition == GlobalStateData.FSMTransistion.None) { Debug.LogError(SCRIPT_NAME + ": None transition is not allowed"); return; } // Ensure map contains transition before attempting delete. if (map.ContainsKey(transition)) { map.Remove(transition); return; } Debug.LogError(SCRIPT_NAME + ": transition passed was not on this State´s List | " + transition); }
/// <summary> /// Adds a transition, stateID pair to the transition map. Every transition called /// in the states Reason method should have a corresponding state id in the map. /// </summary> public void AddTransition(GlobalStateData.FSMTransistion transition, GlobalStateData.FSMStateID id) { // Ensure valid transition. if (transition == GlobalStateData.FSMTransistion.None || id == GlobalStateData.FSMStateID.None) { Debug.LogWarning(SCRIPT_NAME + " : Null transition not allowed"); return; } // Ensure transition not already present in map. if (map.ContainsKey(transition)) { Debug.LogWarning(SCRIPT_NAME + ": transition is already inside the map | " + transition); return; } map.Add(transition, id); }
/// <summary> /// This method returns the state that would be transitioned into based on the FSMTransition. /// </summary> public GlobalStateData.FSMStateID GetOutputState(GlobalStateData.FSMTransistion transition) { // Ensures valid transition. if (transition == GlobalStateData.FSMTransistion.None) { Debug.LogError(SCRIPT_NAME + ": None transition is not allowed"); return GlobalStateData.FSMStateID.None; } // Ensure map contains transition before returning new state. if (map.ContainsKey(transition)) { return map[transition]; } Debug.LogError(SCRIPT_NAME + ": transition passed to the State was not on the list | " + transition); // Transition not in map. return GlobalStateData.FSMStateID.None; }
/// <summary> /// This performs a transistion from one state to another and is invoked in an individual states Reason method. /// </summary> public void SetTransistion(GlobalStateData.FSMTransistion tran) { _statemachine.PerformTransition (tran); }