第一次提交
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AbilitySystemInterface.h"
|
||||
#include "GameplayTagAssetInterface.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "GGA_Character.generated.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief A character with ability system.
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API AGGA_Character : public ACharacter, public IAbilitySystemInterface, public IGameplayTagAssetInterface
|
||||
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this character's properties
|
||||
AGGA_Character(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
virtual void PreInitializeComponents() override;
|
||||
virtual void BeginPlay() override;
|
||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||
|
||||
#pragma region Pawn
|
||||
|
||||
protected:
|
||||
virtual void OnRep_Controller() override;
|
||||
virtual void OnRep_PlayerState() override;
|
||||
|
||||
/**
|
||||
* @brief Called when controller replicated to client.
|
||||
*/
|
||||
UFUNCTION(BlueprintImplementableEvent, Category=Character, meta=(DisplayName="Receive Player Controller"))
|
||||
void ReceivePlayerController();
|
||||
|
||||
/**
|
||||
* @brief Called when player state replicated to client.
|
||||
*/
|
||||
UFUNCTION(BlueprintImplementableEvent, Category=Character, meta=(DisplayName="Receive Player State"))
|
||||
void ReceivePlayerState();
|
||||
|
||||
#pragma endregion Pawn
|
||||
|
||||
|
||||
#pragma region AbilitySystem
|
||||
|
||||
public:
|
||||
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
||||
|
||||
protected:
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
UAbilitySystemComponent* CustomGetAbilitySystemComponent() const;
|
||||
|
||||
private:
|
||||
#pragma endregion AbilitySystem
|
||||
|
||||
public:
|
||||
virtual void GetOwnedGameplayTags(FGameplayTagContainer& TagContainer) const override;
|
||||
|
||||
|
||||
// Called to bind functionality to input
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GGA_AbilitySystemComponent.h"
|
||||
#include "GGA_Character.h"
|
||||
#include "GGA_CharacterWithAbilities.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API AGGA_CharacterWithAbilities : public AGGA_Character
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
AGGA_CharacterWithAbilities(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
||||
|
||||
private:
|
||||
UPROPERTY(Category=Character, VisibleAnywhere, BlueprintReadOnly, meta=(AllowPrivateAccess = "true"))
|
||||
TObjectPtr<UGGA_AbilitySystemComponent> AbilitySystemComponent;
|
||||
};
|
||||
@@ -0,0 +1,78 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "AbilitySystemInterface.h"
|
||||
#include "Engine/EngineTypes.h"
|
||||
#include "GameFramework/GameState.h"
|
||||
#include "GameFramework/GameStateBase.h"
|
||||
#include "GGA_GameState.generated.h"
|
||||
|
||||
class UGGA_AbilitySystemComponent;
|
||||
class UObject;
|
||||
|
||||
|
||||
/**
|
||||
* @brief A Game State base with ability system component.
|
||||
*/
|
||||
UCLASS(Blueprintable)
|
||||
class GENERICGAMEPLAYABILITIES_API AGGA_GameStateBase : public AGameStateBase, public IAbilitySystemInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
AGGA_GameStateBase(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
||||
|
||||
//~ Begin AActor interface
|
||||
virtual void PreInitializeComponents() override;
|
||||
virtual void PostInitializeComponents() override;
|
||||
virtual void BeginPlay() override;
|
||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||
//~ End AActor interface
|
||||
|
||||
//~IAbilitySystemInterface
|
||||
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
||||
//~End of IAbilitySystemInterface
|
||||
|
||||
private:
|
||||
// The ability system component subobject for game-wide things (primarily gameplay cues)
|
||||
UPROPERTY(VisibleAnywhere, Category = "GGA|GameState")
|
||||
TObjectPtr<UGGA_AbilitySystemComponent> AbilitySystemComponent;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief A Game State with ability system component.
|
||||
*/
|
||||
UCLASS(Blueprintable)
|
||||
class GENERICGAMEPLAYABILITIES_API AGGA_GameState : public AGameState, public IAbilitySystemInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
AGGA_GameState(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
||||
|
||||
//~ Begin AActor interface
|
||||
virtual void PreInitializeComponents() override;
|
||||
virtual void PostInitializeComponents() override;
|
||||
virtual void BeginPlay() override;
|
||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||
//~ End AActor interface
|
||||
|
||||
protected:
|
||||
//~ Begin AGameState interface
|
||||
virtual void HandleMatchHasStarted() override;
|
||||
//~ Begin AGameState interface
|
||||
|
||||
|
||||
//~IAbilitySystemInterface
|
||||
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
||||
//~End of IAbilitySystemInterface
|
||||
|
||||
private:
|
||||
// The ability system component subobject for game-wide things (primarily gameplay cues)
|
||||
UPROPERTY(VisibleAnywhere, Category = "GameState")
|
||||
TObjectPtr<UGGA_AbilitySystemComponent> AbilitySystemComponent;
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AbilitySystemInterface.h"
|
||||
#include "GGA_AbilitySystemComponent.h"
|
||||
#include "GameFramework/PlayerState.h"
|
||||
#include "GGA_PlayerState.generated.h"
|
||||
|
||||
/**
|
||||
* @brief Minimal PlayerState class that supports extension by game feature plugins.
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API AGGA_PlayerState : public APlayerState, public IAbilitySystemInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
AGGA_PlayerState(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
||||
|
||||
//~ Begin AActor interface
|
||||
virtual void PreInitializeComponents() override;
|
||||
virtual void BeginPlay() override;
|
||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||
virtual void Reset() override;
|
||||
virtual void ClientInitialize(AController* C) override;
|
||||
//~ End AActor interface
|
||||
|
||||
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
||||
|
||||
protected:
|
||||
//~ Begin APlayerState interface
|
||||
virtual void CopyProperties(APlayerState* PlayerState);
|
||||
//~ End APlayerState interface
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Called by Controller when its PlayerState is initially replicated.
|
||||
* @param Controller
|
||||
*/
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void ReceiveClientInitialize(AController* Controller);
|
||||
|
||||
private:
|
||||
UPROPERTY(Category=PlayerState, VisibleAnywhere, BlueprintReadOnly, meta=(AllowPrivateAccess = "true"))
|
||||
TObjectPtr<UGGA_AbilitySystemComponent> AbilitySystemComponent;
|
||||
};
|
||||
Reference in New Issue
Block a user