mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-04 14:48:45 +00:00
CogCommon: Better debug formating
CogSample: Projectile Progress CogSample: Disable Character Mesh collision on dedicated server
This commit is contained in:
@@ -29,13 +29,13 @@
|
|||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
#define COG_LOG_FUNC(LogCategory, Verbosity, Format, ...) \
|
#define COG_LOG_FUNC(LogCategory, Verbosity, Format, ...) \
|
||||||
COG_LOG(LogCategory, Verbosity, TEXT("%s - %s"), ANSI_TO_TCHAR(__FUNCTION__), *FString::Printf(Format, ##__VA_ARGS__)); \
|
COG_LOG(LogCategory, Verbosity, TEXT("%s | %s"), ANSI_TO_TCHAR(__FUNCTION__), *FString::Printf(Format, ##__VA_ARGS__)); \
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
#define COG_LOG_OBJECT(LogCategory, Verbosity, Object, Format, ...) \
|
#define COG_LOG_OBJECT(LogCategory, Verbosity, Object, Format, ...) \
|
||||||
if (COG_LOG_ACTIVE_FOR_OBJECT(Object) || (int32)Verbosity <= (int32)ELogVerbosity::Warning) \
|
if (COG_LOG_ACTIVE_FOR_OBJECT(Object) || (int32)Verbosity <= (int32)ELogVerbosity::Warning) \
|
||||||
{ \
|
{ \
|
||||||
COG_LOG(LogCategory, Verbosity, TEXT("%s - %s - %s"), \
|
COG_LOG(LogCategory, Verbosity, TEXT("%s | %s | %s"), \
|
||||||
*GetNameSafe(Object), \
|
*GetNameSafe(Object), \
|
||||||
ANSI_TO_TCHAR(__FUNCTION__), \
|
ANSI_TO_TCHAR(__FUNCTION__), \
|
||||||
*FString::Printf(Format, ##__VA_ARGS__)); \
|
*FString::Printf(Format, ##__VA_ARGS__)); \
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
#define COG_LOG_OBJECT_NO_CONTEXT(LogCategory, Verbosity, Object, Format, ...) \
|
#define COG_LOG_OBJECT_NO_CONTEXT(LogCategory, Verbosity, Object, Format, ...) \
|
||||||
if (COG_LOG_ACTIVE_FOR_OBJECT(Object) || (int32)Verbosity <= (int32)ELogVerbosity::Warning) \
|
if (COG_LOG_ACTIVE_FOR_OBJECT(Object) || (int32)Verbosity <= (int32)ELogVerbosity::Warning) \
|
||||||
{ \
|
{ \
|
||||||
COG_LOG(LogCategory, Verbosity, TEXT("%s - %s"), *GetNameSafe(Object), *FString::Printf(Format, ##__VA_ARGS__)); \
|
COG_LOG(LogCategory, Verbosity, TEXT("%s | %s"), *GetNameSafe(Object), *FString::Printf(Format, ##__VA_ARGS__)); \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
#else //ENABLE_COG
|
#else //ENABLE_COG
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "CogSampleRootMotionParams.h"
|
#include "CogSampleRootMotionParams.h"
|
||||||
#include "Components/CapsuleComponent.h"
|
#include "Components/CapsuleComponent.h"
|
||||||
#include "Components/InputComponent.h"
|
#include "Components/InputComponent.h"
|
||||||
|
#include "Engine/CollisionProfile.h"
|
||||||
#include "EnhancedInputComponent.h"
|
#include "EnhancedInputComponent.h"
|
||||||
#include "EnhancedInputSubsystems.h"
|
#include "EnhancedInputSubsystems.h"
|
||||||
#include "GameFramework/CharacterMovementComponent.h"
|
#include "GameFramework/CharacterMovementComponent.h"
|
||||||
@@ -108,6 +109,12 @@ void ACogSampleCharacter::BeginPlay()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GetWorld()->GetNetMode() == NM_DedicatedServer)
|
||||||
|
{
|
||||||
|
GetMesh()->SetCollisionProfileName(UCollisionProfile::NoCollision_ProfileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TryFinishInitialize();
|
TryFinishInitialize();
|
||||||
RefreshServerAnimTickOption();
|
RefreshServerAnimTickOption();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ void UCogSampleProjectileComponent::BeginPlay()
|
|||||||
Creator = UCogSampleFunctionLibrary_Gameplay::GetCreator(GetOwner());
|
Creator = UCogSampleFunctionLibrary_Gameplay::GetCreator(GetOwner());
|
||||||
SpawnPrediction = GetOwner()->FindComponentByClass<UCogSampleSpawnPredictionComponent>();
|
SpawnPrediction = GetOwner()->FindComponentByClass<UCogSampleSpawnPredictionComponent>();
|
||||||
|
|
||||||
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s - Role:%s - IsActive:%d"), *GetNameSafe(GetOwner()), *GetRoleName(), IsActive());
|
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s | Role:%s | IsActive:%d"), *GetNameSafe(GetOwner()), *GetRoleName(), IsActive());
|
||||||
|
|
||||||
RegisterAllEffects();
|
RegisterAllEffects();
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ void UCogSampleProjectileComponent::BeginPlay()
|
|||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void UCogSampleProjectileComponent::Activate(bool bReset)
|
void UCogSampleProjectileComponent::Activate(bool bReset)
|
||||||
{
|
{
|
||||||
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s - Role:%s - bReset:%d"), *GetNameSafe(GetOwner()), *GetRoleName(), bReset);
|
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s | Role:%s | bReset:%d"), *GetNameSafe(GetOwner()), *GetRoleName(), bReset);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
// Save the spawn location and rotation and get them replicated because, we want remote clients
|
// Save the spawn location and rotation and get them replicated because, we want remote clients
|
||||||
@@ -210,7 +210,7 @@ void UCogSampleProjectileComponent::TickComponent(float DeltaTime, enum ELevelTi
|
|||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void UCogSampleProjectileComponent::Catchup(float CatchupDuration)
|
void UCogSampleProjectileComponent::Catchup(float CatchupDuration)
|
||||||
{
|
{
|
||||||
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s - Role:%s - CatchupDuration:%dms"), *GetNameSafe(GetOwner()), *GetRoleName(), (int32)(CatchupDuration * 1000));
|
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s | Role:%s | CatchupDuration:%dms"), *GetNameSafe(GetOwner()), *GetRoleName(), (int32)(CatchupDuration * 1000));
|
||||||
|
|
||||||
IsCatchingUp = true;
|
IsCatchingUp = true;
|
||||||
TickComponent(CatchupDuration, LEVELTICK_All, nullptr);
|
TickComponent(CatchupDuration, LEVELTICK_All, nullptr);
|
||||||
@@ -240,6 +240,17 @@ void UCogSampleProjectileComponent::DrawDebugCurrentState(const FColor& Color, b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void UCogSampleProjectileComponent::DrawDebugHitResult(const FHitResult& HitResult)
|
||||||
|
{
|
||||||
|
FCogDebugDraw::Arrow(LogCogProjectile, GetOwner(), HitResult.Location, HitResult.Location + HitResult.Normal * 50.0f, FColor::Red, true, 0);
|
||||||
|
FCogDebugDraw::Box(LogCogProjectile, GetOwner(), HitResult.Location, FVector(0.0f, 5.0f, 5.0f), FRotationMatrix::MakeFromX(HitResult.Normal).ToQuat(), FColor::Red, true, 0);
|
||||||
|
FCogDebugDraw::Arrow(LogCogProjectile, GetOwner(), HitResult.ImpactPoint, HitResult.ImpactPoint + HitResult.ImpactNormal * 50.0f, FColor::Yellow, true, 0);
|
||||||
|
FCogDebugDraw::Box(LogCogProjectile, GetOwner(), HitResult.ImpactPoint, FVector(0.0f, 5.0f, 5.0f), FRotationMatrix::MakeFromX(HitResult.ImpactNormal).ToQuat(), FColor::Yellow, true, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif //ENABLE_COG
|
#endif //ENABLE_COG
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -268,11 +279,11 @@ bool UCogSampleProjectileComponent::ShouldProcessOverlap(AActor* OtherActor, UPr
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetOwner()->GetLocalRole() != ROLE_Authority)
|
//if (GetOwner()->GetLocalRole() == ROLE_Authority)
|
||||||
{
|
//{
|
||||||
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Skipped:NotAuthority"));
|
// COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Skipped:NotAuthority"));
|
||||||
return false;
|
// return false;
|
||||||
}
|
//}
|
||||||
|
|
||||||
//if (IsStopped)
|
//if (IsStopped)
|
||||||
//{
|
//{
|
||||||
@@ -323,7 +334,7 @@ bool UCogSampleProjectileComponent::ShouldProcessOverlap(AActor* OtherActor, UPr
|
|||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void UCogSampleProjectileComponent::OnCollisionOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool IsFromSweep, const FHitResult& SweepHit)
|
void UCogSampleProjectileComponent::OnCollisionOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool IsFromSweep, const FHitResult& SweepHit)
|
||||||
{
|
{
|
||||||
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s - Role:%s - Other:%s - Comp:%s"),
|
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s | Role:%s | Other:%s | Comp:%s"),
|
||||||
*GetNameSafe(GetOwner()),
|
*GetNameSafe(GetOwner()),
|
||||||
*GetRoleName(),
|
*GetRoleName(),
|
||||||
*GetNameSafe(OtherActor),
|
*GetNameSafe(OtherActor),
|
||||||
@@ -383,7 +394,7 @@ void UCogSampleProjectileComponent::OnCollisionOverlapBegin(UPrimitiveComponent*
|
|||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void UCogSampleProjectileComponent::OnAssistanceOverlapBegin(UPrimitiveComponent* overlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool IsFromSweep, const FHitResult& Hit)
|
void UCogSampleProjectileComponent::OnAssistanceOverlapBegin(UPrimitiveComponent* overlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool IsFromSweep, const FHitResult& Hit)
|
||||||
{
|
{
|
||||||
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s - Role:%s - Other:%s - Comp:%s"),
|
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s | Role:%s | Other:%s | Comp:%s"),
|
||||||
*GetNameSafe(GetOwner()),
|
*GetNameSafe(GetOwner()),
|
||||||
*GetRoleName(),
|
*GetRoleName(),
|
||||||
*GetNameSafe(OtherActor),
|
*GetNameSafe(OtherActor),
|
||||||
@@ -436,7 +447,7 @@ void UCogSampleProjectileComponent::OnAssistanceOverlapBegin(UPrimitiveComponent
|
|||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void UCogSampleProjectileComponent::TryHit(const FHitResult& HitResult)
|
void UCogSampleProjectileComponent::TryHit(const FHitResult& HitResult)
|
||||||
{
|
{
|
||||||
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s - Role:%s - Other:%s - Comp:%s - Bone:%s"),
|
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s | Role:%s | Other:%s | Comp:%s | Bone:%s"),
|
||||||
*GetNameSafe(GetOwner()),
|
*GetNameSafe(GetOwner()),
|
||||||
*GetRoleName(),
|
*GetRoleName(),
|
||||||
*GetNameSafe(HitResult.GetActor()),
|
*GetNameSafe(HitResult.GetActor()),
|
||||||
@@ -469,7 +480,7 @@ void UCogSampleProjectileComponent::TryHit(const FHitResult& HitResult)
|
|||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void UCogSampleProjectileComponent::StopSimulating(const FHitResult& HitResult)
|
void UCogSampleProjectileComponent::StopSimulating(const FHitResult& HitResult)
|
||||||
{
|
{
|
||||||
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s - Role:%s - Other:%s - Comp:%s - Bone:%s"),
|
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s | Role:%s | Other:%s | Comp:%s | Bone:%s"),
|
||||||
*GetNameSafe(GetOwner()),
|
*GetNameSafe(GetOwner()),
|
||||||
*GetRoleName(),
|
*GetRoleName(),
|
||||||
*GetNameSafe(HitResult.GetActor()),
|
*GetNameSafe(HitResult.GetActor()),
|
||||||
@@ -494,16 +505,42 @@ bool UCogSampleProjectileComponent::ShouldHit_Implementation(const FHitResult& H
|
|||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void UCogSampleProjectileComponent::Hit_Implementation(const FHitResult& HitResult, FCogSampleHitConsequence& HitConsequence)
|
void UCogSampleProjectileComponent::Hit_Implementation(const FHitResult& HitResult, FCogSampleHitConsequence& HitConsequence)
|
||||||
{
|
{
|
||||||
AActor* HitActor = HitResult.GetActor();
|
#if ENABLE_COG
|
||||||
|
DrawDebugCurrentState(FColor::White, false);
|
||||||
|
DrawDebugHitResult(HitResult);
|
||||||
|
#endif //ENABLE_COG
|
||||||
|
|
||||||
|
Server_Hit(HitResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
FString UCogSampleProjectileComponent::GetRoleName() const
|
||||||
|
{
|
||||||
|
if (SpawnPrediction == nullptr)
|
||||||
|
{
|
||||||
|
return TEXT("No Prediction");
|
||||||
|
}
|
||||||
|
|
||||||
|
return SpawnPrediction->GetRoleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void UCogSampleProjectileComponent::Server_Hit_Implementation(const FHitResult& HitResult)
|
||||||
|
{
|
||||||
|
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s | Role:%s | Other:%s | Comp:%s | Bone:%s"),
|
||||||
|
*GetNameSafe(GetOwner()),
|
||||||
|
*GetRoleName(),
|
||||||
|
*GetNameSafe(HitResult.GetActor()),
|
||||||
|
*GetNameSafe(HitResult.GetComponent()),
|
||||||
|
*HitResult.BoneName.ToString());
|
||||||
|
|
||||||
#if ENABLE_COG
|
#if ENABLE_COG
|
||||||
DrawDebugCurrentState(FColor::White, false);
|
DrawDebugCurrentState(FColor::White, false);
|
||||||
FCogDebugDraw::Arrow(LogCogProjectile, GetOwner(), HitResult.Location, HitResult.Location + HitResult.Normal * 50.0f, FColor::Red, true, 0);
|
DrawDebugHitResult(HitResult);
|
||||||
FCogDebugDraw::Box(LogCogProjectile, GetOwner(), HitResult.Location, FVector(0.0f, 5.0f, 5.0f), FRotationMatrix::MakeFromX(HitResult.Normal).ToQuat(), FColor::Red, true, 0);
|
|
||||||
FCogDebugDraw::Arrow(LogCogProjectile, GetOwner(), HitResult.ImpactPoint, HitResult.ImpactPoint + HitResult.ImpactNormal * 50.0f, FColor::Yellow, true, 0);
|
|
||||||
FCogDebugDraw::Box(LogCogProjectile, GetOwner(), HitResult.ImpactPoint, FVector(0.0f, 5.0f, 5.0f), FRotationMatrix::MakeFromX(HitResult.ImpactNormal).ToQuat(), FColor::Yellow, true, 0);
|
|
||||||
#endif //ENABLE_COG
|
#endif //ENABLE_COG
|
||||||
|
|
||||||
|
AActor* HitActor = HitResult.GetActor();
|
||||||
|
|
||||||
UAbilitySystemComponent* TargetAbilitySystem = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(HitActor);
|
UAbilitySystemComponent* TargetAbilitySystem = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(HitActor);
|
||||||
if (TargetAbilitySystem == nullptr)
|
if (TargetAbilitySystem == nullptr)
|
||||||
{
|
{
|
||||||
@@ -541,16 +578,3 @@ void UCogSampleProjectileComponent::Hit_Implementation(const FHitResult& HitResu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
FString UCogSampleProjectileComponent::GetRoleName() const
|
|
||||||
{
|
|
||||||
if (SpawnPrediction == nullptr)
|
|
||||||
{
|
|
||||||
return TEXT("No Prediction");
|
|
||||||
}
|
|
||||||
|
|
||||||
return SpawnPrediction->GetRoleName();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,9 @@ protected:
|
|||||||
|
|
||||||
virtual void TryHit(const FHitResult& Hit);
|
virtual void TryHit(const FHitResult& Hit);
|
||||||
|
|
||||||
|
UFUNCTION(Server, Reliable)
|
||||||
|
virtual void Server_Hit(const FHitResult& Hit);
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
virtual void OnCollisionOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool IsFromSweep, const FHitResult& SweepHit);
|
virtual void OnCollisionOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool IsFromSweep, const FHitResult& SweepHit);
|
||||||
|
|
||||||
@@ -86,7 +89,7 @@ protected:
|
|||||||
virtual void OnAssistanceOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool IsFromSweep, const FHitResult& SweepHit);
|
virtual void OnAssistanceOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool IsFromSweep, const FHitResult& SweepHit);
|
||||||
|
|
||||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||||
bool ShouldHit(const FHitResult& hit);
|
bool ShouldHit(const FHitResult& Hit);
|
||||||
|
|
||||||
/** Blueprint hook called when projectile hits something */
|
/** Blueprint hook called when projectile hits something */
|
||||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||||
@@ -140,6 +143,7 @@ protected:
|
|||||||
|
|
||||||
#if ENABLE_COG
|
#if ENABLE_COG
|
||||||
void DrawDebugCurrentState(const FColor& Color, bool DrawVelocity = true);
|
void DrawDebugCurrentState(const FColor& Color, bool DrawVelocity = true);
|
||||||
|
void DrawDebugHitResult(const FHitResult& HitResult);
|
||||||
|
|
||||||
FVector LastDebugLocation = FVector::ZeroVector;
|
FVector LastDebugLocation = FVector::ZeroVector;
|
||||||
#endif //ENABLE_COG
|
#endif //ENABLE_COG
|
||||||
|
|||||||
Reference in New Issue
Block a user