5#include "CoreMinimal.h"
6#include "Components/ActorComponent.h"
7#include "Components/TimelineComponent.h"
8#include "Net/UnrealNetwork.h"
9#include "Kismet/KismetMathLibrary.h"
11#include "RecoilAnimationComponent.generated.h"
23class RECOILANIMATION_API URecoilAnimationComponent :
public UActorComponent
28 URecoilAnimationComponent();
30 virtual
void TickComponent(
float DeltaTime, ELevelTick TickType,
31 FActorComponentTickFunction* ThisTickFunction) override;
33 UFUNCTION(BlueprintCallable, Category = "Essentials")
34 void Init(const
FRecoilAnimData Data, const
float Rate = 0.0f, const
int Bursts = 0);
36 UFUNCTION(BlueprintCallable, Category = "Essentials")
39 UFUNCTION(BlueprintCallable, Category = "Essentials")
42 FORCEINLINE FTransform GetOutput()
const {
return FTransform(OutRot, OutLoc); };
44 UFUNCTION(BlueprintCallable, Category =
"Essentials")
47 UFUNCTION(BlueprintCallable, Category = "Essentials")
48 void SetAimingStatus(
bool bStatus);
50 UFUNCTION(BlueprintCallable, Category = "Essentials")
53 UFUNCTION(BlueprintCallable, Category = "Essentials")
56 UFUNCTION(BlueprintCallable, Category = "Essentials")
59 UFUNCTION(BlueprintCallable, Category = "Essentials")
60 void ResetInputScale();
62 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "
Debug", meta=(DevelopmentOnly))
63 FORCEINLINE
EFireMode_PRAS GetFireMode()
const {
return FireMode; };
66 UFUNCTION(BlueprintCallable, Category =
"Debug")
67 float GetDelta() const;
69 UFUNCTION(BlueprintCallable, Category = "
Debug", meta=(DevelopmentOnly))
70 void Simulate(
bool bStartSim);
72 UFUNCTION(BlueprintCallable, Category = "
Debug", meta=(DevelopmentOnly))
75 UFUNCTION(BlueprintCallable, Category = "
Debug", meta=(DevelopmentOnly))
78 void AddEvent(
float Time, FOnTimelineEvent Event);
80 UPROPERTY(BlueprintReadWrite, Category = "UI")
83 UPROPERTY(BlueprintReadWrite, Category = "UI")
86 UPROPERTY(BlueprintReadWrite, Replicated, Category = "Recoil Animation")
89 UPROPERTY(BlueprintReadWrite, Replicated, Category = "Recoil Animation")
93 virtual
void BeginPlay() override;
97 void AnimationUpdate(FVector VectorAlpha);
100 void CalculateTargetData();
109 double CorrectStart(
double& Last, const
double Current,
bool& bStartRest,
double& StartVal);
112 FORCEINLINE
double GLerp(
double A,
double B,
double Alpha,
double DeltaTime)
114 return FMath::Lerp(A,
B, 1 - FMath::Exp(-Alpha * DeltaTime));
117 FVector GLerp(FVector A, FVector
B, FVector Alpha,
float DeltaTime);
119 FRotator GLerp(FRotator A, FRotator
B, FVector Alpha,
float DeltaTime);
121 void SetupStateMachine();
123 void SetSimulationTimer(
float SemiDelay);
129 double GetAngularRecoil(
const FVector4 RecoilProfile);
132 void CorrectAlpha(
const UCurveVector* Rotation,
const UCurveVector*
Location,
const float TimeCorrection);
135 void SetupTransition(FRotator StartRot, FVector StartLoc, UCurveVector* Rot, UCurveVector* Loc);
137 void SetupComponent();
139 void TickAdvancedSolver(
float DeltaTime);
142 float DampSpring(
float Current, FFloatSpringState& SpringState,
float Stiffness,
float Damping,
float DeltaTime);
144 void ApplySmoothing(
float DeltaTime);
145 void ApplyNoise(FTransform& Finalized,
float DeltaTime);
146 void ApplyPushback(FTransform& Finalized,
float DeltaTime);
147 void ApplyProgression(FTransform& Finalized,
float DeltaTime);
149 double GetNonZero(
double OldValue,
double NewValue)
const
151 if(FMath::IsNearlyZero(NewValue))
159 UPROPERTY(Replicated, BlueprintReadOnly, Category =
"Recoil Animation Output", meta=(AllowPrivateAccess=
true))
162 UPROPERTY(Replicated, BlueprintReadOnly, Category = "Recoil Animation Output", meta=(AllowPrivateAccess=true))
165 UPROPERTY(EditDefaultsOnly, Category = "UI")
166 TSubclassOf<UUserWidget> WidgetClass;
170 UCurveVector* TempRot;
174 UCurveVector* TempLoc;
179 UPROPERTY(BlueprintReadOnly, meta=(AllowPrivateAccess=true), Category = "Essentials")
180 bool bIsAiming = false;
183 float LastShotTime = 0.f;
185 FTimerHandle TimerHandle;
186 FTimeline AnimTimeline;
196 FRotator StartValRot;
203 FFloatSpringState PitchState;
204 FFloatSpringState RollState;
205 FFloatSpringState KickState;
208 FOnTimelineVector ProgressFunction;
227 uint8 CurrentStateIndex = 0;
234 bool bEnableSmoothing = false;
237 bool bAnimActive = true;
239 FVector2D Noise2DTarget = FVector2D::ZeroVector;
240 FVector2D Noise2DCurrent = FVector2D::ZeroVector;
241 FVector2D NoiseSpeed = FVector2D::ZeroVector;
243 double PushbackTarget = 0;
244 double PushbackCurrent = 0;
245 double PushbackOut = 0;
246 double PushbackSpeed = 0;
251 FVector2D PitchProgress = FVector2D::ZeroVector;
252 FVector2D ZProgress = FVector2D::ZeroVector;
253 double PitchProgressSpeed = 0;
254 double ZProgressSpeed = 0;
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
DECLARE_LOG_CATEGORY_EXTERN(LogRecoilAnimation, Log, All)
EFireMode_PRAS
Definition RecoilData.h:24
Definition RecoilAnimation.Build.cs:6
Definition StoredData.h:26
Definition RecoilData.h:98
Definition RecoilData.h:67
Definition RecoilData.h:33
Definition RecoilData.h:82