GAS 적용시도

This commit is contained in:
2023-10-30 00:04:36 +09:00
parent 9c071ad3fc
commit a82d78f0fb
40 changed files with 859 additions and 693 deletions

View File

@@ -5,9 +5,19 @@ ClearInvalidTags=False
AllowEditorTagUnloading=True AllowEditorTagUnloading=True
AllowGameTagUnloading=False AllowGameTagUnloading=False
FastReplication=False FastReplication=False
InvalidTagCharacters="\"\'," InvalidTagCharacters=
NumBitsForContainerSize=6 NumBitsForContainerSize=6
NetIndexFirstBitSegment=16 NetIndexFirstBitSegment=16
+GameplayTagList=(Tag="State.Buff.Regenerate.Health",DevComment="")
+GameplayTagList=(Tag="State.Buff.Regenerate.Mana",DevComment="")
+GameplayTagList=(Tag="State.Buff.Shield",DevComment="")
+GameplayTagList=(Tag="State.Dead",DevComment="") +GameplayTagList=(Tag="State.Dead",DevComment="")
+GameplayTagList=(Tag="State.EffectTag",DevComment="") +GameplayTagList=(Tag="State.Debuff.Burning",DevComment="")
+GameplayTagList=(Tag="State.Debuff.Root",DevComment="")
+GameplayTagList=(Tag="State.Debuff.Slow",DevComment="")
+GameplayTagList=(Tag="State.Debuff.Stun",DevComment="")
+GameplayTagList=(Tag="State.Return",DevComment="")
+GameplayTagList=(Tag="Team.Black",DevComment="")
+GameplayTagList=(Tag="Team.Neutral",DevComment="")
+GameplayTagList=(Tag="Team.White",DevComment="")

View File

@@ -67,7 +67,9 @@ bCaptureMouseOnLaunch=True
bEnableLegacyInputScales=True bEnableLegacyInputScales=True
bEnableMotionControls=True bEnableMotionControls=True
bFilterInputByPlatformUser=False bFilterInputByPlatformUser=False
bEnableInputDeviceSubsystem=True
bShouldFlushPressedKeysOnViewportFocusLost=True bShouldFlushPressedKeysOnViewportFocusLost=True
bEnableDynamicComponentInputBinding=True
bAlwaysShowTouchInterface=False bAlwaysShowTouchInterface=False
bShowConsoleOnFourFingerTap=True bShowConsoleOnFourFingerTap=True
bEnableGestureRecognizer=False bEnableGestureRecognizer=False

BIN
Content/Blueprints/BP_Deathmatch.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/Character/Lb/Ability/BP_BaseAttack.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Character/Lb/BP_Lb.uasset (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

BIN
Content/InputActions/Skill1.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Content/InputActions/Skill2.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Content/InputActions/Skill3.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Content/InputActions/Skill4.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Content/InputActions/Skill4_End.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Content/Maps/DeathmatchMap.umap (Stored with Git LFS)

Binary file not shown.

View File

@@ -9,11 +9,13 @@
void UAN_AnimEnd::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) void UAN_AnimEnd::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference)
{ {
// TODO - animation state update fix
/*
ADefaultPlayerCharacter* MyCharacter = MeshComp->GetOwner<ADefaultPlayerCharacter>(); ADefaultPlayerCharacter* MyCharacter = MeshComp->GetOwner<ADefaultPlayerCharacter>();
if (!MyCharacter) return; if (!MyCharacter) return;
ADefaultPlayerState* MyState = MyCharacter->GetPlayerState<ADefaultPlayerState>(); ADefaultPlayerState* MyState = MyCharacter->GetPlayerState<ADefaultPlayerState>();
if (!MyState) return; if (!MyState) return;
MyState->SetState(ECharacterState::Idle); MyState->SetState(ECharacterState::Idle);
*/
} }

View File

@@ -11,5 +11,5 @@ void UAN_Attack::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Ani
ADefaultPlayerCharacter* MyCharacter = MeshComp->GetOwner<ADefaultPlayerCharacter>(); ADefaultPlayerCharacter* MyCharacter = MeshComp->GetOwner<ADefaultPlayerCharacter>();
if (!MyCharacter) return; if (!MyCharacter) return;
MyCharacter->Attack(); // MyCharacter->Attack(); Replace later
} }

View File

@@ -10,5 +10,5 @@ void UAN_Skill1::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Ani
ADefaultPlayerCharacter* MyCharacter = MeshComp->GetOwner<ADefaultPlayerCharacter>(); ADefaultPlayerCharacter* MyCharacter = MeshComp->GetOwner<ADefaultPlayerCharacter>();
if (!MyCharacter) return; if (!MyCharacter) return;
MyCharacter->Skill1(); // MyCharacter->Skill1(); Replace later
} }

View File

@@ -10,5 +10,5 @@ void UAN_Skill2::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Ani
ADefaultPlayerCharacter* MyCharacter = MeshComp->GetOwner<ADefaultPlayerCharacter>(); ADefaultPlayerCharacter* MyCharacter = MeshComp->GetOwner<ADefaultPlayerCharacter>();
if (!MyCharacter) return; if (!MyCharacter) return;
MyCharacter->Skill2(); // MyCharacter->Skill2(); Replace later
} }

View File

@@ -10,5 +10,5 @@ void UAN_Skill3::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Ani
ADefaultPlayerCharacter* MyCharacter = MeshComp->GetOwner<ADefaultPlayerCharacter>(); ADefaultPlayerCharacter* MyCharacter = MeshComp->GetOwner<ADefaultPlayerCharacter>();
if (!MyCharacter) return; if (!MyCharacter) return;
MyCharacter->Skill3(); // MyCharacter->Skill3(); Replace later
} }

View File

@@ -10,5 +10,5 @@ void UAN_Skill4::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Ani
ADefaultPlayerCharacter* MyCharacter = MeshComp->GetOwner<ADefaultPlayerCharacter>(); ADefaultPlayerCharacter* MyCharacter = MeshComp->GetOwner<ADefaultPlayerCharacter>();
if (!MyCharacter) return; if (!MyCharacter) return;
MyCharacter->Skill4(); // MyCharacter->Skill4(); Replace later
} }

View File

@@ -12,6 +12,10 @@ ADefaultAIController::ADefaultAIController()
void ADefaultAIController::OnPossess(APawn* aPawn) void ADefaultAIController::OnPossess(APawn* aPawn)
{ {
/*
*
* This was Stat initialize code. Depricated.
//debug //debug
FString MyName = aPawn->GetName(); FString MyName = aPawn->GetName();
@@ -30,4 +34,5 @@ void ADefaultAIController::OnPossess(APawn* aPawn)
ControlledPawn->CooldownDuration.GenerateValueArray(CooldownDurationValue); ControlledPawn->CooldownDuration.GenerateValueArray(CooldownDurationValue);
MyPlayerState->InitPlayerStats(DefaultStatsValue, CooldownDurationValue); MyPlayerState->InitPlayerStats(DefaultStatsValue, CooldownDurationValue);
*/
} }

View File

