RexState

RexState is the base class extended by MovingState, JumpState, DashState, and more.

Public Methods

public void ForceBegin()

Forces the RexState to begin, whether or not CanInitiate() returns True.

public void Begin(bool canInterruptSelf = false)

Begins the State, but only if CanInitiate() returns True; canInterruptSelf governs whether this state can Begin() again even while it’s already the currentState.

public void End()

Ends the current state and its movements.

public virtual void UpdateMovement()

Overidden by each state; called automatically every FixedUpdate by RexController. Handles the movement associated with the state.

public bool IsTurnAnimationOverriding()

Checks to see if a Turn animation is playing, and if that should override this state’s animation.

public virtual bool CanInitiate()

Can be overidden by each state to determine what circumstances the state can be initiated from.

public bool IsFrozen()

Returns True if the game is paused or contact delay is happening; used primarily to see if we should accept inputs.

public virtual void OnNewStateAdded(RexState _state)

Called by RexController any time a new RexState component is added to the GameObject this RexState is on. Primarily used to give this RexState a reference to the new RexState if it needs it.

public virtual void OnBegin()

Called automatically when Begin() is successfully called. This can be overidden for each individual movement.

public void PlayAnimation()

This will play the primary animation slotted into this RexState in the Inspector. Called automatically by RexController when the RexState is initiated.

public virtual void OnEnded()

This is called when the state ends; note that states can continue updating even if another state takes priority, so OnEnded won’t necessarily be called just because the state changes.

public virtual void OnStateChanged()

This is called when the attached RexController’s currentState changes, whether or not the previous state has ended.

public virtual void OnAttackComplete()

This is called by RexController when the actor completes an Attack. This can be overridden by each RexState to have unique effects, but it’s most commonly used to play the appropriate animation if there are multiple animations for this RexState.

public virtual void PlayAnimationForSubstate()

Can be overridden by each RexState. Plays the AnimationClip associated with the substate the state is currently in; i.e. if the actor is crouching, this can differentiate between playing the default crouching animation or the crouch-moving animation.

Public Members

public string id

The unique id of a state; should be set in Awake, and should be unique for each state.

public bool hasEnded

Whether or not the state has ended its current movements.

public bool isEnabled

If False, this state will not be updated.

public AnimationClip animation

The AnimationClip that plays when this state is entered.

public AudioClip audioClip

The AudioClip that plays when this state is entered.

public bool willPlayAnimationOnBegin

If False, you must manually play the animation for this state, rather than it auto-starting when the state begins.

public bool isKnockbackEnabled

If knockback can affect the RexController from this state.

public bool willAllowDirectionChange

If changing directions is allowed in this state.

public bool isConcurrent

If True, this state will be updated in the background even if it isn’t the currentState of the RexController; if False, it will not be updated unless it IS currentState of the RexController.

public RexController controller

A reference to the RexController that handles and updates this state.