第一次提交

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,82 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#include "GCS_LogChannels.h"
#include "Engine/EngineTypes.h"
#include "GameFramework/Actor.h"
#include "Components/ActorComponent.h"
#include "GameplayTask.h"
#include "Abilities/GameplayAbility.h"
DEFINE_LOG_CATEGORY(LogGCS)
DEFINE_LOG_CATEGORY(LogGCS_Targeting)
DEFINE_LOG_CATEGORY(LogGCS_Collision)
DEFINE_LOG_CATEGORY(LogGCS_Trace)
FString GetGCSLogContextString(const UObject* ContextObject)
{
ENetRole Role = ROLE_None;
FString RoleName = TEXT("None");
FString Name = "None";
if (const AActor* Actor = Cast<AActor>(ContextObject))
{
Role = Actor->GetLocalRole();
Name = Actor->GetName();
}
else if (const UActorComponent* Component = Cast<UActorComponent>(ContextObject))
{
Role = Component->GetOwnerRole();
Name = Component->GetOwner()->GetName();
}
else if (const UGameplayTask* Task = Cast<UGameplayTask>(ContextObject))
{
Role = Task->GetAvatarActor()->GetLocalRole();
Name = Task->GetAvatarActor()->GetName();
}
else if (const UGameplayAbility* Ability = Cast<UGameplayAbility>(ContextObject))
{
Role = Ability->GetAvatarActorFromActorInfo()->GetLocalRole();
Name = Ability->GetAvatarActorFromActorInfo()->GetName();
}
else if (IsValid(ContextObject))
{
Name = ContextObject->GetName();
}
if (Role != ROLE_None)
{
RoleName = (Role == ROLE_Authority) ? TEXT("Server") : TEXT("Client");
}
return FString::Printf(TEXT("[%s] (%s)"), *RoleName, *Name);
}
FString GetClientServerContextString(UObject* ContextObject)
{
ENetRole Role = ROLE_None;
if (AActor* Actor = Cast<AActor>(ContextObject))
{
Role = Actor->GetLocalRole();
}
else if (UActorComponent* Component = Cast<UActorComponent>(ContextObject))
{
Role = Component->GetOwnerRole();
}
if (Role != ROLE_None)
{
return (Role == ROLE_Authority) ? TEXT("Server") : TEXT("Client");
}
#if WITH_EDITOR
if (GIsEditor)
{
extern ENGINE_API FString GPlayInEditorContextString;
return GPlayInEditorContextString;
}
#endif
return TEXT("[]");
}