6#include "Components/ActorComponent.h"
7#include "CharacterGhostEffectComponent.generated.h"
9class UMaterialInstanceDynamic;
10class UMaterialInterface;
11class UPoseableMeshComponent;
12class USkeletalMeshComponent;
23UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
24class CK_UE_API UCharacterGhostEffectComponent :
public UActorComponent
29 UCharacterGhostEffectComponent();
32 virtual
void BeginPlay() override;
33 virtual
void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
36 UFUNCTION(BlueprintCallable, Category = "Ghost Warp")
37 void InitializeGhostEffect(USkeletalMeshComponent* InSourceMeshComponent);
39 UFUNCTION(BlueprintCallable, Category = "Ghost Warp")
40 void PlayGhostEffect();
42 UFUNCTION(BlueprintCallable, Category = "Ghost Warp")
43 void StopGhostEffect();
45 UFUNCTION(BlueprintCallable, Category = "Ghost Warp")
46 void RemoveGhostEffect(
float InFadeOutDuration);
48 UFUNCTION(BlueprintCallable, Category = "Ghost Warp")
49 void ForceEndGhostEffect();
51 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Parameter")
52 void SetGhostOpacity(
float Value);
54 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Parameter")
55 void SetGhostEmissiveIntensity(
float Value);
57 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Parameter")
58 void SetGhostFresnelPower(
float Value);
60 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Parameter")
61 void SetGhostFresnelIntensity(
float Value);
63 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Parameter")
64 void SetGhostColor(FLinearColor Color);
66 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Timing")
67 void SetGhostHoldDuration(
float Value);
69 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Timing")
70 void SetGhostFadeInDuration(
float Value);
72 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Timing")
73 void SetGhostFadeOutDuration(
float Value);
75 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Visibility")
76 void SetHideOriginalMeshWhileActive(
bool bShouldHide);
79 UFUNCTION(BlueprintPure, Category = "Ghost Warp")
85 UFUNCTION(BlueprintPure, Category =
"Ghost Warp")
86 FORCEINLINE UPoseableMeshComponent* GetGhostMeshComponent()
const
88 return GhostMeshComponent;
92 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category =
"Ghost Warp")
93 TObjectPtr<UMaterialInterface> GhostMaterial =
nullptr;
95 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Timing", meta = (ClampMin = "0.0"))
96 float FadeInDuration = 0.35f;
98 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Timing", meta = (ClampMin = "0.0"))
99 float HoldDuration = 0.25f;
101 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Timing", meta = (ClampMin = "0.0"))
102 float FadeOutDuration = 0.35f;
104 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Parameter", meta = (ClampMin = "0.0", ClampMax = "1.0"))
105 float MaxOpacity = 0.5f;
107 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Visibility")
108 bool bHideOriginalMeshWhileActive = false;
111 const FName GhostColor = TEXT("GhostColor");
112 const FName Opacity = TEXT("Opacity");
113 const FName EmissiveIntensity = TEXT("EmissiveIntensity");
114 const FName FresnelPower = TEXT("FresnelPower");
115 const FName FresnelIntensity = TEXT("FresnelIntensity");
118 bool ResolveSourceMeshComponent();
119 bool EnsureGhostMeshComponent();
120 bool PrepareGhostMeshComponent();
121 void CaptureGhostProjectionPose();
122 void ApplyGhostMaterial();
123 void SetGhostMeshVisible(
bool bVisible);
124 void SetOriginalMeshHidden(
bool bHidden);
125 void RestoreOriginalMeshVisibility();
126 USkeletalMeshComponent* GetPlayerWeaponMeshComponent() const;
129 void StartFadeOut(
float InStartOpacity);
132 void FinishHolding();
133 void ClearHoldTimer();
134 void ClearFadeTimer();
135 void ClearEffectTimers();
139 TObjectPtr<USkeletalMeshComponent> SourceMeshComponent =
nullptr;
142 TObjectPtr<UPoseableMeshComponent> GhostMeshComponent =
nullptr;
145 TArray<TObjectPtr<UMaterialInstanceDynamic>> GhostMaterialInstances;
149 float StateElapsedTime = 0.0f;
150 float CurrentOpacity = 0.0f;
151 float FadeOutStartOpacity = 0.0f;
152 float FadeStartOpacity = 0.0f;
153 float FadeTargetOpacity = 0.0f;
154 float FadeDuration = 0.0f;
155 FTimerHandle HoldTimerHandle;
156 FTimerHandle FadeTimerHandle;
157 bool bOriginalVisibility = true;
158 bool bOriginalHiddenInGame = false;
159 bool bOriginalWeaponVisibility = true;
160 bool bOriginalWeaponHiddenInGame = false;
161 bool bHasStoredOriginalVisibility = false;
162 bool bHasStoredWeaponVisibility = false;
EGhostEffectState
Definition CharacterGhostEffectComponent.h:16