mirror of
https://github.com/Ed94/Cog.git
synced 2026-06-13 00:01:37 -07:00
CogCommon: Better debug formating
CogSample: Projectile Progress CogSample: Disable Character Mesh collision on dedicated server
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "CogSampleRootMotionParams.h"
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "Components/InputComponent.h"
|
||||
#include "Engine/CollisionProfile.h"
|
||||
#include "EnhancedInputComponent.h"
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
@@ -108,6 +109,12 @@ void ACogSampleCharacter::BeginPlay()
|
||||
}
|
||||
}
|
||||
|
||||
if (GetWorld()->GetNetMode() == NM_DedicatedServer)
|
||||
{
|
||||
GetMesh()->SetCollisionProfileName(UCollisionProfile::NoCollision_ProfileName);
|
||||
}
|
||||
|
||||
|
||||
TryFinishInitialize();
|
||||
RefreshServerAnimTickOption();
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ void UCogSampleProjectileComponent::BeginPlay()
|
||||
Creator = UCogSampleFunctionLibrary_Gameplay::GetCreator(GetOwner());
|
||||
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();
|
||||
|
||||
@@ -110,7 +110,7 @@ void UCogSampleProjectileComponent::BeginPlay()
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
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
|
||||
@@ -210,7 +210,7 @@ void UCogSampleProjectileComponent::TickComponent(float DeltaTime, enum ELevelTi
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
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;
|
||||
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
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -268,11 +279,11 @@ bool UCogSampleProjectileComponent::ShouldProcessOverlap(AActor* OtherActor, UPr
|
||||
return false;
|
||||
}
|
||||
|
||||
if (GetOwner()->GetLocalRole() != ROLE_Authority)
|
||||
{
|
||||
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Skipped:NotAuthority"));
|
||||
return false;
|
||||
}
|
||||
//if (GetOwner()->GetLocalRole() == ROLE_Authority)
|
||||
//{
|
||||
// COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Skipped:NotAuthority"));
|
||||
// return false;
|
||||
//}
|
||||
|
||||
//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)
|
||||
{
|
||||
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()),
|
||||
*GetRoleName(),
|
||||
*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)
|
||||
{
|
||||
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()),
|
||||
*GetRoleName(),
|
||||
*GetNameSafe(OtherActor),
|
||||
@@ -436,7 +447,7 @@ void UCogSampleProjectileComponent::OnAssistanceOverlapBegin(UPrimitiveComponent
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
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()),
|
||||
*GetRoleName(),
|
||||
*GetNameSafe(HitResult.GetActor()),
|
||||
@@ -469,7 +480,7 @@ void UCogSampleProjectileComponent::TryHit(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()),
|
||||
*GetRoleName(),
|
||||
*GetNameSafe(HitResult.GetActor()),
|
||||
@@ -494,16 +505,42 @@ bool UCogSampleProjectileComponent::ShouldHit_Implementation(const FHitResult& H
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
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
|
||||
DrawDebugCurrentState(FColor::White, false);
|
||||
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);
|
||||
DrawDebugHitResult(HitResult);
|
||||
#endif //ENABLE_COG
|
||||
|
||||
AActor* HitActor = HitResult.GetActor();
|
||||
|
||||
UAbilitySystemComponent* TargetAbilitySystem = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(HitActor);
|
||||
if (TargetAbilitySystem == nullptr)
|
||||
{
|
||||
@@ -540,17 +577,4 @@ void UCogSampleProjectileComponent::Hit_Implementation(const FHitResult& HitResu
|
||||
TargetAbilitySystem->ApplyGameplayEffectSpecToSelf(*Spec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
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);
|
||||
|
||||
UFUNCTION(Server, Reliable)
|
||||
virtual void Server_Hit(const FHitResult& Hit);
|
||||
|
||||
UFUNCTION()
|
||||
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);
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||
bool ShouldHit(const FHitResult& hit);
|
||||
bool ShouldHit(const FHitResult& Hit);
|
||||
|
||||
/** Blueprint hook called when projectile hits something */
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||
@@ -140,6 +143,7 @@ protected:
|
||||
|
||||
#if ENABLE_COG
|
||||
void DrawDebugCurrentState(const FColor& Color, bool DrawVelocity = true);
|
||||
void DrawDebugHitResult(const FHitResult& HitResult);
|
||||
|
||||
FVector LastDebugLocation = FVector::ZeroVector;
|
||||
#endif //ENABLE_COG
|
||||
|
||||
Reference in New Issue
Block a user