diff --git a/Content/Core/Actors/BP_Base_ProjectileLauncher.uasset b/Content/Core/Actors/BP_Base_ProjectileLauncher.uasset index e5da814..a901012 100644 Binary files a/Content/Core/Actors/BP_Base_ProjectileLauncher.uasset and b/Content/Core/Actors/BP_Base_ProjectileLauncher.uasset differ diff --git a/Content/__ExternalActors__/Maps/L_Default/4/98/HCM4KXTG2Y2G1I0BTX2UNY.uasset b/Content/__ExternalActors__/Maps/L_Default/4/98/HCM4KXTG2Y2G1I0BTX2UNY.uasset index 4052957..a086acb 100644 Binary files a/Content/__ExternalActors__/Maps/L_Default/4/98/HCM4KXTG2Y2G1I0BTX2UNY.uasset and b/Content/__ExternalActors__/Maps/L_Default/4/98/HCM4KXTG2Y2G1I0BTX2UNY.uasset differ diff --git a/Content/__ExternalActors__/Maps/L_Default/E/HA/CXMK7W9FIGA0C2MR0GYXOO.uasset b/Content/__ExternalActors__/Maps/L_Default/E/HA/CXMK7W9FIGA0C2MR0GYXOO.uasset index 63f308a..c0417af 100644 Binary files a/Content/__ExternalActors__/Maps/L_Default/E/HA/CXMK7W9FIGA0C2MR0GYXOO.uasset and b/Content/__ExternalActors__/Maps/L_Default/E/HA/CXMK7W9FIGA0C2MR0GYXOO.uasset differ diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp index 9c8cb1b..9a052a1 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp @@ -53,12 +53,12 @@ void UCogWindowManager::InitializeInternal() IniHandler.UserData = this; ImGui::AddSettingsHandler(&IniHandler); - SpaceWindows.Add(CreateWindow("Spacing 1", false)); - SpaceWindows.Add(CreateWindow("Spacing 2", false)); - SpaceWindows.Add(CreateWindow("Spacing 3", false)); - SpaceWindows.Add(CreateWindow("Spacing 4", false)); + SpaceWindows.Add(AddWindow("Spacing 1", false)); + SpaceWindows.Add(AddWindow("Spacing 2", false)); + SpaceWindows.Add(AddWindow("Spacing 3", false)); + SpaceWindows.Add(AddWindow("Spacing 4", false)); - SettingsWindow = CreateWindow("Window.Settings", false); + SettingsWindow = AddWindow("Window.Settings", false); ConsoleCommands.Add(IConsoleManager::Get().RegisterConsoleCommand( *ToggleInputCommand, diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h b/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h index fc113ca..13c254f 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h @@ -85,7 +85,7 @@ public: const UObject* GetAsset(const TSubclassOf AssetClass); template - T* CreateWindow(const FString& Name, bool AddToMainMenu = true) + T* AddWindow(const FString& Name, bool AddToMainMenu = true) { T* Window = new T(); AddWindow(Window, Name, AddToMainMenu); diff --git a/Source/CogSample/CogSampleGameState.cpp b/Source/CogSample/CogSampleGameState.cpp index c24bb30..04e9778 100644 --- a/Source/CogSample/CogSampleGameState.cpp +++ b/Source/CogSample/CogSampleGameState.cpp @@ -123,15 +123,15 @@ void ACogSampleGameState::InitializeCog() //--------------------------------------- // Engine //--------------------------------------- - CogWindowManager->CreateWindow("Engine.Collision"); + CogWindowManager->AddWindow("Engine.Collision"); - CogWindowManager->CreateWindow("Engine.Command Bindings"); + CogWindowManager->AddWindow("Engine.Command Bindings"); - CogWindowManager->CreateWindow("Engine.Debug Settings"); + CogWindowManager->AddWindow("Engine.Debug Settings"); - CogWindowManager->CreateWindow("Engine.ImGui"); + CogWindowManager->AddWindow("Engine.ImGui"); - FCogEngineWindow_Inspector* Inspector = CogWindowManager->CreateWindow("Engine.Inspector"); + FCogEngineWindow_Inspector* Inspector = CogWindowManager->AddWindow("Engine.Inspector"); Inspector->AddFavorite(GEngine->GetGameUserSettings(), [](UObject* Object) { if (UGameUserSettings* UserSettings = Cast(Object)) @@ -140,60 +140,60 @@ void ACogSampleGameState::InitializeCog() } }); - CogWindowManager->CreateWindow("Engine.Log Categories"); + CogWindowManager->AddWindow("Engine.Log Categories"); - CogWindowManager->CreateWindow("Engine.Net Emulation"); + CogWindowManager->AddWindow("Engine.Net Emulation"); - CogWindowManager->CreateWindow("Engine.Output Log"); + CogWindowManager->AddWindow("Engine.Output Log"); - CogWindowManager->CreateWindow("Engine.Metrics"); + CogWindowManager->AddWindow("Engine.Metrics"); - CogWindowManager->CreateWindow("Engine.Plots"); + CogWindowManager->AddWindow("Engine.Plots"); - FCogEngineWindow_Selection* SelectionWindow = CogWindowManager->CreateWindow("Engine.Selection"); + FCogEngineWindow_Selection* SelectionWindow = CogWindowManager->AddWindow("Engine.Selection"); SelectionWindow->SetActorClasses({ ACharacter::StaticClass(), AActor::StaticClass(), AGameModeBase::StaticClass(), AGameStateBase::StaticClass() }); SelectionWindow->SetTraceType(UEngineTypes::ConvertToTraceType(ECollisionChannel::ECC_Pawn)); - CogWindowManager->CreateWindow("Engine.Scalability"); + CogWindowManager->AddWindow("Engine.Scalability"); - CogWindowManager->CreateWindow("Engine.Skeleton"); + CogWindowManager->AddWindow("Engine.Skeleton"); - CogWindowManager->CreateWindow("Engine.Spawns"); + CogWindowManager->AddWindow("Engine.Spawns"); - FCogEngineWindow_Stats* StatsWindow = CogWindowManager->CreateWindow("Engine.Stats"); + FCogEngineWindow_Stats* StatsWindow = CogWindowManager->AddWindow("Engine.Stats"); - CogWindowManager->CreateWindow("Engine.Time Scale"); + CogWindowManager->AddWindow("Engine.Time Scale"); //--------------------------------------- // Abilities //--------------------------------------- - CogWindowManager->CreateWindow("Gameplay.Abilities"); + CogWindowManager->AddWindow("Gameplay.Abilities"); - CogWindowManager->CreateWindow("Gameplay.Attributes"); + CogWindowManager->AddWindow("Gameplay.Attributes"); - CogWindowManager->CreateWindow("Gameplay.Cheats"); + CogWindowManager->AddWindow("Gameplay.Cheats"); - CogWindowManager->CreateWindow("Gameplay.Effects"); + CogWindowManager->AddWindow("Gameplay.Effects"); - CogWindowManager->CreateWindow("Gameplay.Pools"); + CogWindowManager->AddWindow("Gameplay.Pools"); - CogWindowManager->CreateWindow("Gameplay.Tags"); + CogWindowManager->AddWindow("Gameplay.Tags"); - CogWindowManager->CreateWindow("Gameplay.Tweaks"); + CogWindowManager->AddWindow("Gameplay.Tweaks"); //--------------------------------------- // AI //--------------------------------------- - CogWindowManager->CreateWindow("AI.Behavior Tree"); + CogWindowManager->AddWindow("AI.Behavior Tree"); - CogWindowManager->CreateWindow("AI.Blackboard"); + CogWindowManager->AddWindow("AI.Blackboard"); //--------------------------------------- // Input //--------------------------------------- - CogWindowManager->CreateWindow("Input.Actions"); + CogWindowManager->AddWindow("Input.Actions"); - CogWindowManager->CreateWindow("Input.Gamepad"); + CogWindowManager->AddWindow("Input.Gamepad"); //--------------------------------------- // Main Menu Widget diff --git a/Source/CogSample/CogSamplePlayerController.cpp b/Source/CogSample/CogSamplePlayerController.cpp index ab9c779..6f46c35 100644 --- a/Source/CogSample/CogSamplePlayerController.cpp +++ b/Source/CogSample/CogSamplePlayerController.cpp @@ -226,6 +226,8 @@ const ACogSamplePlayerController* ACogSamplePlayerController::GetFirstLocalPlaye //-------------------------------------------------------------------------------------------------------------------------- float ACogSamplePlayerController::GetClientLag() const { - return (PlayerState != nullptr && GetNetMode() != NM_Standalone) ? (0.0001f * 0.5f * PlayerState->ExactPing) : 0.f; + const float Ping = (PlayerState != nullptr && GetNetMode() != NM_Standalone) ? PlayerState->ExactPing : 0.0f; + const float HalfPingInSeconds = Ping * 0.0001f * 0.5f; + return HalfPingInSeconds; } diff --git a/Source/CogSample/CogSampleProjectileComponent.cpp b/Source/CogSample/CogSampleProjectileComponent.cpp index dcea728..339bfd2 100644 --- a/Source/CogSample/CogSampleProjectileComponent.cpp +++ b/Source/CogSample/CogSampleProjectileComponent.cpp @@ -82,6 +82,8 @@ void UCogSampleProjectileComponent::BeginPlay() Creator = UCogSampleFunctionLibrary_Gameplay::GetCreator(GetOwner()); SpawnPrediction = GetOwner()->FindComponentByClass(); + COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s - Role:%s - IsActive:%d"), *GetNameSafe(GetOwner()), *GetRoleName(), IsActive()); + RegisterAllEffects(); Collision = Cast(CollisionReference.GetComponent(GetOwner())); @@ -98,13 +100,17 @@ void UCogSampleProjectileComponent::BeginPlay() if (GetOwner()->GetLocalRole() != ROLE_Authority) { - Activate(false); + //----------------------------------------------------------------------------------------------- + // Must force the activation because the server might have already replicated the IsActive flag. + //----------------------------------------------------------------------------------------------- + Activate(true); } } //-------------------------------------------------------------------------------------------------------------------------- void UCogSampleProjectileComponent::Activate(bool 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 @@ -126,8 +132,6 @@ void UCogSampleProjectileComponent::Activate(bool bReset) Velocity = ServerSpawnVelocity; } - Super::Activate(bReset); - #if ENABLE_COG DrawDebugCurrentState(FColor::Green); if (FCogDebugLog::IsLogCategoryActive(LogCogProjectile)) @@ -148,6 +152,7 @@ void UCogSampleProjectileComponent::Activate(bool bReset) } } + Super::Activate(bReset); } //-------------------------------------------------------------------------------------------------------------------------- @@ -205,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:%0.2f"), *GetName(), *GetRoleName(), CatchupDuration); + 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); @@ -319,10 +324,10 @@ 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"), - *GetName(), + *GetNameSafe(GetOwner()), *GetRoleName(), - OtherActor != nullptr ? *OtherActor->GetName() : TEXT("NULL"), - OtherComp != nullptr ? *OtherComp->GetName() : TEXT("NULL")); + *GetNameSafe(OtherActor), + *GetNameSafe(OtherComp)); if (ShouldProcessOverlap(OtherActor, OtherComp, false) == false) { @@ -379,10 +384,10 @@ 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"), - *GetName(), + *GetNameSafe(GetOwner()), *GetRoleName(), - OtherActor != nullptr ? *OtherActor->GetName() : TEXT("NULL"), - OtherComp != nullptr ? *OtherComp->GetName() : TEXT("NULL")); + *GetNameSafe(OtherActor), + *GetNameSafe(OtherComp)); //------------------------------------------------------------------------------------- // Call ShouldProcessOverlap with a requirement of a valid actor because the @@ -432,10 +437,10 @@ 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"), - *GetName(), + *GetNameSafe(GetOwner()), *GetRoleName(), - HitResult.GetActor() != nullptr ? *HitResult.GetActor()->GetName() : TEXT("NULL"), - HitResult.GetComponent() != nullptr ? *HitResult.GetComponent()->GetName() : TEXT("NULL"), + *GetNameSafe(HitResult.GetActor()), + *GetNameSafe(HitResult.GetComponent()), *HitResult.BoneName.ToString()); //----------------------------------------------------------------------------------------- @@ -461,6 +466,19 @@ 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"), + *GetNameSafe(GetOwner()), + *GetRoleName(), + *GetNameSafe(HitResult.GetActor()), + *GetNameSafe(HitResult.GetComponent()), + *HitResult.BoneName.ToString()); + + Super::StopSimulating(HitResult); +} + //-------------------------------------------------------------------------------------------------------------------------- void UCogSampleProjectileComponent::ClearHitActors() { @@ -534,3 +552,5 @@ FString UCogSampleProjectileComponent::GetRoleName() const return SpawnPrediction->GetRoleName(); } + + diff --git a/Source/CogSample/CogSampleProjectileComponent.h b/Source/CogSample/CogSampleProjectileComponent.h index c4d5448..b408bf0 100644 --- a/Source/CogSample/CogSampleProjectileComponent.h +++ b/Source/CogSample/CogSampleProjectileComponent.h @@ -57,6 +57,9 @@ public: virtual void Activate(bool bReset) override; + virtual void StopSimulating(const FHitResult& HitResult) override; + + UFUNCTION(BlueprintCallable) void ClearHitActors(); diff --git a/TODO.txt b/TODO.txt index 727bf48..2ef9bcd 100644 --- a/TODO.txt +++ b/TODO.txt @@ -11,6 +11,7 @@ - CogEngine: make a better widget for CheckBoxState for input shortcuts - CogEngine: save active log categories - CogEngine: add menu on the PlotWindow wih the controls +- CogEngine: Improve collision window: Add Query Type, Single or Multi, By Channel or Object Type, Object Type. - CogSample: Add a custom window in sample (changing the character faction) - CogSample: Create more abilities