94 lines
2.8 KiB
C++
94 lines
2.8 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "AbilitySystemInterface.h"
|
|
#include "Engine/TimerHandle.h"
|
|
#include "GameFramework/Character.h"
|
|
#include "BotCharacter.generated.h"
|
|
|
|
class UAbilitySystemComponent;
|
|
class UAttributeSet;
|
|
class UGameplayAbility;
|
|
class UGameplayEffect;
|
|
struct FGameplayTag;
|
|
struct FOnAttributeChangeData;
|
|
|
|
UCLASS()
|
|
class PVPDEMO_API ABotCharacter : public ACharacter, public IAbilitySystemInterface
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
// Sets default values for this character's properties
|
|
ABotCharacter();
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
|
|
|
virtual void PossessedBy(AController* NewController) override;
|
|
|
|
protected:
|
|
// Called when the game starts or when spawned
|
|
virtual void BeginPlay() override;
|
|
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
|
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="GAS")
|
|
TObjectPtr<UAbilitySystemComponent> AbilitySystemComponent;
|
|
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="GAS")
|
|
TObjectPtr<UAttributeSet> AttributeSet;
|
|
|
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="GAS")
|
|
TArray<TSubclassOf<UGameplayAbility>> DefaultAbilities;
|
|
|
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="GAS")
|
|
TSubclassOf<UGameplayEffect> DefaultAttributeEffect;
|
|
|
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Respawn", meta=(ClampMin="0", Units="s"))
|
|
float RespawnDelay = 2.f;
|
|
|
|
UFUNCTION(BlueprintImplementableEvent, Category="Death")
|
|
void BP_OnDeath();
|
|
|
|
public:
|
|
// Called every frame
|
|
virtual void Tick(float DeltaTime) override;
|
|
|
|
// Called to bind functionality to input
|
|
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
|
|
|
private:
|
|
void InitAbilityActorInfo();
|
|
void BindHealthChangedDelegate();
|
|
void UnbindHealthChangedDelegate();
|
|
void BindSlowedTagChangedDelegate();
|
|
void UnbindSlowedTagChangedDelegate();
|
|
void OnHealthChanged(const FOnAttributeChangeData& Data);
|
|
void OnSlowedTagChanged(const FGameplayTag Tag, int32 NewCount);
|
|
void CacheDefaultMovementState();
|
|
void ApplySlowedState(bool bSlowed);
|
|
void GiveDefaultAbilities();
|
|
void ApplyDefaultAttributeEffect();
|
|
void HandleDeath();
|
|
void HandleRespawn();
|
|
|
|
UFUNCTION(NetMulticast, Reliable)
|
|
void MulticastHandleDeath();
|
|
|
|
UFUNCTION(NetMulticast, Reliable)
|
|
void MulticastRestoreRespawnState();
|
|
|
|
bool bHasGivenDefaultAbilities = false;
|
|
bool bHasAppliedDefaultAttributeEffect = false;
|
|
bool bHasHandledDeath = false;
|
|
bool bHasNotifiedDeath = false;
|
|
FDelegateHandle HealthChangedHandle;
|
|
FDelegateHandle SlowedTagChangedHandle;
|
|
float DefaultMaxWalkSpeed = 0.f;
|
|
float DefaultGlobalAnimRateScale = 1.f;
|
|
bool bHasCachedDefaultMovementState = false;
|
|
FTimerHandle RespawnTimer;
|
|
};
|