deleted off unnecessary, conflicting files in our solution file

This commit is contained in:
Ji Yoon Rhee 2024-06-01 09:29:00 +09:00
parent 87c47a72e3
commit c03b8968e1
11 changed files with 4 additions and 943 deletions

View File

@ -1,15 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "HYCharacAbilitySystemComponent.h"
UHYCharacAbilitySystemComponent::UHYCharacAbilitySystemComponent()
{
}
void UHYCharacAbilitySystemComponent::ReceiveDamage(
UHYCharacAbilitySystemComponent* SourceASC, float UnmitigatedDamage, float MitigatedDamage)
{
ReceivedDamage.Broadcast(SourceASC, UnmitigatedDamage, MitigatedDamage);
}

View File

@ -1,30 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "AbilitySystemComponent.h"
#include "HYCharacAbilitySystemComponent.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FReceivedDamageDelegate,
UHYCharacAbilitySystemComponent*, SourceASC, float, UnmitigatedDamage, float, MitigatedDamage);
/**
*
*/
UCLASS()
class HWANYOUNG2_API UHYCharacAbilitySystemComponent : public UAbilitySystemComponent
{
GENERATED_BODY()
public:
bool CharacterAbilitiesGiven = false;
bool StartupEffectApplied = false;
FReceivedDamageDelegate ReceivedDamage;
//constructor
UHYCharacAbilitySystemComponent();
virtual void ReceiveDamage(UHYCharacAbilitySystemComponent* SourceASC, float UnmitigatedDamage, float MitigatedDamage);
};

View File

@ -1,21 +0,0 @@
#include "HYCharacGameplayAbility.h"
#include "AbilitySystemComponent.h"
UHYCharacGameplayAbility::UHYCharacGameplayAbility()
{
InstancingPolicy = EGameplayAbilityInstancingPolicy::InstancedPerActor;
ActivationBlockedTags.AddTag(FGameplayTag::RequestGameplayTag(FName("State.Dead")));
ActivationBlockedTags.AddTag(FGameplayTag::RequestGameplayTag(FName("State.Debuff.Stun")));
}
void UHYCharacGameplayAbility::OnAvatarSet(const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilitySpec& Spec)
{
Super::OnAvatarSet(ActorInfo, Spec);
if (ActivateAbilityOnGranted)
{
ActorInfo->AbilitySystemComponent->TryActivateAbility(Spec.Handle, false);
}
}

View File

@ -1,32 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Abilities/GameplayAbility.h"
#include "hwanyoung2.h"
#include "HYCharacGameplayAbility.generated.h"
/**
*
*/
UCLASS()
class HWANYOUNG2_API UHYCharacGameplayAbility : public UGameplayAbility
{
GENERATED_BODY()
public:
UHYCharacGameplayAbility();
//Abilities with this set will automatically activate when the input is pressed:
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Ability")
EAbilityInputID AbilityInputID = EAbilityInputID::None;
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Ability")
EAbilityInputID AbilityID = EAbilityInputID::None;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Ability")
bool ActivateAbilityOnGranted = false;
virtual void OnAvatarSet(const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilitySpec& Spec) override;
};

View File