@@ -10,6 +10,62 @@ UDefaultGameInstance::UDefaultGameInstance()
ConstructorHelpers::FObjectFinder<UClass> RIANA(TEXT("Class'/Game/Character/Riana/BP_Riana.BP_Riana_C'")); ConstructorHelpers::FObjectFinder<UClass> RIANA(TEXT("Class'/Game/Character/Riana/BP_Riana.BP_Riana_C'"));
ConstructorHelpers::FObjectFinder<UClass> LB(TEXT("Class'/Game/Character/Lb/BP_Lb.BP_Lb_C'")); ConstructorHelpers::FObjectFinder<UClass> LB(TEXT("Class'/Game/Character/Lb/BP_Lb.BP_Lb_C'"));
static ConstructorHelpers::FObjectFinder<UInputMappingContext>
DEFAULT_CONTEXT(TEXT("/Script/EnhancedInput.InputMappingContext'/Game/InputActions/InputMappingContext.InputMappingContext'"));
if (!DEFAULT_CONTEXT.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("DEFAULT_CONTEXT load failed."));
return;
}
PlayerInputMapping = DEFAULT_CONTEXT.Object;
static ConstructorHelpers::FObjectFinder<UInputAction>
IA_RUNESPELL1(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/RuneSpell1.RuneSpell1'")),
IA_RUNESPELL2(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/RuneSpell2.RuneSpell2'")),
IA_WARD(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/Ward.Ward'")),
IA_BOMB(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/Bomb.Bomb'")),
IA_OBJECTSELECT(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/ObjectSelect.ObjectSelect'")),
IA_MOVE(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/Move.Move'"));
if (!IA_RUNESPELL1.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_RUNESPELL1 load failed."));
return;
}
if (!IA_RUNESPELL2.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_RUNESPELL2 load failed."));
return;
}
if (!IA_WARD.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_WARD load failed."));
return;
}
if (!IA_BOMB.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_BOMB load failed."));
return;
}
if (!IA_OBJECTSELECT.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_OBJECTSELECT load failed."));
return;
}
if (!IA_MOVE.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_MOVE load failed."));
return;
}
RuneSpell1Action = IA_RUNESPELL1.Object;
RuneSpell2Action = IA_RUNESPELL2.Object;
WardAction = IA_WARD.Object;
BombAction = IA_BOMB.Object;
ObjectSelectAction = IA_OBJECTSELECT.Object;
MoveAction = IA_MOVE.Object;
if if
( (
//!LUKRIEL.Succeeded() || //!LUKRIEL.Succeeded() ||

View File

@@ -5,6 +5,9 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Engine/GameInstance.h" #include "Engine/GameInstance.h"
#include "PrometherEnum.h" #include "PrometherEnum.h"
#include "EnhancedInputSubsystems.h"
#include "EnhancedInputComponent.h"
#include "InputMappingContext.h"
#include "DefaultGameInstance.generated.h" #include "DefaultGameInstance.generated.h"
UCLASS() UCLASS()
@@ -19,6 +22,22 @@ public:
UClass* GetCharacterBPRef(CharacterType Type) { return BP_Characters[(uint8)Type]; } UClass* GetCharacterBPRef(CharacterType Type) { return BP_Characters[(uint8)Type]; }
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputMappingContext> PlayerInputMapping;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> RuneSpell1Action;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> RuneSpell2Action;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> WardAction;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> BombAction;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> ObjectSelectAction;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> MoveAction;
private: private:
UPROPERTY() UPROPERTY()
UClass* BP_Characters[(uint8)CharacterType::SIZE]; UClass* BP_Characters[(uint8)CharacterType::SIZE];

View File

@@ -2,4 +2,22 @@
#include "CharacterGameplayAbility.h" #include "CharacterGameplayAbility.h"
#include "../DefaultAbilitySystemComponent.h"
UCharacterGameplayAbility::UCharacterGameplayAbility()
{
InstancingPolicy = EGameplayAbilityInstancingPolicy::InstancedPerActor;
ActivationBlockedTags.AddTag(FGameplayTag::RequestGameplayTag(FName("State.Dead")));
ActivationBlockedTags.AddTag(FGameplayTag::RequestGameplayTag(FName("State.Debuff.Stun")));
}
void UCharacterGameplayAbility::OnAvatarSet(const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilitySpec& Spec)
{
Super::OnAvatarSet(ActorInfo, Spec);
if (ActivateAbilityOnGranted)
{
ActorInfo->AbilitySystemComponent->TryActivateAbility(Spec.Handle, false);
}
}

View File

@@ -4,6 +4,7 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Abilities/GameplayAbility.h" #include "Abilities/GameplayAbility.h"
#include "../../Promether.h"
#include "CharacterGameplayAbility.generated.h" #include "CharacterGameplayAbility.generated.h"
/** /**
@@ -13,5 +14,17 @@ UCLASS()
class PROMETHER_API UCharacterGameplayAbility : public UGameplayAbility class PROMETHER_API UCharacterGameplayAbility : public UGameplayAbility
{ {
GENERATED_BODY() GENERATED_BODY()
public:
UCharacterGameplayAbility();
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Ability")
EDefaultAbilityID AbilityID = EDefaultAbilityID::None;
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Ability")
EDefaultAbilityID AbilityInputID = EDefaultAbilityID::None;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Ability")
bool ActivateAbilityOnGranted = false;
virtual void OnAvatarSet(const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilitySpec& Spec) override;
}; };

View File

@@ -8,12 +8,24 @@ void UCharacterBaseAttribute::GetLifetimeReplicatedProps(TArray<FLifetimePropert
{ {
Super::GetLifetimeReplicatedProps(OutLifetimeProps); Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME_CONDITION_NOTIFY(UCharacterBaseAttribute, Team, COND_None, REPNOTIFY_Always);
DOREPLIFETIME_CONDITION_NOTIFY(UCharacterBaseAttribute, XP, COND_None, REPNOTIFY_Always);
DOREPLIFETIME_CONDITION_NOTIFY(UCharacterBaseAttribute, Health, COND_None, REPNOTIFY_Always); DOREPLIFETIME_CONDITION_NOTIFY(UCharacterBaseAttribute, Health, COND_None, REPNOTIFY_Always);
DOREPLIFETIME_CONDITION_NOTIFY(UCharacterBaseAttribute, MaxHealth, COND_None, REPNOTIFY_Always); DOREPLIFETIME_CONDITION_NOTIFY(UCharacterBaseAttribute, MaxHealth, COND_None, REPNOTIFY_Always);
DOREPLIFETIME_CONDITION_NOTIFY(UCharacterBaseAttribute, Mana, COND_None, REPNOTIFY_Always); DOREPLIFETIME_CONDITION_NOTIFY(UCharacterBaseAttribute, Mana, COND_None, REPNOTIFY_Always);
DOREPLIFETIME_CONDITION_NOTIFY(UCharacterBaseAttribute, MaxMana, COND_None, REPNOTIFY_Always); DOREPLIFETIME_CONDITION_NOTIFY(UCharacterBaseAttribute, MaxMana, COND_None, REPNOTIFY_Always);
} }
void UCharacterBaseAttribute::OnRep_Team(const FGameplayAttributeData& OldTeam)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UCharacterBaseAttribute, Team, OldTeam);
}
void UCharacterBaseAttribute::OnRep_XP(const FGameplayAttributeData& OldXP)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UCharacterBaseAttribute, XP, OldXP);
}
void UCharacterBaseAttribute::OnRep_Health(const FGameplayAttributeData& OldHealth) void UCharacterBaseAttribute::OnRep_Health(const FGameplayAttributeData& OldHealth)
{ {
GAMEPLAYATTRIBUTE_REPNOTIFY(UCharacterBaseAttribute, Health, OldHealth); GAMEPLAYATTRIBUTE_REPNOTIFY(UCharacterBaseAttribute, Health, OldHealth);

View File

@@ -22,6 +22,14 @@ public:
//Replicated //Replicated
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override; virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
UPROPERTY(BlueprintReadonly, Category = "Team", ReplicatedUsing = OnRep_Team)
FGameplayAttributeData Team;
ATTRIBUTE_ACCESSORS(UCharacterBaseAttribute, Team)
UPROPERTY(BlueprintReadonly, Category = "XP", ReplicatedUsing = OnRep_XP)
FGameplayAttributeData XP;
ATTRIBUTE_ACCESSORS(UCharacterBaseAttribute, XP)
UPROPERTY(BlueprintReadonly, Category = "Health", ReplicatedUsing = OnRep_Health) UPROPERTY(BlueprintReadonly, Category = "Health", ReplicatedUsing = OnRep_Health)
FGameplayAttributeData Health; FGameplayAttributeData Health;
ATTRIBUTE_ACCESSORS(UCharacterBaseAttribute, Health) ATTRIBUTE_ACCESSORS(UCharacterBaseAttribute, Health)
@@ -38,6 +46,10 @@ public:
FGameplayAttributeData MaxMana; FGameplayAttributeData MaxMana;
ATTRIBUTE_ACCESSORS(UCharacterBaseAttribute, MaxMana) ATTRIBUTE_ACCESSORS(UCharacterBaseAttribute, MaxMana)
UFUNCTION()
virtual void OnRep_Team(const FGameplayAttributeData& OldTeam);
UFUNCTION()
virtual void OnRep_XP(const FGameplayAttributeData& OldXP);
UFUNCTION() UFUNCTION()
virtual void OnRep_Health(const FGameplayAttributeData& OldHealth); virtual void OnRep_Health(const FGameplayAttributeData& OldHealth);
UFUNCTION() UFUNCTION()

View File

@@ -2,8 +2,184 @@
#include "DefaultAbilitySystemComponent.h" #include "DefaultAbilitySystemComponent.h"
#include "InputAction.h"
#include "EnhancedInputComponent.h"
#include "AbilitySystemComponent.h"
#include "AbilitySystemGlobals.h"
namespace EnhancedInputAbilitySystem_Impl
{
constexpr int32 InvalidInputID = 0;
int32 IncrementingInputID = InvalidInputID;
static int32 GetNextInputID()
{
return ++IncrementingInputID;
}
}
void UDefaultAbilitySystemComponent::ReceiveDamage(UDefaultAbilitySystemComponent* SourceASC, float UnmitigatedDamage, float MitigatedDamage) void UDefaultAbilitySystemComponent::ReceiveDamage(UDefaultAbilitySystemComponent* SourceASC, float UnmitigatedDamage, float MitigatedDamage)
{ {
ReceivedDamage.ExecuteIfBound(SourceASC, UnmitigatedDamage, MitigatedDamage); ReceivedDamage.ExecuteIfBound(SourceASC, UnmitigatedDamage, MitigatedDamage);
} }
void UDefaultAbilitySystemComponent::SetInputBinding(UInputAction* InputAction, FGameplayAbilitySpecHandle AbilityHandle)
{
using namespace EnhancedInputAbilitySystem_Impl;
FGameplayAbilitySpec* BindingAbility = FindAbilitySpec(AbilityHandle);
FAbilityInputBinding* AbilityInputBinding = MappedAbilities.Find(InputAction);
if (AbilityInputBinding)
{
FGameplayAbilitySpec* OldBoundAbility = FindAbilitySpec(AbilityInputBinding->BoundAbilitiesStack.Top());
if (OldBoundAbility && OldBoundAbility->InputID == AbilityInputBinding->InputID)
{
OldBoundAbility->InputID = InvalidInputID;
}
}
else
{
AbilityInputBinding = &MappedAbilities.Add(InputAction);
AbilityInputBinding->InputID = GetNextInputID();
}
if (BindingAbility)
{
BindingAbility->InputID = AbilityInputBinding->InputID;
}
AbilityInputBinding->BoundAbilitiesStack.Push(AbilityHandle);
TryBindAbilityInput(InputAction, *AbilityInputBinding);
}
void UDefaultAbilitySystemComponent::ClearInputBinding(FGameplayAbilitySpecHandle AbilityHandle)
{
using namespace EnhancedInputAbilitySystem_Impl;
if (FGameplayAbilitySpec* FoundAbility = FindAbilitySpec(AbilityHandle))
{
// Find the mapping for this ability
auto MappedIterator = MappedAbilities.CreateIterator();
while (MappedIterator)
{
if (MappedIterator.Value().InputID == FoundAbility->InputID)
{
break;
}
++MappedIterator;
}
if (MappedIterator)
{
FAbilityInputBinding& AbilityInputBinding = MappedIterator.Value();
if (AbilityInputBinding.BoundAbilitiesStack.Remove(AbilityHandle) > 0)
{
if (AbilityInputBinding.BoundAbilitiesStack.Num() > 0)
{
FGameplayAbilitySpec* StackedAbility = FindAbilitySpec(AbilityInputBinding.BoundAbilitiesStack.Top());
if (StackedAbility && StackedAbility->InputID == 0)
{
StackedAbility->InputID = AbilityInputBinding.InputID;
}
}
else
{
// NOTE: This will invalidate the `AbilityInputBinding` ref above
RemoveEntry(MappedIterator.Key());
}
// DO NOT act on `AbilityInputBinding` after here (it could have been removed)
FoundAbility->InputID = InvalidInputID;
}
}
}
}
void UDefaultAbilitySystemComponent::ClearAbilityBindings(UInputAction* InputAction)
{
RemoveEntry(InputAction);
}
void UDefaultAbilitySystemComponent::OnAbilityInputPressed(UInputAction* InputAction)
{
using namespace EnhancedInputAbilitySystem_Impl;
FAbilityInputBinding* FoundBinding = MappedAbilities.Find(InputAction);
if (FoundBinding && ensure(FoundBinding->InputID != InvalidInputID))
{
AbilityLocalInputPressed(FoundBinding->InputID);
}
}
void UDefaultAbilitySystemComponent::OnAbilityInputReleased(UInputAction* InputAction)
{
using namespace EnhancedInputAbilitySystem_Impl;
FAbilityInputBinding* FoundBinding = MappedAbilities.Find(InputAction);
if (FoundBinding && ensure(FoundBinding->InputID != InvalidInputID))
{
AbilityLocalInputReleased(FoundBinding->InputID);
}
}
void UDefaultAbilitySystemComponent::RemoveEntry(UInputAction* InputAction)
{
if (FAbilityInputBinding* Bindings = MappedAbilities.Find(InputAction))
{
if (InputComponent)
{
InputComponent->RemoveBindingByHandle(Bindings->OnPressedHandle);
InputComponent->RemoveBindingByHandle(Bindings->OnReleasedHandle);
}
for (FGameplayAbilitySpecHandle AbilityHandle : Bindings->BoundAbilitiesStack)
{
using namespace EnhancedInputAbilitySystem_Impl;
FGameplayAbilitySpec* AbilitySpec = FindAbilitySpec(AbilityHandle);
if (AbilitySpec && AbilitySpec->InputID == Bindings->InputID)
{
AbilitySpec->InputID = InvalidInputID;
}
}
MappedAbilities.Remove(InputAction);
}
}
FGameplayAbilitySpec* UDefaultAbilitySystemComponent::FindAbilitySpec(FGameplayAbilitySpecHandle Handle)
{
FGameplayAbilitySpec* FoundAbility = nullptr;
FoundAbility = FindAbilitySpecFromHandle(Handle);
return FoundAbility;
}
void UDefaultAbilitySystemComponent::TryBindAbilityInput(UInputAction* InputAction, FAbilityInputBinding& AbilityInputBinding)
{
if (InputComponent)
{
// Pressed event
if (AbilityInputBinding.OnPressedHandle == 0)
{
AbilityInputBinding.OnPressedHandle = InputComponent->BindAction(InputAction, ETriggerEvent::Started, this, &UDefaultAbilitySystemComponent::OnAbilityInputPressed, InputAction).GetHandle();
}
// Released event
if (AbilityInputBinding.OnReleasedHandle == 0)
{
AbilityInputBinding.OnReleasedHandle = InputComponent->BindAction(InputAction, ETriggerEvent::Completed, this, &UDefaultAbilitySystemComponent::OnAbilityInputReleased, InputAction).GetHandle();
}
}
}
void UDefaultAbilitySystemComponent::BeginPlay() {
Super::BeginPlay();
AActor* Owner = GetOwner();
if (IsValid(Owner) && Owner->InputComponent) {
InputComponent = CastChecked<UEnhancedInputComponent>(Owner->InputComponent);
}
}

View File

@@ -4,17 +4,62 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "AbilitySystemComponent.h" #include "AbilitySystemComponent.h"
#include "GameplayAbilitySpec.h"
#include "EnhancedInputComponent.h"
#include "DefaultAbilitySystemComponent.generated.h" #include "DefaultAbilitySystemComponent.generated.h"
DECLARE_DYNAMIC_DELEGATE_ThreeParams(FReceivedDamageDelegate, UDefaultAbilitySystemComponent*, SourceASC, float, UnmitigatedDamage, float, MitigatedDamage); DECLARE_DYNAMIC_DELEGATE_ThreeParams(FReceivedDamageDelegate, UDefaultAbilitySystemComponent*, SourceASC, float, UnmitigatedDamage, float, MitigatedDamage);
UCLASS() class UInputAction;
USTRUCT()
struct FAbilityInputBinding
{
GENERATED_BODY()
int32 InputID = 0;
uint32 OnPressedHandle = 0;
uint32 OnReleasedHandle = 0;
TArray<FGameplayAbilitySpecHandle> BoundAbilitiesStack;
};
UCLASS(Blueprintable, BlueprintType, Category = "AbilityInput", meta = (BlueprintSpawnableComponent))
class PROMETHER_API UDefaultAbilitySystemComponent : public UAbilitySystemComponent class PROMETHER_API UDefaultAbilitySystemComponent : public UAbilitySystemComponent
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
bool CharacterAbilitiesGiven = false;
bool StartupEffectsApplied = false;
FReceivedDamageDelegate ReceivedDamage; FReceivedDamageDelegate ReceivedDamage;
virtual void ReceiveDamage(UDefaultAbilitySystemComponent* SourceASC, float UnmitigatedDamage, float MitigatedDamage); virtual void ReceiveDamage(UDefaultAbilitySystemComponent* SourceASC, float UnmitigatedDamage, float MitigatedDamage);
UFUNCTION(BlueprintCallable, Category = "Enhanced Input Abilities")
void SetInputBinding(UInputAction* InputAction, FGameplayAbilitySpecHandle AbilityHandle);
UFUNCTION(BlueprintCallable, Category = "Enhanced Input Abilities")
void ClearInputBinding(FGameplayAbilitySpecHandle AbilityHandle);
UFUNCTION(BlueprintCallable, Category = "Enhanced Input Abilities")
void ClearAbilityBindings(UInputAction* InputAction);
private:
void OnAbilityInputPressed(UInputAction* InputAction);
void OnAbilityInputReleased(UInputAction* InputAction);
void RemoveEntry(UInputAction* InputAction);
void TryBindAbilityInput(UInputAction* InputAction, FAbilityInputBinding& AbilityInputBinding);
FGameplayAbilitySpec* FindAbilitySpec(FGameplayAbilitySpecHandle Handle);
virtual void BeginPlay() override;
UPROPERTY(transient)
TMap<UInputAction*, FAbilityInputBinding> MappedAbilities;
UPROPERTY(transient)
UEnhancedInputComponent* InputComponent;
}; };

View File

@@ -143,8 +143,7 @@ FString ADeathmatch::InitNewPlayer(APlayerController* NewPlayerController, const
if (ADefaultPlayerState* NewPlayerState = NewPlayerController->GetPlayerState<ADefaultPlayerState>()) if (ADefaultPlayerState* NewPlayerState = NewPlayerController->GetPlayerState<ADefaultPlayerState>())
{ {
NewPlayerState->SetCharacterBPRef(GetGameInstance<UDefaultGameInstance>()->GetCharacterBPRef(Type)); NewPlayerState->SetCharacterBPRef(GetGameInstance<UDefaultGameInstance>()->GetCharacterBPRef(Type));
//NewPlayerState->InitPlayerStats(); //NewPlayerState->SetTeam(Team); TODO - change to tag base
NewPlayerState->SetTeam(Team);
} }
return ErrorMessage; return ErrorMessage;

View File

@@ -17,8 +17,11 @@ void UDefaultAnimBPBase::NativeUpdateAnimation(float DeltaSeconds)
{ {
if (ADefaultPlayerState* MyPlayerState = MyPawn->GetPlayerState<ADefaultPlayerState>()) if (ADefaultPlayerState* MyPlayerState = MyPawn->GetPlayerState<ADefaultPlayerState>())
{ {
// TODO - animation state update fix
/*
State = MyPlayerState->GetState(); State = MyPlayerState->GetState();
AttackType = MyPlayerState->GetAttackType(); AttackType = MyPlayerState->GetAttackType();
*/
/* /*
if (!GPlayInEditorID) if (!GPlayInEditorID)

View File

@@ -2,17 +2,34 @@
#include "DefaultPlayerCharacter.h" #include "DefaultPlayerCharacter.h"
#include "DefaultPlayerState.h" #include "GameFramework/CharacterMovementComponent.h"
#include "EnhancedInputSubsystems.h"
#include "EnhancedInputComponent.h"
#include "../DefaultAIController.h" #include "../DefaultAIController.h"
#include "Engine/DamageEvents.h" #include "Engine/DamageEvents.h"
#include "Kismet/GameplayStatics.h" #include "Kismet/GameplayStatics.h"
#include "Components/CapsuleComponent.h" #include "Components/CapsuleComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "Camera/CameraComponent.h"
#include "Promether/Promether.h"
#include "Promether/GAS/DefaultAbilitySystemComponent.h"
#include "Promether/GAS/AttributeSet/CharacterBaseAttribute.h"
ADefaultPlayerCharacter::ADefaultPlayerCharacter() ADefaultPlayerCharacter::ADefaultPlayerCharacter(const FObjectInitializer& ObjectInitializer) :
Super(ObjectInitializer.SetDefaultSubobjectClass<UCharacterMovementComponent>(ACharacter::CharacterMovementComponentName))
{ {
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it. // Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bCanEverTick = true;
SetCanBeDamaged(true); SetCanBeDamaged(true);
GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Visibility, ECollisionResponse::ECR_Overlap);
bAlwaysRelevant = true;
DeadTag = FGameplayTag::RequestGameplayTag(FName("State.Dead"));
TeamTag = FGameplayTag::RequestGameplayTag(FName("Team.Neutral"));
EffectRemoveOnDeathTag = FGameplayTag::RequestGameplayTag(FName("Status.Buff.Regenerate.Health"));
bUseControllerRotationYaw = false; bUseControllerRotationYaw = false;
AIControllerClass = ADefaultAIController::StaticClass(); AIControllerClass = ADefaultAIController::StaticClass();
@@ -29,12 +46,11 @@ ADefaultPlayerCharacter::ADefaultPlayerCharacter()
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera")); Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
Camera->SetupAttachment(CameraSpringArm, USpringArmComponent::SocketName); Camera->SetupAttachment(CameraSpringArm, USpringArmComponent::SocketName);
}
for (uint8 i = 0; i < (uint8)EStats::SIZE; i++)
DefaultStats.Add((EStats)i, 0.0f);
for (uint8 i = 0; i < (uint8)CooldownType::SIZE; i++) UAbilitySystemComponent* ADefaultPlayerCharacter::GetAbilitySystemComponent() const
CooldownDuration.Add((CooldownType)i, 0.0f); {
return AbilitySystemComponent.Get();
} }
void ADefaultPlayerCharacter::Tick(float DeltaTime) void ADefaultPlayerCharacter::Tick(float DeltaTime)
@@ -54,173 +70,221 @@ void ADefaultPlayerCharacter::Tick(float DeltaTime)
*/ */
} }
void ADefaultPlayerCharacter::Attack_Implementation() void ADefaultPlayerCharacter::PossessedBy(AController* NewController)
{ {
Client_Attack(); Super::PossessedBy(NewController);
BP_Attack();
}
void ADefaultPlayerCharacter::Client_Attack_Implementation()
{
BP_Attack();
}
float ADefaultPlayerCharacter::TakeDamage_Implementation(float DamageAmount, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, AActor* DamageCauser)
{
float ReturnValue = Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
ADefaultPlayerState* State = GetPlayerState<ADefaultPlayerState>();
if (!State) return ReturnValue;
if (!Cast<APawn>(DamageCauser)) return ReturnValue;
ADefaultPlayerState* AttackerState = Cast<APawn>(DamageCauser)->GetPlayerState<ADefaultPlayerState>();
if (!AttackerState) return ReturnValue;
float ADDamageMultiplier = 0;
float APDamageMultiplier = 0;
if (State->Stats[(uint8)EStats::Armor] >= 0)
ADDamageMultiplier = 100 / (100 + State->Stats[(uint8)EStats::Armor]);
else
ADDamageMultiplier = 2 - 100 / (100 - State->Stats[(uint8)EStats::Armor]);
if (State->Stats[(uint8)EStats::MagicResistance] >= 0)
APDamageMultiplier = 100 / (100 + State->Stats[(uint8)EStats::MagicResistance]);
else
APDamageMultiplier = 2 - 100 / (100 - State->Stats[(uint8)EStats::MagicResistance]);
UE_LOG(LogTemp, Warning, TEXT("%s : ADDamageMultiplier : %f CalculatedDamage : %f"), *DamageCauser->GetName(), ADDamageMultiplier, DamageAmount * ADDamageMultiplier);
UE_LOG(LogTemp, Warning, TEXT("%s : APDamageMultiplier : %f CalculatedDamage : %f"), *DamageCauser->GetName(), APDamageMultiplier, DamageAmount * APDamageMultiplier);
float UpdatedHealth = 0;
if (Cast<UBaseAttack>(DamageEvent.DamageTypeClass->GetDefaultObject()))
{
UE_LOG(LogTemp, Warning, TEXT("DamageType : BaseAttack"));
UpdatedHealth = State->Stats[(uint8)EStats::Health] - AttackerState->Stats[(uint8)EStats::AttackDamage] * ADDamageMultiplier;
}
else if (Cast<UAPDamage>(DamageEvent.DamageTypeClass->GetDefaultObject()))
{
UE_LOG(LogTemp, Warning, TEXT("DamageType : APDamage"));
UpdatedHealth = State->Stats[(uint8)EStats::Health] - AttackerState->Stats[(uint8)EStats::AbilityPower] * APDamageMultiplier;
}
if (UpdatedHealth < 0 || UpdatedHealth < 0.1 )
{
State->Stats[(uint8)EStats::Health] = 0;
Server_PerformDead();
Client_PerformDead();
}
else
{
State->Stats[(uint8)EStats::Health] = UpdatedHealth;
}
UE_LOG(LogTemp, Warning, TEXT("Current Health : %f"), State->Stats[(uint8)EStats::Health]);
return ReturnValue;
}
void ADefaultPlayerCharacter::Skill1_Implementation()
{
NetMulticast_Skill1();
}
void ADefaultPlayerCharacter::NetMulticast_Skill1_Implementation()
{
BP_Skill1();
}
void ADefaultPlayerCharacter::Skill2_Implementation()
{
NetMulticast_Skill2();
}
void ADefaultPlayerCharacter::NetMulticast_Skill2_Implementation()
{
BP_Skill2();
}
void ADefaultPlayerCharacter::Skill3_Implementation()
{
NetMulticast_Skill3();
}
void ADefaultPlayerCharacter::NetMulticast_Skill3_Implementation()
{
BP_Skill3();
}
void ADefaultPlayerCharacter::Skill4_Implementation()
{
NetMulticast_Skill4();
}
void ADefaultPlayerCharacter::NetMulticast_Skill4_Implementation()
{
BP_Skill4();
}
void ADefaultPlayerCharacter::Skill4_End_Implementation()
{
NetMulticast_Skill4_End();
}
void ADefaultPlayerCharacter::NetMulticast_Skill4_End_Implementation()
{
BP_Skill4_End();
}
void ADefaultPlayerCharacter::Skill5_Implementation()
{
NetMulticast_Skill5();
}
void ADefaultPlayerCharacter::NetMulticast_Skill5_Implementation()
{
BP_Skill5();
}
void ADefaultPlayerCharacter::Skill6_Implementation()
{
NetMulticast_Skill6();
}
void ADefaultPlayerCharacter::NetMulticast_Skill6_Implementation()
{
BP_Skill6();
}
void ADefaultPlayerCharacter::Skill7_Implementation()
{
NetMulticast_Skill7();
}
void ADefaultPlayerCharacter::NetMulticast_Skill7_Implementation()
{
BP_Skill7();
}
void ADefaultPlayerCharacter::PerformDead()
{
ADefaultPlayerState* State = GetPlayerState<ADefaultPlayerState>(); ADefaultPlayerState* State = GetPlayerState<ADefaultPlayerState>();
if (!State) return; if (!State) return;
State->SetState(ECharacterState::Dead); InitializeStartingValues(State);
GetCapsuleComponent()->SetGenerateOverlapEvents(false);
AddStartupEffects();
AddCharacterAbilities();
}
bool ADefaultPlayerCharacter::IsDead() const
{
return GetHealth() < 0.0f;
}
int32 ADefaultPlayerCharacter::GetAbilityLevel(EDefaultAbilityID AbilityID) const
{
return 0;
}
void ADefaultPlayerCharacter::RemoveCharacterAbilities()
{
if (GetLocalRole() != ROLE_Authority || !AbilitySystemComponent.IsValid() || !AbilitySystemComponent->CharacterAbilitiesGiven)
return;
TArray<FGameplayAbilitySpecHandle> AbilitiesToRemove;
for (const FGameplayAbilitySpec& Spec : AbilitySystemComponent->GetActivatableAbilities())
{
if ((Spec.SourceObject == this) && CharacterAbilities.Contains(Spec.Ability->GetClass()))
{
AbilitiesToRemove.Add(Spec.Handle);
}
}
for (int32 i = 0; i < AbilitiesToRemove.Num(); i++)
AbilitySystemComponent->ClearAbility(AbilitiesToRemove[i]);
AbilitySystemComponent->CharacterAbilitiesGiven = false;
}
void ADefaultPlayerCharacter::beginDead()
{
RemoveCharacterAbilities();
GetCapsuleComponent()->SetCollisionEnabled(ECollisionEnabled::NoCollision); GetCapsuleComponent()->SetCollisionEnabled(ECollisionEnabled::NoCollision);
GetCharacterMovement()->Velocity = FVector(0);
//OnCharacterDied.ExecuteIfBound(this);
OnCharacterDied.Broadcast(this);
if (AbilitySystemComponent.IsValid())
{
AbilitySystemComponent->CancelAbilities();
FGameplayTagContainer EffectTagsToRemove;
EffectTagsToRemove.AddTag(EffectRemoveOnDeathTag);
int32 NumEffectsRemoved = AbilitySystemComponent->RemoveActiveEffectsWithTags(EffectTagsToRemove);
AbilitySystemComponent->AddLooseGameplayTag(DeadTag);
}
} }
void ADefaultPlayerCharacter::Server_PerformDead_Implementation() void ADefaultPlayerCharacter::FinishDying()
{ {
PerformDead();
} }
void ADefaultPlayerCharacter::Client_PerformDead_Implementation() float ADefaultPlayerCharacter::GetXP() const
{ {
PerformDead(); if (Attribute.IsValid())
return Attribute->GetXP();
return 0.0f;
}
float ADefaultPlayerCharacter::GetCalculatedLevel() const
{
if (Attribute.IsValid())
return Attribute->GetXP() / 100.0f; //fix later
return 0.0f;
}
float ADefaultPlayerCharacter::GetHealth() const
{
if (Attribute.IsValid())
return Attribute->GetHealth();
return 0.0f;
}
float ADefaultPlayerCharacter::GetMaxHealth() const
{
if (Attribute.IsValid())
return Attribute->GetMaxHealth();
return 0.0f;
}
float ADefaultPlayerCharacter::GetMana() const
{
if (Attribute.IsValid())
return Attribute->GetMana();
return 0.0f;
}
float ADefaultPlayerCharacter::GetMaxMana() const
{
if (Attribute.IsValid())
return Attribute->GetMaxMana();
return 0.0f;
}
void ADefaultPlayerCharacter::BeginPlay()
{
Super::BeginPlay();
}
void ADefaultPlayerCharacter::AddCharacterAbilities()
{
if (GetLocalRole() != ROLE_Authority || !AbilitySystemComponent.IsValid() || AbilitySystemComponent->CharacterAbilitiesGiven)
return;
for (TSubclassOf<UCharacterGameplayAbility>& StartupAbility : CharacterAbilities)
{
AbilitySystemComponent->GiveAbility( FGameplayAbilitySpec (
StartupAbility,
GetAbilityLevel(StartupAbility.GetDefaultObject()->AbilityID),
static_cast<int32>(StartupAbility.GetDefaultObject()->AbilityInputID),
this
));
}
AbilitySystemComponent->CharacterAbilitiesGiven = true;
}
void ADefaultPlayerCharacter::InitializeAttributes()
{
if (!AbilitySystemComponent.IsValid())
return;
if (!DefaultAttributes)
{
UE_LOG(LogTemp, Error, TEXT("%s() Missing DefaultAttributes for %s. Please fill in the character's Blueprint."), *FString(__FUNCTION__), *GetName());
return;
}
FGameplayEffectContextHandle EffectContext = AbilitySystemComponent->MakeEffectContext();
EffectContext.AddSourceObject(this);
FGameplayEffectSpecHandle NewHandle = AbilitySystemComponent->MakeOutgoingSpec(DefaultAttributes, GetCalculatedLevel(), EffectContext);
if (NewHandle.IsValid())
{
FActiveGameplayEffectHandle ActiveGEHandle = AbilitySystemComponent->ApplyGameplayEffectSpecToTarget(*NewHandle.Data.Get(), AbilitySystemComponent.Get());
}
}
void ADefaultPlayerCharacter::AddStartupEffects()
{
if (GetLocalRole() != ROLE_Authority || !AbilitySystemComponent.IsValid() || AbilitySystemComponent->StartupEffectsApplied)
return;
FGameplayEffectContextHandle EffectContext = AbilitySystemComponent->MakeEffectContext();
EffectContext.AddSourceObject(this);
for (TSubclassOf<UGameplayEffect> GameplayEffects : StartupEffects)
{
FGameplayEffectSpecHandle NewHandle = AbilitySystemComponent->MakeOutgoingSpec(GameplayEffects, GetCalculatedLevel(), EffectContext);
if (NewHandle.IsValid())
{
FActiveGameplayEffectHandle ActiveGEHandle = AbilitySystemComponent->ApplyGameplayEffectSpecToTarget(*NewHandle.Data.Get(), AbilitySystemComponent.Get());
}
}
AbilitySystemComponent->StartupEffectsApplied = true;
}
void ADefaultPlayerCharacter::InitializeStartingValues(ADefaultPlayerState* State)
{
if (!State) return;
AbilitySystemComponent = Cast<UDefaultAbilitySystemComponent>(State->GetAbilitySystemComponent());
State->GetAbilitySystemComponent()->InitAbilityActorInfo(State, this);
Attribute = State->GetAttributeSet();
AbilitySystemComponent->SetTagMapCount(DeadTag, 0);
SetHealth(GetMaxHealth());
SetMana(GetMaxMana());
}
void ADefaultPlayerCharacter::SetHealth(float Health)
{
if (Attribute.IsValid())
Attribute->SetHealth(Health);
}
void ADefaultPlayerCharacter::SetMana(float Mana)
{
if (Attribute.IsValid())
Attribute->SetHealth(Mana);
}
void ADefaultPlayerCharacter::OnRep_PlayerState()
{
Super::OnRep_PlayerState();
ADefaultPlayerState* State = GetPlayerState<ADefaultPlayerState>();
if (!State) return;
InitializeStartingValues(State);
InitializeAttributes();
} }

View File

@@ -4,119 +4,93 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "GameFramework/Character.h" #include "GameFramework/Character.h"
#include "GameFramework/SpringArmComponent.h" #include "GameFramework/CharacterMovementComponent.h"
#include "Camera/CameraComponent.h" #include "AbilitySystemInterface.h"
#include "GameplayTagContainer.h"
#include "../PrometherEnum.h" #include "DefaultPlayerState.h"
#include "../GAS/DefaultAbilitySystemComponent.h"
#include "../GAS/AttributeSet/CharacterBaseAttribute.h"
#include "../GAS/Abilities/CharacterGameplayAbility.h"
#include "DefaultPlayerCharacter.generated.h" #include "DefaultPlayerCharacter.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCharacterDiedDelegate, ADefaultPlayerCharacter*, Character);
UCLASS() UCLASS()
class PROMETHER_API ADefaultPlayerCharacter : public ACharacter class PROMETHER_API ADefaultPlayerCharacter : public ACharacter, public IAbilitySystemInterface
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
// Sets default values for this character's properties // Sets default values for this character's properties
ADefaultPlayerCharacter(); ADefaultPlayerCharacter(const class FObjectInitializer& ObjectInitializer);
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
virtual void Tick(float DeltaTime) override; virtual void Tick(float DeltaTime) override;
UFUNCTION(BlueprintCallable, Server, Reliable) virtual void PossessedBy(AController* NewController) override;
void Attack();
//Override me
UFUNCTION(BlueprintImplementableEvent)
void BP_Attack();
UFUNCTION(Client, Reliable)
void Client_Attack();
UFUNCTION(BlueprintNativeEvent) UPROPERTY(BlueprintAssignable, Category = "Character")
float TakeDamage( float Damage, FCharacterDiedDelegate OnCharacterDied;
struct FDamageEvent const& DamageEvent,
AController* EventInstigator,
AActor* DamageCauser ) override;
UFUNCTION(BlueprintCallable, Category = "Character")
virtual bool IsDead() const;
void PerformDead(); UFUNCTION(BlueprintCallable, Category = "Character")
virtual int32 GetAbilityLevel(EDefaultAbilityID AbilityID) const;
UFUNCTION(Client, Reliable) virtual void RemoveCharacterAbilities();
void Client_PerformDead(); virtual void beginDead();
UFUNCTION(Server, Reliable) UFUNCTION(BlueprintCallable, Category = "Character")
void Server_PerformDead(); virtual void FinishDying();
UFUNCTION(BlueprintCallable, Category = "Character|Attribute")
float GetXP() const;
UFUNCTION(BlueprintCallable, Category = "Character|Attribute")
float GetCalculatedLevel() const;
UFUNCTION(BlueprintCallable, Category = "Character|Attribute")
float GetHealth() const;
UFUNCTION(BlueprintCallable, Category = "Character|Attribute")
float GetMaxHealth() const;
UFUNCTION(BlueprintCallable, Category = "Character|Attribute")
float GetMana() const;
UFUNCTION(BlueprintCallable, Category = "Character|Attribute")
float GetMaxMana() const;
UFUNCTION(BlueprintCallable, Server, Reliable)
void Skill1();
//Override me
UFUNCTION(BlueprintImplementableEvent)
void BP_Skill1();
UFUNCTION(NetMulticast, Reliable)
void NetMulticast_Skill1();
UFUNCTION(BlueprintCallable, Server, Reliable)
void Skill2();
//Override me
UFUNCTION(BlueprintImplementableEvent)
void BP_Skill2();
UFUNCTION(NetMulticast, Reliable)
void NetMulticast_Skill2();
UFUNCTION(BlueprintCallable, Server, Reliable)
void Skill3();
//Override me
UFUNCTION(BlueprintImplementableEvent)
void BP_Skill3();
UFUNCTION(NetMulticast, Reliable)
void NetMulticast_Skill3();
UFUNCTION(BlueprintCallable, Server, Reliable)
void Skill4();
//Override me
UFUNCTION(BlueprintImplementableEvent)
void BP_Skill4();
UFUNCTION(NetMulticast, Reliable)
void NetMulticast_Skill4();
UFUNCTION(BlueprintCallable, Server, Reliable)
void Skill4_End();
//Override me
UFUNCTION(BlueprintImplementableEvent)
void BP_Skill4_End();
UFUNCTION(NetMulticast, Reliable)
void NetMulticast_Skill4_End();
UFUNCTION(BlueprintCallable, Server, Reliable)
void Skill5();
//Override me
UFUNCTION(BlueprintImplementableEvent)
void BP_Skill5();
UFUNCTION(NetMulticast, Reliable)
void NetMulticast_Skill5();
UFUNCTION(BlueprintCallable, Server, Reliable)
void Skill6();
//Override me
UFUNCTION(BlueprintImplementableEvent)
void BP_Skill6();
UFUNCTION(NetMulticast, Reliable)
void NetMulticast_Skill6();
UFUNCTION(BlueprintCallable, Server, Reliable)
void Skill7();
//Override me
UFUNCTION(BlueprintImplementableEvent)
void BP_Skill7();
UFUNCTION(NetMulticast, Reliable)
void NetMulticast_Skill7();
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats")
TMap<EStats, float> DefaultStats;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats")
TMap<CooldownType, float> CooldownDuration;
protected: protected:
virtual void BeginPlay() override;
TWeakObjectPtr<class UDefaultAbilitySystemComponent> AbilitySystemComponent;
TWeakObjectPtr<class UCharacterBaseAttribute> Attribute;
FGameplayTag DeadTag;
FGameplayTag TeamTag;
FGameplayTag EffectRemoveOnDeathTag;
UPROPERTY(BlueprintReadOnly, EditAnywhere, category = "Abilities")
TArray<TSubclassOf<UCharacterGameplayAbility>> CharacterAbilities;
UPROPERTY(BlueprintReadOnly, EditAnywhere, category = "Abilities")
TSubclassOf<UGameplayEffect> DefaultAttributes;
UPROPERTY(BlueprintReadOnly, EditAnywhere, category = "Abilities")
TArray<TSubclassOf<UGameplayEffect>> StartupEffects;
virtual void AddCharacterAbilities();
virtual void InitializeAttributes();
virtual void AddStartupEffects();
void InitializeStartingValues(ADefaultPlayerState* State);
virtual void SetHealth(float Health);
virtual void SetMana(float Mana);
virtual void OnRep_PlayerState() override;
bool ASCInputBound = false;
UPROPERTY(EditAnywhere) UPROPERTY(EditAnywhere)
USpringArmComponent* CameraSpringArm; class USpringArmComponent* CameraSpringArm;
UPROPERTY(EditAnywhere) UPROPERTY(EditAnywhere)
UCameraComponent* Camera; class UCameraComponent* Camera;
}; };

View File

@@ -11,8 +11,12 @@
#include "Navigation/PathFollowingComponent.h" #include "Navigation/PathFollowingComponent.h"
#include "AIController.h" #include "AIController.h"
#include "../DefaultGameInstance.h"
#include "DefaultPlayerState.h" #include "DefaultPlayerState.h"
#include "DefaultPlayerCharacter.h"
#include "DefaultPlayerCamera.h" #include "DefaultPlayerCamera.h"
#include "../Promether.h"
@@ -26,13 +30,10 @@ void ADefaultPlayerController::BeginPlay()
UEnhancedInputLocalPlayerSubsystem* InputSystem = LocalPlayer->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(); UEnhancedInputLocalPlayerSubsystem* InputSystem = LocalPlayer->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>();
if (!InputSystem) return; if (!InputSystem) return;
if (PlayerInputMapping.IsNull()) UDefaultGameInstance* Instance = GetGameInstance<UDefaultGameInstance>();
{ if (!Instance) return;
UE_LOG(LogTemp, Error, TEXT("AddMappingContext Failed"));
return;
}
InputSystem->AddMappingContext(PlayerInputMapping.LoadSynchronous(), 0); InputSystem->AddMappingContext(Instance->PlayerInputMapping.LoadSynchronous(), 0);
this->bShowMouseCursor = true; this->bShowMouseCursor = true;
} }
@@ -42,7 +43,10 @@ void ADefaultPlayerController::OnPossess(APawn* aPawn)
Server_SpawnPlayerCamera(); Server_SpawnPlayerCamera();
AActor *PlayerCamera = GetPlayerState<ADefaultPlayerState>()->GetPlayerCamera(); ADefaultPlayerState* State = GetPlayerState<ADefaultPlayerState>();
if (!State) return;
AActor *PlayerCamera = State->GetPlayerCamera();
if (!PlayerCamera) if (!PlayerCamera)
{ {
UE_LOG(LogTemp, Error, TEXT("GetPlayerCamera Failed.")); UE_LOG(LogTemp, Error, TEXT("GetPlayerCamera Failed."));
@@ -51,7 +55,12 @@ void ADefaultPlayerController::OnPossess(APawn* aPawn)
SetViewTarget(PlayerCamera); SetViewTarget(PlayerCamera);
UE_LOG(LogTemp, Warning, TEXT("SetViewTarget Success : %s"), *GetPlayerState<ADefaultPlayerState>()->GetPlayerCamera()->GetName()); UE_LOG(LogTemp, Warning, TEXT("SetViewTarget Success : %s"), *State->GetPlayerCamera()->GetName());
State->GetAbilitySystemComponent()->InitAbilityActorInfo(State, aPawn);
/*
*
* This was Stat initialize code. Depricated.
ADefaultPlayerCharacter* ControlledPawn = GetPawn<ADefaultPlayerCharacter>(); ADefaultPlayerCharacter* ControlledPawn = GetPawn<ADefaultPlayerCharacter>();
if (!ControlledPawn) return; if (!ControlledPawn) return;
@@ -66,6 +75,7 @@ void ADefaultPlayerController::OnPossess(APawn* aPawn)
ControlledPawn->CooldownDuration.GenerateValueArray(CooldownDurationValue); ControlledPawn->CooldownDuration.GenerateValueArray(CooldownDurationValue);
MyPlayerState->InitPlayerStats(DefaultStatsValue, CooldownDurationValue); MyPlayerState->InitPlayerStats(DefaultStatsValue, CooldownDurationValue);
*/
} }
void ADefaultPlayerController::OnUnPossess() void ADefaultPlayerController::OnUnPossess()
@@ -134,96 +144,11 @@ ADefaultPlayerController::ADefaultPlayerController()
AutoManageActiveCameraTarget(false); AutoManageActiveCameraTarget(false);
DefaultMouseCursor = EMouseCursor::Crosshairs; DefaultMouseCursor = EMouseCursor::Crosshairs;
static ConstructorHelpers::FObjectFinder<UInputMappingContext>
DEFAULT_CONTEXT(TEXT("/Script/EnhancedInput.InputMappingContext'/Game/InputActions/InputMappingContext.InputMappingContext'"));
if (!DEFAULT_CONTEXT.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("DEFAULT_CONTEXT load failed."));
return;
}
static ConstructorHelpers::FObjectFinder<UInputAction>
IA_SKILL1(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/Skill1.Skill1'")),
IA_SKILL2(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/Skill2.Skill2'")),
IA_SKILL3(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/Skill3.Skill3'")),
IA_SKILL4(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/Skill4.Skill4'")),
IA_RUNESPELL1(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/RuneSpell1.RuneSpell1'")),
IA_RUNESPELL2(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/RuneSpell2.RuneSpell2'")),
IA_WARD(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/Ward.Ward'")),
IA_BOMB(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/Bomb.Bomb'")),
IA_OBJECTSELECT(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/ObjectSelect.ObjectSelect'")),
IA_MOVE(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/Move.Move'"));
if (!IA_SKILL1.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_SKILL1 load failed."));
return;
}
if (!IA_SKILL2.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_SKILL2 load failed."));
return;
}
if (!IA_SKILL3.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_SKILL3 load failed."));
return;
}
if (!IA_SKILL4.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_ULTIMATESKILL load failed."));
return;
}
if (!IA_RUNESPELL1.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_RUNESPELL1 load failed."));
return;
}
if (!IA_RUNESPELL2.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_RUNESPELL2 load failed."));
return;
}
if (!IA_WARD.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_WARD load failed."));
return;
}
if (!IA_BOMB.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_BOMB load failed."));
return;
}
if (!IA_OBJECTSELECT.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_OBJECTSELECT load failed."));
return;
}
if (!IA_MOVE.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_MOVE load failed."));
return;
}
PlayerInputMapping = DEFAULT_CONTEXT.Object;
Skill1Action = IA_SKILL1.Object;
Skill2Action = IA_SKILL2.Object;
Skill3Action = IA_SKILL3.Object;
Skill4Action = IA_SKILL4.Object;
RuneSpell1Action = IA_RUNESPELL1.Object;
RuneSpell2Action = IA_RUNESPELL2.Object;
WardAction = IA_WARD.Object;
BombAction = IA_BOMB.Object;
ObjectSelectAction = IA_OBJECTSELECT.Object;
MoveAction = IA_MOVE.Object;
} }
void ADefaultPlayerController::Tick(float DeltaTime) void ADefaultPlayerController::Tick(float DeltaTime)
{ {
Super::Tick(DeltaTime); Super::Tick(DeltaTime);
} }
void ADefaultPlayerController::SetupInputComponent() void ADefaultPlayerController::SetupInputComponent()
@@ -233,174 +158,35 @@ void ADefaultPlayerController::SetupInputComponent()
UEnhancedInputComponent* EnhancedInputComponent = Cast<UEnhancedInputComponent>(InputComponent); UEnhancedInputComponent* EnhancedInputComponent = Cast<UEnhancedInputComponent>(InputComponent);
if (!EnhancedInputComponent) return; if (!EnhancedInputComponent) return;
EnhancedInputComponent->BindAction(Skill1Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Skill1); UDefaultGameInstance* Instance = GetGameInstance<UDefaultGameInstance>();
EnhancedInputComponent->BindAction(Skill2Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Skill2); if (!Instance) return;
EnhancedInputComponent->BindAction(Skill3Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Skill3);
EnhancedInputComponent->BindAction(Skill4Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Skill4Triggered); EnhancedInputComponent->BindAction(Instance->RuneSpell1Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::RuneSpell1);
EnhancedInputComponent->BindAction(Skill4Action.Get(), ETriggerEvent::Completed, this, &ADefaultPlayerController::Skill4Completed); EnhancedInputComponent->BindAction(Instance->RuneSpell2Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::RuneSpell2);
EnhancedInputComponent->BindAction(RuneSpell1Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::RuneSpell1); EnhancedInputComponent->BindAction(Instance->WardAction.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Ward);
EnhancedInputComponent->BindAction(RuneSpell2Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::RuneSpell2); EnhancedInputComponent->BindAction(Instance->BombAction.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Bomb);
EnhancedInputComponent->BindAction(WardAction.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Ward); EnhancedInputComponent->BindAction(Instance->ObjectSelectAction.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::ObjectSelect);
EnhancedInputComponent->BindAction(BombAction.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Bomb); EnhancedInputComponent->BindAction(Instance->MoveAction.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Move);
EnhancedInputComponent->BindAction(ObjectSelectAction.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::ObjectSelect);
EnhancedInputComponent->BindAction(MoveAction.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Move);
}
void ADefaultPlayerController::Skill1()
{
if (!GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skillusable] == 0)
return;
if (!(GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Mana] >= GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skill1Cost]))
return;
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Mana] -= GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skill1Cost];
EndAttack();
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Attackable] = 1;
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skillusable] = 1;
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Movable] = 1;
ACharacter* HitObject = nullptr;
FVector Location = GetPawn()->GetActorLocation();
Location.Z = 0;
Server_StopMove();
Multicast_StopMove();
Multicast_SetRotation(GetMouseHitLocation());
Server_SetRotation(GetMouseHitLocation());
UE_LOG(LogTemp, Warning, TEXT("Skill1"));
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Attack);
GetPlayerState<ADefaultPlayerState>()->SetAttackType(CooldownType::Skill1);
}
void ADefaultPlayerController::Skill2()
{
if (!GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skillusable] == 0)
return;
if (!(GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Mana] >= GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skill2Cost]))
return;
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Mana] -= GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skill2Cost];
EndAttack();
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Attackable] = 1;
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skillusable] = 1;
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Movable] = 1;
ACharacter* HitObject = nullptr;
FVector Location = GetPawn()->GetActorLocation();
Location.Z = 0;
Server_StopMove();
Multicast_StopMove();
Multicast_SetRotation(GetMouseHitLocation());
Server_SetRotation(GetMouseHitLocation());
UE_LOG(LogTemp, Warning, TEXT("Skill2"));
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Attack);
GetPlayerState<ADefaultPlayerState>()->SetAttackType(CooldownType::Skill2);
}
void ADefaultPlayerController::Skill3()
{
if (!GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skillusable] == 0)
return;
if (!(GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Mana] >= GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skill3Cost]))
return;
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Mana] -= GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skill3Cost];
EndAttack();
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Attackable] = 1;
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skillusable] = 1;
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Movable] = 1;
ACharacter* HitObject = nullptr;
FVector Location = GetPawn()->GetActorLocation();
Location.Z = 0;
Server_StopMove();
Multicast_StopMove();
Multicast_SetRotation(GetMouseHitLocation());
Server_SetRotation(GetMouseHitLocation());
UE_LOG(LogTemp, Warning, TEXT("Skill3"));
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Attack);
GetPlayerState<ADefaultPlayerState>()->SetAttackType(CooldownType::Skill3);
}
void ADefaultPlayerController::Skill4Triggered()
{
if (GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::charging] == 1)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1(false)<29><> <20><>
{
if (!GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skillusable] == 0)
return;
if (!(GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Mana] >= GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skill4Cost]))
return;
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Mana] -= GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skill4Cost];
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::charging] = 0;// <20><>ġ<EFBFBD><C4A1> <20><><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD> charge<67><65> true(0)<29><> <20><><EFBFBD><EFBFBD>
}
else if (GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::charging] == 2) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2(never)<29><> <20><>
{
if (!GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skillusable] == 0)
return;
if (!(GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Mana] >= GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skill4Cost]))
return;
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Mana] -= GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skill4Cost]; // <20>׳<EFBFBD> <20><>ġ <20><><EFBFBD><20><><EFBFBD><EFBFBD>
}
EndAttack();
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Attackable] = 1;
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Skillusable] = 1;
GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Movable] = 1;
ACharacter* HitObject = nullptr;
FVector Location = GetPawn()->GetActorLocation();
Location.Z = 0;
Server_StopMove();
Multicast_StopMove();
Multicast_SetRotation(GetMouseHitLocation());
Server_SetRotation(GetMouseHitLocation());
UE_LOG(LogTemp, Warning, TEXT("Skill4 Triggered"));
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Attack);
GetPlayerState<ADefaultPlayerState>()->SetAttackType(CooldownType::Skill4Triggered);
}
void ADefaultPlayerController::Skill4Completed()
{
UE_LOG(LogTemp, Warning, TEXT("Skill4 Completed"));
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Attack);
GetPlayerState<ADefaultPlayerState>()->SetAttackType(CooldownType::Skill4Comlpleted);
} }
void ADefaultPlayerController::RuneSpell1() void ADefaultPlayerController::RuneSpell1()
{ {
UE_LOG(LogTemp, Warning, TEXT("RuneSpell1")); UE_LOG(LogTemp, Warning, TEXT("RuneSpell1"));
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Attack);
GetPlayerState<ADefaultPlayerState>()->SetAttackType(CooldownType::RuneSpell1);
} }
void ADefaultPlayerController::RuneSpell2() void ADefaultPlayerController::RuneSpell2()
{ {
UE_LOG(LogTemp, Warning, TEXT("RuneSpell2")); UE_LOG(LogTemp, Warning, TEXT("RuneSpell2"));
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Attack);
GetPlayerState<ADefaultPlayerState>()->SetAttackType(CooldownType::RuneSpell2);
} }
void ADefaultPlayerController::Ward() void ADefaultPlayerController::Ward()
{ {
UE_LOG(LogTemp, Warning, TEXT("Ward")); UE_LOG(LogTemp, Warning, TEXT("Ward"));
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Attack);
GetPlayerState<ADefaultPlayerState>()->SetAttackType(CooldownType::Ward);
} }
void ADefaultPlayerController::Bomb() void ADefaultPlayerController::Bomb()
{ {
UE_LOG(LogTemp, Warning, TEXT("Bomb")); UE_LOG(LogTemp, Warning, TEXT("Bomb"));
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Attack);
GetPlayerState<ADefaultPlayerState>()->SetAttackType(CooldownType::Bomb);
} }
void ADefaultPlayerController::ObjectSelect() void ADefaultPlayerController::ObjectSelect()
@@ -448,15 +234,18 @@ void ADefaultPlayerController::Move()
if (GetPlayerState<ADefaultPlayerState>()->GetCurrentAttackTarget() != GetPawn<AActor>() && if (GetPlayerState<ADefaultPlayerState>()->GetCurrentAttackTarget() != GetPawn<AActor>() &&
Cast<ADefaultPlayerCharacter>(GetPlayerState<ADefaultPlayerState>()->GetCurrentAttackTarget())) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƴϰ<C6B4> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>(<28><><EFBFBD>̵<EFBFBD> <20>Ʊ<EFBFBD><C6B1>̵<EFBFBD>)<29><> <20><> Cast<ADefaultPlayerCharacter>(GetPlayerState<ADefaultPlayerState>()->GetCurrentAttackTarget())) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƴϰ<C6B4> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>(<28><><EFBFBD>̵<EFBFBD> <20>Ʊ<EFBFBD><C6B1>̵<EFBFBD>)<29><> <20><>
{ {
if (!GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Attackable] == 0) return; //if (!GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Attackable] == 0) return;
BeginAttack(); //HitObject<63><74> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BeginAttack <20><><EFBFBD><EFBFBD> BeginAttack(); //HitObject<63><74> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BeginAttack <20><><EFBFBD><EFBFBD>
} }
else else
{ {
if (!GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Movable] == 0) //if (!GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Movable] == 0)
return; // return;
FVector Destination = GetMouseHitLocation(); FVector Destination = GetMouseHitLocation();
// TODO - animation state update fix
/*
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Moving); GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Moving);
*/
SimpleMoveToLocation(this, Destination); SimpleMoveToLocation(this, Destination);
this->MoveToLocation(Destination); this->MoveToLocation(Destination);
} }
@@ -632,7 +421,10 @@ void ADefaultPlayerController::OnMoveCompleted(FAIRequestID RequestID, const FPa
UE_LOG(LogTemp, Warning, TEXT("Client%d MoveCompleted"), GPlayInEditorID); UE_LOG(LogTemp, Warning, TEXT("Client%d MoveCompleted"), GPlayInEditorID);
} }
// TODO - animation state update fix
/*
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Idle); GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Idle);
*/
} }
void ADefaultPlayerController::BeginAttack() void ADefaultPlayerController::BeginAttack()
@@ -652,19 +444,19 @@ void ADefaultPlayerController::RepeatedAttack()
void ADefaultPlayerController::Attack() void ADefaultPlayerController::Attack()
{ {
if (!GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Attackable] == 0) //if (!GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats::Attackable] == 0)
return; // return;
float MinDistance = GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats:: AttackRange]; //float MinDistance = GetPlayerState<ADefaultPlayerState>()->Stats[(uint8)EStats:: AttackRange];
if (!GetPlayerState<ADefaultPlayerState>()->GetCurrentAttackTarget()) return; if (!GetPlayerState<ADefaultPlayerState>()->GetCurrentAttackTarget()) return;
FVector Destination = GetPlayerState<ADefaultPlayerState>()->GetCurrentAttackTarget()->GetActorLocation(); // HitObject<63><74> <20><>ġ<EFBFBD><C4A1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> FVector Destination = GetPlayerState<ADefaultPlayerState>()->GetCurrentAttackTarget()->GetActorLocation(); // HitObject<63><74> <20><>ġ<EFBFBD><C4A1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
if (FVector::Dist(Destination, GetPawn()->GetActorLocation()) <= MinDistance) if (/*FVector::Dist(Destination, GetPawn()->GetActorLocation()) <= MinDistance*/ true)
{ {
if ((GetPlayerState<ADefaultPlayerState>()->CooldownDuration[(uint8)CooldownType::Attack] != 0)) //if ((GetPlayerState<ADefaultPlayerState>()->CooldownDuration[(uint8)CooldownType::Attack] != 0))
return; // return;
FVector Location = GetPawn()->GetActorLocation(); FVector Location = GetPawn()->GetActorLocation();
Location.X = 0; Location.X = 0;
@@ -675,13 +467,19 @@ void ADefaultPlayerController::Attack()
Multicast_SetRotation(Destination); Multicast_SetRotation(Destination);
Server_SetRotation(Destination); Server_SetRotation(Destination);
// TODO - animation state update fix
/*
UE_LOG(LogTemp, Warning, TEXT("Attack")); UE_LOG(LogTemp, Warning, TEXT("Attack"));
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Attack); GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Attack);
GetPlayerState<ADefaultPlayerState>()->SetAttackType(CooldownType::Attack); GetPlayerState<ADefaultPlayerState>()->SetAttackType(CooldownType::Attack);
*/
} }
else else
{ {
// TODO - animation state update fix
/*
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Moving); GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Moving);
*/
SimpleMoveToLocation(this, Destination); SimpleMoveToLocation(this, Destination);
this->MoveToLocation(Destination); this->MoveToLocation(Destination);
} }

