第一次提交

This commit is contained in:
不明不惑
2026-03-03 01:23:02 +08:00
commit 3e434877e8
1053 changed files with 102411 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#include "GameplayActors/GGA_Character.h"
#include "AbilitySystemComponent.h"
#include "Components/GameFrameworkComponentManager.h"
AGGA_Character::AGGA_Character(const FObjectInitializer& ObjectInitializer): Super(ObjectInitializer)
{
PrimaryActorTick.bCanEverTick = true;
}
void AGGA_Character::PreInitializeComponents()
{
Super::PreInitializeComponents();
UGameFrameworkComponentManager::AddGameFrameworkComponentReceiver(this);
}
void AGGA_Character::BeginPlay()
{
UGameFrameworkComponentManager::SendGameFrameworkComponentExtensionEvent(this, UGameFrameworkComponentManager::NAME_GameActorReady);
Super::BeginPlay();
}
void AGGA_Character::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
UGameFrameworkComponentManager::RemoveGameFrameworkComponentReceiver(this);
Super::EndPlay(EndPlayReason);
}
void AGGA_Character::OnRep_Controller()
{
Super::OnRep_Controller();
ReceivePlayerController();
}
void AGGA_Character::OnRep_PlayerState()
{
Super::OnRep_PlayerState();
ReceivePlayerState();
}
UAbilitySystemComponent* AGGA_Character::GetAbilitySystemComponent() const
{
if (UAbilitySystemComponent* BpProvidedASC = CustomGetAbilitySystemComponent())
{
return BpProvidedASC;
}
return nullptr;
}
void AGGA_Character::GetOwnedGameplayTags(FGameplayTagContainer& TagContainer) const
{
}
// Called to bind functionality to input
void AGGA_Character::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}

View File

@@ -0,0 +1,21 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#include "GameplayActors/GGA_CharacterWithAbilities.h"
#include "GGA_AbilitySystemComponent.h"
AGGA_CharacterWithAbilities::AGGA_CharacterWithAbilities(const FObjectInitializer& ObjectInitializer): Super(ObjectInitializer)
{
AbilitySystemComponent = CreateDefaultSubobject<UGGA_AbilitySystemComponent>(TEXT("AbilitySystemComponent"));
AbilitySystemComponent->SetIsReplicated(true);
}
UAbilitySystemComponent* AGGA_CharacterWithAbilities::GetAbilitySystemComponent() const
{
if (UAbilitySystemComponent* BpProvidedASC = CustomGetAbilitySystemComponent())
{
return BpProvidedASC;
}
return AbilitySystemComponent;
}

View File

