diff --git a/Config/DefaultGame.ini b/Config/DefaultGame.ini index 34b2b1c..e550978 100644 --- a/Config/DefaultGame.ini +++ b/Config/DefaultGame.ini @@ -1,3 +1,6 @@ [/Script/EngineSettings.GeneralProjectSettings] ProjectID=2D0786A947A0B6CFB887E3899DC531FE ProjectName=Third Person Game Template + +[/Script/GameplayAbilities.AbilitySystemGlobals] +AbilitySystemGlobalsClassName=/Script/CogSample.CogSampleAbilitySystemGlobals diff --git a/Config/DefaultGameplayTags.ini b/Config/DefaultGameplayTags.ini new file mode 100644 index 0000000..e067393 --- /dev/null +++ b/Config/DefaultGameplayTags.ini @@ -0,0 +1,12 @@ +[/Script/GameplayTags.GameplayTagsSettings] +ImportTagsFromConfig=True +WarnOnInvalidTags=True +ClearInvalidTags=False +AllowEditorTagUnloading=True +AllowGameTagUnloading=False +FastReplication=False +InvalidTagCharacters="\"\'," +NumBitsForContainerSize=6 +NetIndexFirstBitSegment=16 ++GameplayTagList=(Tag="GameplayCue.Ability.Hero1.PuhBack",DevComment="") + diff --git a/Content/Characters/BP_Character.uasset b/Content/Characters/BP_Character.uasset index 3c7d59a..985bb7b 100644 Binary files a/Content/Characters/BP_Character.uasset and b/Content/Characters/BP_Character.uasset differ diff --git a/Content/Characters/Children/Creature1/BP_Creature1.uasset b/Content/Characters/Children/Creature1/BP_Creature1.uasset index c5a7b2f..86c02b0 100644 Binary files a/Content/Characters/Children/Creature1/BP_Creature1.uasset and b/Content/Characters/Children/Creature1/BP_Creature1.uasset differ diff --git a/Content/Characters/Children/Creature2/BP_Creature2.uasset b/Content/Characters/Children/Creature2/BP_Creature2.uasset index c9ba9c8..b0d332b 100644 Binary files a/Content/Characters/Children/Creature2/BP_Creature2.uasset and b/Content/Characters/Children/Creature2/BP_Creature2.uasset differ diff --git a/Content/Characters/Children/Hero1/Abilities/Ability2/GA_Hero1_Ability2.uasset b/Content/Characters/Children/Hero1/Abilities/Ability2/GA_Hero1_Ability2.uasset deleted file mode 100644 index abda076..0000000 Binary files a/Content/Characters/Children/Hero1/Abilities/Ability2/GA_Hero1_Ability2.uasset and /dev/null differ diff --git a/Content/Characters/Children/Hero1/Abilities/Ability1/GA_Hero1_Ability1.uasset b/Content/Characters/Children/Hero1/Abilities/Jump/GA_Hero1_Jump.uasset similarity index 52% rename from Content/Characters/Children/Hero1/Abilities/Ability1/GA_Hero1_Ability1.uasset rename to Content/Characters/Children/Hero1/Abilities/Jump/GA_Hero1_Jump.uasset index 3a292ae..6499a61 100644 Binary files a/Content/Characters/Children/Hero1/Abilities/Ability1/GA_Hero1_Ability1.uasset and b/Content/Characters/Children/Hero1/Abilities/Jump/GA_Hero1_Jump.uasset differ diff --git a/Content/Characters/Children/Hero1/Abilities/PushBack/AM_Hero1_PushBack.uasset b/Content/Characters/Children/Hero1/Abilities/PushBack/AM_Hero1_PushBack.uasset new file mode 100644 index 0000000..3bb3639 Binary files /dev/null and b/Content/Characters/Children/Hero1/Abilities/PushBack/AM_Hero1_PushBack.uasset differ diff --git a/Content/Characters/Children/Hero1/Abilities/PushBack/GA_Hero1_PushBack.uasset b/Content/Characters/Children/Hero1/Abilities/PushBack/GA_Hero1_PushBack.uasset new file mode 100644 index 0000000..f0294b5 Binary files /dev/null and b/Content/Characters/Children/Hero1/Abilities/PushBack/GA_Hero1_PushBack.uasset differ diff --git a/Content/Characters/Children/Hero1/Abilities/PushBack/GC_Hero1_PushBack.uasset b/Content/Characters/Children/Hero1/Abilities/PushBack/GC_Hero1_PushBack.uasset new file mode 100644 index 0000000..143d639 Binary files /dev/null and b/Content/Characters/Children/Hero1/Abilities/PushBack/GC_Hero1_PushBack.uasset differ diff --git a/Content/Characters/Children/Hero1/Abilities/PushBack/MI_Hero1_Pushback_Area.uasset b/Content/Characters/Children/Hero1/Abilities/PushBack/MI_Hero1_Pushback_Area.uasset new file mode 100644 index 0000000..dd8250a Binary files /dev/null and b/Content/Characters/Children/Hero1/Abilities/PushBack/MI_Hero1_Pushback_Area.uasset differ diff --git a/Content/Characters/Children/Hero1/Abilities/PushBack/VFX_Hero1_PushBack_Area.uasset b/Content/Characters/Children/Hero1/Abilities/PushBack/VFX_Hero1_PushBack_Area.uasset new file mode 100644 index 0000000..162580a Binary files /dev/null and b/Content/Characters/Children/Hero1/Abilities/PushBack/VFX_Hero1_PushBack_Area.uasset differ diff --git a/Content/Characters/Children/Hero1/BP_Hero1.uasset b/Content/Characters/Children/Hero1/BP_Hero1.uasset index 1827bcd..aaac6cf 100644 Binary files a/Content/Characters/Children/Hero1/BP_Hero1.uasset and b/Content/Characters/Children/Hero1/BP_Hero1.uasset differ diff --git a/Content/Characters/Children/Hero2/BP_Hero2.uasset b/Content/Characters/Children/Hero2/BP_Hero2.uasset index 3ebdd58..208fcd2 100644 Binary files a/Content/Characters/Children/Hero2/BP_Hero2.uasset and b/Content/Characters/Children/Hero2/BP_Hero2.uasset differ diff --git a/Content/Core/AnimNotify/AN_Cast.uasset b/Content/Core/AnimNotify/AN_Cast.uasset new file mode 100644 index 0000000..0e88021 Binary files /dev/null and b/Content/Core/AnimNotify/AN_Cast.uasset differ diff --git a/Content/Core/Debug/Cheats/GA_Debug.uasset b/Content/Core/Debug/Cheats/GA_Debug.uasset new file mode 100644 index 0000000..4119026 Binary files /dev/null and b/Content/Core/Debug/Cheats/GA_Debug.uasset differ diff --git a/Content/Core/Debug/DA_Debug_Abilities.uasset b/Content/Core/Debug/DA_Debug_Abilities.uasset index 9936197..71d060f 100644 Binary files a/Content/Core/Debug/DA_Debug_Abilities.uasset and b/Content/Core/Debug/DA_Debug_Abilities.uasset differ diff --git a/Content/Core/Materials/M_Basic_Additive.uasset b/Content/Core/Materials/M_Basic_Additive.uasset new file mode 100644 index 0000000..5560527 Binary files /dev/null and b/Content/Core/Materials/M_Basic_Additive.uasset differ diff --git a/Content/Core/Materials/M_Basic_Solid.uasset b/Content/Core/Materials/M_Basic_Solid.uasset new file mode 100644 index 0000000..0df20fd Binary files /dev/null and b/Content/Core/Materials/M_Basic_Solid.uasset differ diff --git a/Content/Core/Materials/M_Basic_Translucent.uasset b/Content/Core/Materials/M_Basic_Translucent.uasset new file mode 100644 index 0000000..9539266 Binary files /dev/null and b/Content/Core/Materials/M_Basic_Translucent.uasset differ diff --git a/Content/Maps/LevelPrototyping/Materials/MI_PrototypeGrid_Gray.uasset b/Content/Maps/LevelPrototyping/Materials/MI_PrototypeGrid_Gray.uasset index 9911e53..5dc51b6 100644 Binary files a/Content/Maps/LevelPrototyping/Materials/MI_PrototypeGrid_Gray.uasset and b/Content/Maps/LevelPrototyping/Materials/MI_PrototypeGrid_Gray.uasset differ diff --git a/Content/Maps/LevelPrototyping/Materials/MI_Solid_Blue.uasset b/Content/Maps/LevelPrototyping/Materials/MI_Solid_Blue.uasset index 82cd5cc..b5a46b6 100644 Binary files a/Content/Maps/LevelPrototyping/Materials/MI_Solid_Blue.uasset and b/Content/Maps/LevelPrototyping/Materials/MI_Solid_Blue.uasset differ diff --git a/Content/Maps/LevelPrototyping/Materials/M_PrototypeGrid.uasset b/Content/Maps/LevelPrototyping/Materials/M_PrototypeGrid.uasset index 34602b8..3b5b832 100644 Binary files a/Content/Maps/LevelPrototyping/Materials/M_PrototypeGrid.uasset and b/Content/Maps/LevelPrototyping/Materials/M_PrototypeGrid.uasset differ diff --git a/Content/Maps/LevelPrototyping/Materials/M_Solid.uasset b/Content/Maps/LevelPrototyping/Materials/M_Solid.uasset index c65e077..2542659 100644 Binary files a/Content/Maps/LevelPrototyping/Materials/M_Solid.uasset and b/Content/Maps/LevelPrototyping/Materials/M_Solid.uasset differ diff --git a/Content/__ExternalActors__/Maps/L_Default/5/88/NDHUEK1ROBM2RCW7ZU51MM.uasset b/Content/__ExternalActors__/Maps/L_Default/5/88/NDHUEK1ROBM2RCW7ZU51MM.uasset index dd8bbc1..2fadfcc 100644 Binary files a/Content/__ExternalActors__/Maps/L_Default/5/88/NDHUEK1ROBM2RCW7ZU51MM.uasset and b/Content/__ExternalActors__/Maps/L_Default/5/88/NDHUEK1ROBM2RCW7ZU51MM.uasset differ diff --git a/Content/__ExternalActors__/Maps/L_Default/6/U3/6O7DJ03I0JB041XHH0L21L.uasset b/Content/__ExternalActors__/Maps/L_Default/6/U3/6O7DJ03I0JB041XHH0L21L.uasset index e0ac248..5ea5f7c 100644 Binary files a/Content/__ExternalActors__/Maps/L_Default/6/U3/6O7DJ03I0JB041XHH0L21L.uasset and b/Content/__ExternalActors__/Maps/L_Default/6/U3/6O7DJ03I0JB041XHH0L21L.uasset differ diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityReplicator.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityReplicator.cpp index 847201e..85a83df 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityReplicator.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityReplicator.cpp @@ -23,8 +23,12 @@ void ACogAbilityReplicator::Create(APlayerController* Controller) ACogAbilityReplicator::ACogAbilityReplicator(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { +#if !UE_BUILD_SHIPPING + bReplicates = true; - RootComponent = ObjectInitializer.CreateOptionalDefaultSubobject(this, TEXT("Root")); + bOnlyRelevantToOwner = true; + +#endif // !UE_BUILD_SHIPPING } //-------------------------------------------------------------------------------------------------------------------------- @@ -40,20 +44,23 @@ void ACogAbilityReplicator::GetLifetimeReplicatedProps(TArray< FLifetimeProperty DOREPLIFETIME_WITH_PARAMS_FAST(ACogAbilityReplicator, TweakProfileIndex, Params); } - //-------------------------------------------------------------------------------------------------------------------------- void ACogAbilityReplicator::BeginPlay() { Super::BeginPlay(); + OwnerPlayerController = Cast(GetOwner()); - if (OwnerPlayerController->IsLocalController()) + if (OwnerPlayerController != nullptr) { - FCogAbilityModule::Get().SetLocalReplicator(this); - } - else - { - FCogAbilityModule::Get().AddRemoteReplicator(this); + if (OwnerPlayerController->IsLocalController()) + { + FCogAbilityModule::Get().SetLocalReplicator(this); + } + else + { + FCogAbilityModule::Get().AddRemoteReplicator(this); + } } } diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp index f772342..7ff400c 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp @@ -155,11 +155,11 @@ void UCogAbilityWindow_Cheats::RequestCheat(AActor* CheatInstigator, AActor* Sel if (ICogInterfacesAllegianceActor* AllegianceInterface = Cast(OtherActor)) { - AllegianceInterface->GetAllegiance(CheatInstigator); + AllegianceInterface->GetAllegianceWithOtherActor(CheatInstigator); } if ((IsShiftDown && (Allegiance == ECogInterfacesAllegiance::Enemy)) - || (IsAltDown && (Allegiance == ECogInterfacesAllegiance::Ally))) + || (IsAltDown && (Allegiance == ECogInterfacesAllegiance::Friendly))) { Actors.Add(OtherActor); } diff --git a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugDraw.cpp b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugDraw.cpp index cf349a6..88f3bd9 100644 --- a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugDraw.cpp +++ b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugDraw.cpp @@ -506,13 +506,24 @@ void FCogDebugDraw::Skeleton(const FLogCategoryBase& LogCategory, const USkeleta //-------------------------------------------------------------------------------------------------------------------------- void FCogDebugDraw::ReplicateShape(const UObject* WorldContextObject, const FCogDebugShape& Shape) { - const UWorld* World = WorldContextObject != nullptr ? WorldContextObject->GetWorld() : nullptr; + UWorld* World = WorldContextObject != nullptr ? WorldContextObject->GetWorld() : nullptr; + if (World == nullptr) + { + return; + } + const ENetMode NetMode = World->GetNetMode(); if (NetMode == NM_DedicatedServer || NetMode == NM_ListenServer) { - for (const TObjectPtr& Replicator : FCogDebugModule::Get().GetRemoteReplicators()) + TArray Replicators; + FCogDebugModule::Get().GetRemoteReplicators(*World, Replicators); + + for (ACogDebugReplicator* Replicator : Replicators) { - Replicator->ReplicatedShapes.Add(Shape); + if (Replicator != nullptr) + { + Replicator->ReplicatedShapes.Add(Shape); + } } } } diff --git a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugDrawBlueprint.cpp b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugDrawBlueprint.cpp index 088c10c..8d30735 100644 --- a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugDrawBlueprint.cpp +++ b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugDrawBlueprint.cpp @@ -3,7 +3,7 @@ #include "CogDebugDraw.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugLogString(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FString& Text, const FVector Location, const FLinearColor Color, bool Persistent) +void UCogDebugDrawBlueprint::DebugDrawString(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FString& Text, const FVector Location, const FLinearColor Color, bool Persistent) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -14,7 +14,7 @@ void UCogDebugDrawBlueprint::DebugLogString(const UObject* WorldContextObject, F } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugLogPoint(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, float Size, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawPoint(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, float Size, const FLinearColor Color, bool Persistent, uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -25,7 +25,7 @@ void UCogDebugDrawBlueprint::DebugLogPoint(const UObject* WorldContextObject, FC } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugLogSegment(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawSegment(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, bool Persistent, uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -36,7 +36,7 @@ void UCogDebugDrawBlueprint::DebugLogSegment(const UObject* WorldContextObject, } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugLogArrow(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawArrow(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, bool Persistent, uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -47,7 +47,7 @@ void UCogDebugDrawBlueprint::DebugLogArrow(const UObject* WorldContextObject, FC } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugLogAxis(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, const FRotator Rotation, float Scale, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawAxis(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, const FRotator Rotation, float Scale, bool Persistent, uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -58,7 +58,7 @@ void UCogDebugDrawBlueprint::DebugLogAxis(const UObject* WorldContextObject, FCo } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugLogSphere(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, float Radius, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawSphere(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, float Radius, const FLinearColor Color, bool Persistent, uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -69,7 +69,7 @@ void UCogDebugDrawBlueprint::DebugLogSphere(const UObject* WorldContextObject, F } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugLogBox(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawBox(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -80,7 +80,7 @@ void UCogDebugDrawBlueprint::DebugLogBox(const UObject* WorldContextObject, FCog } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugLogSolidBox(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawSolidBox(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -91,7 +91,7 @@ void UCogDebugDrawBlueprint::DebugLogSolidBox(const UObject* WorldContextObject, } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugLogCapsule(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const float HalfHeight, const float Radius, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawCapsule(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const float HalfHeight, const float Radius, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -102,7 +102,7 @@ void UCogDebugDrawBlueprint::DebugLogCapsule(const UObject* WorldContextObject, } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugLogCircle(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FMatrix& Matrix, float Radius, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawCircle(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FMatrix& Matrix, float Radius, const FLinearColor Color, bool Persistent, uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -113,7 +113,7 @@ void UCogDebugDrawBlueprint::DebugLogCircle(const UObject* WorldContextObject, F } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugLogCircleArc(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FMatrix& Matrix, float InnerRadius, float OuterRadius, float Angle, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawCircleArc(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FMatrix& Matrix, float InnerRadius, float OuterRadius, float Angle, const FLinearColor Color, bool Persistent, uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -124,7 +124,7 @@ void UCogDebugDrawBlueprint::DebugLogCircleArc(const UObject* WorldContextObject } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugLogPoints(const UObject* WorldContextObject, FCogLogCategory LogCategory, const TArray& Points, float Radius, const FLinearColor StartColor, const FLinearColor EndColor, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawPoints(const UObject* WorldContextObject, FCogLogCategory LogCategory, const TArray& Points, float Radius, const FLinearColor StartColor, const FLinearColor EndColor, bool Persistent, uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -135,7 +135,7 @@ void UCogDebugDrawBlueprint::DebugLogPoints(const UObject* WorldContextObject, F } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugLogPath(const UObject* WorldContextObject, FCogLogCategory LogCategory, const TArray& Points, float PointSize, const FLinearColor StartColor, const FLinearColor EndColor, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawPath(const UObject* WorldContextObject, FCogLogCategory LogCategory, const TArray& Points, float PointSize, const FLinearColor StartColor, const FLinearColor EndColor, bool Persistent, uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -146,7 +146,7 @@ void UCogDebugDrawBlueprint::DebugLogPath(const UObject* WorldContextObject, FCo } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugLogString2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FString& Text, const FVector2D Location, const FLinearColor Color, bool Persistent) +void UCogDebugDrawBlueprint::DebugDrawString2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FString& Text, const FVector2D Location, const FLinearColor Color, bool Persistent) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -157,7 +157,7 @@ void UCogDebugDrawBlueprint::DebugLogString2D(const UObject* WorldContextObject, } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugLogSegment2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D SegmentStart, const FVector2D SegmentEnd, const FLinearColor Color, bool Persistent) +void UCogDebugDrawBlueprint::DebugDrawSegment2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D SegmentStart, const FVector2D SegmentEnd, const FLinearColor Color, bool Persistent) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -168,7 +168,7 @@ void UCogDebugDrawBlueprint::DebugLogSegment2D(const UObject* WorldContextObject } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugLogCircle2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D Location, float Radius, const FLinearColor Color, bool Persistent) +void UCogDebugDrawBlueprint::DebugDrawCircle2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D Location, float Radius, const FLinearColor Color, bool Persistent) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -179,7 +179,7 @@ void UCogDebugDrawBlueprint::DebugLogCircle2D(const UObject* WorldContextObject, } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugLogRect2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D Min, const FVector2D Max, const FLinearColor Color, bool Persistent) +void UCogDebugDrawBlueprint::DebugDrawRect2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D Min, const FVector2D Max, const FLinearColor Color, bool Persistent) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) diff --git a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugLogBlueprint.cpp b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugLogBlueprint.cpp index f5f6a23..5c56a70 100644 --- a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugLogBlueprint.cpp +++ b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugLogBlueprint.cpp @@ -4,7 +4,7 @@ #include "CogDebugLogMacros.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugLogBlueprint::Log(FCogLogCategory LogCategory, ECogLogVerbosity Verbosity, const AActor* Actor, const FString& Text) +void UCogDebugLogBlueprint::Log(const UObject* WorldContextObject, FCogLogCategory LogCategory, ECogLogVerbosity Verbosity, const FString& Text) { #if ENABLE_COG @@ -16,9 +16,9 @@ void UCogDebugLogBlueprint::Log(FCogLogCategory LogCategory, ECogLogVerbosity Ve return; } - if (Actor != nullptr) + if (WorldContextObject != nullptr) { - COG_LOG_ACTOR_NO_CONTEXT(*LogCategoryPtr, (ELogVerbosity::Type)Verbosity, Actor, TEXT("%s"), *Text); + COG_LOG_OBJECT_NO_CONTEXT(*LogCategoryPtr, (ELogVerbosity::Type)Verbosity, WorldContextObject, TEXT("%s"), *Text); } else { @@ -29,7 +29,7 @@ void UCogDebugLogBlueprint::Log(FCogLogCategory LogCategory, ECogLogVerbosity Ve } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogDebugLogBlueprint::IsLogActive(FCogLogCategory LogCategory, const AActor* Actor) +bool UCogDebugLogBlueprint::IsLogActive(const UObject* WorldContextObject, FCogLogCategory LogCategory) { #if ENABLE_COG @@ -40,7 +40,7 @@ bool UCogDebugLogBlueprint::IsLogActive(FCogLogCategory LogCategory, const AActo return false; } - if (FCogDebugSettings::IsDebugActiveForActor(Actor) == false) + if (FCogDebugSettings::IsDebugActiveForObject(WorldContextObject) == false) { return false; } diff --git a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugLogCategoryManager.cpp b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugLogCategoryManager.cpp index 536e34b..dc88dea 100644 --- a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugLogCategoryManager.cpp +++ b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugLogCategoryManager.cpp @@ -34,7 +34,7 @@ FString FCogDebugLogCategoryInfo::GetDisplayName() const //-------------------------------------------------------------------------------------------------------------------------- // FCogDebugLogCategoryManager //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugLogCategoryManager::AddLogCategory(FLogCategoryBase& LogCategory, const FString& DisplayName) +void FCogDebugLogCategoryManager::AddLogCategory(FLogCategoryBase& LogCategory, const FString& DisplayName, bool bVisible) { LogCategories.Add(LogCategory.GetCategoryName(), FCogDebugLogCategoryInfo @@ -42,6 +42,7 @@ void FCogDebugLogCategoryManager::AddLogCategory(FLogCategoryBase& LogCategory, &LogCategory, ELogVerbosity::NumVerbosity, DisplayName, + bVisible, }); } @@ -95,18 +96,18 @@ ELogVerbosity::Type FCogDebugLogCategoryManager::GetServerVerbosity(FName Catego } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugLogCategoryManager::SetServerVerbosity(FName CategoryName, ELogVerbosity::Type Verbosity) +void FCogDebugLogCategoryManager::SetServerVerbosity(UWorld& World, FName CategoryName, ELogVerbosity::Type Verbosity) { - if (ACogDebugReplicator* Replicator = FCogDebugModule::Get().GetLocalReplicator()) + if (ACogDebugReplicator* Replicator = FCogDebugModule::Get().GetLocalReplicator(World)) { Replicator->Server_SetCategoryVerbosity(CategoryName, (ECogLogVerbosity)Verbosity); } } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugLogCategoryManager::SetServerVerbosityActive(FName CategoryName, bool Value) +void FCogDebugLogCategoryManager::SetServerVerbosityActive(UWorld& World, FName CategoryName, bool Value) { - SetServerVerbosity(CategoryName, Value ? ELogVerbosity::Verbose : ELogVerbosity::Warning); + SetServerVerbosity(World, CategoryName, Value ? ELogVerbosity::Verbose : ELogVerbosity::Warning); } //-------------------------------------------------------------------------------------------------------------------------- diff --git a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugMetric.cpp b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugMetric.cpp index bcf6963..b1dbd11 100644 --- a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugMetric.cpp +++ b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugMetric.cpp @@ -1,7 +1,6 @@ #include "CogDebugMetric.h" #include "CogDebugSettings.h" -#include "CogInterfaceFilteredActor.h" //-------------------------------------------------------------------------------------------------------------------------- float FCogDebugMetric::MaxDurationSetting = 0.0f; @@ -14,12 +13,9 @@ TMap FCogDebugMetric::Metrics; //-------------------------------------------------------------------------------------------------------------------------- void FCogDebugMetric::AddMetric(const FCogDebugMetricParams& Params) { - if (Cast(Params.WorldContextObject)) + if (FCogDebugSettings::IsDebugActiveForObject(Params.WorldContextObject) == false) { - if (Params.WorldContextObject != FCogDebugSettings::GetSelection()) - { - return; - } + return; } FCogDebugMetricEntry& Entry = Metrics.FindOrAdd(Params.Name); diff --git a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugModule.cpp b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugModule.cpp index 187c0d1..de83c6a 100644 --- a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugModule.cpp +++ b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugModule.cpp @@ -1,5 +1,8 @@ #include "CogDebugModule.h" +#include "CogDebugReplicator.h" +#include "EngineUtils.h" + #define LOCTEXT_NAMESPACE "FCogDebugModule" //-------------------------------------------------------------------------------------------------------------------------- @@ -13,34 +16,25 @@ void FCogDebugModule::ShutdownModule() } //-------------------------------------------------------------------------------------------------------------------------- -ACogDebugReplicator* FCogDebugModule::GetLocalReplicator() +ACogDebugReplicator* FCogDebugModule::GetLocalReplicator(UWorld& World) { - return LocalReplicator; -} - -//-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugModule::SetLocalReplicator(ACogDebugReplicator* Value) -{ - LocalReplicator = Value; -} - -//-------------------------------------------------------------------------------------------------------------------------- -ACogDebugReplicator* FCogDebugModule::GetRemoteReplicator(const APlayerController* PlayerController) -{ - for (ACogDebugReplicator* Replicator : RemoteReplicators) + for (TActorIterator It(&World, ACogDebugReplicator::StaticClass()); It; ++It) { - if (Replicator->GetPlayerController() == PlayerController) - { - return Replicator; - } + ACogDebugReplicator* Replicator = *It; + return Replicator; } + return nullptr; } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugModule::AddRemoteReplicator(ACogDebugReplicator* Value) +void FCogDebugModule::GetRemoteReplicators(UWorld& World, TArray& Replicators) { - RemoteReplicators.Add(Value); + for (TActorIterator It(&World, ACogDebugReplicator::StaticClass()); It; ++It) + { + ACogDebugReplicator* Replicator = Cast(*It); + Replicators.Add(Replicator); + } } #undef LOCTEXT_NAMESPACE diff --git a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugPlot.cpp b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugPlot.cpp index db96271..7e0668e 100644 --- a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugPlot.cpp +++ b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugPlot.cpp @@ -2,7 +2,6 @@ #include "CogDebugDraw.h" #include "CogDebugHelper.h" -#include "CogInterfaceFilteredActor.h" #include "CogImguiHelper.h" FCogDebugPlotEvent FCogDebugPlot::DefaultEvent; @@ -424,15 +423,9 @@ FCogDebugPlotEntry* FCogDebugPlot::RegisterPlot(const UObject* WorldContextObjec return nullptr; } - //--------------------------------------------------------------------------------- - // Cast to ICogActorFilteringDebugInterface to know if we should filter - //--------------------------------------------------------------------------------- - if (Cast(WorldContextObject)) + if (FCogDebugSettings::IsDebugActiveForObject(WorldContextObject) == false) { - if (WorldContextObject != FCogDebugSettings::GetSelection()) - { - return nullptr; - } + return nullptr; } FCogDebugPlotEntry* EntryPtr = FindPlot(PlotName); diff --git a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugReplicator.cpp b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugReplicator.cpp index 181f8c2..6a51d48 100644 --- a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugReplicator.cpp +++ b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugReplicator.cpp @@ -115,11 +115,10 @@ ACogDebugReplicator::ACogDebugReplicator(const FObjectInitializer& ObjectInitial PrimaryActorTick.bStartWithTickEnabled = true; PrimaryActorTick.TickGroup = TG_PrePhysics; - bHasAuthority = false; - bIsLocal = false; bReplicates = true; bOnlyRelevantToOwner = true; + bHasAuthority = false; ReplicatedData.Owner = this; #endif // !UE_BUILD_SHIPPING @@ -134,19 +133,13 @@ void ACogDebugReplicator::BeginPlay() check(World); const ENetMode NetMode = World->GetNetMode(); bHasAuthority = NetMode != NM_Client; - bIsLocal = NetMode != NM_DedicatedServer; OwnerPlayerController = Cast(GetOwner()); if (OwnerPlayerController->IsLocalController()) { - FCogDebugModule::Get().SetLocalReplicator(this); Server_RequestAllCategoriesVerbosity(); } - else - { - FCogDebugModule::Get().AddRemoteReplicator(this); - } } //-------------------------------------------------------------------------------------------------------------------------- @@ -186,7 +179,7 @@ void ACogDebugReplicator::Server_SetCategoryVerbosity_Implementation(FName LogCa #if !UE_BUILD_SHIPPING ENetMode NetMode = GetWorld()->GetNetMode(); - if (NetMode == NM_DedicatedServer || NetMode == NM_DedicatedServer) + if (NetMode == NM_DedicatedServer || NetMode == NM_ListenServer) { if (FCogDebugLogCategoryInfo* LogCategoryInfo = FCogDebugLogCategoryManager::FindLogCategoryInfo(LogCategoryName)) { @@ -239,7 +232,7 @@ void ACogDebugReplicator::Server_RequestAllCategoriesVerbosity_Implementation() #if !UE_BUILD_SHIPPING ENetMode NetMode = GetWorld()->GetNetMode(); - if (NetMode == NM_DedicatedServer || NetMode == NM_DedicatedServer) + if (NetMode == NM_DedicatedServer || NetMode == NM_ListenServer) { TArray CategoriesData; for (auto& Entry : FCogDebugLogCategoryManager::GetLogCategories()) diff --git a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugSettings.cpp b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugSettings.cpp index 124a462..07ac063 100644 --- a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugSettings.cpp +++ b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugSettings.cpp @@ -1,6 +1,6 @@ #include "CogDebugSettings.h" -#include "CogInterfaceFilteredActor.h" +#include "CogInterfaceDebugFilteredActor.h" //-------------------------------------------------------------------------------------------------------------------------- TWeakObjectPtr FCogDebugSettings::Selection; @@ -66,17 +66,44 @@ void FCogDebugSettings::Reset() } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogDebugSettings::IsDebugActiveForActor(const AActor* Actor) +bool FCogDebugSettings::IsDebugActiveForObject(const UObject* WorldContextObject) { - const AActor* SelectionPtr = Selection.Get(); - if (Actor == nullptr || SelectionPtr == nullptr) + if (FilterBySelection == false) { return true; } - if (Cast(Actor)) + if (WorldContextObject == nullptr) { - return (SelectionPtr == Actor || FilterBySelection == false); + return true; + } + + const AActor* SelectionPtr = Selection.Get(); + if (SelectionPtr == nullptr) + { + return true; + } + + const UObject* Outer = WorldContextObject; + for (;;) + { + if (SelectionPtr == Outer) + { + return true; + } + + if (Cast(Outer)) + { + return false; + } + + const UObject* NewOuter = Outer->GetOuter(); + if (NewOuter == Outer || NewOuter == nullptr) + { + return true; + } + + Outer = NewOuter; } return true; diff --git a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugDrawBlueprint.h b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugDrawBlueprint.h index efb94e8..a2adf59 100644 --- a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugDrawBlueprint.h +++ b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugDrawBlueprint.h @@ -13,54 +13,54 @@ class COGDEBUG_API UCogDebugDrawBlueprint : public UBlueprintFunctionLibrary public: UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static void DebugLogString(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FString& Text, const FVector Location, const FLinearColor Color, bool Persistent); + static void DebugDrawString(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FString& Text, const FVector Location, const FLinearColor Color, bool Persistent); UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static void DebugLogPoint(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, float size, const FLinearColor Color, bool Persistent, uint8 DepthPriority); + static void DebugDrawPoint(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, float size, const FLinearColor Color, bool Persistent, uint8 DepthPriority); UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static void DebugLogSegment(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, bool Persistent, uint8 DepthPriority); + static void DebugDrawSegment(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, bool Persistent, uint8 DepthPriority); UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static void DebugLogArrow(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, bool Persistent, uint8 DepthPriority); + static void DebugDrawArrow(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, bool Persistent, uint8 DepthPriority); UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static void DebugLogAxis(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, const FRotator Rotation, float Scale, bool Persistent, uint8 DepthPriority); + static void DebugDrawAxis(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, const FRotator Rotation, float Scale, bool Persistent, uint8 DepthPriority); UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static void DebugLogSphere(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, float Radius, const FLinearColor Color, bool Persistent, uint8 DepthPriority); + static void DebugDrawSphere(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, float Radius, const FLinearColor Color, bool Persistent, uint8 DepthPriority); UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static void DebugLogBox(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority); + static void DebugDrawBox(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority); UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static void DebugLogSolidBox(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority); + static void DebugDrawSolidBox(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority); UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static void DebugLogCapsule(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const float HalfHeight, const float Radius, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority); + static void DebugDrawCapsule(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const float HalfHeight, const float Radius, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority); UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static void DebugLogCircle(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FMatrix& Matrix, float Radius, const FLinearColor Color, bool Persistent, uint8 DepthPriority); + static void DebugDrawCircle(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FMatrix& Matrix, float Radius, const FLinearColor Color, bool Persistent, uint8 DepthPriority); UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static void DebugLogCircleArc(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FMatrix& Matrix, float InnerRadius, float OuterRadius, float Angle, const FLinearColor Color, bool Persistent, uint8 DepthPriority); + static void DebugDrawCircleArc(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FMatrix& Matrix, float InnerRadius, float OuterRadius, float Angle, const FLinearColor Color, bool Persistent, uint8 DepthPriority); UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static void DebugLogPoints(const UObject* WorldContextObject, FCogLogCategory LogCategory, const TArray& Points, float Radius, const FLinearColor StartColor, const FLinearColor EndColor, bool Persistent, uint8 DepthPriority); + static void DebugDrawPoints(const UObject* WorldContextObject, FCogLogCategory LogCategory, const TArray& Points, float Radius, const FLinearColor StartColor, const FLinearColor EndColor, bool Persistent, uint8 DepthPriority); UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static void DebugLogPath(const UObject* WorldContextObject, FCogLogCategory LogCategory, const TArray& Points, float PointSize, const FLinearColor StartColor, const FLinearColor EndColor, bool Persistent, uint8 DepthPriority); + static void DebugDrawPath(const UObject* WorldContextObject, FCogLogCategory LogCategory, const TArray& Points, float PointSize, const FLinearColor StartColor, const FLinearColor EndColor, bool Persistent, uint8 DepthPriority); UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static void DebugLogString2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FString& Text, const FVector2D Location, const FLinearColor Color, bool Persistent); + static void DebugDrawString2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FString& Text, const FVector2D Location, const FLinearColor Color, bool Persistent); UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static void DebugLogSegment2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D SegmentStart, const FVector2D SegmentEnd, const FLinearColor Color, bool Persistent); + static void DebugDrawSegment2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D SegmentStart, const FVector2D SegmentEnd, const FLinearColor Color, bool Persistent); UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static void DebugLogCircle2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D Location, float Radius, const FLinearColor Color, bool Persistent); + static void DebugDrawCircle2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D Location, float Radius, const FLinearColor Color, bool Persistent); UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static void DebugLogRect2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D Min, const FVector2D Max, const FLinearColor Color, bool Persistent); + static void DebugDrawRect2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D Min, const FVector2D Max, const FLinearColor Color, bool Persistent); }; \ No newline at end of file diff --git a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLogBlueprint.h b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLogBlueprint.h index 355eafd..b37d57f 100644 --- a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLogBlueprint.h +++ b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLogBlueprint.h @@ -26,10 +26,10 @@ class COGDEBUG_API UCogDebugLogBlueprint : public UBlueprintFunctionLibrary public: - UFUNCTION(BlueprintCallable, Category = "Log", meta = (DevelopmentOnly)) - static void Log(FCogLogCategory LogCategory, ECogLogVerbosity Verbosity = ECogLogVerbosity::Verbose, const AActor* Actor = nullptr, const FString& Text = FString("")); + UFUNCTION(BlueprintCallable, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) + static void Log(const UObject* WorldContextObject, FCogLogCategory LogCategory, ECogLogVerbosity Verbosity = ECogLogVerbosity::Verbose, const FString& Text = FString("")); - UFUNCTION(BlueprintPure, Category = "Log", meta = (DevelopmentOnly, AdvancedDisplay = "ScreenTextColor")) - static bool IsLogActive(FCogLogCategory LogCategory, const AActor* Actor = nullptr); + UFUNCTION(BlueprintPure, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) + static bool IsLogActive(const UObject* WorldContextObject, FCogLogCategory LogCategory); }; \ No newline at end of file diff --git a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLogCategoryManager.h b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLogCategoryManager.h index 2d15edb..0d69d65 100644 --- a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLogCategoryManager.h +++ b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLogCategoryManager.h @@ -14,6 +14,7 @@ struct COGDEBUG_API FCogDebugLogCategoryInfo FLogCategoryBase* LogCategory = nullptr; ELogVerbosity::Type ServerVerbosity = ELogVerbosity::NoLogging; FString DisplayName; + bool bVisible = true; FString GetDisplayName() const; }; @@ -21,7 +22,7 @@ struct COGDEBUG_API FCogDebugLogCategoryInfo //-------------------------------------------------------------------------------------------------------------------------- struct COGDEBUG_API FCogDebugLogCategoryManager { - static void AddLogCategory(FLogCategoryBase& LogCategory, const FString& DisplayName = ""); + static void AddLogCategory(FLogCategoryBase& LogCategory, const FString& DisplayName = "", bool bVisible = true); static bool IsVerbosityActive(ELogVerbosity::Type Verbosity); @@ -37,13 +38,13 @@ struct COGDEBUG_API FCogDebugLogCategoryManager static TMap& GetLogCategories() { return LogCategories; } - static void SetServerVerbosityActive(FName LogCategory, bool Value); + static void SetServerVerbosityActive(UWorld& World, FName LogCategory, bool Value); static bool IsServerVerbosityActive(FName LogCategory); static ELogVerbosity::Type GetServerVerbosity(FName LogCategory); - static void SetServerVerbosity(FName LogCategory, ELogVerbosity::Type Verbosity); + static void SetServerVerbosity(UWorld& World, FName LogCategory, ELogVerbosity::Type Verbosity); static void OnServerVerbosityChanged(FName LogCategory, ELogVerbosity::Type Verbosity); diff --git a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLogMacros.h b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLogMacros.h index 34b1d98..b2e37d6 100644 --- a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLogMacros.h +++ b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLogMacros.h @@ -7,15 +7,16 @@ #if !ENABLE_COG +#define COG_LOG_ACTIVE_FOR_OBJECT(Object) (0) #define COG_LOG(LogCategory, Verbosity, Format, ...) (0) #define COG_LOG_FUNC(LogCategory, Verbosity, Format, ...) (0) -#define COG_LOG_ACTOR(LogCategory, Verbosity, Actor, Format, ...) (0) -#define COG_LOG_ACTOR_NO_CONTEXT(LogCategory, Verbosity, Actor, Format, ...) (0) +#define COG_LOG_OBJECT(LogCategory, Verbosity, Actor, Format, ...) (0) +#define COG_LOG_OBJECT_NO_CONTEXT(LogCategory, Verbosity, Actor, Format, ...) (0) #else //!ENABLE_COG //-------------------------------------------------------------------------------------------------------------------------- -#define COG_LOG_ACTIVE_FOR_ACTOR(Actor) (FCogDebugSettings::IsDebugActiveForActor(Actor)) +#define COG_LOG_ACTIVE_FOR_OBJECT(Object) (FCogDebugSettings::IsDebugActiveForObject(Object)) //-------------------------------------------------------------------------------------------------------------------------- #define COG_LOG(LogCategory, Verbosity, Format, ...) \ @@ -32,20 +33,20 @@ COG_LOG(LogCategory, Verbosity, TEXT("%s - %s"), ANSI_TO_TCHAR(__FUNCTION__), *FString::Printf(Format, ##__VA_ARGS__)); \ //-------------------------------------------------------------------------------------------------------------------------- -#define COG_LOG_ACTOR(LogCategory, Verbosity, Actor, Format, ...) \ - if (COG_LOG_ACTIVE_FOR_ACTOR(Actor) || (int32)Verbosity <= (int32)ELogVerbosity::Warning) \ +#define COG_LOG_OBJECT(LogCategory, Verbosity, Object, Format, ...) \ + if (COG_LOG_ACTIVE_FOR_OBJECT(Object) || (int32)Verbosity <= (int32)ELogVerbosity::Warning) \ { \ COG_LOG(LogCategory, Verbosity, TEXT("%s - %s - %s"), \ - *GetNameSafe(Actor), \ + *GetNameSafe(Object), \ ANSI_TO_TCHAR(__FUNCTION__), \ *FString::Printf(Format, ##__VA_ARGS__)); \ } \ //-------------------------------------------------------------------------------------------------------------------------- -#define COG_LOG_ACTOR_NO_CONTEXT(LogCategory, Verbosity, Actor, Format, ...) \ - if (COG_LOG_ACTIVE_FOR_ACTOR(Actor) || (int32)Verbosity <= (int32)ELogVerbosity::Warning) \ +#define COG_LOG_OBJECT_NO_CONTEXT(LogCategory, Verbosity, Object, Format, ...) \ + if (COG_LOG_ACTIVE_FOR_OBJECT(Object) || (int32)Verbosity <= (int32)ELogVerbosity::Warning) \ { \ - COG_LOG(LogCategory, Verbosity, TEXT("%s - %s"), *GetNameSafe(Actor), *FString::Printf(Format, ##__VA_ARGS__)); \ + COG_LOG(LogCategory, Verbosity, TEXT("%s - %s"), *GetNameSafe(Object), *FString::Printf(Format, ##__VA_ARGS__)); \ } \ diff --git a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugModule.h b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugModule.h index c370565..1a78dbe 100644 --- a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugModule.h +++ b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugModule.h @@ -16,19 +16,10 @@ public: virtual void ShutdownModule() override; - ACogDebugReplicator* GetLocalReplicator(); + ACogDebugReplicator* GetLocalReplicator(UWorld& World); - void SetLocalReplicator(ACogDebugReplicator* Value); - - ACogDebugReplicator* GetRemoteReplicator(const APlayerController* PlayerController); - - TArray> GetRemoteReplicators() const { return RemoteReplicators; } - - void AddRemoteReplicator(ACogDebugReplicator* Value); + void GetRemoteReplicators(UWorld& World, TArray& Replicators); private: - TObjectPtr LocalReplicator; - - TArray> RemoteReplicators; }; diff --git a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugReplicator.h b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugReplicator.h index e848ac7..f6daef8 100644 --- a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugReplicator.h +++ b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugReplicator.h @@ -65,8 +65,6 @@ public: APlayerController* GetPlayerController() const { return OwnerPlayerController.Get(); } - bool IsLocal() const { return bIsLocal; } - TArray ReplicatedShapes; UFUNCTION(Server, Reliable) @@ -87,7 +85,6 @@ protected: TObjectPtr OwnerPlayerController; uint32 bHasAuthority : 1; - uint32 bIsLocal : 1; private: diff --git a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugSettings.h b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugSettings.h index 0e09721..e0fb732 100644 --- a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugSettings.h +++ b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugSettings.h @@ -8,38 +8,68 @@ struct COGDEBUG_API FCogDebugSettings public: //---------------------------------------------------------------------------------------------------------------------- - static bool IsDebugActiveForActor(const AActor* Actor); + static bool IsDebugActiveForObject(const UObject* WorldContextObject); + static AActor* GetSelection(); + static void SetSelection(AActor* Value); + static bool GetDebugPersistent(bool bPersistent); + static float GetDebugDuration(bool bPersistent); + static float GetDebugTextDuration(bool bPersistent); + static int GetCircleSegments(); + static int GetDebugSegments(); + static float GetDebugThickness(float Thickness); + static float GetDebugServerThickness(float Thickness); + static uint8 GetDebugDepthPriority(float DepthPriority); + static FColor ModulateDebugColor(const UWorld* World, const FColor& Color, bool bPersistent = true); + static FColor ModulateServerColor(const FColor& Color); + static bool IsSecondarySkeletonBone(FName BoneName); + static void Reset(); //---------------------------------------------------------------------------------------------------------------------- static TWeakObjectPtr Selection; + static bool FilterBySelection; + static bool Persistent; + static bool TextShadow; + static bool Fade2D; + static float Duration; + static int DepthPriority; + static int Segments; + static float Thickness; + static float ServerThickness; + static float ServerColorMultiplier; + static float ArrowSize; + static float AxesScale; + static float GradientColorIntensity; + static float GradientColorSpeed; + static float TextSize; + static TArray SecondaryBoneWildcards; }; diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineModule.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineModule.cpp index 2cd436e..c11d4bc 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineModule.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineModule.cpp @@ -24,19 +24,6 @@ void FCogEngineModule::SetLocalReplicator(ACogEngineReplicator* Value) LocalReplicator = Value; } -//-------------------------------------------------------------------------------------------------------------------------- -ACogEngineReplicator* FCogEngineModule::GetRemoteReplicator(const APlayerController* PlayerController) -{ - for (ACogEngineReplicator* Replicator : RemoteReplicators) - { - if (Replicator->GetPlayerController() == PlayerController) - { - return Replicator; - } - } - return nullptr; -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineModule::AddRemoteReplicator(ACogEngineReplicator* Value) { diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp index fd1d74d..8da5cfd 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp @@ -12,6 +12,50 @@ void UCogEngineWindow_DebugSettings::RenderHelp() ); } +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_DebugSettings::PostInitProperties() +{ + Super::PostInitProperties(); + + FCogDebugSettings::FilterBySelection = FilterBySelection; + FCogDebugSettings::Persistent = Persistent; + FCogDebugSettings::TextShadow = TextShadow; + FCogDebugSettings::Fade2D = Fade2D; + FCogDebugSettings::Duration = Duration; + FCogDebugSettings::DepthPriority = DepthPriority; + FCogDebugSettings::Segments = Segments; + FCogDebugSettings::Thickness = Thickness; + FCogDebugSettings::ServerThickness = ServerThickness; + FCogDebugSettings::ServerColorMultiplier = ServerColorMultiplier; + FCogDebugSettings::ArrowSize = ArrowSize; + FCogDebugSettings::AxesScale = AxesScale; + FCogDebugSettings::GradientColorIntensity = GradientColorIntensity; + FCogDebugSettings::GradientColorSpeed = GradientColorSpeed; + FCogDebugSettings::TextSize = TextSize; +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_DebugSettings::PreSaveConfig() +{ + Super::PreSaveConfig(); + + FilterBySelection = FCogDebugSettings::FilterBySelection; + Persistent = FCogDebugSettings::Persistent; + TextShadow = FCogDebugSettings::TextShadow; + Fade2D = FCogDebugSettings::Fade2D; + Duration = FCogDebugSettings::Duration; + DepthPriority = FCogDebugSettings::DepthPriority; + Segments = FCogDebugSettings::Segments; + Thickness = FCogDebugSettings::Thickness; + ServerThickness = FCogDebugSettings::ServerThickness; + ServerColorMultiplier = FCogDebugSettings::ServerColorMultiplier; + ArrowSize = FCogDebugSettings::ArrowSize; + AxesScale = FCogDebugSettings::AxesScale; + GradientColorIntensity = FCogDebugSettings::GradientColorIntensity; + GradientColorSpeed = FCogDebugSettings::GradientColorSpeed; + TextSize = FCogDebugSettings::TextSize; +} + //-------------------------------------------------------------------------------------------------------------------------- void UCogEngineWindow_DebugSettings::PreRender(ImGuiWindowFlags& WindowFlags) { diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp index e6bfd90..fed1ada 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp @@ -81,6 +81,11 @@ void UCogEngineWindow_LogCategories::RenderContent() { FName CategoryName = Entry.Key; const FCogDebugLogCategoryInfo& CategoryInfo = Entry.Value; + if (CategoryInfo.bVisible == false) + { + continue; + } + FLogCategoryBase* Category = CategoryInfo.LogCategory; ImGui::PushID(Index); @@ -102,7 +107,7 @@ void UCogEngineWindow_LogCategories::RenderContent() if (ImGui::Checkbox("##Server", &IsActive)) { ELogVerbosity::Type NewVerbosity = IsActive ? (IsControlDown ? ELogVerbosity::VeryVerbose : ELogVerbosity::Verbose) : ELogVerbosity::Warning; - FCogDebugLogCategoryManager::SetServerVerbosity(CategoryName, NewVerbosity); + FCogDebugLogCategoryManager::SetServerVerbosity(*World, CategoryName, NewVerbosity); } if (Verbosity == ELogVerbosity::VeryVerbose) @@ -168,7 +173,7 @@ void UCogEngineWindow_LogCategories::RenderContent() if (ImGui::Selectable(FCogDebugHelper::VerbosityToString(Verbosity), IsSelected)) { - FCogDebugLogCategoryManager::SetServerVerbosity(CategoryName, Verbosity); + FCogDebugLogCategoryManager::SetServerVerbosity(*World, CategoryName, Verbosity); } } ImGui::EndCombo(); diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp index 4e35bbb..fe53a8f 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp @@ -14,12 +14,23 @@ void UCogEngineWindow_Metrics::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Metrics::PostLoad() +void UCogEngineWindow_Metrics::PostInitProperties() { + Super::PostInitProperties(); + FCogDebugMetric::MaxDurationSetting = MaxDurationSetting; FCogDebugMetric::RestartDelaySetting = RestartDelaySetting; } +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_Metrics::PreSaveConfig() +{ + Super::PreSaveConfig(); + + MaxDurationSetting = FCogDebugMetric::MaxDurationSetting; + RestartDelaySetting = FCogDebugMetric::RestartDelaySetting; +} + //-------------------------------------------------------------------------------------------------------------------------- void UCogEngineWindow_Metrics::PreRender(ImGuiWindowFlags& WindowFlags) { @@ -47,17 +58,11 @@ void UCogEngineWindow_Metrics::RenderContent() bool bSettingModified = false; FCogWindowWidgets::PushStyleCompact(); - if (ImGui::DragFloat("Auto Restart Delay", &RestartDelaySetting, 0.1f, 0.0f, FLT_MAX, "%0.1f")) - { - FCogDebugMetric::RestartDelaySetting = RestartDelaySetting; - } + ImGui::DragFloat("Auto Restart Delay", &FCogDebugMetric::RestartDelaySetting, 0.1f, 0.0f, FLT_MAX, "%0.1f"); FCogWindowWidgets::PopStyleCompact(); FCogWindowWidgets::PushStyleCompact(); - if (ImGui::DragFloat("Max Time", &MaxDurationSetting, 0.1f, 0.0f, FLT_MAX, "%0.1f")) - { - FCogDebugMetric::MaxDurationSetting = MaxDurationSetting; - } + ImGui::DragFloat("Max Time", &FCogDebugMetric::MaxDurationSetting, 0.1f, 0.0f, FLT_MAX, "%0.1f"); FCogWindowWidgets::PopStyleCompact(); ImGui::EndMenu(); diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineModule.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineModule.h index 84e7005..7d08301 100644 --- a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineModule.h +++ b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineModule.h @@ -20,8 +20,6 @@ public: void SetLocalReplicator(ACogEngineReplicator* Value); - ACogEngineReplicator* GetRemoteReplicator(const APlayerController* PlayerController); - TArray> GetRemoteReplicators() const { return RemoteReplicators; } void AddRemoteReplicator(ACogEngineReplicator* Value); diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h index 4bbf95b..f53aba7 100644 --- a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h +++ b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h @@ -4,15 +4,67 @@ #include "CogWindow.h" #include "CogEngineWindow_DebugSettings.generated.h" -UCLASS() +UCLASS(Config = Cog) class COGENGINE_API UCogEngineWindow_DebugSettings : public UCogWindow { GENERATED_BODY() -public: - virtual void RenderHelp()override; +protected: + + virtual void RenderHelp() override; + + virtual void PreSaveConfig() override; + + virtual void PostInitProperties() override; virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; virtual void RenderContent() override; + +private: + + UPROPERTY(Config) + bool FilterBySelection = true; + + UPROPERTY(Config) + bool Persistent = false; + + UPROPERTY(Config) + bool TextShadow = true; + + UPROPERTY(Config) + bool Fade2D = true; + + UPROPERTY(Config) + float Duration = 3.0f; + + UPROPERTY(Config) + int DepthPriority = 0; + + UPROPERTY(Config) + int Segments = 12; + + UPROPERTY(Config) + float Thickness = 0.0f; + + UPROPERTY(Config) + float ServerThickness = 2.0f; + + UPROPERTY(Config) + float ServerColorMultiplier = 0.8f; + + UPROPERTY(Config) + float ArrowSize = 10.0f; + + UPROPERTY(Config) + float AxesScale = 1.0f; + + UPROPERTY(Config) + float GradientColorIntensity = 0.0f; + + UPROPERTY(Config) + float GradientColorSpeed = 2.0f; + + UPROPERTY(Config) + float TextSize = 1.0f; }; diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Metrics.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Metrics.h index 14e42de..eb67b0f 100644 --- a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Metrics.h +++ b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Metrics.h @@ -16,9 +16,11 @@ public: protected: - virtual void RenderHelp() override; + virtual void PostInitProperties() override; - virtual void PostLoad() override; + virtual void PreSaveConfig() override; + + virtual void RenderHelp() override; virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; diff --git a/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceAllegianceActor.h b/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceAllegianceActor.h index b473d02..657a89c 100644 --- a/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceAllegianceActor.h +++ b/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceAllegianceActor.h @@ -7,8 +7,9 @@ UENUM(BlueprintType) enum class ECogInterfacesAllegiance : uint8 { - Ally, - Enemy + Friendly, + Enemy, + Neutral }; //-------------------------------------------------------------------------------------------------------------------------- @@ -25,5 +26,5 @@ class ICogInterfacesAllegianceActor public: - virtual ECogInterfacesAllegiance GetAllegiance(const AActor* OtherActor) const = 0; + virtual ECogInterfacesAllegiance GetAllegianceWithOtherActor(const AActor* OtherActor) const = 0; }; \ No newline at end of file diff --git a/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceDebugFilteredActor.h b/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceDebugFilteredActor.h new file mode 100644 index 0000000..8970e50 --- /dev/null +++ b/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceDebugFilteredActor.h @@ -0,0 +1,15 @@ +#pragma once + +#include "CoreMinimal.h" +#include "CogInterfaceDebugFilteredActor.generated.h" + +UINTERFACE(MinimalAPI, Blueprintable) +class UCogInterfacesDebugFilteredActor : public UInterface +{ + GENERATED_BODY() +}; + +class ICogInterfacesDebugFilteredActor +{ + GENERATED_BODY() +}; diff --git a/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceFilteredActor.h b/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceFilteredActor.h deleted file mode 100644 index 808a1ed..0000000 --- a/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceFilteredActor.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "CoreMinimal.h" -#include "CogInterfaceFilteredActor.generated.h" - -UINTERFACE(MinimalAPI, Blueprintable) -class UCogInterfacesFilteredActor : public UInterface -{ - GENERATED_BODY() -}; - -class ICogInterfacesFilteredActor -{ - GENERATED_BODY() -}; diff --git a/Plugins/CogWindow/Source/CogWindow/Private/CogWindowManager.cpp b/Plugins/CogWindow/Source/CogWindow/Private/CogWindowManager.cpp index c674f71..44f03ee 100644 --- a/Plugins/CogWindow/Source/CogWindow/Private/CogWindowManager.cpp +++ b/Plugins/CogWindow/Source/CogWindow/Private/CogWindowManager.cpp @@ -34,7 +34,7 @@ void UCogWindowManager::Shutdown() { for (UCogWindow* Window : Windows) { - Window->Shutdown(); + Window->PreSaveConfig(); Window->SaveConfig(); } @@ -146,6 +146,15 @@ void UCogWindowManager::SetHideAllWindows(bool Value) bHideAllWindows = HideAllWindowsCounter > 0; } +//-------------------------------------------------------------------------------------------------------------------------- +void UCogWindowManager::ResetLayout() +{ + for (UCogWindow* Window : Windows) + { + ImGui::SetWindowPos(TCHAR_TO_ANSI(*Window->GetName()), ImVec2(10, 10), ImGuiCond_Always); + } +} + //-------------------------------------------------------------------------------------------------------------------------- void UCogWindowManager::CloseAllWindows() { @@ -230,7 +239,17 @@ void UCogWindowManager::DrawMainMenu() if (ImGui::BeginMenu("Window")) { - if (ImGui::BeginMenu("Load Layout")) + if (ImGui::MenuItem("Close All Windows")) + { + CloseAllWindows(); + } + + if (ImGui::MenuItem("Reset Window Layout")) + { + ResetLayout(); + } + + if (ImGui::BeginMenu("Load Window Layout")) { for (int32 i = 1; i <= 4; ++i) { @@ -243,7 +262,7 @@ void UCogWindowManager::DrawMainMenu() ImGui::EndMenu(); } - if (ImGui::BeginMenu("Save Layout")) + if (ImGui::BeginMenu("Save Window Layout")) { for (int32 i = 1; i <= 4; ++i) { @@ -258,12 +277,6 @@ void UCogWindowManager::DrawMainMenu() ImGui::Separator(); - if (ImGui::MenuItem("Close All")) - { - CloseAllWindows(); - } - - ImGui::MenuItem("Transparent Mode", nullptr, &bTransparentMode); ImGui::MenuItem("Compact Mode", nullptr, &bCompactMode); ImGui::Text("DPI Scale"); diff --git a/Plugins/CogWindow/Source/CogWindow/Public/CogWindow.h b/Plugins/CogWindow/Source/CogWindow/Public/CogWindow.h index bf726fa..31956e5 100644 --- a/Plugins/CogWindow/Source/CogWindow/Public/CogWindow.h +++ b/Plugins/CogWindow/Source/CogWindow/Public/CogWindow.h @@ -17,7 +17,7 @@ public: virtual void Initialize() {} - virtual void Shutdown() {} + virtual void PreSaveConfig() {} /** Called every frame with a valid imgui context if the window is visible. */ virtual void Render(float DeltaTime); diff --git a/Plugins/CogWindow/Source/CogWindow/Public/CogWindowManager.h b/Plugins/CogWindow/Source/CogWindow/Public/CogWindowManager.h index 996c7da..f4a89ca 100644 --- a/Plugins/CogWindow/Source/CogWindow/Public/CogWindowManager.h +++ b/Plugins/CogWindow/Source/CogWindow/Public/CogWindowManager.h @@ -47,6 +47,8 @@ public: void CloseAllWindows(); + void ResetLayout(); + void LoadLayout(int LayoutIndex); void SaveLayout(int LayoutIndex); diff --git a/Source/CogSample/CogAbilitySystemComponent.cpp.temp b/Source/CogSample/CogAbilitySystemComponent.cpp.temp deleted file mode 100644 index ba3f242..0000000 --- a/Source/CogSample/CogAbilitySystemComponent.cpp.temp +++ /dev/null @@ -1 +0,0 @@ -#include "CogAbilitySystemComponent.h" diff --git a/Source/CogSample/CogAbilitySystemComponent.h.temp b/Source/CogSample/CogAbilitySystemComponent.h.temp deleted file mode 100644 index 8e8819a..0000000 --- a/Source/CogSample/CogAbilitySystemComponent.h.temp +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include "CoreMinimal.h" -#include "AttributeSet.h" -#include "AbilitySystemComponent.h" -#include "CogAbilitySystemComponent.generated.h" - -UCLASS(BlueprintType) -class UCogAbilitySystemComponent : public UAbilitySystemComponent -{ - GENERATED_BODY() - -public: - - template - const T* GetAttributeSet() const - { - UClass* DesiredClass = T::StaticClass(); - check(DesiredClass->IsChildOf(UAttributeSet::StaticClass())); - return Cast(Super::GetAttributeSet(DesiredClass)); - } -}; \ No newline at end of file diff --git a/Source/CogSample/CogSampleAbilitySystemGlobals.cpp b/Source/CogSample/CogSampleAbilitySystemGlobals.cpp new file mode 100644 index 0000000..a91f04c --- /dev/null +++ b/Source/CogSample/CogSampleAbilitySystemGlobals.cpp @@ -0,0 +1,8 @@ +#include "CogSampleAbilitySystemGlobals.h" + +#include "CogSampleGameplayEffectContext.h" + +FGameplayEffectContext* UCogSampleAbilitySystemGlobals::AllocGameplayEffectContext() const +{ + return new FCogSampleGameplayEffectContext(); +} diff --git a/Source/CogSample/CogSampleAbilitySystemGlobals.h b/Source/CogSample/CogSampleAbilitySystemGlobals.h new file mode 100644 index 0000000..6282878 --- /dev/null +++ b/Source/CogSample/CogSampleAbilitySystemGlobals.h @@ -0,0 +1,13 @@ +#pragma once + +#include "CoreMinimal.h" +#include "AbilitySystemGlobals.h" +#include "CogSampleAbilitySystemGlobals.generated.h" + +UCLASS() +class UCogSampleAbilitySystemGlobals : public UAbilitySystemGlobals +{ + GENERATED_BODY() + + virtual FGameplayEffectContext* AllocGameplayEffectContext() const override; +}; diff --git a/Source/CogSample/CogSampleCharacter.cpp b/Source/CogSample/CogSampleCharacter.cpp index 6237c54..d2a55ba 100644 --- a/Source/CogSample/CogSampleCharacter.cpp +++ b/Source/CogSample/CogSampleCharacter.cpp @@ -6,6 +6,7 @@ #include "CogSampleAttributeSet_Health.h" #include "CogSampleAttributeSet_Misc.h" #include "CogSampleCharacterMovementComponent.h" +#include "CogSampleForcedMove.h" #include "CogSampleLogCategories.h" #include "CogSampleTagLibrary.h" #include "Components/CapsuleComponent.h" @@ -15,6 +16,7 @@ #include "GameFramework/CharacterMovementComponent.h" #include "GameFramework/CheatManagerDefines.h" #include "GameFramework/Controller.h" +#include "GameFramework/RootMotionSource.h" #include "GameFramework/SpringArmComponent.h" #include "Net/Core/PushModel/PushModel.h" #include "Net/UnrealNetwork.h" @@ -74,6 +76,7 @@ void ACogSampleCharacter::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > Params.Condition = COND_OwnerOnly; DOREPLIFETIME_WITH_PARAMS_FAST(ACogSampleCharacter, ActiveAbilityHandles, Params); + DOREPLIFETIME_WITH_PARAMS_FAST(ACogSampleCharacter, TeamID, Params); } //-------------------------------------------------------------------------------------------------------------------------- @@ -109,6 +112,23 @@ UAbilitySystemComponent* ACogSampleCharacter::GetAbilitySystemComponent() const return AbilitySystem; } +//-------------------------------------------------------------------------------------------------------------------------- +ECogInterfacesAllegiance ACogSampleCharacter::GetAllegianceWithOtherActor(const AActor* OtherActor) const +{ + const ACogSampleCharacter* OtherCharacter = Cast(OtherActor); + if (OtherCharacter == nullptr) + { + return ECogInterfacesAllegiance::Neutral; + } + + if (TeamID == OtherCharacter->TeamID) + { + return ECogInterfacesAllegiance::Friendly; + } + + return ECogInterfacesAllegiance::Enemy; +} + //-------------------------------------------------------------------------------------------------------------------------- void ACogSampleCharacter::InitializeAbilitySystem() { @@ -301,7 +321,7 @@ void ACogSampleCharacter::OnAbilityInputCompleted(const FInputActionValue& Value //-------------------------------------------------------------------------------------------------------------------------- void ACogSampleCharacter::ActivateItem(const FInputActionValue& Value, int32 Index) { - COG_LOG_ACTOR(LogCogInput, ELogVerbosity::Verbose, this, TEXT("%d"), Index); + COG_LOG_OBJECT(LogCogInput, ELogVerbosity::Verbose, this, TEXT("%d"), Index); } //-------------------------------------------------------------------------------------------------------------------------- @@ -468,3 +488,74 @@ void ACogSampleCharacter::OnScaleAttributeChanged(const FOnAttributeChangeData& { SetActorScale3D(FVector(Data.NewValue)); } + +//-------------------------------------------------------------------------------------------------------------------------- +void ACogSampleCharacter::SetTeamID(int32 Value) +{ + TeamID = Value; + MARK_PROPERTY_DIRTY_FROM_NAME(ACogSampleCharacter, TeamID, this); +} + +//-------------------------------------------------------------------------------------------------------------------------- +int32 ACogSampleCharacter::ApplyForcedMove(const FCogSampleForcedMoveParams& Params) +{ + if (HasAuthority() == false) + { + return (uint16)ERootMotionSourceID::Invalid;; + } + + if (IsValid(Params.Effect)) + { + FGameplayEffectContextHandle EffectContextHandle = AbilitySystem->MakeEffectContext(); + EffectContextHandle.AddInstigator(Params.Instigator, Params.Causer); + + FGameplayEffectSpecHandle SpecHandle = AbilitySystem->MakeOutgoingSpec(Params.Effect, 1.0f, EffectContextHandle); + SpecHandle.Data->SetDuration(Params.Duration, true); + + if (SpecHandle.IsValid()) + { + AbilitySystem->ApplyGameplayEffectSpecToSelf(*SpecHandle.Data.Get()); + } + } + + Client_ApplyForcedMove(Params); + int32 RootMotionSourceID = ApplyForcedMoveInternal(Params); + return RootMotionSourceID; +} + +//-------------------------------------------------------------------------------------------------------------------------- +void ACogSampleCharacter::Client_ApplyForcedMove_Implementation(const FCogSampleForcedMoveParams& Params) +{ + if (GetWorld()->GetNetMode() == NM_Client) + { + ApplyForcedMoveInternal(Params); + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +uint16 ACogSampleCharacter::ApplyForcedMoveInternal(const FCogSampleForcedMoveParams& Params) +{ + UCogSampleCharacterMovementComponent* MovementComponent = Cast(GetMovementComponent()); + if (MovementComponent == nullptr) + { + return (uint16)ERootMotionSourceID::Invalid;; + } + + TSharedPtr JumpForce = MakeShared(); + JumpForce->InstanceName = "ForceMove"; + JumpForce->AccumulateMode = Params.IsAdditive ? ERootMotionAccumulateMode::Additive : ERootMotionAccumulateMode::Override; + JumpForce->Priority = (uint16)Params.Priority; + JumpForce->Duration = Params.Duration; + JumpForce->Rotation = Params.Rotation; + JumpForce->Distance = Params.Distance; + JumpForce->Height = Params.Height; + JumpForce->bDisableTimeout = Params.bFinishOnLanded; // If we finish on landed, we need to disable force's timeout + JumpForce->PathOffsetCurve = Params.PathOffsetCurve; + JumpForce->TimeMappingCurve = Params.TimeMappingCurve; + JumpForce->FinishVelocityParams.Mode = Params.FinishVelocityMode; + JumpForce->FinishVelocityParams.SetVelocity = Params.FinishSetVelocity; + JumpForce->FinishVelocityParams.ClampVelocity = Params.FinishClampVelocity; + + uint16 RootMotionSourceID = MovementComponent->ApplyRootMotionSource(JumpForce); + return RootMotionSourceID; +} \ No newline at end of file diff --git a/Source/CogSample/CogSampleCharacter.h b/Source/CogSample/CogSampleCharacter.h index b8c393b..f2e1c39 100644 --- a/Source/CogSample/CogSampleCharacter.h +++ b/Source/CogSample/CogSampleCharacter.h @@ -5,7 +5,8 @@ #include "ActiveGameplayEffectHandle.h" #include "AttributeSet.h" #include "CogDefines.h" -#include "CogInterfaceFilteredActor.h" +#include "CogInterfaceAllegianceActor.h" +#include "CogInterfaceDebugFilteredActor.h" #include "GameFramework/Character.h" #include "GameplayAbilitySpecHandle.h" #include "GameplayTagContainer.h" @@ -21,9 +22,21 @@ class UInputAction; class UInputMappingContext; class USpringArmComponent; struct FActiveGameplayEffect; +struct FCogSampleForcedMoveParams; struct FGameplayEffectSpec; struct FOnAttributeChangeData; +//-------------------------------------------------------------------------------------------------------------------------- +UENUM(BlueprintType, meta = (Bitflags, UseEnumValuesAsMaskValuesInEditor = "true")) +enum class ECogSampleAllegianceFilter : uint8 +{ + None = 0 UMETA(Hidden), + Ally = 1 << 0, + Neutral = 1 << 1, + Enemy = 1 << 2, +}; +ENUM_CLASS_FLAGS(ECogSampleAllegianceFilter); + //-------------------------------------------------------------------------------------------------------------------------- USTRUCT(BlueprintType) struct FActiveAbilityInfo @@ -57,7 +70,8 @@ public: UCLASS(config=Game) class ACogSampleCharacter : public ACharacter , public IAbilitySystemInterface - , public ICogInterfacesFilteredActor + , public ICogInterfacesDebugFilteredActor + , public ICogInterfacesAllegianceActor { GENERATED_BODY() @@ -83,6 +97,11 @@ public: UFUNCTION(BlueprintPure) UAbilitySystemComponent* GetAbilitySystemComponent() const override; + //---------------------------------------------------------------------------------------------------------------------- + // ICogInterfacesAllegianceActor overrides + //---------------------------------------------------------------------------------------------------------------------- + ECogInterfacesAllegiance GetAllegianceWithOtherActor(const AActor* OtherActor) const override; + //---------------------------------------------------------------------------------------------------------------------- void OnAcknowledgePossession(APlayerController* InController); @@ -94,13 +113,13 @@ public: void OnRevived(AActor* InInstigator, AActor* InCauser, const FGameplayEffectSpec& InEffectSpec, float InMagnitude); + //---------------------------------------------------------------------------------------------------------------------- + // Camera + //---------------------------------------------------------------------------------------------------------------------- USpringArmComponent* GetCameraBoom() const { return CameraBoom; } UCameraComponent* GetFollowCamera() const { return FollowCamera; } - //---------------------------------------------------------------------------------------------------------------------- - // Camera - //---------------------------------------------------------------------------------------------------------------------- /** Camera boom positioning the camera behind the character */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true")) USpringArmComponent* CameraBoom; @@ -157,12 +176,30 @@ public: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Ability) TArray> Effects; + //---------------------------------------------------------------------------------------------------------------------- + // Team + //---------------------------------------------------------------------------------------------------------------------- + + UFUNCTION(BlueprintPure) + int32 GetTeamID() const { return TeamID; } + + UFUNCTION(BlueprintCallable) + void SetTeamID(int32 Value); + + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Team, Replicated, meta = (AllowPrivateAccess = "true")) + int32 TeamID = 0; + + //---------------------------------------------------------------------------------------------------------------------- + // Forced Move + //---------------------------------------------------------------------------------------------------------------------- + UFUNCTION(BlueprintCallable) + int32 ApplyForcedMove(const FCogSampleForcedMoveParams& Params); + private: - void InitializeAbilitySystem(); - - void ShutdownAbilitySystem(); - + //---------------------------------------------------------------------------------------------------------------------- + // Inputs + //---------------------------------------------------------------------------------------------------------------------- void Move(const FInputActionValue& Value); void MoveZ(const FInputActionValue& Value); @@ -175,6 +212,13 @@ private: void ActivateItem(const FInputActionValue& Value, int32 Index); + //---------------------------------------------------------------------------------------------------------------------- + // Ability system + //---------------------------------------------------------------------------------------------------------------------- + void InitializeAbilitySystem(); + + void ShutdownAbilitySystem(); + void OnGameplayEffectAdded(UAbilitySystemComponent* AbilitySystemComponent, const FGameplayEffectSpec& GameplayEffectSpec, FActiveGameplayEffectHandle Handle); void OnGameplayEffectRemoved(const FActiveGameplayEffect& RemovedGameplayEffect); @@ -183,6 +227,15 @@ private: void OnScaleAttributeChanged(const FOnAttributeChangeData& Data); + //---------------------------------------------------------------------------------------------------------------------- + // Forced Move + //---------------------------------------------------------------------------------------------------------------------- + UFUNCTION(Reliable, Client) + void Client_ApplyForcedMove(const FCogSampleForcedMoveParams& Params); + + uint16 ApplyForcedMoveInternal(const FCogSampleForcedMoveParams& Params); + + //---------------------------------------------------------------------------------------------------------------------- UPROPERTY(Replicated, Transient) TArray ActiveAbilityHandles; @@ -197,5 +250,6 @@ private: bool bIsGhost = false; bool bIsInitialized = false; + }; diff --git a/Source/CogSample/CogSampleCharacterMovementComponent.cpp b/Source/CogSample/CogSampleCharacterMovementComponent.cpp index fb6b02e..c4ab62e 100644 --- a/Source/CogSample/CogSampleCharacterMovementComponent.cpp +++ b/Source/CogSample/CogSampleCharacterMovementComponent.cpp @@ -220,7 +220,7 @@ void UCogSampleCharacterMovementComponent::TickComponent(float DeltaTime, enum E const ACharacter* Character = GetCharacterOwner(); const UCapsuleComponent* CapsuleComponent = Character->GetCapsuleComponent(); - if (FCogDebugSettings::IsDebugActiveForActor(GetPawnOwner())) + if (FCogDebugSettings::IsDebugActiveForObject(GetPawnOwner())) { FCogDebugPlot::PlotValue(GetPawnOwner(), "Move Input X", GetPendingInputVector().X); FCogDebugPlot::PlotValue(GetPawnOwner(), "Move Input Y", GetPendingInputVector().Y); @@ -236,7 +236,7 @@ void UCogSampleCharacterMovementComponent::TickComponent(float DeltaTime, enum E const FVector DebugLocation = Character->GetActorLocation(); const FVector DebugBottomLocation = DebugLocation - FVector::UpVector * CapsuleComponent->GetScaledCapsuleHalfHeight(); - if (FCogDebugSettings::IsDebugActiveForActor(GetPawnOwner())) + if (FCogDebugSettings::IsDebugActiveForObject(GetPawnOwner())) { const FRotator Rotation = Character->GetActorRotation(); const FVector Forward = Character->GetActorForwardVector(); diff --git a/Source/CogSample/CogSampleForcedMove.h b/Source/CogSample/CogSampleForcedMove.h new file mode 100644 index 0000000..384f5d1 --- /dev/null +++ b/Source/CogSample/CogSampleForcedMove.h @@ -0,0 +1,66 @@ +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/RootMotionSource.h" +#include "CogSampleForcedMove.generated.h" + +class UGameplayEffect; + +//-------------------------------------------------------------------------------------------------------------------------- +USTRUCT(BlueprintType) +struct FCogSampleForcedMoveParams +{ + GENERATED_BODY() + +public: + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + AActor* Instigator; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + AActor* Causer; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + TSubclassOf Effect; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + FRotator Rotation; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + bool IsAdditive = true; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + int32 Priority = 0; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + float Duration = 0.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + float Distance = 0.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + float Height = 0.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + float MinimumLandedTriggerTime = 0.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + bool bFinishOnLanded = 0.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + ERootMotionFinishVelocityMode FinishVelocityMode = ERootMotionFinishVelocityMode::MaintainLastRootMotionVelocity; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + FVector FinishSetVelocity = FVector::ZeroVector; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + float FinishClampVelocity = 0.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + UCurveVector* PathOffsetCurve = nullptr; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + UCurveFloat* TimeMappingCurve = nullptr; + +}; + diff --git a/Source/CogSample/CogSampleGameplayEffectContext.cpp b/Source/CogSample/CogSampleGameplayEffectContext.cpp new file mode 100644 index 0000000..52311aa --- /dev/null +++ b/Source/CogSample/CogSampleGameplayEffectContext.cpp @@ -0,0 +1,252 @@ +#include "CogSampleGameplayEffectContext.h" + +#include "AbilitySystemComponent.h" + +//-------------------------------------------------------------------------------------------------------------------------- +bool FCogSampleGameplayEffectContextFloatValue::NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess) +{ + enum RepFlag + { + REP_Name = 0, + REP_Value, + REP_MAX + }; + + uint16 RepBits = 0; + if (Ar.IsSaving()) + { + if (Name.IsValid()) + { + RepBits |= (1 << REP_Name); + } + + if (Value != 0.f) + { + RepBits |= (1 << REP_Value); + } + } + + Ar.SerializeBits(&RepBits, REP_MAX); + + + if (RepBits & (1 << REP_Name)) + { + Ar << Name; + } + + if (RepBits & (1 << REP_Value)) + { + Ar << Value; + } + + bOutSuccess = true; + return true; +} + +//-------------------------------------------------------------------------------------------------------------------------- + +FCogSampleGameplayEffectContext* FCogSampleGameplayEffectContext::ExtractEffectContext(struct FGameplayEffectContextHandle Handle) +{ + FGameplayEffectContext* BaseEffectContext = Handle.Get(); + if ((BaseEffectContext != nullptr) && BaseEffectContext->GetScriptStruct()->IsChildOf(FCogSampleGameplayEffectContext::StaticStruct())) + { + return (FCogSampleGameplayEffectContext*)BaseEffectContext; + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------------------------------- + +bool FCogSampleGameplayEffectContext::NetSerialize(FArchive& Ar, UPackageMap* Map, bool& bOutSuccess) +{ + enum RepFlag + { + Rep_Instigator = 0, + Rep_EffectCauser, + Rep_AbilityCDO, + Rep_SourceObject, + Rep_Actors, + Rep_HitResult, + Rep_HasWorldOrigin, + + Rep_FloatValues, + Rep_MAX + }; + + uint32 RepBits = 0; + if (Ar.IsSaving()) + { + if (Instigator.IsValid()) + { + RepBits |= 1 << Rep_Instigator; + } + if (EffectCauser.IsValid()) + { + RepBits |= 1 << Rep_EffectCauser; + } + if (AbilityCDO.IsValid()) + { + RepBits |= 1 << Rep_AbilityCDO; + } + if (bReplicateSourceObject && SourceObject.IsValid()) + { + RepBits |= 1 << Rep_SourceObject; + } + if (Actors.Num() > 0) + { + RepBits |= 1 << Rep_Actors; + } + if (HitResult.IsValid()) + { + RepBits |= 1 << Rep_HitResult; + } + if (bHasWorldOrigin) + { + RepBits |= 1 << Rep_HasWorldOrigin; + } + + //------------------------------ + // Our custom fields + //------------------------------ + if (FloatValues.Num() > 0) + { + RepBits |= 1 << Rep_FloatValues; + } + //------------------------------ + } + + Ar.SerializeBits(&RepBits, Rep_MAX); + + if (RepBits & (1 << Rep_Instigator)) + { + Ar << Instigator; + } + if (RepBits & (1 << Rep_EffectCauser)) + { + Ar << EffectCauser; + } + if (RepBits & (1 << Rep_AbilityCDO)) + { + Ar << AbilityCDO; + } + if (RepBits & (1 << Rep_SourceObject)) + { + Ar << SourceObject; + } + if (RepBits & (1 << Rep_Actors)) + { + SafeNetSerializeTArray_Default<31>(Ar, Actors); + } + if (RepBits & (1 << Rep_HitResult)) + { + if (Ar.IsLoading()) + { + if (!HitResult.IsValid()) + { + HitResult = TSharedPtr(new FHitResult()); + } + } + HitResult->NetSerialize(Ar, Map, bOutSuccess); + } + if (RepBits & (1 << Rep_HasWorldOrigin)) + { + Ar << WorldOrigin; + bHasWorldOrigin = true; + } + else + { + bHasWorldOrigin = false; + } + + //------------------------------ + // Our custom fields + //------------------------------ + if (RepBits & (1 << Rep_FloatValues)) + { + SafeNetSerializeTArray_WithNetSerialize<31>(Ar, FloatValues, Map); + } + + if (Ar.IsLoading()) + { + AddInstigator(Instigator.Get(), EffectCauser.Get()); // Just to initialize InstigatorAbilitySystemComponent + } + + bOutSuccess = true; + return true; +} + +//-------------------------------------------------------------------------------------------------------------------------- + +UScriptStruct* FCogSampleGameplayEffectContext::GetScriptStruct() const +{ + return FCogSampleGameplayEffectContext::StaticStruct(); +} + +//-------------------------------------------------------------------------------------------------------------------------- + +FCogSampleGameplayEffectContext* FCogSampleGameplayEffectContext::Duplicate() const +{ + FCogSampleGameplayEffectContext* newContext = new FCogSampleGameplayEffectContext(); + *newContext = *this; + newContext->AddActors(Actors); + if (GetHitResult()) + { + // Does a deep copy of the hit result + newContext->AddHitResult(*GetHitResult(), true); + } + return newContext; +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogSampleEffectContextLibrary::EffectContextSetFloatValue(FGameplayEffectContextHandle EffectContext, FName Name, float Value) +{ + if (FCogSampleGameplayEffectContext* TypedEffectContext = FCogSampleGameplayEffectContext::ExtractEffectContext(EffectContext)) + { + FCogSampleGameplayEffectContextFloatValue* Result = TypedEffectContext->FloatValues.FindByPredicate([&Name](const FCogSampleGameplayEffectContextFloatValue& Entry) + { + return Entry.Name == Name; + }); + + if (Result != nullptr) + { + Result->Value = Value; + } + else + { + FCogSampleGameplayEffectContextFloatValue Entry; + Entry.Name = Name; + Entry.Value = Value; + TypedEffectContext->FloatValues.Emplace(Entry); + } + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogSampleEffectContextLibrary::EffectContextGetFloatValue(FGameplayEffectContextHandle EffectContext, FName Name, float& Value, bool& Found) +{ + Found = false; + + if (FCogSampleGameplayEffectContext* TypedEffectContext = FCogSampleGameplayEffectContext::ExtractEffectContext(EffectContext)) + { + const FCogSampleGameplayEffectContextFloatValue* Result = TypedEffectContext->FloatValues.FindByPredicate([&Name](const FCogSampleGameplayEffectContextFloatValue& Entry) + { + return Entry.Name == Name; + }); + + if (Result != nullptr) + { + Value = Result->Value; + Found = true; + } + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogSampleEffectContextLibrary::EffectContextGetAllFloatValues(FGameplayEffectContextHandle EffectContext, TArray& Entries) +{ + if (FCogSampleGameplayEffectContext* TypedEffectContext = FCogSampleGameplayEffectContext::ExtractEffectContext(EffectContext)) + { + Entries = TypedEffectContext->FloatValues; + } +} \ No newline at end of file diff --git a/Source/CogSample/CogSampleGameplayEffectContext.h b/Source/CogSample/CogSampleGameplayEffectContext.h new file mode 100644 index 0000000..c91ce10 --- /dev/null +++ b/Source/CogSample/CogSampleGameplayEffectContext.h @@ -0,0 +1,102 @@ +#pragma once + +#include "CoreMinimal.h" +#include "GameplayEffectTypes.h" +#include "Kismet/BlueprintFunctionLibrary.h" +#include "CogSampleGameplayEffectContext.generated.h" + +//-------------------------------------------------------------------------------------------------------------------------- +USTRUCT(BlueprintType) +struct FCogSampleGameplayEffectContextFloatValue +{ + GENERATED_BODY() + + virtual ~FCogSampleGameplayEffectContextFloatValue() + { + } + + UPROPERTY(BlueprintReadWrite) + FName Name; + + UPROPERTY(BlueprintReadWrite) + float Value = 0.0f; + + virtual bool NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess); +}; + +//-------------------------------------------------------------------------------------------------------------------------- + +template<> +struct TStructOpsTypeTraits : public TStructOpsTypeTraitsBase2 +{ + enum + { + WithNetSerializer = true + }; +}; + +//-------------------------------------------------------------------------------------------------------------------------- + +USTRUCT() +struct FCogSampleGameplayEffectContext : public FGameplayEffectContext +{ + GENERATED_BODY() + +public: + + FCogSampleGameplayEffectContext() + : FGameplayEffectContext() + { + } + + FCogSampleGameplayEffectContext(AActor* InInstigator, AActor* InEffectCauser) + : FGameplayEffectContext(InInstigator, InEffectCauser) + { + } + + /** Returns the wrapped FGPCoreGameplayEffectContext from the handle, or nullptr if it doesn't exist or is the wrong type */ + static FCogSampleGameplayEffectContext* ExtractEffectContext(struct FGameplayEffectContextHandle Handle); + + virtual UScriptStruct* GetScriptStruct() const override; + + virtual FCogSampleGameplayEffectContext* Duplicate() const override; + + virtual bool NetSerialize(FArchive& Ar, UPackageMap* Map, bool& bOutSuccess) override; + + bool CanGameplayCueBePredicted(); + + /* REPLICATED */ + UPROPERTY() + TArray FloatValues; +}; + +//-------------------------------------------------------------------------------------------------------------------------- + +template<> +struct TStructOpsTypeTraits : public TStructOpsTypeTraitsBase2 +{ + enum + { + WithNetSerializer = true, + WithCopy = true + }; +}; + +//-------------------------------------------------------------------------------------------------------------------------- + +UCLASS(meta = (ScriptName = "CogSampleEffectContextLibrary")) +class UCogSampleEffectContextLibrary : public UBlueprintFunctionLibrary +{ + GENERATED_BODY() + +public: + + UFUNCTION(BlueprintCallable) + static void EffectContextSetFloatValue(FGameplayEffectContextHandle EffectContext, FName Name, float Value); + + UFUNCTION(BlueprintPure) + static void EffectContextGetFloatValue(FGameplayEffectContextHandle EffectContext, FName Name, float& Value, bool& Found); + + UFUNCTION(BlueprintPure) + static void EffectContextGetAllFloatValues(FGameplayEffectContextHandle EffectContext, TArray& Entries); +}; \ No newline at end of file diff --git a/Source/CogSample/CogSampleGameplayLibrary.cpp b/Source/CogSample/CogSampleGameplayLibrary.cpp new file mode 100644 index 0000000..69b50e9 --- /dev/null +++ b/Source/CogSample/CogSampleGameplayLibrary.cpp @@ -0,0 +1,69 @@ +#include "CogSampleGameplayLibrary.h" + +#include "Abilities/GameplayAbility.h" +#include "AbilitySystemComponent.h" +#include "AbilitySystemGlobals.h" +#include "CogSampleGameplayEffectContext.h" +#include "Components/CapsuleComponent.h" +#include "GameFramework/Character.h" +#include "GameplayCueNotifyTypes.h" +#include "Particles/ParticleSystemComponent.h" + +//-------------------------------------------------------------------------------------------------------------------------- +FVector UCogSampleGameplayLibrary::GetActorBottomLocation(const AActor* Actor) +{ + const FVector Location = Actor->GetActorLocation(); + + if (const ACharacter* Character = Cast(Actor)) + { + const UCapsuleComponent* CapsuleComponent = Character->GetCapsuleComponent(); + const FVector BottomLocation = Location - FVector::UpVector * CapsuleComponent->GetScaledCapsuleHalfHeight(); + return BottomLocation; + } + + return Location; +} + +//-------------------------------------------------------------------------------------------------------------------------- +bool UCogSampleGameplayLibrary::FindAbilitySpecHandleFromClass(UAbilitySystemComponent* AbilitySystemComponent, TSubclassOf AbilityClass, FGameplayAbilitySpecHandle& SpecHandle) +{ + if (const FGameplayAbilitySpec* Spec = AbilitySystemComponent->FindAbilitySpecFromClass(AbilityClass)) + { + SpecHandle = Spec->Handle; + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogSampleGameplayLibrary::ApplyAllGameplayEffectContextValues(const FGameplayCueParameters& Parameters, const FGameplayCueNotify_SpawnResult& SpawnResult) +{ + TArray Entries; + UCogSampleEffectContextLibrary::EffectContextGetAllFloatValues(Parameters.EffectContext, Entries); + + for (TObjectPtr FXSystemComponent : SpawnResult.FxSystemComponents) + { + if (UFXSystemComponent* FXSystemComponentPtr = FXSystemComponent.Get()) + { + for (const FCogSampleGameplayEffectContextFloatValue& Entry : Entries) + { + FXSystemComponentPtr->SetFloatParameter(Entry.Name, Entry.Value); + } + } + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogSampleGameplayLibrary::SendMontageEvent(AActor* Actor, FGameplayTag EventTag, FGameplayEventData Payload) +{ + if (::IsValid(Actor)) + { + UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Actor); + if (AbilitySystemComponent != nullptr && IsValidChecked(AbilitySystemComponent)) + { + FScopedPredictionWindow NewScopedWindow(AbilitySystemComponent, true); + AbilitySystemComponent->HandleGameplayEvent(EventTag, &Payload); + } + } +} \ No newline at end of file diff --git a/Source/CogSample/CogSampleGameplayLibrary.h b/Source/CogSample/CogSampleGameplayLibrary.h new file mode 100644 index 0000000..95c1c6e --- /dev/null +++ b/Source/CogSample/CogSampleGameplayLibrary.h @@ -0,0 +1,37 @@ +#pragma once + +#include "CoreMinimal.h" +#include "Kismet/KismetSystemLibrary.h" +#include "CogSampleGameplayLibrary.generated.h" + +class UAbilitySystemComponent; +class UGameplayAbility; +struct FGameplayAbilitySpecHandle; +struct FGameplayCueParameters; +struct FGameplayCueNotify_SpawnResult; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(meta = (ScriptName = "CogSampleGameplayLibrary")) +class UCogSampleGameplayLibrary : public UBlueprintFunctionLibrary +{ + GENERATED_BODY() + +public: + + UFUNCTION(BlueprintPure) + static FVector GetActorBottomLocation(const AActor* Actor); + + UFUNCTION(BlueprintCallable) + static bool FindAbilitySpecHandleFromClass(UAbilitySystemComponent* AbilitySystemComponent, TSubclassOf AbilityClass, FGameplayAbilitySpecHandle& SpecHandle); + + UFUNCTION(BlueprintCallable) + static void ApplyAllGameplayEffectContextValues(const FGameplayCueParameters& Parameters, const FGameplayCueNotify_SpawnResult& SpawnResult); + + /* Same as UAbilitySystemBlueprintLibrary::SendGameplayEventToActor but doesn't log an error when the ability system + * is not found. When a montage is played in the montage editor the notifications are executed and if a notification + * uses SendGameplayEventToActor it will log an error. */ + UFUNCTION(BlueprintCallable) + static void SendMontageEvent(AActor* Actor, FGameplayTag EventTag, FGameplayEventData Payload); + +}; + diff --git a/Source/CogSample/CogSampleLogCategories.cpp b/Source/CogSample/CogSampleLogCategories.cpp index a1b2a81..defe467 100644 --- a/Source/CogSample/CogSampleLogCategories.cpp +++ b/Source/CogSample/CogSampleLogCategories.cpp @@ -7,6 +7,7 @@ #include "CogDebugLogCategoryManager.h" #endif //USE_COG +DEFINE_LOG_CATEGORY(LogCogAlways); DEFINE_LOG_CATEGORY(LogCogCollision); DEFINE_LOG_CATEGORY(LogCogInput); DEFINE_LOG_CATEGORY(LogCogPosition); @@ -20,6 +21,7 @@ namespace CogSampleLog void RegiterAllLogCategories() { #if USE_COG + FCogDebugLogCategoryManager::AddLogCategory(LogCogAlways, "Always", false); FCogDebugLogCategoryManager::AddLogCategory(LogAbilitySystem, "AbilitySystem"); FCogDebugLogCategoryManager::AddLogCategory(LogGameplayEffects, "Gameplay Effects"); FCogDebugLogCategoryManager::AddLogCategory(LogCogCollision, "Collision"); diff --git a/Source/CogSample/CogSampleLogCategories.h b/Source/CogSample/CogSampleLogCategories.h index 7c4dd88..c85f12b 100644 --- a/Source/CogSample/CogSampleLogCategories.h +++ b/Source/CogSample/CogSampleLogCategories.h @@ -1,5 +1,6 @@ #include "CoreMinimal.h" +DECLARE_LOG_CATEGORY_EXTERN(LogCogAlways, VeryVerbose, All); DECLARE_LOG_CATEGORY_EXTERN(LogCogCollision, Warning, All); DECLARE_LOG_CATEGORY_EXTERN(LogCogInput, Warning, All); DECLARE_LOG_CATEGORY_EXTERN(LogCogPosition, Warning, All); diff --git a/Source/CogSample/CogSampleTagLibrary.cpp b/Source/CogSample/CogSampleTagLibrary.cpp index abad092..3537ec1 100644 --- a/Source/CogSample/CogSampleTagLibrary.cpp +++ b/Source/CogSample/CogSampleTagLibrary.cpp @@ -14,6 +14,9 @@ UE_DEFINE_GAMEPLAY_TAG(Tag_Effect_Type_Heal_Revive, "Effect.Type.Heal.Revive"); UE_DEFINE_GAMEPLAY_TAG(Tag_GameplayEvent_Killed, "GameplayEvent.Killed"); UE_DEFINE_GAMEPLAY_TAG(Tag_GameplayEvent_Revived, "GameplayEvent.Revived"); +UE_DEFINE_GAMEPLAY_TAG(Tag_MontageEvent_Cast_Begin, "MontageEvent.Cast.Begin"); +UE_DEFINE_GAMEPLAY_TAG(Tag_MontageEvent_Cast_End, "MontageEvent.Cast.End"); + UE_DEFINE_GAMEPLAY_TAG(Tag_Status_Dead, "Effect.Status.Dead"); UE_DEFINE_GAMEPLAY_TAG(Tag_Status_Ghost, "Effect.Status.Ghost"); UE_DEFINE_GAMEPLAY_TAG(Tag_Status_Immobilized, "Effect.Status.Immobilized"); diff --git a/Source/CogSample/CogSampleTagLibrary.h b/Source/CogSample/CogSampleTagLibrary.h index c5bf20f..698d24f 100644 --- a/Source/CogSample/CogSampleTagLibrary.h +++ b/Source/CogSample/CogSampleTagLibrary.h @@ -17,6 +17,9 @@ UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_Effect_Type_Heal_Revive); UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_GameplayEvent_Killed); UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_GameplayEvent_Revived); +UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_MontageEvent_Cast_Begin); +UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_MontageEvent_Cast_End); + UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_Status_Dead); UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_Status_Ghost); UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_Status_Immobilized);