@ -1,77 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "HYPlayerCharacAttributeSet.h"
#include "Net/UnrealNetwork.h"
UHYPlayerCharacAttributeSet::UHYPlayerCharacAttributeSet()
{
}
UHYPlayerCharacAttributeSet::~UHYPlayerCharacAttributeSet()
{
}
void UHYPlayerCharacAttributeSet::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME_CONDITION_NOTIFY(UHYPlayerCharacAttributeSet, PlayerLevel, COND_None, REPNOTIFY_Always);
DOREPLIFETIME_CONDITION_NOTIFY(UHYPlayerCharacAttributeSet, Health, COND_None, REPNOTIFY_Always);
DOREPLIFETIME_CONDITION_NOTIFY(UHYPlayerCharacAttributeSet, MaxHealth, COND_None, REPNOTIFY_Always);
DOREPLIFETIME_CONDITION_NOTIFY(UHYPlayerCharacAttributeSet, Mana, COND_None, REPNOTIFY_Always);
DOREPLIFETIME_CONDITION_NOTIFY(UHYPlayerCharacAttributeSet, MaxMana, COND_None, REPNOTIFY_Always);
DOREPLIFETIME_CONDITION_NOTIFY(UHYPlayerCharacAttributeSet, Stamina, COND_None, REPNOTIFY_Always);
DOREPLIFETIME_CONDITION_NOTIFY(UHYPlayerCharacAttributeSet, MaxStamina, COND_None, REPNOTIFY_Always);
DOREPLIFETIME_CONDITION_NOTIFY(UHYPlayerCharacAttributeSet, GaugeP, COND_None, REPNOTIFY_Always);
DOREPLIFETIME_CONDITION_NOTIFY(UHYPlayerCharacAttributeSet, MaxGaugeP, COND_None, REPNOTIFY_Always);
}
void UHYPlayerCharacAttributeSet::OnRep_Level(const FGameplayAttributeData& OldPlayerLevel)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UHYPlayerCharacAttributeSet, PlayerLevel, OldPlayerLevel);
}
void UHYPlayerCharacAttributeSet::OnRep_Health(const FGameplayAttributeData& OldHealth)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UHYPlayerCharacAttributeSet, Health, OldHealth);
}
void UHYPlayerCharacAttributeSet::OnRep_MaxHealth(const FGameplayAttributeData& OldMaxHealth)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UHYPlayerCharacAttributeSet, MaxHealth, OldMaxHealth);
}
void UHYPlayerCharacAttributeSet::OnRep_Mana(const FGameplayAttributeData& OldMana)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UHYPlayerCharacAttributeSet, Mana, OldMana);
}
void UHYPlayerCharacAttributeSet::OnRep_MaxMana(const FGameplayAttributeData& OldMaxMana)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UHYPlayerCharacAttributeSet, MaxMana, OldMaxMana);
}
void UHYPlayerCharacAttributeSet::OnRep_GaugeP(const FGameplayAttributeData& OldGaugeP)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UHYPlayerCharacAttributeSet, GaugeP, OldGaugeP);
}
void UHYPlayerCharacAttributeSet::OnRep_MaxGaugeP(const FGameplayAttributeData& OldMaxGaugeP)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UHYPlayerCharacAttributeSet, MaxGaugeP, OldMaxGaugeP);
}
void UHYPlayerCharacAttributeSet::OnRep_Stamina(const FGameplayAttributeData& OldStamina)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UHYPlayerCharacAttributeSet, Stamina, OldStamina);
}
void UHYPlayerCharacAttributeSet::OnRep_MaxStamina(const FGameplayAttributeData& OldMaxStamina)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UHYPlayerCharacAttributeSet, MaxStamina, OldMaxStamina);
}

View File

