230 lines
6.1 KiB
C++
230 lines
6.1 KiB
C++
|
// © 2024 Long Ly. All rights reserved. Any unauthorized use, reproduction, or distribution of this trademark is strictly prohibited and may result in legal action.
|
||
|
|
||
|
|
||
|
#include "Data/OLSAnimationData.h"
|
||
|
|
||
|
#include "Data/OLSEnumLibrary.h"
|
||
|
|
||
|
UAnimSequence* FOLSTurnInPlaceAnimSet::GetTurnInPlaceAnimationByDirection(const float direction) const
|
||
|
{
|
||
|
if (FMath::Abs(direction) < 130.f)
|
||
|
{
|
||
|
return (direction > 0) ? TurnInPlace_90_R : TurnInPlace_90_L;
|
||
|
}
|
||
|
return (direction > 0) ? TurnInPlace_180_R : TurnInPlace_180_L;
|
||
|
}
|
||
|
|
||
|
bool FOLSIdleAnimSet::HasAnyIdleBreaks() const
|
||
|
{
|
||
|
return !IdleBreaks.IsEmpty();
|
||
|
}
|
||
|
|
||
|
UAnimSequence* FOLSIdleAnimSet::GetIdleAnimation() const
|
||
|
{
|
||
|
return Idle;
|
||
|
}
|
||
|
|
||
|
UAnimSequence* FOLSIdleAnimSet::GetRandomIdleBreakAnimation() const
|
||
|
{
|
||
|
if (!HasAnyIdleBreaks())
|
||
|
{
|
||
|
return nullptr;
|
||
|
}
|
||
|
|
||
|
const int32 idleBreaksNum = IdleBreaks.Num();
|
||
|
return IdleBreaks[FMath::RandRange(0, idleBreaksNum - 1)];
|
||
|
}
|
||
|
|
||
|
UAnimSequence* FOLSIdleAndTurnInPlaceAnimSet::GetIdleExitAnimation() const
|
||
|
{
|
||
|
return IdleAnimSet.IdleExit;
|
||
|
}
|
||
|
|
||
|
UAnimSequence* FOLSIdleAndTurnInPlaceAnimSet::GetIdleAnimation() const
|
||
|
{
|
||
|
return IdleAnimSet.GetIdleAnimation();
|
||
|
}
|
||
|
|
||
|
UAnimSequence* FOLSIdleAndTurnInPlaceAnimSet::GetRandomIdleBreakAnimation() const
|
||
|
{
|
||
|
return IdleAnimSet.GetRandomIdleBreakAnimation();
|
||
|
}
|
||
|
|
||
|
UAnimSequence* FOLSIdleAndTurnInPlaceAnimSet::GetTurnInPlaceAnimation(const float direction) const
|
||
|
{
|
||
|
return TurnInPlaceAnimSet.GetTurnInPlaceAnimationByDirection(direction);
|
||
|
}
|
||
|
|
||
|
bool FOLSIdleAndTurnInPlaceAnimSet::CanPlayIdleBreakAnimation() const
|
||
|
{
|
||
|
return IdleAnimSet.HasAnyIdleBreaks();
|
||
|
}
|
||
|
|
||
|
UAnimSequence* FOLSMovementAnimSet::GetMovementAnimationByCardinalDirection(const EOLSCardinalDirection& direction) const
|
||
|
{
|
||
|
TObjectPtr<UAnimSequence> result = nullptr;
|
||
|
switch (direction)
|
||
|
{
|
||
|
case EOLSCardinalDirection::EForward:
|
||
|
result = Forward;
|
||
|
break;
|
||
|
case EOLSCardinalDirection::EBackward:
|
||
|
result = Backward;
|
||
|
break;
|
||
|
case EOLSCardinalDirection::ERight:
|
||
|
result = Right;
|
||
|
break;
|
||
|
case EOLSCardinalDirection::ELeft:
|
||
|
result = Left;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
class UAnimSequence* FOLSMovementAnimSet_ForwardFacing_StartCycle::GetForwardLeftOrRightFootByAngle(
|
||
|
const bool isRightFootFront) const
|
||
|
{
|
||
|
return (isRightFootFront) ? Forward_R : Forward_L;
|
||
|
}
|
||
|
|
||
|
UAnimSequence* FOLSMovementAnimSet_ForwardFacing_StartCycle::GetForward180LeftOrRightByAngle(const float angle) const
|
||
|
{
|
||
|
return (angle > 0.f) ? Forward180_R : Forward180_L;
|
||
|
}
|
||
|
|
||
|
class UAnimSequence* FOLSMovementAnimSet_ForwardFacing_StartCycle::GetMovementAnimationByAngle(
|
||
|
const EOLSCardinalDirection direction, const float angle, const bool isRightFootFront) const
|
||
|
{
|
||
|
TObjectPtr<UAnimSequence> result = nullptr;
|
||
|
|
||
|
switch (direction)
|
||
|
{
|
||
|
case EOLSCardinalDirection::EForward:
|
||
|
result = GetForwardLeftOrRightFootByAngle(isRightFootFront);
|
||
|
break;
|
||
|
case EOLSCardinalDirection::ELeft:
|
||
|
result = Left;
|
||
|
break;
|
||
|
case EOLSCardinalDirection::ERight:
|
||
|
result = Right;
|
||
|
break;
|
||
|
case EOLSCardinalDirection::EBackward:
|
||
|
result = GetForward180LeftOrRightByAngle(angle);
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
void FOLSMovementAnimSets_ForwardFacing_Pivot::GetLeftOrRightAnimSet(const bool isLeftFootPlanted,
|
||
|
const bool isRightFootPlanted, FOLSMovementAnimSet_ForwardFacing_Pivot& outAnimSet) const
|
||
|
{
|
||
|
if (isLeftFootPlanted)
|
||
|
{
|
||
|
outAnimSet = Pivot_LeftFoot;
|
||
|
}
|
||
|
else if (isRightFootPlanted)
|
||
|
{
|
||
|
outAnimSet = Pivot_RightFoot;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class UAnimSequence* FOLSMovementAnimSets_ForwardFacing_Pivot::GetLeftOrRightByAngle(const float angle,
|
||
|
const bool isLeftFootPlanted, const bool isRightFootPlanted, float& outPivotTime) const
|
||
|
{
|
||
|
FOLSMovementAnimSet_ForwardFacing_Pivot animSet;
|
||
|
GetLeftOrRightAnimSet(isLeftFootPlanted, isRightFootPlanted, animSet);
|
||
|
|
||
|
outPivotTime = PivotTime;
|
||
|
|
||
|
return (angle > 0.f) ? animSet.Pivot180R : animSet.Pivot180L;
|
||
|
}
|
||
|
|
||
|
void FOLSGaitAnimSet::GetPlayRateByLocomotionState(const EOLSLocomotionStatePlayRate& state, FVector2D& outPlayRate) const
|
||
|
{
|
||
|
switch (state)
|
||
|
{
|
||
|
case EOLSLocomotionStatePlayRate::EStart:
|
||
|
outPlayRate = PlayRate_Start;
|
||
|
break;
|
||
|
case EOLSLocomotionStatePlayRate::ECycle:
|
||
|
outPlayRate = PlayRate_Cycle;
|
||
|
break;
|
||
|
case EOLSLocomotionStatePlayRate::EPivot:
|
||
|
outPlayRate = PlayRate_Pivot;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const FOLSMovementAnimSet& FOLSGaitAnimSet_CameraFacing::GetStartCycleFromHipDirection(const EOLSHipDirection hipDirection) const
|
||
|
{
|
||
|
return (hipDirection == EOLSHipDirection::EForward) ? StartCycle_HipForward : StartCycle_HipBackward;
|
||
|
}
|
||
|
|
||
|
const FOLSMovementAnimSet& FOLSGaitAnimSet_CameraFacing::GetCycleFromHipDirection(const EOLSHipDirection hipDirection) const
|
||
|
{
|
||
|
return (hipDirection == EOLSHipDirection::EForward) ? Cycle_HipForward : Cycle_HipBackward;
|
||
|
}
|
||
|
|
||
|
const FOLSMovementAnimSet& FOLSGaitAnimSet_CameraFacing::GetPivotFromHipDirection(const EOLSHipDirection hipDirection) const
|
||
|
{
|
||
|
return (hipDirection == EOLSHipDirection::EForward) ? Pivot_HipForward : Pivot_HipBackward;
|
||
|
}
|
||
|
|
||
|
const FOLSMovementAnimSet& FOLSGaitAnimSet_CameraFacing::GetStopCycleFromHipDirection(const EOLSHipDirection hipDirection) const
|
||
|
{
|
||
|
return (hipDirection == EOLSHipDirection::EForward) ? StopCycle_HipForward : StopCycle_HipBackward;
|
||
|
}
|
||
|
|
||
|
UAnimSequence* FOLSStanceAnimSets::GetIdleAnimation() const
|
||
|
{
|
||
|
return IdleAndTurnInPlaceAnimSet.GetIdleAnimation();
|
||
|
}
|
||
|
|
||
|
UAnimSequence* FOLSStanceAnimSets::GetIdleExitAnimation() const
|
||
|
{
|
||
|
return IdleAndTurnInPlaceAnimSet.GetIdleExitAnimation();
|
||
|
}
|
||
|
|
||
|
UAnimSequence* FOLSStanceAnimSets::GetRandomIdleBreakAnimation() const
|
||
|
{
|
||
|
return IdleAndTurnInPlaceAnimSet.GetRandomIdleBreakAnimation();
|
||
|
}
|
||
|
|
||
|
UAnimSequence* FOLSStanceAnimSets::GetTurnInPlaceAnimation(const float direction) const
|
||
|
{
|
||
|
return IdleAndTurnInPlaceAnimSet.GetTurnInPlaceAnimation(direction);
|
||
|
}
|
||
|
|
||
|
bool FOLSStanceAnimSets::CanPlayIdleBreakAnimation() const
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
const FOLSGaitAnimSets& FOLSStanceAnimSets::GetGaitAnimSetByGait(const EOLSGait& gait) const
|
||
|
{
|
||
|
return WalkAnimSets;
|
||
|
}
|
||
|
|
||
|
const FOLSGaitAnimSets& FOLSStanceAnimSets_Standing::GetGaitAnimSetByGait(const EOLSGait& gait) const
|
||
|
{
|
||
|
switch (gait)
|
||
|
{
|
||
|
case EOLSGait::EWalk:
|
||
|
return WalkAnimSets;
|
||
|
break;
|
||
|
|
||
|
case EOLSGait::EJog:
|
||
|
return JogAnimSets;
|
||
|
|
||
|
case EOLSGait::ESprint:
|
||
|
return SprintAnimSets;
|
||
|
}
|
||
|
|
||
|
return FOLSStanceAnimSets::GetGaitAnimSetByGait(gait);
|
||
|
}
|
||
|
|
||
|
FOLSGaitAnimSets FOLSGaitAnimSets::EmptyAnimSet = FOLSGaitAnimSets();
|
||
|
|