50 virtual void BeginPlay()
override;
51 virtual void EndPlay(
const EEndPlayReason::Type EndPlayReason)
override;
54 UFUNCTION(BlueprintCallable, Category =
"Ghost Warp")
55 void InitializeGhostEffect(USkeletalMeshComponent* InSourceMeshComponent);
57 UFUNCTION(BlueprintCallable, Category =
"Ghost Warp")
58 void PlayGhostEffect();
60 UFUNCTION(BlueprintCallable, Category =
"Ghost Warp")
61 void StopGhostEffect();
63 UFUNCTION(BlueprintCallable, Category =
"Ghost Warp")
64 void RemoveGhostEffect(
float InFadeOutDuration);
66 UFUNCTION(BlueprintCallable, Category =
"Ghost Warp")
67 void ForceEndGhostEffect();
70 UFUNCTION(BlueprintCallable, Category =
"Ghost Warp")
71 bool StartTravelGhost(
const FVector& Direction);
74 UFUNCTION(BlueprintCallable, Category =
"Ghost Warp")
75 void StopTravelGhost(
bool bImmediate =
false);
77 UFUNCTION(BlueprintCallable, Category =
"Ghost Warp|Parameter")
78 void SetGhostOpacity(
float Value);
80 UFUNCTION(BlueprintCallable, Category =
"Ghost Warp|Parameter")
81 void SetGhostEmissiveIntensity(
float Value);
83 UFUNCTION(BlueprintCallable, Category =
"Ghost Warp|Parameter")
84 void SetGhostFresnelPower(
float Value);
86 UFUNCTION(BlueprintCallable, Category =
"Ghost Warp|Parameter")
87 void SetGhostFresnelIntensity(
float Value);
89 UFUNCTION(BlueprintCallable, Category =
"Ghost Warp|Parameter")
90 void SetGhostColor(FLinearColor Color);
92 UFUNCTION(BlueprintCallable, Category =
"Ghost Warp|Timing")
93 void SetGhostHoldDuration(
float Value);
95 UFUNCTION(BlueprintCallable, Category =
"Ghost Warp|Timing")
96 void SetGhostFadeInDuration(
float Value);
98 UFUNCTION(BlueprintCallable, Category =
"Ghost Warp|Timing")
99 void SetGhostFadeOutDuration(
float Value);
101 UFUNCTION(BlueprintCallable, Category =
"Ghost Warp|Visibility")
102 void SetHideOriginalMeshWhileActive(
bool bShouldHide);
105 UFUNCTION(BlueprintPure, Category =
"Ghost Warp")
111 UFUNCTION(BlueprintPure, Category =
"Ghost Warp")
112 FORCEINLINE UPoseableMeshComponent* GetGhostMeshComponent()
const
114 return GhostMeshComponent;
118 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category =
"Ghost Warp")
119 TObjectPtr<UMaterialInterface> GhostMaterial =
nullptr;
121 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Timing", meta = (ClampMin = "0.0"))
122 float FadeInDuration = 0.35f;
124 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Timing", meta = (ClampMin = "0.0"))
125 float HoldDuration = 0.25f;
127 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Timing", meta = (ClampMin = "0.0"))
128 float FadeOutDuration = 0.35f;
130 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Parameter", meta = (ClampMin = "0.0", ClampMax = "1.0"))
131 float MaxOpacity = 0.5f;
133 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Visibility")
134 bool bHideOriginalMeshWhileActive = false;
137 const FName GhostColor = TEXT("GhostColor");
138 const FName Opacity = TEXT("Opacity");
139 const FName EmissiveIntensity = TEXT("EmissiveIntensity");
140 const FName FresnelPower = TEXT("FresnelPower");
141 const FName FresnelIntensity = TEXT("FresnelIntensity");
144 bool ResolveSourceMeshComponent();
145 bool EnsureGhostMeshComponent();
146 bool PrepareGhostMeshComponent();
147 void CaptureGhostProjectionPose();
148 void ApplyGhostMaterial();
149 void SetGhostMeshVisible(
bool bVisible);
150 void SetOriginalMeshHidden(
bool bHidden);
151 void RestoreOriginalMeshVisibility();
152 USkeletalMeshComponent* GetPlayerWeaponMeshComponent() const;
155 void StartFadeOut(
float InStartOpacity);
158 void FinishHolding();
159 void ClearHoldTimer();
160 void ClearFadeTimer();
161 void ClearEffectTimers();
163 void CaptureTrailSample(const FVector& Direction);
165 void UpdateTravelGhost();
169 TObjectPtr<USkeletalMeshComponent> SourceMeshComponent =
nullptr;
172 TObjectPtr<UPoseableMeshComponent> GhostMeshComponent =
nullptr;
175 TArray<TObjectPtr<UMaterialInstanceDynamic>> GhostMaterialInstances;
182 double StateStartTime = 0.0;
183 float CurrentOpacity = 0.0f;
184 float FadeOutStartOpacity = 0.0f;
185 float FadeStartOpacity = 0.0f;
186 float FadeTargetOpacity = 0.0f;
187 float FadeDuration = 0.0f;
188 FTimerHandle HoldTimerHandle;
189 FTimerHandle FadeTimerHandle;
190 bool bOriginalVisibility = true;
191 bool bOriginalHiddenInGame = false;
192 bool bOriginalWeaponVisibility = true;
193 bool bOriginalWeaponHiddenInGame = false;
194 bool bHasStoredOriginalVisibility = false;
195 bool bHasStoredWeaponVisibility = false;
197 static constexpr int32 MaxTrailSamples = 4;
198 static constexpr
float TrailLifetime = 0.12f;
199 static constexpr
float TrailInterval = 0.03f;
200 FTimerHandle TrailTimerHandle;
201 FVector LastTrailLocation = FVector::ZeroVector;
202 double LastTrailTime = 0.0;
203 int32 NextTrailIndex = 0;
204 bool bTravelActive = false;
205 EVisibilityBasedAnimTickOption OriginalAnimTickOption{};