@ -1,117 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "AttributeSet.h"
#include "AbilitySystemComponent.h"
#include "HYPlayerCharacAttributeSet.generated.h"
/**
*
*/
UCLASS()
class HWANYOUNG2_API UHYPlayerCharacAttributeSet : public UAttributeSet
{
GENERATED_BODY()
public:
UHYPlayerCharacAttributeSet(); //constructor
~UHYPlayerCharacAttributeSet(); //destructor
//when there are changes to any attributes, the attribute set needs to be replicated
//in order for other appropriate entities within the game level to be aware of such changes
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
UPROPERTY(BlueprintReadOnly, Category = "Player Level", ReplicatedUsing = OnRep_Level)
FGameplayAttributeData PlayerLevel;
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(UHYPlayerCharacAttributeSet, PlayerLevel)
GAMEPLAYATTRIBUTE_VALUE_GETTER(PlayerLevel)
GAMEPLAYATTRIBUTE_VALUE_SETTER(PlayerLevel)
GAMEPLAYATTRIBUTE_VALUE_INITTER(PlayerLevel)
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Health", ReplicatedUsing = OnRep_Health)
FGameplayAttributeData Health;
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(UHYPlayerCharacAttributeSet, Health)
GAMEPLAYATTRIBUTE_VALUE_GETTER(Health)
GAMEPLAYATTRIBUTE_VALUE_SETTER(Health)
GAMEPLAYATTRIBUTE_VALUE_INITTER(Health)
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Health", ReplicatedUsing = OnRep_MaxHealth)
FGameplayAttributeData MaxHealth;
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(UHYPlayerCharacAttributeSet, MaxHealth)
GAMEPLAYATTRIBUTE_VALUE_GETTER(MaxHealth)
GAMEPLAYATTRIBUTE_VALUE_SETTER(MaxHealth)
GAMEPLAYATTRIBUTE_VALUE_INITTER(MaxHealth)
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Mana", ReplicatedUsing = OnRep_Mana)
FGameplayAttributeData Mana;
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(UHYPlayerCharacAttributeSet, Mana)
GAMEPLAYATTRIBUTE_VALUE_GETTER(Mana)
GAMEPLAYATTRIBUTE_VALUE_SETTER(Mana)
GAMEPLAYATTRIBUTE_VALUE_INITTER(Mana)
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Mana", ReplicatedUsing = OnRep_MaxMana)
FGameplayAttributeData MaxMana;
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(UHYPlayerCharacAttributeSet, MaxMana)
GAMEPLAYATTRIBUTE_VALUE_GETTER(MaxMana)
GAMEPLAYATTRIBUTE_VALUE_SETTER(MaxMana)
GAMEPLAYATTRIBUTE_VALUE_INITTER(MaxMana)
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ultimate Gauge Point", ReplicatedUsing = OnRep_GaugeP)
FGameplayAttributeData GaugeP;
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(UHYPlayerCharacAttributeSet, GaugeP)
GAMEPLAYATTRIBUTE_VALUE_GETTER(GaugeP)
GAMEPLAYATTRIBUTE_VALUE_SETTER(GaugeP)
GAMEPLAYATTRIBUTE_VALUE_INITTER(GaugeP)
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Ultimate Gauge Point", ReplicatedUsing = OnRep_MaxGaugeP)
FGameplayAttributeData MaxGaugeP;
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(UHYPlayerCharacAttributeSet, MaxGaugeP)
GAMEPLAYATTRIBUTE_VALUE_GETTER(MaxGaugeP)
GAMEPLAYATTRIBUTE_VALUE_SETTER(MaxGaugeP)
GAMEPLAYATTRIBUTE_VALUE_INITTER(MaxGaugeP)
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Stamina", ReplicatedUsing = OnRep_Stamina)
FGameplayAttributeData Stamina;
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(UHYPlayerCharacAttributeSet, Stamina)
GAMEPLAYATTRIBUTE_VALUE_GETTER(Stamina)
GAMEPLAYATTRIBUTE_VALUE_SETTER(Stamina)
GAMEPLAYATTRIBUTE_VALUE_INITTER(Stamina)
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Stamina", ReplicatedUsing = OnRep_MaxStamina)
FGameplayAttributeData MaxStamina;
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(UHYPlayerCharacAttributeSet, MaxStamina)
GAMEPLAYATTRIBUTE_VALUE_GETTER(MaxStamina)
GAMEPLAYATTRIBUTE_VALUE_SETTER(MaxStamina)
GAMEPLAYATTRIBUTE_VALUE_INITTER(MaxStamina)
UFUNCTION()
virtual void OnRep_Level(const FGameplayAttributeData& OldPlayerLevel);
UFUNCTION()
virtual void OnRep_Health(const FGameplayAttributeData& OldHealth);
UFUNCTION()
virtual void OnRep_MaxHealth(const FGameplayAttributeData& OldMaxHealth);
UFUNCTION()
virtual void OnRep_Mana(const FGameplayAttributeData& OldMana);
UFUNCTION()
virtual void OnRep_MaxMana(const FGameplayAttributeData& OldMaxMana);
UFUNCTION()
virtual void OnRep_GaugeP(const FGameplayAttributeData& OldGaugeP);
UFUNCTION()
virtual void OnRep_MaxGaugeP(const FGameplayAttributeData& OldMaxGaugeP);
UFUNCTION()
virtual void OnRep_Stamina(const FGameplayAttributeData& OldStamina);
UFUNCTION()
virtual void OnRep_MaxStamina(const FGameplayAttributeData& OldMaxStamina);
};

View File