View File

@@ -30,12 +30,7 @@ public:
virtual void Tick(float DeltaTime) override; virtual void Tick(float DeltaTime) override;
virtual void SetupInputComponent() override; virtual void SetupInputComponent() override;
void Skill1();
void Skill2();
void Skill3();
void Skill4Triggered();
void Skill4Completed();
void RuneSpell1(); void RuneSpell1();
void RuneSpell2(); void RuneSpell2();
void Ward(); void Ward();
@@ -78,29 +73,4 @@ public:
float MouseClickInterval; float MouseClickInterval;
FTimerHandle TimerHandle; FTimerHandle TimerHandle;
private:
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputMappingContext> PlayerInputMapping;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> Skill1Action;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> Skill2Action;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> Skill3Action;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> Skill4Action;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> RuneSpell1Action;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> RuneSpell2Action;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> WardAction;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> BombAction;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> ObjectSelectAction;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> MoveAction;
}; };

View File

@@ -6,8 +6,6 @@
ADefaultPlayerState::ADefaultPlayerState() ADefaultPlayerState::ADefaultPlayerState()
{ {
CharacterBPRef = nullptr; CharacterBPRef = nullptr;
Team = TeamType::Null;
State = ECharacterState::Idle;
AbilitySystemComponent = CreateDefaultSubobject<UDefaultAbilitySystemComponent>(TEXT("AbilitySystemComponent")); AbilitySystemComponent = CreateDefaultSubobject<UDefaultAbilitySystemComponent>(TEXT("AbilitySystemComponent"));
AbilitySystemComponent->SetIsReplicated(true); AbilitySystemComponent->SetIsReplicated(true);
@@ -18,7 +16,8 @@ ADefaultPlayerState::ADefaultPlayerState()
NetUpdateFrequency = 100.0f; NetUpdateFrequency = 100.0f;
DeadTag = FGameplayTag::RequestGameplayTag(FName("State.Dead")); DeadTag = FGameplayTag::RequestGameplayTag(FName("State.Dead"));
EffectTag = FGameplayTag::RequestGameplayTag(FName("State.EffectTag")); TeamTag = FGameplayTag::RequestGameplayTag(FName("Team.Neutral"));;
EffectTag = FGameplayTag::RequestGameplayTag(FName("State.Return"));
} }
void ADefaultPlayerState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const void ADefaultPlayerState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
@@ -26,17 +25,7 @@ void ADefaultPlayerState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>&
Super::GetLifetimeReplicatedProps(OutLifetimeProps); Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(ADefaultPlayerState, CharacterBPRef); DOREPLIFETIME(ADefaultPlayerState, CharacterBPRef);
DOREPLIFETIME(ADefaultPlayerState, Team);
DOREPLIFETIME(ADefaultPlayerState, CooldownDuration);
DOREPLIFETIME(ADefaultPlayerState, Stats);
DOREPLIFETIME(ADefaultPlayerState, MaxStats);
DOREPLIFETIME(ADefaultPlayerState, State);
DOREPLIFETIME(ADefaultPlayerState, AttackType);
DOREPLIFETIME(ADefaultPlayerState, PlayerCamera); DOREPLIFETIME(ADefaultPlayerState, PlayerCamera);
DOREPLIFETIME(ADefaultPlayerState, CurrentAttackTarget); DOREPLIFETIME(ADefaultPlayerState, CurrentAttackTarget);
DOREPLIFETIME(ADefaultPlayerState, PreviousAttackTarget); DOREPLIFETIME(ADefaultPlayerState, PreviousAttackTarget);
} }
@@ -46,6 +35,31 @@ UAbilitySystemComponent* ADefaultPlayerState::GetAbilitySystemComponent() const
return AbilitySystemComponent; return AbilitySystemComponent;
} }
UCharacterBaseAttribute* ADefaultPlayerState::GetAttributeSet() const
{
return Attribute;
}
bool ADefaultPlayerState::IsDead() const
{
return GetHealth() < 0.0f;
}
void ADefaultPlayerState::ShowAbliityConfirmCancelText(bool ShowText)
{
// TODO -- implement HUD
}
TeamType ADefaultPlayerState::GetTeam() const
{
return TeamType::Null;
}
float ADefaultPlayerState::GetXP() const
{
return Attribute->GetXP();
}
float ADefaultPlayerState::GetHealth() const float ADefaultPlayerState::GetHealth() const
{ {
return Attribute->GetHealth(); return Attribute->GetHealth();
@@ -66,42 +80,58 @@ float ADefaultPlayerState::GetMaxMana() const
return Attribute->GetMaxMana(); return Attribute->GetMaxMana();
} }
void ADefaultPlayerState::InitPlayerStats_Implementation(const TArray<float>& StatsValue, const TArray<float>& CooldownDurationValue) int32 ADefaultPlayerState::GetCharacterLevel() const
{ {
MaxStats.Append(StatsValue); return Attribute->GetXP() / 100.0f;
Stats.Append(StatsValue); }
CooldownDuration.Append(CooldownDurationValue);
MaxCooldownDuration.Append(CooldownDurationValue);
for (float Value : StatsValue) void ADefaultPlayerState::BeginPlay()
{
Super::BeginPlay();
if (AbilitySystemComponent)
{ {
UE_LOG(LogTemp, Warning, TEXT("Values: %f"), Value); TeamChangedDelegateHandle = AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(Attribute->GetHealthAttribute()).AddUObject(this, &ADefaultPlayerState::TeamChanged);
XPChangedDelegateHandle = AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(Attribute->GetHealthAttribute()).AddUObject(this, &ADefaultPlayerState::XPChanged);
HealthChangedDelegateHandle = AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(Attribute->GetHealthAttribute()).AddUObject(this, &ADefaultPlayerState::HealthChanged);
MaxHealthChangedDelegateHandle = AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(Attribute->GetMaxHealthAttribute()).AddUObject(this, &ADefaultPlayerState::MaxHealthChanged);
ManaChangedDelegateHandle = AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(Attribute->GetManaAttribute()).AddUObject(this, &ADefaultPlayerState::ManaChanged);
MaxManaChangedDelegateHandle = AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(Attribute->GetMaxManaAttribute()).AddUObject(this, &ADefaultPlayerState::MaxManaChanged);
AbilitySystemComponent->RegisterGameplayTagEvent(
FGameplayTag::RequestGameplayTag(FName("State.Debuff.Stun")), EGameplayTagEventType::NewOrRemoved
).AddUObject(this, &ADefaultPlayerState::StunTagChanged);
} }
} }
void ADefaultPlayerState::NetMulticast_SetAttackType_Implementation(CooldownType Value) void ADefaultPlayerState::TeamChanged(const FOnAttributeChangeData& Data)
{ {
AttackType = Value; UE_LOG(LogTemp, Warning, TEXT("TeamChanged"));
} }
void ADefaultPlayerState::NetMulticast_SetState_Implementation(ECharacterState Value) void ADefaultPlayerState::XPChanged(const FOnAttributeChangeData& Data)
{ {
State = Value; UE_LOG(LogTemp, Warning, TEXT("XPChanged"));
} }
void ADefaultPlayerState::SetState_Implementation(ECharacterState Value) void ADefaultPlayerState::HealthChanged(const FOnAttributeChangeData& Data)
{ {
NetMulticast_SetState(Value); UE_LOG(LogTemp, Warning, TEXT("HealthChanged"));
} }
void ADefaultPlayerState::SetAttackType_Implementation(CooldownType Value) void ADefaultPlayerState::MaxHealthChanged(const FOnAttributeChangeData& Data)
{ {
NetMulticast_SetAttackType(Value); UE_LOG(LogTemp, Warning, TEXT("MaxHealthChanged"));
} }
int32 ADefaultPlayerState::GetCharacterLevel() const void ADefaultPlayerState::ManaChanged(const FOnAttributeChangeData& Data)
{ {
return int32(); UE_LOG(LogTemp, Warning, TEXT("ManaChanged"));
}
void ADefaultPlayerState::MaxManaChanged(const FOnAttributeChangeData& Data)
{
UE_LOG(LogTemp, Warning, TEXT("MaxManaChanged"));
} }
void ADefaultPlayerState::SetCurrentAttackTarget(AActor* Target) void ADefaultPlayerState::SetCurrentAttackTarget(AActor* Target)
@@ -110,6 +140,12 @@ void ADefaultPlayerState::SetCurrentAttackTarget(AActor* Target)
Client_SetCurrentAttackTarget(Target); Client_SetCurrentAttackTarget(Target);
} }
void ADefaultPlayerState::SetPreviousAttackTarget(AActor* Target)
{
Server_SetPreviousAttackTarget(Target);
Client_SetPreviousAttackTarget(Target);
}
void ADefaultPlayerState::Server_SetCurrentAttackTarget_Implementation(AActor* Target) void ADefaultPlayerState::Server_SetCurrentAttackTarget_Implementation(AActor* Target)
{ {
CurrentAttackTarget = Target; CurrentAttackTarget = Target;
@@ -120,43 +156,6 @@ void ADefaultPlayerState::Client_SetCurrentAttackTarget_Implementation(AActor* T
CurrentAttackTarget = Target; CurrentAttackTarget = Target;
} }
void ADefaultPlayerState::SetPreviousAttackTarget(AActor* Target)
{
Server_SetPreviousAttackTarget(Target);
Client_SetPreviousAttackTarget(Target);
}
void ADefaultPlayerState::BeginPlay()
{
Super::BeginPlay();
if (AbilitySystemComponent)
{
HealthChangedDelegateHandle = AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(Attribute->GetHealthAttribute()).AddUObject(this, &ADefaultPlayerState::HealthChanged);
MaxHealthChangedDelegateHandle = AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(Attribute->GetMaxHealthAttribute()).AddUObject(this, &ADefaultPlayerState::MaxHealthChanged);
ManaChangedDelegateHandle = AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(Attribute->GetManaAttribute()).AddUObject(this, &ADefaultPlayerState::ManaChanged);
MaxManaChangedDelegateHandle = AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(Attribute->GetMaxManaAttribute()).AddUObject(this, &ADefaultPlayerState::MaxManaChanged);
//AbilitySystemComponent->RegisterGameplayTagEvent(FGameplayTag::Request)
}
}
void ADefaultPlayerState::HealthChanged(const FOnAttributeChangeData& Data)
{
}
void ADefaultPlayerState::MaxHealthChanged(const FOnAttributeChangeData& Data)
{
}
void ADefaultPlayerState::ManaChanged(const FOnAttributeChangeData& Data)
{
}
void ADefaultPlayerState::MaxManaChanged(const FOnAttributeChangeData& Data)
{
}
void ADefaultPlayerState::Server_SetPreviousAttackTarget_Implementation(AActor* Target) void ADefaultPlayerState::Server_SetPreviousAttackTarget_Implementation(AActor* Target)
{ {
PreviousAttackTarget = Target; PreviousAttackTarget = Target;
@@ -166,3 +165,17 @@ void ADefaultPlayerState::Client_SetPreviousAttackTarget_Implementation(AActor*
{ {
PreviousAttackTarget = Target; PreviousAttackTarget = Target;
} }
void ADefaultPlayerState::StunTagChanged(const FGameplayTag CallbackTag, int32 NewCount)
{
if (NewCount > 0)
{
FGameplayTagContainer AbilityTagsToCancel;
AbilityTagsToCancel.AddTag(FGameplayTag::RequestGameplayTag(FName("Ability")));
FGameplayTagContainer AbilityTagsToIgnore;
AbilityTagsToCancel.AddTag(FGameplayTag::RequestGameplayTag(FName("Ability.NotCanceledByStun")));
AbilitySystemComponent->CancelAbilities(&AbilityTagsToCancel, &AbilityTagsToIgnore);
}
}

View File

@@ -11,7 +11,7 @@
#include <map> #include <map>
#include "../PrometherEnum.h" #include "../PrometherEnum.h"
#include "DefaultPlayerCharacter.h" #include "../GAS/AttributeSet/CharacterBaseAttribute.h"
#include "DefaultPlayerState.generated.h" #include "DefaultPlayerState.generated.h"
UCLASS() UCLASS()
@@ -23,58 +23,35 @@ public:
ADefaultPlayerState(); ADefaultPlayerState();
void GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const override; void GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const override;
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override; virtual class UAbilitySystemComponent* GetAbilitySystemComponent() const override;
UFUNCTION(Server, Reliable)
void InitPlayerStats(const TArray<float>& StatsValue, const TArray<float>& CooldownDurationValue);
void SetCharacterBPRef(UClass* Value) { CharacterBPRef = Value; } void SetCharacterBPRef(UClass* Value) { CharacterBPRef = Value; }
UClass* GetCharacterBPRef() const { return CharacterBPRef; } UClass* GetCharacterBPRef() const { return CharacterBPRef; }
UFUNCTION(BlueprintCallable, Category = "Attributes") UFUNCTION(BlueprintCallable, Category = "DefaultPlayerState")
TeamType GetTeam() const;
UFUNCTION(BlueprintCallable, Category = "DefaultPlayerState|Attributes")
float GetXP() const;
UFUNCTION(BlueprintCallable, Category = "DefaultPlayerState|Attributes")
float GetHealth() const; float GetHealth() const;
UFUNCTION(BlueprintCallable, Category = "Attributes") UFUNCTION(BlueprintCallable, Category = "DefaultPlayerState|Attributes")
float GetMaxHealth() const; float GetMaxHealth() const;
UFUNCTION(BlueprintCallable, Category = "Attributes") UFUNCTION(BlueprintCallable, Category = "DefaultPlayerState|Attributes")
float GetMana() const; float GetMana() const;
UFUNCTION(BlueprintCallable, Category = "Attributes") UFUNCTION(BlueprintCallable, Category = "DefaultPlayerState|Attributes")
float GetMaxMana() const; float GetMaxMana() const;
class UCharacterBaseAttribute* GetAttributeSet() const; class UCharacterBaseAttribute* GetAttributeSet() const;
//UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
//bool IsDead() const; bool IsDead() const;
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable, Category = "DefaultPlayerState|UI")
void SetTeam(TeamType Value) { Team = Value; } void ShowAbliityConfirmCancelText(bool ShowText);
UFUNCTION(BlueprintCallable)
TeamType GetTeam() const { return Team; }
void SetPlayerCamera(AActor* Actor) { PlayerCamera = Actor; } void SetPlayerCamera(AActor* Actor) { PlayerCamera = Actor; }
AActor* GetPlayerCamera() const { return PlayerCamera; } AActor* GetPlayerCamera() const { return PlayerCamera; }
//fix later
//UFUNCTION(BlueprintCallable)
//void SetCooldownDuration(CooldownType Key, float Value) { CooldownDuration[(uint8)Key] = Value; }
//UFUNCTION(BlueprintCallable)
//float GetCooldownDuration(CooldownType Key) const { return CooldownDuration[(uint8)Key]; }
//Execute on server
UFUNCTION(BlueprintCallable, Server, Reliable)
void SetState(ECharacterState Value);
UFUNCTION(BlueprintCallable, NetMulticast, Reliable)
void NetMulticast_SetState(ECharacterState Value);
UFUNCTION(BlueprintCallable)
ECharacterState GetState() const { return State; }
//Execute on server
UFUNCTION(BlueprintCallable, Server, Reliable)
void SetAttackType(CooldownType Value);
UFUNCTION(BlueprintCallable, NetMulticast, Reliable)
void NetMulticast_SetAttackType(CooldownType Value);
UFUNCTION(BlueprintCallable)
CooldownType GetAttackType() const { return AttackType; }
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
int32 GetCharacterLevel() const; int32 GetCharacterLevel() const;
@@ -110,8 +87,11 @@ protected:
class UCharacterBaseAttribute* Attribute; class UCharacterBaseAttribute* Attribute;
FGameplayTag DeadTag; FGameplayTag DeadTag;
FGameplayTag TeamTag;
FGameplayTag EffectTag; FGameplayTag EffectTag;
FDelegateHandle TeamChangedDelegateHandle;
FDelegateHandle XPChangedDelegateHandle;
FDelegateHandle HealthChangedDelegateHandle; FDelegateHandle HealthChangedDelegateHandle;
FDelegateHandle MaxHealthChangedDelegateHandle; FDelegateHandle MaxHealthChangedDelegateHandle;
FDelegateHandle ManaChangedDelegateHandle; FDelegateHandle ManaChangedDelegateHandle;
@@ -119,24 +99,21 @@ protected:
virtual void BeginPlay() override; virtual void BeginPlay() override;
virtual void TeamChanged(const FOnAttributeChangeData& Data);
virtual void XPChanged(const FOnAttributeChangeData& Data);
virtual void HealthChanged(const FOnAttributeChangeData& Data); virtual void HealthChanged(const FOnAttributeChangeData& Data);
virtual void MaxHealthChanged(const FOnAttributeChangeData& Data); virtual void MaxHealthChanged(const FOnAttributeChangeData& Data);
virtual void ManaChanged(const FOnAttributeChangeData& Data); virtual void ManaChanged(const FOnAttributeChangeData& Data);
virtual void MaxManaChanged(const FOnAttributeChangeData& Data); virtual void MaxManaChanged(const FOnAttributeChangeData& Data);
virtual void StunTagChanged(const FGameplayTag CallbackTag, int32 NewCount);
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Abilities") UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Abilities")
TSubclassOf<class UGameplayEffect> DefaultAttributes; TSubclassOf<class UGameplayEffect> DefaultAttributes;
private: private:
UPROPERTY(Replicated, Transient) UPROPERTY(Replicated, Transient)
UClass* CharacterBPRef; UClass* CharacterBPRef;
UPROPERTY(Replicated, Transient)
TeamType Team;
UPROPERTY(Replicated, Transient)
ECharacterState State;
UPROPERTY(Replicated, Transient)
CooldownType AttackType;
UPROPERTY(Replicated, Transient) UPROPERTY(Replicated, Transient)
AActor* PlayerCamera; AActor* PlayerCamera;

View File

@@ -8,14 +8,12 @@ UENUM(BlueprintType)
enum class EDefaultAbilityID : uint8 enum class EDefaultAbilityID : uint8
{ {
None UMETA(DisplayName = "None"), None UMETA(DisplayName = "None"),
Confirm UMETA(DisplayName = "Confirm"),
Cancel UMETA(DisplayName = "Cancel"),
BaseAttack UMETA(DisplayName = "BaseAttack"), BaseAttack UMETA(DisplayName = "BaseAttack"),
Skill1 UMETA(DisplayName = "Skill1"), Skill1 UMETA(DisplayName = "Skill1"),
Skill2 UMETA(DisplayName = "Skill2"), Skill2 UMETA(DisplayName = "Skill2"),
Skill3 UMETA(DisplayName = "Skill3"), Skill3 UMETA(DisplayName = "Skill3"),
Skill4 UMETA(DisplayName = "Skill4"), Skill4 UMETA(DisplayName = "Skill4"),
RuneSpell1 UMETA(DisplayName = "RuneSpell1"),
RuneSpell2 UMETA(DisplayName = "RuneSpell2"),
Ward UMETA(DisplayName = "Ward"),
Bomb UMETA(DisplayName = "Bomb"),
SIZE SIZE
}; };