Payback 0.0.1
CK Graduation Project
로딩중...
검색중...
일치하는것 없음
WeaponLoadoutComponent.h
이 파일의 문서화 페이지로 가기
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Components/ActorComponent.h"
8#include "GameplayTagContainer.h"
9#include "WeaponLoadoutComponent.generated.h"
10
11class UAbilitySystemComponent;
12class UAudioEmitterComponent;
14
15// 장착 무기가 실제로 교체된 뒤 브로드캐스트된다. (이전 무기 태그, 새 무기 태그)
16DECLARE_MULTICAST_DELEGATE_TwoParams(FOnWeaponChanged, const FGameplayTag& /*PreviousWeaponTag*/, const FGameplayTag& /*NewWeaponTag*/);
17
18UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
19class CK_UE_API UWeaponLoadoutComponent : public UActorComponent
20{
21 GENERATED_BODY()
22
23public:
24 UWeaponLoadoutComponent();
25
26public:
27 bool EquipWeapon(const FGameplayTag& WeaponTag);
28 bool SwapWeapon(const FGameplayTag& WeaponTag);
29 void UnequipCurrent();
30 void ResetSkillCooldowns();
31
32public:
33 FOnWeaponChanged OnWeaponChanged;
34
35public:
36 FORCEINLINE FGameplayTag GetCurrentWeaponTag() const
37 {
38 return CurrentWeaponTag;
39 }
40
41 FORCEINLINE UWeaponDefinition* GetCurrentDefinition() const
42 {
43 return CurrentDefinition;
44 }
45
46protected:
47 virtual void BeginPlay() override;
48 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
49
50 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Weapon")
51 TArray<TObjectPtr<UWeaponDefinition>> WeaponDefinitions;
52
53private:
54 bool ApplyWeapon(const FGameplayTag& WeaponTag, bool bActivateSwapInSkill);
55 bool ApplyStatBaseline(UWeaponDefinition* Definition);
56 UWeaponDefinition* FindWeaponDefinition(const FGameplayTag& WeaponTag) const;
57
58 // 새 Definition 의 InputAbilityMap 순회하며 GiveAbility + 핸들을 GrantedHandles 에 누적.
59 void GrantAbilitiesFromDefinition(UWeaponDefinition* Definition);
60
61 // 메시/AnimBP 교체.
62 void ApplyVisualData(UWeaponDefinition* Definition);
63 void ApplyAudioData(UWeaponDefinition* Definition);
64 void ClearAudioData();
65 void ActivateSwapInSkill(UWeaponDefinition* Definition, FGameplayAbilitySpecHandle SwapInSkillHandle);
66
67 UAudioEmitterComponent* GetWeaponAudioTagComponent();
68
69 // 안전한 ASC 획득 (소유자 변경에 대비해 매번 IAbilitySystemInterface 로 해석).
70 UAbilitySystemComponent* GetASC() const;
71 FGameplayAbilitySpecHandle GrantSwapInSkill(UWeaponDefinition* Definition);
72
73private:
74 UPROPERTY(Transient)
75 TObjectPtr<UWeaponDefinition> CurrentDefinition = nullptr;
76
77 UPROPERTY(Transient)
78 FGameplayTag CurrentWeaponTag;
79
80 // 현재 무기가 ASC 에 부여한 어빌리티/GE 핸들 묶음.
81 // UnequipCurrent 에서 TakeFromAbilitySystem 한 번으로 일괄 회수.
82 UPROPERTY(Transient)
83 FGrantedHandles GrantedHandles;
84
85 UPROPERTY(Transient)
86 TWeakObjectPtr<UAbilitySystemComponent> CachedASC;
87
88 UPROPERTY(Transient)
89 TWeakObjectPtr<UAudioEmitterComponent> CachedWeaponAudioTagComponent;
90};
DECLARE_MULTICAST_DELEGATE_TwoParams(FOnWeaponChanged, const FGameplayTag &, const FGameplayTag &)
Definition WeaponDefinition.h:77
Definition GrantedHandles.h:24