@ -1,207 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "HYPlayerState.h"
#include "HYCharacAbilitySystemComponent.h"
#include "HYPlayerCharacAttributeSet.h"
AHYPlayerState::AHYPlayerState()
{
AbilitySystemComponent =
CreateDefaultSubobject<UHYCharacAbilitySystemComponent>(
TEXT("AbilitySystemComponent"));
AbilitySystemComponent->SetIsReplicated(true);
//we do mixed because we only need to replicate gameplay cues
//which are responsible for visual stuff
AbilitySystemComponent->SetReplicationMode(
EGameplayEffectReplicationMode::Mixed);
AttributeSetBase =
CreateDefaultSubobject<UHYPlayerCharacAttributeSet>(
TEXT("AttributeSetBase"));
NetUpdateFrequency = 100.0f;
DeadTag = FGameplayTag::RequestGameplayTag(FName("State.Dead"));
}
UAbilitySystemComponent* AHYPlayerState::GetAbilitySystemComponent() const
{
return AbilitySystemComponent;
}
UHYPlayerCharacAttributeSet* AHYPlayerState::GetAttributeSetBase() const
{
return AttributeSetBase;
}
bool AHYPlayerState::IsAlive() const
{
return GetHealth() > 0.0f;
}
void AHYPlayerState::ShowAbilityConfirmCancelText(bool showText)
{
}
float AHYPlayerState::GetHealth() const
{
return AttributeSetBase->GetHealth();
}
float AHYPlayerState::GetMaxHealth() const
{
return AttributeSetBase->GetMaxHealth();
}
float AHYPlayerState::GetMana() const
{
return AttributeSetBase->GetMana();
}
float AHYPlayerState::GetMaxMana() const
{
return AttributeSetBase->GetMaxMana();
}
float AHYPlayerState::GetStamina() const
{
return AttributeSetBase->GetStamina();
}
float AHYPlayerState::GetMaxStamina() const
{
return AttributeSetBase->GetMaxStamina();
}
float AHYPlayerState::GetGaugeP() const
{
return AttributeSetBase->GetGaugeP();
}
float AHYPlayerState::GetMaxGaugeP() const
{
return AttributeSetBase->GetGaugeP();
}
float AHYPlayerState::GetPlayerLevel() const
{
return AttributeSetBase->GetPlayerLevel();
}
void AHYPlayerState::BeginPlay()
{
Super::BeginPlay();
if (AbilitySystemComponent)
{
//what we are doing here is creating a "link"
//between the attribute change event and the function.
//we will do this for all attribute change delegate handlers
HPChangedDelegateHandle =
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(
AttributeSetBase->GetHealthAttribute()).AddUObject(
this, &AHYPlayerState::HealthChanged);
MaxHPChangedDelegateHandle =
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(
AttributeSetBase->GetMaxHealthAttribute()).AddUObject(
this, &AHYPlayerState::MaxHealthChanged);
MPChangedDelegateHandle =
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(
AttributeSetBase->GetManaAttribute()).AddUObject(
this, &AHYPlayerState::ManaChanged);
MaxMPChangedDelegateHandle =
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(
AttributeSetBase->GetMaxManaAttribute()).AddUObject(
this, &AHYPlayerState::MaxManaChanged);
StaminaChangedDelegateHandle =
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(
AttributeSetBase->GetStaminaAttribute()).AddUObject(
this, &AHYPlayerState::StaminaChanged);
MaxStaminaChangedDelegateHandle =
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(
AttributeSetBase->GetMaxStaminaAttribute()).AddUObject(
this, &AHYPlayerState::MaxStaminaChanged);
GaugePChangedDelegateHandle =
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(
AttributeSetBase->GetGaugePAttribute()).AddUObject(
this, &AHYPlayerState::GaugePChanged);
MaxGaugePChangedDelegateHandle =
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(
AttributeSetBase->GetMaxGaugePAttribute()).AddUObject(
this, &AHYPlayerState::MaxGaugePChanged);
CharacterLevelChangedDelegateHandle =
AbilitySystemComponent->GetGameplayAttributeValueChangeDelegate(
AttributeSetBase->GetPlayerLevelAttribute()).AddUObject(
this, &AHYPlayerState::PlayerLevelChanged);
//here we are making a custom gameplay tag event for State.Debuff.Stun
AbilitySystemComponent->RegisterGameplayTagEvent(FGameplayTag::RequestGameplayTag(
FName("State.Debuff.Stun")), EGameplayTagEventType::NewOrRemoved).AddUObject(
this, &AHYPlayerState::StunTagChanged);
}
}
void AHYPlayerState::HealthChanged(const FOnAttributeChangeData& Data)
{
UE_LOG(LogTemp, Warning, TEXT("Health changed!"));
}
void AHYPlayerState::MaxHealthChanged(const FOnAttributeChangeData& Data)
{
UE_LOG(LogTemp, Warning, TEXT("Max Health changed!"));
}
void AHYPlayerState::ManaChanged(const FOnAttributeChangeData& Data)
{
UE_LOG(LogTemp, Warning, TEXT("Mana changed!"));
}
void AHYPlayerState::MaxManaChanged(const FOnAttributeChangeData& Data)
{
UE_LOG(LogTemp, Warning, TEXT("Max Mana changed!"));
}
void AHYPlayerState::StaminaChanged(const FOnAttributeChangeData& Data)
{
UE_LOG(LogTemp, Warning, TEXT("Stamina changed!"));
}
void AHYPlayerState::MaxStaminaChanged(const FOnAttributeChangeData& Data)
{
UE_LOG(LogTemp, Warning, TEXT("Max Stamina changed!"));
}
void AHYPlayerState::GaugePChanged(const FOnAttributeChangeData& Data)
{
UE_LOG(LogTemp, Warning, TEXT("Gauge Point changed!"));
}
void AHYPlayerState::MaxGaugePChanged(const FOnAttributeChangeData& Data)
{
UE_LOG(LogTemp, Warning, TEXT("Max Gauge Point changed!"));
}
void AHYPlayerState::PlayerLevelChanged(const FOnAttributeChangeData& Data)
{
UE_LOG(LogTemp, Warning, TEXT("Player Level changed!"));
}
void AHYPlayerState::StunTagChanged(const FGameplayTag CallbackTag, int32 NewCount)
{
if (NewCount > 0)
{
FGameplayTagContainer AbilityTagsToCancel;
AbilityTagsToCancel.AddTag(FGameplayTag::RequestGameplayTag(FName("Ability")));
FGameplayTagContainer AbilityTagsToIgnore;
AbilityTagsToIgnore.AddTag(FGameplayTag::RequestGameplayTag(
FName("Ability.NotCanceledByStun")));
AbilitySystemComponent->CancelAbilities(
&AbilityTagsToCancel, &AbilityTagsToCancel);
}
}

