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 "CharacterGhostEffectComponent.generated.h"
8
9class UMaterialInstanceDynamic;
10class UMaterialInterface;
11class UPoseableMeshComponent;
12class USkeletalMeshComponent;
13
14UENUM(BlueprintType)
15enum class EGhostEffectState : uint8
16{
19 Holding,
21};
22
23UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
24class CK_UE_API UCharacterGhostEffectComponent : public UActorComponent
25{
26 GENERATED_BODY()
27
28public:
29 UCharacterGhostEffectComponent();
30
31protected:
32 virtual void BeginPlay() override;
33 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
34
35public:
36 UFUNCTION(BlueprintCallable, Category = "Ghost Warp")
37 void InitializeGhostEffect(USkeletalMeshComponent* InSourceMeshComponent);
38
39 UFUNCTION(BlueprintCallable, Category = "Ghost Warp")
40 void PlayGhostEffect();
41
42 UFUNCTION(BlueprintCallable, Category = "Ghost Warp")
43 void StopGhostEffect();
44
45 UFUNCTION(BlueprintCallable, Category = "Ghost Warp")
46 void RemoveGhostEffect(float InFadeOutDuration);
47
48 UFUNCTION(BlueprintCallable, Category = "Ghost Warp")
49 void ForceEndGhostEffect();
50
51 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Parameter")
52 void SetGhostOpacity(float Value);
53
54 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Parameter")
55 void SetGhostEmissiveIntensity(float Value);
56
57 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Parameter")
58 void SetGhostFresnelPower(float Value);
59
60 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Parameter")
61 void SetGhostFresnelIntensity(float Value);
62
63 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Parameter")
64 void SetGhostColor(FLinearColor Color);
65
66 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Timing")
67 void SetGhostHoldDuration(float Value);
68
69 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Timing")
70 void SetGhostFadeInDuration(float Value);
71
72 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Timing")
73 void SetGhostFadeOutDuration(float Value);
74
75 UFUNCTION(BlueprintCallable, Category = "Ghost Warp|Visibility")
76 void SetHideOriginalMeshWhileActive(bool bShouldHide);
77
78public:
79 UFUNCTION(BlueprintPure, Category = "Ghost Warp")
80 FORCEINLINE EGhostEffectState GetGhostEffectState() const
81 {
82 return CurrentState;
83 }
84
85 UFUNCTION(BlueprintPure, Category = "Ghost Warp")
86 FORCEINLINE UPoseableMeshComponent* GetGhostMeshComponent() const
87 {
88 return GhostMeshComponent;
89 }
90
91protected:
92 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp")
93 TObjectPtr<UMaterialInterface> GhostMaterial = nullptr;
94
95 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Timing", meta = (ClampMin = "0.0"))
96 float FadeInDuration = 0.35f;
97
98 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Timing", meta = (ClampMin = "0.0"))
99 float HoldDuration = 0.25f;
100
101 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Timing", meta = (ClampMin = "0.0"))
102 float FadeOutDuration = 0.35f;
103
104 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Parameter", meta = (ClampMin = "0.0", ClampMax = "1.0"))
105 float MaxOpacity = 0.5f;
106
107 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ghost Warp|Visibility")
108 bool bHideOriginalMeshWhileActive = false;
109
110private:
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");
116
117private:
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;
127 void SetCurrentState(EGhostEffectState NewState);
128 void StartFadeIn();
129 void StartFadeOut(float InStartOpacity);
130 void UpdateFade();
131 void StartHolding();
132 void FinishHolding();
133 void ClearHoldTimer();
134 void ClearFadeTimer();
135 void ClearEffectTimers();
136
137private:
138 UPROPERTY(Transient)
139 TObjectPtr<USkeletalMeshComponent> SourceMeshComponent = nullptr;
140
141 UPROPERTY(Transient)
142 TObjectPtr<UPoseableMeshComponent> GhostMeshComponent = nullptr;
143
144 UPROPERTY(Transient)
145 TArray<TObjectPtr<UMaterialInstanceDynamic>> GhostMaterialInstances;
146
147private:
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;
163};
EGhostEffectState
Definition CharacterGhostEffectComponent.h:16