protected void SetState(FSMState newState) { if (currentStatus == FSMStatus.NONE) { InitEvent.Invoke(this); } if (currentStatus != FSMStatus.DOING_END && statesByHash[currentstateHash] != null) { currentStatus = FSMStatus.DOING_END; FSMState c = statesByHash[currentstateHash]; currentstateHash = -1; currentStateName = null; StateEnd(c); } if (currentStatus != FSMStatus.DOING_START) { currentStatus = FSMStatus.DOING_START; currentstateHash = statesByName[newState.stateName].hash; currentStateName = newState.stateName; currentStateInitRealtime = Time.realtimeSinceStartup; currentStateInitTime = Time.time; StateStart(newState); currentStatus = FSMStatus.DOING_UPDATE; } }
public void IgnoreAndChangeState(string stateName) { FSMState n = GetState(stateName); currentStatus = FSMStatus.DOING_START; currentstateHash = n.hash; currentStateName = n.stateName; currentStateInitRealtime = Time.realtimeSinceStartup; currentStateInitTime = Time.time; StateStart(n); currentStatus = FSMStatus.DOING_UPDATE; }