View File

@ -1,94 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "AbilitySystemInterface.h"
#include "GameplayTagContainer.h"
#include "GameplayEffectTypes.h"
#include "GameFramework/PlayerState.h"
#include "HYPlayerState.generated.h"
/**
*
*/
UCLASS()
class HWANYOUNG2_API AHYPlayerState : public APlayerState, public IAbilitySystemInterface
{
GENERATED_BODY()
public:
AHYPlayerState();
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
class UHYPlayerCharacAttributeSet* GetAttributeSetBase() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Player State")
bool IsAlive() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Player State|UI")
void ShowAbilityConfirmCancelText(bool showText);
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Player State|Attributes")
float GetHealth() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Player State|Attributes")
float GetMaxHealth() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Player State|Attributes")
float GetMana() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Player State|Attributes")
float GetMaxMana() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Player State|Attributes")
float GetStamina() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Player State|Attributes")
float GetMaxStamina() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Player State|Attributes")
float GetGaugeP() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Player State|Attributes")
float GetMaxGaugeP() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Player State|Attributes")
float GetPlayerLevel() const;
protected:
UPROPERTY()
class UHYCharacAbilitySystemComponent* AbilitySystemComponent;
UPROPERTY()
class UHYPlayerCharacAttributeSet* AttributeSetBase;
FGameplayTag DeadTag;
FDelegateHandle HPChangedDelegateHandle;
FDelegateHandle MaxHPChangedDelegateHandle;
FDelegateHandle MPChangedDelegateHandle;
FDelegateHandle MaxMPChangedDelegateHandle;
FDelegateHandle StaminaChangedDelegateHandle;
FDelegateHandle MaxStaminaChangedDelegateHandle;
FDelegateHandle GaugePChangedDelegateHandle;
FDelegateHandle MaxGaugePChangedDelegateHandle;
FDelegateHandle CharacterLevelChangedDelegateHandle;
virtual void BeginPlay() override;
virtual void HealthChanged(const FOnAttributeChangeData& Data);
virtual void MaxHealthChanged(const FOnAttributeChangeData& Data);
virtual void ManaChanged(const FOnAttributeChangeData& Data);
virtual void MaxManaChanged(const FOnAttributeChangeData& Data);
virtual void StaminaChanged(const FOnAttributeChangeData& Data);
virtual void MaxStaminaChanged(const FOnAttributeChangeData& Data);
virtual void GaugePChanged(const FOnAttributeChangeData& Data);
virtual void MaxGaugePChanged(const FOnAttributeChangeData& Data);
virtual void PlayerLevelChanged(const FOnAttributeChangeData& Data);
virtual void StunTagChanged(const FGameplayTag CallbackTag, int32 NewCount);
};

