protected bool Equals(StateTransition other) { return currentState == other.currentState && command == other.command && below.Equals(other.below) && above.Equals(other.above) && front.Equals(other.front) && behind.Equals(other.behind); }
public RunnerState Transition(InputState action, bool touching, Vector3 currentVelocity) { touchingPlatform = touching; velocity = currentVelocity; if (_transitionCache != null) { var state = new StateTransition { currentState = currentState, command = action, below = touching, above = false, behind = false, front = false, }; ToState transition; var foundTransition = _transitionCache.TryGetValue(state, out transition); var allowedTransition = foundTransition && (currentVelocity.x > transition.minSpeedX) && (transition.maxSpeedX > currentVelocity.x); if (allowedTransition) { Debug.Log("Transitioning from " + currentState + " to " + transition.nextState); currentState = transition.nextState; } else { if (!foundTransition) Debug.Log("No transition found for - CurrentState: " + currentState + ", Action: " + action + ", Touching: " + touching); } } else { Debug.LogError("Runner State is not initialized!"); } StateProcessQueue.Enqueue(currentState); return currentState; }