Payback 0.0.1
CK Graduation Project
로딩중...
검색중...
일치하는것 없음
CharacterGhostEffectComponent.h
이 파일의 문서화 페이지로 가기
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CK_UE.h"
6#include "Components/ActorComponent.h"
7#include "Engine/TimerHandle.h"
8#include "CharacterGhostEffectComponent.generated.h"
9
10class UMaterialInstanceDynamic;
11class UMaterialInterface;
12class UPoseableMeshComponent;
13class USkeletalMeshComponent;
14enum class EVisibilityBasedAnimTickOption : uint8;
15
17USTRUCT()
19{
20 GENERATED_BODY()
21
22 UPROPERTY(Transient)
23 TObjectPtr<UPoseableMeshComponent> Mesh;
24
25 UPROPERTY(Transient)
26 TObjectPtr<UMaterialInstanceDynamic> Material;
27
28 double SpawnTime = 0.0;
29};
30
31UENUM(BlueprintType)
32enum class EGhostEffectState : uint8
33{
36 Holding,
38};
39
41UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
42class CK_UE_API UCharacterGhostEffectComponent : public UActorComponent
43{
44 GENERATED_BODY()
45
46public:
48
49protected:
50 virtual void BeginPlay() override;
51 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
52
53public:
54 UFUNCTION(BlueprintCallable, Category = "Ghost Warp")
55 void InitializeGhostEffect(USkeletalMeshComponent* InSourceMeshComponent);
56
57 UFUNCTION(BlueprintCallable, Category = "Ghost Warp")
58 void PlayGhostEffect();
59
60 UFUNCTION(BlueprintCallable, Category = "Ghost Warp")
61 void StopGhostEffect();
62
63 UFUNCTION(BlueprintCallable, Category = "Ghost Warp")
64 void RemoveGhostEffect(float InFadeOutDuration);
65
66 UFUNCTION(BlueprintCallable, Category = "Ghost Warp")
67 void ForceEndGhostEffect();
68
70 UFUNCTION(BlueprintCallable, Category = "Ghost Warp")
71 bool StartTravelGhost(const FVector& Direction);
72
74 UFUNCTION(BlueprintCallable, Category = "Ghost Warp")
75 void StopTravelGhost(bool bImmediate = false);
76
77 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Parameter")
78 void SetGhostOpacity(float Value);
79
80 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Parameter")
81 void SetGhostEmissiveIntensity(float Value);
82
83 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Parameter")
84 void SetGhostFresnelPower(float Value);
85
86 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Parameter")
87 void SetGhostFresnelIntensity(float Value);
88
89 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Parameter")
90 void SetGhostColor(FLinearColor Color);
91
92 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Timing")
93 void SetGhostHoldDuration(float Value);
94
95 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Timing")
96 void SetGhostFadeInDuration(float Value);
97
98 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Timing")
99 void SetGhostFadeOutDuration(float Value);
100
101 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Visibility")
102 void SetHideOriginalMeshWhileActive(bool bShouldHide);
103
104public:
105 UFUNCTION(BlueprintPure, Category = "Ghost Warp")
106 FORCEINLINE EGhostEffectState GetGhostEffectState() const
107 {
108 return CurrentState;
109 }
110
111 UFUNCTION(BlueprintPure, Category = "Ghost Warp")
112 FORCEINLINE UPoseableMeshComponent* GetGhostMeshComponent() const
113 {
114 return GhostMeshComponent;
115 }
116
117protected:
118 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp")
119 TObjectPtr<UMaterialInterface> GhostMaterial = nullptr;
120
121 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Timing", meta = (ClampMin = "0.0"))
122 float FadeInDuration = 0.35f;
123
124 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Timing", meta = (ClampMin = "0.0"))
125 float HoldDuration = 0.25f;
126
127 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Timing", meta = (ClampMin = "0.0"))
128 float FadeOutDuration = 0.35f;
129
130 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Parameter", meta = (ClampMin = "0.0", ClampMax = "1.0"))
131 float MaxOpacity = 0.5f;
132
133 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Visibility")
134 bool bHideOriginalMeshWhileActive = false;
135
136private:
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");
142
143private:
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;
153 void SetCurrentState(EGhostEffectState NewState);
154 void StartFadeIn();
155 void StartFadeOut(float InStartOpacity);
156 void UpdateFade();
157 void StartHolding();
158 void FinishHolding();
159 void ClearHoldTimer();
160 void ClearFadeTimer();
161 void ClearEffectTimers();
163 void CaptureTrailSample(const FVector& Direction);
165 void UpdateTravelGhost();
166
167private:
168 UPROPERTY(Transient)
169 TObjectPtr<USkeletalMeshComponent> SourceMeshComponent = nullptr;
170
171 UPROPERTY(Transient)
172 TObjectPtr<UPoseableMeshComponent> GhostMeshComponent = nullptr;
173
174 UPROPERTY(Transient)
175 TArray<TObjectPtr<UMaterialInstanceDynamic>> GhostMaterialInstances;
176
177 UPROPERTY(Transient)
178 TArray<FGhostTrailSample> TrailSamples;
179
180private:
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;
196
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{};
206};
EGhostEffectState
Definition CharacterGhostEffectComponent.h:33
Definition CharacterGhostEffectComponent.h:43
Definition CharacterGhostEffectComponent.h:19