View File

@ -9,6 +9,5 @@ public class hwanyoung2 : ModuleRules
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "EnhancedInput" });
PrivateDependencyModuleNames.AddRange(new string[] { "GameplayAbilities", "GameplayTags", "GameplayTasks" });
}
}

View File

@ -1,9 +1,6 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "hwanyoung2Character.h"
#include "HYCharacAbilitySystemComponent.h"
#include "HYPlayerCharacAttributeSet.h"
#include "HYCharacGameplayAbility.h"
#include "HYPlayerCharacController.h"
#include "Camera/CameraComponent.h"
#include "Components/CapsuleComponent.h"
@ -20,86 +17,17 @@
//////////////////////////////////////////////////////////////////////////
// Ahwanyoung2Character
float Ahwanyoung2Character::GetGaugeP() const
{
if (AttributeSetBase.IsValid())
{
return AttributeSetBase->GetGaugeP();
}
return 0.0f;
}
float Ahwanyoung2Character::GetMaxGaugeP() const
{
if (AttributeSetBase.IsValid())
{
return AttributeSetBase->GetMaxGaugeP();
}
return 0.0f;
}
Ahwanyoung2Character::Ahwanyoung2Character()
{
Initialize();
}
Ahwanyoung2Character::Ahwanyoung2Character(const FObjectInitializer& ObjectInitializer):
Super(ObjectInitializer.SetDefaultSubobjectClass<UCharacterMovementComponent>(
ACharacter::CharacterMovementComponentName))
{
Initialize();
// 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;
//setting up the capsule collider object for the character:
GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Visibility,
ECollisionResponse::ECR_Overlap);
bAlwaysRelevant = true;
DeadTag = FGameplayTag::RequestGameplayTag(FName("State.Dead"));
EffectRemoveOnDeathTag = FGameplayTag::RequestGameplayTag(FName("State.RemoveOnDeath"));
}
void Ahwanyoung2Character::PossessedBy(AController* NewController)
{
Super::PossessedBy(NewController);
//In the server:
if (AbilitySystemComponent != NULL) {
AbilitySystemComponent->InitAbilityActorInfo(this, this); // who is the avatar?
}
SetOwner(this);
InitializeAttributes();
AddCharacterAbilities();
}
void Ahwanyoung2Character::OnRep_PlayerState()
{
Super::OnRep_PlayerState();
//The same business with intializing:
AbilitySystemComponent->InitAbilityActorInfo(this, this);
InitializeAttributes();
//Key binding:
if (AbilitySystemComponent != 0 && InputComponent) {
const FGameplayAbilityInputBinds Binds("Confirm", "Cancel", "EAbilityInputID",
static_cast<int32>(EAbilityInputID::Confirm), static_cast<int32>(EAbilityInputID::Cancel));
AbilitySystemComponent->BindAbilityActivationToInputComponent(InputComponent, Binds);
}
}
UAbilitySystemComponent* Ahwanyoung2Character::GetAbilitySystemComponent() const
{
return AbilitySystemComponent.Get();
}
float Ahwanyoung2Character::GetStartingCameraBoomArmLength()
@ -268,15 +196,9 @@ void Ahwanyoung2Character::Initialize()
// are set in the derived blueprint asset named ThirdPersonCharacter (to avoid direct content references in C++)
}
bool Ahwanyoung2Character::IsAlive() const
{
return GetHealth() > 0.0f;
}
int32 Ahwanyoung2Character::GetAbilityLevel(EAbilityInputID AbilityID) const
{
return int32();
}
//void Ahwanyoung2Character::RemoveCharacterAbilities()
//{
@ -337,185 +259,3 @@ int32 Ahwanyoung2Character::GetAbilityLevel(EAbilityInputID AbilityID) const
// FinishDying();
// }
//}
void Ahwanyoung2Character::FinishDying()
{
Destroy();
}
float Ahwanyoung2Character::GetPlayerLevel() const
{
if (AttributeSetBase.IsValid())
{
return AttributeSetBase->GetPlayerLevel();
}
return 0.0f;
}
float Ahwanyoung2Character::GetHealth() const
{
if (AttributeSetBase.IsValid())
{
return AttributeSetBase->GetHealth();
}
return 0.0f;
}
float Ahwanyoung2Character::GetMaxHealth() const
{
if (AttributeSetBase.IsValid())
{
return AttributeSetBase->GetMaxHealth();
}
return 0.0f;
}
float Ahwanyoung2Character::GetMana() const
{
if (AttributeSetBase.IsValid())
{
return AttributeSetBase->GetMana();
}
return 0.0f;
}
float Ahwanyoung2Character::GetMaxMana() const
{
if (AttributeSetBase.IsValid())
{
return AttributeSetBase->GetMaxMana();
}
return 0.0f;
}
float Ahwanyoung2Character::GetStamina() const
{
if (AttributeSetBase.IsValid())
{
return AttributeSetBase->GetStamina();
}
return 0.0f;
}
float Ahwanyoung2Character::GetMaxStamina() const
{
if (AttributeSetBase.IsValid())
{
return AttributeSetBase->GetMaxStamina();
}
return 0.0f;
}
void Ahwanyoung2Character::AddCharacterAbilities()
{
if (GetLocalRole() != ROLE_Authority ||
!AbilitySystemComponent.IsValid() ||
AbilitySystemComponent->CharacterAbilitiesGiven)
{
return;
}
//if there are no abilities added to the character:
for (TSubclassOf<UHYCharacGameplayAbility>& StartUpAbility : CharacterAbilities)
{
AbilitySystemComponent->GiveAbility(
FGameplayAbilitySpec(StartUpAbility,
GetAbilityLevel(StartUpAbility.GetDefaultObject()->AbilityID),
static_cast<int32> (StartUpAbility.GetDefaultObject()->AbilityInputID),
this));
}
}
void Ahwanyoung2Character::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, GetPlayerLevel(), EffectContext);
if (NewHandle.IsValid())
{
//apply the gameplayeffect here:
FActiveGameplayEffectHandle ActiveGEHandle = AbilitySystemComponent->ApplyGameplayEffectSpecToTarget(
*NewHandle.Data.Get(), AbilitySystemComponent.Get());
}
}
void Ahwanyoung2Character::AddStartupEffects()
{
if (GetLocalRole() != ROLE_Authority ||
!AbilitySystemComponent.IsValid() ||
AbilitySystemComponent->StartupEffectApplied)
{
return;
}
FGameplayEffectContextHandle EffectContext = AbilitySystemComponent->MakeEffectContext();
EffectContext.AddSourceObject(this);
for (TSubclassOf<UGameplayEffect> GameplayEffect : StartupEffects)
{
FGameplayEffectSpecHandle NewHandle = AbilitySystemComponent->MakeOutgoingSpec(GameplayEffect, GetPlayerLevel(), EffectContext);
if (NewHandle.IsValid())
{
FActiveGameplayEffectHandle ActiveGEHandle =
AbilitySystemComponent->ApplyGameplayEffectSpecToTarget(
*NewHandle.Data.Get(), AbilitySystemComponent.Get());
}
}
AbilitySystemComponent->StartupEffectApplied = true;
}
void Ahwanyoung2Character::SetHealth(float Health)
{
if (AttributeSetBase.IsValid())
{
AttributeSetBase->SetHealth(Health);
}
}
void Ahwanyoung2Character::SetMana(float Mana)
{
if (AttributeSetBase.IsValid())
{
AttributeSetBase->SetMana(Mana);
}
}
void Ahwanyoung2Character::SetStamina(float Stamina)
{
if (AttributeSetBase.IsValid())
{
AttributeSetBase->SetStamina(Stamina);
}
}
void Ahwanyoung2Character::SetGaugeP(float GaugeP)
{
if (AttributeSetBase.IsValid())
{
AttributeSetBase->SetGaugeP(GaugeP);
}
}