@@ -0,0 +1,116 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#include "GameplayActors/GGA_GameState.h"
#include "GGA_AbilitySystemComponent.h"
#include "Components/GameFrameworkComponentManager.h"
#include "Components/GameStateComponent.h"
#include "Containers/Array.h"
// #include UE_INLINE_GENERATED_CPP_BY_NAME(ModularGameState)
AGGA_GameStateBase::AGGA_GameStateBase(const FObjectInitializer& ObjectInitializer)
{
PrimaryActorTick.bCanEverTick = true;
PrimaryActorTick.bStartWithTickEnabled = true;
AbilitySystemComponent = ObjectInitializer.CreateDefaultSubobject<UGGA_AbilitySystemComponent>(this, TEXT("AbilitySystemComponent"));
AbilitySystemComponent->SetIsReplicated(true);
AbilitySystemComponent->SetReplicationMode(EGameplayEffectReplicationMode::Mixed);
}
void AGGA_GameStateBase::PostInitializeComponents()
{
Super::PostInitializeComponents();
if (AbilitySystemComponent)
{
AbilitySystemComponent->InitAbilityActorInfo(/*Owner=*/ this, /*Avatar=*/ this);
}
}
UAbilitySystemComponent* AGGA_GameStateBase::GetAbilitySystemComponent() const
{
return AbilitySystemComponent;
}
void AGGA_GameStateBase::PreInitializeComponents()
{
Super::PreInitializeComponents();
UGameFrameworkComponentManager::AddGameFrameworkComponentReceiver(this);
}
void AGGA_GameStateBase::BeginPlay()
{
UGameFrameworkComponentManager::SendGameFrameworkComponentExtensionEvent(this, UGameFrameworkComponentManager::NAME_GameActorReady);
Super::BeginPlay();
}
void AGGA_GameStateBase::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
UGameFrameworkComponentManager::RemoveGameFrameworkComponentReceiver(this);
Super::EndPlay(EndPlayReason);
}
AGGA_GameState::AGGA_GameState(const FObjectInitializer& ObjectInitializer): Super(ObjectInitializer)
{
PrimaryActorTick.bCanEverTick = true;
PrimaryActorTick.bStartWithTickEnabled = true;
AbilitySystemComponent = ObjectInitializer.CreateDefaultSubobject<UGGA_AbilitySystemComponent>(this, TEXT("AbilitySystemComponent"));
AbilitySystemComponent->SetIsReplicated(true);
AbilitySystemComponent->SetReplicationMode(EGameplayEffectReplicationMode::Mixed);
}
UAbilitySystemComponent* AGGA_GameState::GetAbilitySystemComponent() const
{
return AbilitySystemComponent;
}
void AGGA_GameState::PreInitializeComponents()
{
Super::PreInitializeComponents();
UGameFrameworkComponentManager::AddGameFrameworkComponentReceiver(this);
}
void AGGA_GameState::PostInitializeComponents()
{
Super::PostInitializeComponents();
if (AbilitySystemComponent)
{
AbilitySystemComponent->InitAbilityActorInfo(/*Owner=*/ this, /*Avatar=*/ this);
}
}
void AGGA_GameState::BeginPlay()
{
UGameFrameworkComponentManager::SendGameFrameworkComponentExtensionEvent(this, UGameFrameworkComponentManager::NAME_GameActorReady);
Super::BeginPlay();
}
void AGGA_GameState::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
UGameFrameworkComponentManager::RemoveGameFrameworkComponentReceiver(this);
Super::EndPlay(EndPlayReason);
}
void AGGA_GameState::HandleMatchHasStarted()
{
Super::HandleMatchHasStarted();
TArray<UGameStateComponent*> ModularComponents;
GetComponents(ModularComponents);
for (UGameStateComponent* Component : ModularComponents)
{
Component->HandleMatchHasStarted();
}
}

View File

@@ -0,0 +1,72 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#include "GameplayActors/GGA_PlayerState.h"
#include "Components/GameFrameworkComponentManager.h"
#include "Components/PlayerStateComponent.h"
AGGA_PlayerState::AGGA_PlayerState(const FObjectInitializer& ObjectInitializer):Super(ObjectInitializer)
{
AbilitySystemComponent = ObjectInitializer.CreateDefaultSubobject<UGGA_AbilitySystemComponent>(this, TEXT("AbilitySystemComponent"));
AbilitySystemComponent->SetIsReplicated(true);
AbilitySystemComponent->SetReplicationMode(EGameplayEffectReplicationMode::Mixed);
}
void AGGA_PlayerState::PreInitializeComponents()
{
Super::PreInitializeComponents();
UGameFrameworkComponentManager::AddGameFrameworkComponentReceiver(this);
}
void AGGA_PlayerState::BeginPlay()
{
UGameFrameworkComponentManager::SendGameFrameworkComponentExtensionEvent(this, UGameFrameworkComponentManager::NAME_GameActorReady);
Super::BeginPlay();
}
void AGGA_PlayerState::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
UGameFrameworkComponentManager::RemoveGameFrameworkComponentReceiver(this);
Super::EndPlay(EndPlayReason);
}
void AGGA_PlayerState::Reset()
{
TArray<UPlayerStateComponent*> ModularComponents;
GetComponents(ModularComponents);
for (UPlayerStateComponent* Component : ModularComponents)
{
Component->Reset();
}
Super::Reset();
}
void AGGA_PlayerState::ClientInitialize(AController* C)
{
Super::ClientInitialize(C);
ReceiveClientInitialize(C);
}
UAbilitySystemComponent* AGGA_PlayerState::GetAbilitySystemComponent() const
{
return AbilitySystemComponent;
}
void AGGA_PlayerState::CopyProperties(APlayerState* PlayerState)
{
Super::CopyProperties(PlayerState);
TInlineComponentArray<UPlayerStateComponent*> PlayerStateComponents;
GetComponents(PlayerStateComponents);
for (UPlayerStateComponent* SourcePSComp : PlayerStateComponents)
{
if (UPlayerStateComponent* TargetComp = Cast<UPlayerStateComponent>(static_cast<UObject*>(FindObjectWithOuter(PlayerState, SourcePSComp->GetClass(), SourcePSComp->GetFName()))))
{
SourcePSComp->CopyProperties(TargetComp);
}
}
}