Unreal Project

SHSkillEffectBase

갠소롱 2024. 6. 11. 03:05

Skill Effect들을 처리하는 Class

 

SkillEffect는 등록된 계산식을 순차적으로 수행을 하면서 최종 데미지를 계산해주고, 계산된 FinalDamage를 어떤 Stat에 영향을 끼칠지 들고 있다.

 

이렇게 구현을 하려면 기존에 구현했던 SHCharacterStatsComponent를 수정해야 한다.

 

내가 원하는 방식은 SkillEffect가 어떤 Stat에 영향을 끼칠지 GameplayTag로 들고 있고, TargetStatsComponent에서 Tag로 해당 스텟을 가져온 다음에 해당 스텟에 +- FinalDamage를 해주는 방식.

 

하지만 현재 CharacterStats은 Stat들을 각각의 변수명을 갖고 있다. Strength, CurrentHealth, Speed. Stat들마다 고유의 번호, 이름, Tag등이 정의가 되어 있으면 어떻게든 가능하겠지만, 현재 Stat들을 구분해줄 만한것은 없다. 그렇기 때문에 Stat들을 구분할 수 있는 고유의 무언가를 만들어 줘야겠다고 판단했고. 결국 Tag로 하기로 결정 (이건 빠른 시일 내에 수정하자)

 

 

 

UCLASS(Blueprintable)
class SHPROJECT_API USHSkillEffectBase : public UObject
{
	GENERATED_BODY()

public:
	void SetCaptureByTag(const FGameplayTag& InTag, const float InValue);
	const float GetCapturedByTag(const FGameplayTag& InTag) const;

	virtual void ExecuteMultiModifierCalculation();

#pragma region public: Getters and Setters
public:
	USHSkillSystemComponent* GetSourceSkillSystemComponent() const { return SourceSkillSystemComponent; };
	void SetSourceSkillSystemComponent(USHSkillSystemComponent* InSkillSystemComponent) { SourceSkillSystemComponent = InSkillSystemComponent; };

	USHSkillSystemComponent* GetTargetSkillSystemComponent() const { return TargetSkillSystemComponent; };
	void SetTargetSkillSystemComponent(USHSkillSystemComponent* InSkillSystemComponent) { TargetSkillSystemComponent = InSkillSystemComponent; };

	float GetFinalDamage() const { return FinalDamage; };

	bool GetIsCritical() const { return IsCritical; };
	void SetIsCritical(bool NewIsCritical) { IsCritical = NewIsCritical; };

	bool GetIsHealing() const { return IsHealing; };
	void SetIsHealing(bool NewIsHealing) { IsHealing = NewIsHealing; };

#pragma endregion

protected:
	UPROPERTY()
	TObjectPtr<USHSkillSystemComponent> SourceSkillSystemComponent;

	UPROPERTY()
	TObjectPtr<USHSkillSystemComponent> TargetSkillSystemComponent;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effect")
	FGameplayTag TargetStat;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effect")
	float FinalDamage = 0.f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effect")
	bool IsCritical = false;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effect")
	bool IsHealing = false;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effect")
	TArray<TSubclassOf<USHDamageModifierBase>> Modifiers;

	UPROPERTY()
	TMap<FGameplayTag, float> CaptureBoard;
};