View File

@ -5,18 +5,12 @@
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "InputActionValue.h"
#include "AbilitySystemInterface.h" //allows defining an interface for ability system
#include "GameplayEffectTypes.h"
#include "GameplayTagContainer.h"
#include "hwanyoung2.h"
#include "hwanyoung2Character.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCharacterDiedDelegate,
Ahwanyoung2Character*, Character);
UCLASS(config=Game)
class Ahwanyoung2Character : public ACharacter, public IAbilitySystemInterface
class Ahwanyoung2Character : public ACharacter
{
GENERATED_BODY()
@ -56,54 +50,14 @@ private:
void Initialize();
public:
UPROPERTY(BlueprintAssignable, Category = "Hwanyoung|Character")
FCharacterDiedDelegate OnCharacterDied;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Character")
virtual bool IsAlive() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Character")
virtual int32 GetAbilityLevel(EAbilityInputID AbilityID) const;
////this function is called only in the server:
//virtual void RemoveCharacterAbilities();
////this is also called only in the server:
//virtual void Die();
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Character")
virtual void FinishDying();
//attribute getter functions
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Attributes")
float GetPlayerLevel() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Attributes")
float GetHealth() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Atributes")
float GetMaxHealth() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Attributes")
float GetMana() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Atributes")
float GetMaxMana() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Attributes")
float GetStamina() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Atributes")
float GetMaxStamina() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Attributes")
float GetGaugeP() const;
UFUNCTION(BlueprintCallable, Category = "Hwanyoung|Atributes")
float GetMaxGaugeP() const;
Ahwanyoung2Character();
Ahwanyoung2Character(const class FObjectInitializer& ObjectInitializer);
//Updates the AbilitysystemComponent's actorInfo, especially in a multiplayer environment
//Gets called on the server (so basically my end)
virtual void PossessedBy(AController* NewController) override;
//Gets called on the client (their end)
virtual void OnRep_PlayerState() override;
//getter function for ability system component:
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
UFUNCTION(BlueprintCallable, Category = "HY_Character|Camera")
float GetStartingCameraBoomArmLength();
@ -120,15 +74,6 @@ public:
protected:
//pointers to the attribute set and ability system component
//of the player character
/** Our ability system */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Abilities, meta = (AllowPrivateAccess = "true"))
TWeakObjectPtr<class UHYCharacAbilitySystemComponent> AbilitySystemComponent;
UPROPERTY()
TWeakObjectPtr<class UHYPlayerCharacAttributeSet> AttributeSetBase;
UPROPERTY(BlueprintReadOnly, Category = "HY_Character|Camera")
float StartingCameraBoomArmLength;
@ -141,40 +86,10 @@ protected:
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "HY_Character|Camera")
float BaseLookUpRate = 45.0f;
//gameplaytags represent the states of the object;
//so if we were to modify the gameplay tags of a character,
//we are, comprehensively speaking, changing the states of
//the given character
FGameplayTag DeadTag;
FGameplayTag EffectRemoveOnDeathTag;
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Hwanyoung|Character")
FText CharacterName;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Hwanyoung|Animation")
UAnimMontage* DeathMontage;
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Hwanyoung|Abilties")
TSubclassOf<class UGameplayEffect> DefaultAttributes;
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Hwanyoung|Abilities")
TArray<TSubclassOf<class UGameplayEffect>> StartupEffects;
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Hwanyoung|Abilities")
TArray<TSubclassOf<class UHYCharacGameplayAbility>> CharacterAbilities;
virtual void AddCharacterAbilities();
virtual void InitializeAttributes();
virtual void AddStartupEffects();
//these two functions are going to be used
//when re/spawn; changes to these attributes mid-gameplay
//are going to be calculated via GameplayEffects
virtual void SetHealth(float Health);
virtual void SetMana(float Mana);
virtual void SetStamina(float Stamina);
virtual void SetGaugeP(float GaugeP);
/** Called for movement input */
void Move(const FInputActionValue& Value);