bool USFCharacterMovementComponent::DoJump(bool bReplayingMoves)
{
	GravityScale = 5;
	
	if (CharacterOwner && CharacterOwner->CanJump())
	{
		// Don't jump if we can't move up/down.
		if (!bConstrainToPlane || FMath::Abs(PlaneConstraintNormal.Z) != 1.f)
		{
			Velocity.Z = JumpZVelocity;
			
			auto owner = Cast<ASUPERFASTCharacter>(CharacterOwner);
			if (owner && IsFalling())
			{
				owner->mayDoubleJump = false;

				if (owner->wallSlideBit == 1)
				{
					Velocity.X = JumpZVelocity * -0.7;
				}
				else if (owner->wallSlideBit == 2)
				{
					Velocity.X = JumpZVelocity * 0.7;
				}
				owner->wallSlideBit = 0;
			}

			SetMovementMode(MOVE_Falling);

			return true;
		}
	}

	return false;
}
void URealmCharacterMovementComponent::ClearMovementIgnorance()
{
	//clear any timers that have been set for clearing this (i.e. if someone gets rid of a stun before its duration is up)
	GetCharacterOwner()->GetWorldTimerManager().ClearTimer(ignoreMovementTimer);

	SetMovementMode(MOVE_Walking);
}
void URealmCharacterMovementComponent::IgnoreMovement()
{
	//end any dashes this character may be performing
	EndDash();

	StopMovementImmediately();
	SetMovementMode(MOVE_None);
}
bool URealmCharacterMovementComponent::HandlePendingLaunch()
{
	if (!PendingLaunchVelocity.IsZero() && HasValidData())
	{
		Velocity = PendingLaunchVelocity;
		PendingLaunchVelocity = FVector::ZeroVector;
		if (bCharacterWantsDash)
		{
			StopMovementImmediately();
			SetMovementMode(MOVE_Flying);
			bCharacterWantsDash = false;
			bCharacterDashing = true;
		}
		else
			SetMovementMode(MOVE_Falling);

		return true;
	}

	return false;
}
void URealmCharacterMovementComponent::EndDash()
{
	if (!bCharacterDashing)
		return;

	bCharacterDashing = false;
	StopMovementImmediately();
	SetMovementMode(MOVE_Walking);

	AGameCharacter* gc = Cast<AGameCharacter>(CharacterOwner);
	if (IsValid(gc))
	{
		gc->bAcceptingMoveCommands = true;
		gc->CharacterDashFinished();
	}
}