diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..53b9c9c5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,24 @@ +[submodule "UHL"] + path = UHL + url = https://github.com/Ciberusps/UHL.git +[submodule "UHLAI"] + path = UHLAI + url = https://github.com/Ciberusps/UHLAI.git +[submodule "UHLCharacter"] + path = UHLCharacter + url = https://github.com/Ciberusps/UHLCharacter.git +[submodule "UHLCommonMaps"] + path = UHLCommonMaps + url = https://github.com/Ciberusps/UHLCommonMaps.git +[submodule "UHLDebugSystem"] + path = UHLDebugSystem + url = https://github.com/Ciberusps/UHLDebugSystem.git +[submodule "UHLGAS"] + path = UHLGAS + url = https://github.com/Ciberusps/UHLGAS.git +[submodule "UHLStateTree"] + path = UHLStateTree + url = https://github.com/Ciberusps/UHLStateTree.git +[submodule "UHLBehaviorTree"] + path = UHLBehaviorTree + url = https://github.com/Ciberusps/UHLBehaviorTree.git diff --git a/Config/DefaultUnrealHelperLibrary.ini b/Config/DefaultUnrealHelperLibrary.ini deleted file mode 100644 index 1a1f1e2b..00000000 --- a/Config/DefaultUnrealHelperLibrary.ini +++ /dev/null @@ -1,209 +0,0 @@ -[CoreRedirects] -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPLibrary",NewName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTT_RotateTo",NewName="/Script/UnrealHelperLibrary.BTT_TurnTo") -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.TurnToSettings",NewName="/Script/UnrealHelperLibrary.TurnSettings") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.TurnSettings.TurnToRanges",NewName="/Script/UnrealHelperLibrary.TurnSettings.TurnRangesGroups") -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.TurnToRanges",NewName="/Script/UnrealHelperLibrary.TurnRanges") -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.TurnToRange",NewName="/Script/UnrealHelperLibrary.TurnRange") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.TurnRanges.Ranges",NewName="/Script/UnrealHelperLibrary.TurnRanges.TurnRanges") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.TurnSettings.TurnRanges",NewName="/Script/UnrealHelperLibrary.TurnSettings.TurnRangesGroups") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.TurnSettings.TurnGroups",NewName="/Script/UnrealHelperLibrary.TurnSettings.TurnRangesGroups") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.TurnToAnimationsDataAsset.TurnToSettings",NewName="/Script/UnrealHelperLibrary.TurnSettingsDataAsset.TurnSettings") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.TurnToAnimationsDataAsset.TurnToSettings",NewName="/Script/UnrealHelperLibrary.TurnSettingsDataAsset.TurnSettings") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.TurnToAnimationsDataAsset.SetupPreset_90_180",NewName="/Script/UnrealHelperLibrary.TurnSettingsDataAsset.SetupPreset_Recommended_90_180") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.BTT_TurnTo.SetupPreset_90_180",NewName="/Script/UnrealHelperLibrary.BTT_TurnTo.SetupPreset_Recommended_90_180") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.BTT_TurnTo.SetupPreset_Recommended_90_180",NewName="/Script/UnrealHelperLibrary.BTT_TurnTo.SetupPreset_Default_90_180") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BInputComponent",NewName="/Script/UnrealHelperLibrary.UHLInputComponent") -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.BInputAction",NewName="/Script/UnrealHelperLibrary.UHLInputAction") -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.BInputActionAbilities",NewName="/Script/UnrealHelperLibrary.UHLInputActionAbilities") -+EnumRedirects=(OldName="/Script/UnrealHelperLibrary.EBAbilityActivationPolicy",NewName="/Script/UnrealHelperLibrary.EUHLAbilityActivationPolicy") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.TurnToAnimationsDataAsset",NewName="/Script/UnrealHelperLibrary.TurnSettingsDataAsset") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.GetHighestPoint",NewName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.GetHighestPointInBox") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.GetPointAtRelativeAngleBetweenActors",NewName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.GetPointAtAngleRelativeToOtherActor") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.GetPointAtRelativeDirectionBetweenActors",NewName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.GetPointAtDirectionRelativeToOtherActor") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.OtherActorInAngle",NewName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.IsOtherActorInAngle") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.OtherCharacterInRange",NewName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.IsOtherCharacterInRange") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.UHLGameplayAbility.CacheInputActivationRequiredTags",NewName="/Script/UnrealHelperLibrary.UHLGameplayAbility.AddingToCacheInputRequiredTags") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.UHLGameplayAbility.CacheInputActivationBlockedTags",NewName="/Script/UnrealHelperLibrary.UHLGameplayAbility.AddingToCacheInputBlockedTags") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.UHLDebugCategory.Tag",NewName="/Script/UnrealHelperLibrary.UHLDebugCategory.Tags") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHL_DDC_AbilitySystem_Attributes",NewName="/Script/UnrealHelperLibrary.DCC_AbilitySystem_Attributes") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.DebugCategoryCheckboxWidget",NewName="/Script/UnrealHelperLibrary.DebugCategoryButtonWidget") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.UHLDebugCategory.bForceDeactivateOnGameStart",NewName="/Script/UnrealHelperLibrary.UHLDebugCategory.bForceComponentsDeactivateOnEnd") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.UHLDebugCategory.bForceDeactivateOnEnd",NewName="/Script/UnrealHelperLibrary.UHLDebugCategory.bForceComponentsDeactivateOnEnd") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.UHLDebugSubsystemSettings.GameplayTagTableList",NewName="/Script/UnrealHelperLibrary.UHLDebugSubsystemSettings.DebugCategoriesGameplayTagsTableList") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.UHLDebugSubsystemSettings.bExcludeUHLDebugCategories",NewName="/Script/UnrealHelperLibrary.UHLDebugSubsystemSettings.bExcludeDefaultUHLDebugCategories") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.UHLDebugCategory.ByDefaultEnabledIn",NewName="/Script/UnrealHelperLibrary.UHLDebugCategory.ByDefaultEnabledInBuildTypes") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.UHLAbilitySystemComponent.InitialActiveAbilities",NewName="/Script/UnrealHelperLibrary.UHLAbilitySystemComponent.ActiveAbilitiesOnStart") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.UHLAbilitySystemComponent.GiveAbilitiesOnStart",NewName="/Script/UnrealHelperLibrary.UHLAbilitySystemComponent.Abilities") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.UHLAbilitySystemComponent.GiveAttributeSetsOnStart",NewName="/Script/UnrealHelperLibrary.UHLAbilitySystemComponent.AttributeSets") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.UHLAbilitySystemComponent.InitialGameplayAttributes",NewName="/Script/UnrealHelperLibrary.UHLAbilitySystemComponent.InitialAttributes") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.UHLAbilitySystemComponent.bUseUHLAbilitySystemConfig",NewName="/Script/UnrealHelperLibrary.UHLAbilitySystemComponent.bUseAbilitySystemConfig") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.UHLAbilitySystemComponent.UHLAbilitySystemConfig",NewName="/Script/UnrealHelperLibrary.UHLAbilitySystemComponent.AbilitySystemConfig") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.ANS_UnrealHelperLibrary",NewName="/Script/UnrealHelperLibrary.ANS_UHL_Base") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.EnemyTickManagerSubsystem",NewName="/Script/UnrealHelperLibrary.EnemyTickOptimizerSubsystem") - -; Split on modules BEGIN -; UHLCharacter -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLBaseCharacter",NewName="/Script/UHLCharacter.UHLBaseCharacter") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLBaseCharacterWithASC",NewName="/Script/UHLCharacter.UHLBaseCharacterWithASC") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLPlayerController",NewName="/Script/UHLCharacter.UHLPlayerController") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLCharacter",NewName="/Script/UHLCharacter.UHLCharacter") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLBaseCharacterAttributeSet",NewName="/Script/UHLCharacter.UHLBaseCharacterAttributeSet") - -; UHLDebug -; TODO протестить было /Script/UnrealHelperLibrary/UHLDebugSubsystemSettings почему-то -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLDebugSubsystemSettings",NewName="/Script/UHLDebugSystem.UHLDebugSystemSettings") -;+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLDebugSubsystem",NewName="/Script/UHLDebug.UHLDebugSubsystem") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLDebugSubsystem",NewName="/Script/UHLDebugSystem.UHLDebugSystemSubsystem") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLDebugCategory",NewName="/Script/UHLDebugSystem.UHLDebugCategory") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLDebugCategoryComponent",NewName="/Script/UHLDebugSystem.UHLDebugCategoryComponent") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.AA_WaitDebugCategoryChange",NewName="/Script/UHLDebugSystem.AA_WaitDebugCategoryChange") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.DCC_AbilitySystem_Abilities",NewName="/Script/UHLDebugSystem.DCC_AbilitySystem_Abilities") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.DCC_AbilitySystem_Attributes",NewName="/Script/UHLDebugSystem.DCC_AbilitySystem_Attributes") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.DCC_AbilitySystem_Effects",NewName="/Script/UHLDebugSystem.DCC_AbilitySystem_Effects") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.DCC_Collisions",NewName="/Script/UHLDebugSystem.DCC_Collisions") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.DCC_InputSystem_EnhancedInput",NewName="/Script/UHLDebugSystem.DCC_InputSystem_EnhancedInput") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLDebugCategoriesListWidget",NewName="/Script/UHLDebugSystem.UHLDebugCategoriesListWidget") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLDebugWidget",NewName="/Script/UHLDebug.UHLDebugWidget") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.IsUHLDebugCategoryEnabled",NewName="/Script/UHLDebugSystem.UHLDebugBlueprintLibrary.IsUHLDebugCategoryEnabled") -+PropertyRedirects=(OldName="/Script/UHLDebugSystem.UHLDebugCategory.ShortName",NewName="/Script/UHLDebugSystem.UHLDebugCategory.Name") - -; UHLAI -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLAIPerceptionComponent",NewName="/Script/UHLAI.UHLAIPerceptionComponent") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTC_RandomSelector",NewName="/Script/UHLAI.BTC_RandomSelector") -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.TurnRange",NewName="/Script/UHLAI.TurnRange") -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.TurnRanges",NewName="/Script/UHLAI.TurnRanges") -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.TurnSettings",NewName="/Script/UHLAI.TurnSettings") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.TurnSettingsDataAsset",NewName="/Script/UHLAI.TurnSettingsDataAsset") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLActorSettings",NewName="/Script/UHLAI.UHLAIActorSettings") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTD_Base",NewName="/Script/UHLAI.BTD_Base") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTD_CheckGASGameplayTagsOnActor",NewName="/Script/UHLAI.BTD_CheckGASGameplayTagsOnActor") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTD_InAngle",NewName="/Script/UHLAI.BTD_InAngle") -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.AngleRange",NewName="/Script/UHLAI.AngleRange") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTD_InRange",NewName="/Script/UHLAI.BTD_InRange") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTD_LoopRandomCount",NewName="/Script/UHLAI.BTD_LoopRandomCount") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTD_RandomChance",NewName="/Script/UHLAI.BTD_RandomChance") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTD_TimeLimitRandom",NewName="/Script/UHLAI.BTD_TimeLimitRandom") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTS_GameplayFocus",NewName="/Script/UHLAI.BTS_GameplayFocus") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTT_ClearFocus",NewName="/Script/UHLAI.BTT_ClearFocus") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTT_DebugPrintBBValue",NewName="/Script/UHLAI.BTT_DebugPrintBBValue") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTT_DebugPrintString",NewName="/Script/UHLAI.BTT_DebugPrintString") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTT_FireGameplayEvent",NewName="/Script/UHLAI.BTT_FireGameplayEvent") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTT_InvokeGameplayAbility",NewName="/Script/UHLAI.BTT_InvokeGameplayAbility") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTT_PlayAnimMontage",NewName="/Script/UHLAI.BTT_PlayAnimMontage") -+EnumRedirects=(OldName="/Script/UnrealHelperLibrary.ETaskNodeEndPolicy",NewName="/Script/UHLAI.ETaskNodeEndPolicy") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTT_SetBBValue",NewName="/Script/UHLAI.BTT_SetBBValue") -+EnumRedirects=(OldName="/Script/UnrealHelperLibrary.ESetBBValue_MathOperations",NewName="/Script/UHLAI.EUHL_MathOperations") - - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.BTT_TurnTo",NewName="/Script/UHLAI.BTT_TurnTo") - -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.ValueOrBBKey_GameplayTag",NewName="/Script/UHLAI.UHLValueOrBBKey_GameplayTag") - - -; UHL GAS -;+EnumRedirects=(OldName="/Script/UnrealHelperLibrary.",NewName="/Script/UHLGAS.") -;+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.",NewName="/Script/UHLGAS.") -;+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.",NewName="/Script/UHLGAS.") -;+StructRedirects=(OldName="/Script/UnrealHelperLibrary.",NewName="/Script/UHLGAS.") -;+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.",NewName="/Script/UHLGAS.UHLGASBlueprintLibrary.") - -+EnumRedirects=(OldName="/Script/UnrealHelperLibrary.EUHLAbilityActivationPolicy",NewName="/Script/UHLGAS.EUHLAbilityActivationPolicy") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLGameplayAbility",NewName="/Script/UHLGAS.UHLGameplayAbility") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.AN_FireGameplayEvent",NewName="/Script/UHLGAS.AN_FireGameplayEvent") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.ANS_ActivateAbility",NewName="/Script/UHLGAS.ANS_ActivateAbility") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.ANS_CatchToAbilityInputCache",NewName="/Script/UHLGAS.ANS_CatchToAbilityInputCache") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.ANS_CheckAbilityInputCache",NewName="/Script/UHLGAS.ANS_CheckAbilityInputCache") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.ANS_GlobalTimeDilation",NewName="/Script/UHLGAS.ANS_UHLGAS_GlobalTimeDilation") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLAttributeSet",NewName="/Script/UHLGAS.UHLAttributeSet") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLAbilitySystemInterface",NewName="/Script/UHLGAS.UHLAbilitySystemInterface") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.AbilityInputCachePayload",NewName="/Script/UHLGAS.AbilityInputCachePayload") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.AbilityInputCache",NewName="/Script/UHLGAS.AbilityInputCache") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLInputComponent",NewName="/Script/UHLGAS.UHLInputComponent") - -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.UHLInputAction",NewName="/Script/UHLGAS.UHLInputAction") -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.UHLInputActionAbilities",NewName="/Script/UHLGAS.UHLInputActionAbilities") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLInputConfig",NewName="/Script/UHLGAS.UHLInputConfig") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.AA_WaitAbilityActivate",NewName="/Script/UHLGAS.AA_WaitAbilityActivate") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.AA_WaitAbilityActivate.WaitForAbilityActivate",NewName="/Script/UHLGAS.AA_WaitAbilityActivate.WaitForAbilityActivate") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.AA_WaitAbilityActivate.WaitAbilityActivate",NewName="/Script/UHLGAS.AA_WaitAbilityActivate.WaitForAbilityActivate") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.AT_InterpolateToPosition",NewName="/Script/UHLGAS.AT_InterpolateToPosition") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.AT_InterpolateToPosition.InterpolateToPosition",NewName="/Script/UHLGAS.AT_InterpolateToPosition.InterpolateToPosition") - -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.FUHLAbilitySet_GameplayAbility",NewName="/Script/UHLGAS.FUHLAbilitySet_GameplayAbility") -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.FUHLAbilitySet_GameplayEffect",NewName="/Script/UHLGAS.FUHLAbilitySet_GameplayEffect") -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.FUHLAbilitySet_AttributeSet",NewName="/Script/UHLGAS.FUHLAbilitySet_AttributeSet") -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.FUHLAbilitySet_GrantedHandles",NewName="/Script/UHLGAS.FUHLAbilitySet_GrantedHandles") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLAbilitySet",NewName="/Script/UHLGAS.UHLAbilitySet") - -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLAbilitySystemComponent",NewName="/Script/UHLGAS.UHLAbilitySystemComponent") - -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.FUHLAbilitySystemSettings",NewName="/Script/UHLGAS.FUHLAbilitySystemSettings") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.UHLAbilitySystemConfig",NewName="/Script/UHLGAS.UHLAbilitySystemConfig") - -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.UHLSettings.AbilitySystemConfigDefaults",NewName="/Script/UHLGAS.UHLGASSettings.AbilitySystemConfigDefaults") -+PropertyRedirects=(OldName="/Script/UnrealHelperLibrary.UHLSettings.bUseAbilitySystemConfigDefaultsInASC",NewName="/Script/UHLGAS.UHLGASSettings.bUseAbilitySystemConfigDefaultsInASC") - -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.GetUHLAbilitySystemComponent",NewName="/Script/UHLGAS.UHLGASBlueprintLibrary.GetUHLAbilitySystemComponent") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.CreateGenericGASGameplayEffectSpec",NewName="/Script/UHLGAS.UHLGASBlueprintLibrary.CreateGenericGASGameplayEffectSpec") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.UpdateStateGameplayTags",NewName="/Script/UHLGAS.UHLGASBlueprintLibrary.UpdateStateGameplayTags") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.IsAbilityActiveByTag",NewName="/Script/UHLGAS.UHLGASBlueprintLibrary.IsAbilityActiveByTag") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.TryActivateAbilityWithTag",NewName="/Script/UHLGAS.UHLGASBlueprintLibrary.TryActivateAbilityWithTag") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.TryCancelAbilityWithTag",NewName="/Script/UHLGAS.UHLGASBlueprintLibrary.TryCancelAbilityWithTag") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.ToggleAbilityWithTag",NewName="/Script/UHLGAS.UHLGASBlueprintLibrary.ToggleAbilityWithTag") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.TryCancelAbilitiesWithTags",NewName="/Script/UHLGAS.UHLGASBlueprintLibrary.TryCancelAbilitiesWithTags") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.FireGameplayEvent",NewName="/Script/UHLGAS.UHLGASBlueprintLibrary.FireGameplayEvent") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.FindTagByString",NewName="/Script/UHLGAS.UHLGASBlueprintLibrary.FindTagByString") - -; UHLEditor -+ClassRedirects=(OldName="/Script/UnrealHelperEditor.UHESettings",NewName="/Script/UHLEditor.UHLEditorSettings") -+ClassRedirects=(OldName="/Script/UnrealHelperEditor.UHEBlueprintThumbnailRenderer",NewName="/Script/UHLEditor.UHLEditorBlueprintThumbnailRenderer") -+StructRedirects=(OldName="/Script/UnrealHelperEditor.UHECustomClassIconDescription",NewName="/Script/UHLEditor.UHLEditorCustomClassIconDescription") -+StructRedirects=(OldName="/Script/UnrealHelperLibrary.UHECustomClassIcon",NewName="/Script/UHLEditor.UHLEditorCustomClassIconDescription") -+StructRedirects=(OldName="/Script/UnrealHelperEditor.UnrealHelperEditorCommands",NewName="/Script/UHLEditor.UHLEditorCommands") -+StructRedirects=(OldName="/Script/UnrealHelperEditor.UnrealHelperEditorStyle",NewName="/Script/UHLEditor.UHLEditorStyle") - -+ClassRedirects=(OldName="/Script/UnrealHelperEditor.EUW_UHL_Utils",NewName="/Script/UHLEditor.EUW_UHL_Utils") -+ClassRedirects=(OldName="/Script/UnrealHelperEditor.UHECustomThumbnail",NewName="/Script/UHLEditor.UHLEditorCustomThumbnail") -+ClassRedirects=(OldName="/Script/UHLEditor.UHLBlueprintThumbnailRenderer",NewName="/Script/UHLEditor.UHLEditorBlueprintThumbnailRenderer") -+EnumRedirects=(OldName="/Script/UHLAI.ESetBBValue_MathOperations",NewName="/Script/UHLAI.EUHL_MathOperations") - -+EnumRedirects=(OldName="/Script/UHLAI.EBBValueType",NewName="/Script/UHLAI.EBlackboardValueType") -+StructRedirects=(OldName="/Script/UHLAI.MathOperation",NewName="/Script/UHLAI.OperationOnBBValue") -+StructRedirects=(OldName="/Script/UHLAI.BBKeyOperation",NewName="/Script/UHLAI.OperationOnBBValue") - -+PropertyRedirects=(OldName="/Script/CommonMaps.CommonMapCategory.AutoSearchMapsInFolder",NewName="/Script/CommonMaps.CommonMapCategory.SearchFolder") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.AN_AttachWithUniqueId",NewName="/Script/UnrealHelperLibrary.AN_AttachActorWithUniqueId") -+FunctionRedirects=(OldName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.IsOtherCharacterInRange",NewName="/Script/UnrealHelperLibrary.UnrealHelperLibraryBPL.InRangeToOtherCharacter") -+StructRedirects=(OldName="/Script/UHLAI.ValueOrBBKey_GameplayTag",NewName="/Script/UHLAI.UHLValueOrBBKey_GameplayTag") -+PropertyRedirects=(OldName="/Script/UHLGAS.UHLGameplayAbility.AddingToCacheInputRequiredTags",NewName="/Script/UHLGAS.UHLGameplayAbility.AddToCacheRequiredTags") -+PropertyRedirects=(OldName="/Script/UHLGAS.UHLGameplayAbility.AddingToCacheInputBlockedTags",NewName="/Script/UHLGAS.UHLGameplayAbility.AddToCacheBlockedTags") -+ClassRedirects=(OldName="/Script/UnrealHelperLibrary.ANS_SpawnAndSwitchCamera",NewName="/Script/UnrealHelperLibrary.ANS_SpawnAndSwitchPlayerCamera") -+ClassRedirects=(OldName="/Script/UHLGAS.ANS_GlobalTimeDilation",NewName="/Script/UHLGAS.ANS_UHLGAS_GlobalTimeDilation") -+ClassRedirects=(OldName="/Script/UHLGAS.AA_WaitAbilityActivate",NewName="/Script/UHLGAS.AA_UHLGAS_WaitAbilityActivate") \ No newline at end of file diff --git a/Config/FilterPlugin.ini b/Config/FilterPlugin.ini deleted file mode 100644 index 9c78e117..00000000 --- a/Config/FilterPlugin.ini +++ /dev/null @@ -1,11 +0,0 @@ -[FilterPlugin] -; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and -; may include "...", "*", and "?" wildcards to match directories, files, and individual characters respectively. -; -; Examples: -; /README.txt -; /Extras/... -; /Binaries/ThirdParty/*.dll - -/README.md -/Config/... \ No newline at end of file diff --git a/Config/Tags/UnrealHeaderLibraryTags.ini b/Config/Tags/UnrealHeaderLibraryTags.ini deleted file mode 100644 index d1a4237b..00000000 --- a/Config/Tags/UnrealHeaderLibraryTags.ini +++ /dev/null @@ -1,3 +0,0 @@ -[/Script/GameplayTags.GameplayTagsList] -GameplayTagList=(Tag="UHL.Debug.InvokeGameplayAbility_Test1",DevComment="") -GameplayTagList=(Tag="UHL.Debug.InvokeGameplayAbility_Test2",DevComment="") diff --git a/Content/AI/BB_UHL_Base.uasset b/Content/AI/BB_UHL_Base.uasset deleted file mode 100644 index 12b2cc33..00000000 Binary files a/Content/AI/BB_UHL_Base.uasset and /dev/null differ diff --git a/Content/AI/BP_UHL_TestBlueprint.uasset b/Content/AI/BP_UHL_TestBlueprint.uasset deleted file mode 100644 index 46f9472d..00000000 Binary files a/Content/AI/BP_UHL_TestBlueprint.uasset and /dev/null differ diff --git a/Content/AI/BT_UHL_AI_Nodes.uasset b/Content/AI/BT_UHL_AI_Nodes.uasset deleted file mode 100644 index 6e4339d6..00000000 Binary files a/Content/AI/BT_UHL_AI_Nodes.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_CheckGASGameplayTagsOnActor.uasset b/Content/AI/BehaviorTrees/BT_UHL_CheckGASGameplayTagsOnActor.uasset deleted file mode 100644 index d9f2c818..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_CheckGASGameplayTagsOnActor.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_GameplayFocus.uasset b/Content/AI/BehaviorTrees/BT_UHL_GameplayFocus.uasset deleted file mode 100644 index d4d43bae..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_GameplayFocus.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_GameplayFocus_Comparison.uasset b/Content/AI/BehaviorTrees/BT_UHL_GameplayFocus_Comparison.uasset deleted file mode 100644 index 781e1d82..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_GameplayFocus_Comparison.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_InAngle.uasset b/Content/AI/BehaviorTrees/BT_UHL_InAngle.uasset deleted file mode 100644 index 604e7880..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_InAngle.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_InAngle_OverrideDebugLinesDistance.uasset b/Content/AI/BehaviorTrees/BT_UHL_InAngle_OverrideDebugLinesDistance.uasset deleted file mode 100644 index cb954562..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_InAngle_OverrideDebugLinesDistance.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_InAngle_OverrideDebugLinesDistance_Moving.uasset b/Content/AI/BehaviorTrees/BT_UHL_InAngle_OverrideDebugLinesDistance_Moving.uasset deleted file mode 100644 index a8f2b089..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_InAngle_OverrideDebugLinesDistance_Moving.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_InAngle_Vector.uasset b/Content/AI/BehaviorTrees/BT_UHL_InAngle_Vector.uasset deleted file mode 100644 index 71688978..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_InAngle_Vector.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_InRange.uasset b/Content/AI/BehaviorTrees/BT_UHL_InRange.uasset deleted file mode 100644 index 47681679..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_InRange.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_InRange_CapsuleToCapsule.uasset b/Content/AI/BehaviorTrees/BT_UHL_InRange_CapsuleToCapsule.uasset deleted file mode 100644 index 4b3e5289..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_InRange_CapsuleToCapsule.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_InRange_CapsuleToCapsule_Moving.uasset b/Content/AI/BehaviorTrees/BT_UHL_InRange_CapsuleToCapsule_Moving.uasset deleted file mode 100644 index 1c57e525..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_InRange_CapsuleToCapsule_Moving.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_InRange_Vector.uasset b/Content/AI/BehaviorTrees/BT_UHL_InRange_Vector.uasset deleted file mode 100644 index 1b09142a..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_InRange_Vector.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_InvokeGameplayAbility.uasset b/Content/AI/BehaviorTrees/BT_UHL_InvokeGameplayAbility.uasset deleted file mode 100644 index d61801af..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_InvokeGameplayAbility.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_InvokeGameplayAbility_StressTest.uasset b/Content/AI/BehaviorTrees/BT_UHL_InvokeGameplayAbility_StressTest.uasset deleted file mode 100644 index c97e36e0..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_InvokeGameplayAbility_StressTest.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_PlayAnimMontage.uasset b/Content/AI/BehaviorTrees/BT_UHL_PlayAnimMontage.uasset deleted file mode 100644 index 08f1d91f..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_PlayAnimMontage.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_PlayAnimMontage_StressTest.uasset b/Content/AI/BehaviorTrees/BT_UHL_PlayAnimMontage_StressTest.uasset deleted file mode 100644 index 3fd38574..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_PlayAnimMontage_StressTest.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_RandomChance.uasset b/Content/AI/BehaviorTrees/BT_UHL_RandomChance.uasset deleted file mode 100644 index 49b2dd39..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_RandomChance.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_RandomChance_Scalable.uasset b/Content/AI/BehaviorTrees/BT_UHL_RandomChance_Scalable.uasset deleted file mode 100644 index a0716c32..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_RandomChance_Scalable.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_RandomLoop.uasset b/Content/AI/BehaviorTrees/BT_UHL_RandomLoop.uasset deleted file mode 100644 index bc174390..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_RandomLoop.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_RandomSelector.uasset b/Content/AI/BehaviorTrees/BT_UHL_RandomSelector.uasset deleted file mode 100644 index adccc3b4..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_RandomSelector.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_RandomTimelimit.uasset b/Content/AI/BehaviorTrees/BT_UHL_RandomTimelimit.uasset deleted file mode 100644 index 340ef69a..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_RandomTimelimit.uasset and /dev/null differ diff --git a/Content/AI/BehaviorTrees/BT_UHL_SetBBValue.uasset b/Content/AI/BehaviorTrees/BT_UHL_SetBBValue.uasset deleted file mode 100644 index 77c6c904..00000000 Binary files a/Content/AI/BehaviorTrees/BT_UHL_SetBBValue.uasset and /dev/null differ diff --git a/Content/AI/Tasks/BTT_TeleportToStartPoint.uasset b/Content/AI/Tasks/BTT_TeleportToStartPoint.uasset deleted file mode 100644 index 6afafada..00000000 Binary files a/Content/AI/Tasks/BTT_TeleportToStartPoint.uasset and /dev/null differ diff --git a/Content/AbilitySystem/Abilities/GA_UHL_InvokeGameplayAbility_Test1.uasset b/Content/AbilitySystem/Abilities/GA_UHL_InvokeGameplayAbility_Test1.uasset deleted file mode 100644 index 75b1cbf3..00000000 Binary files a/Content/AbilitySystem/Abilities/GA_UHL_InvokeGameplayAbility_Test1.uasset and /dev/null differ diff --git a/Content/AbilitySystem/Abilities/GA_UHL_InvokeGameplayAbility_Test2.uasset b/Content/AbilitySystem/Abilities/GA_UHL_InvokeGameplayAbility_Test2.uasset deleted file mode 100644 index a98bc0e1..00000000 Binary files a/Content/AbilitySystem/Abilities/GA_UHL_InvokeGameplayAbility_Test2.uasset and /dev/null differ diff --git a/Content/BP_UHL_BlueprintNode.uasset b/Content/BP_UHL_BlueprintNode.uasset deleted file mode 100644 index e1bb2e10..00000000 Binary files a/Content/BP_UHL_BlueprintNode.uasset and /dev/null differ diff --git a/Content/Characters/Base/Animations/AM_TH_BS_Attack_1.uasset b/Content/Characters/Base/Animations/AM_TH_BS_Attack_1.uasset deleted file mode 100644 index 0e3c73e0..00000000 Binary files a/Content/Characters/Base/Animations/AM_TH_BS_Attack_1.uasset and /dev/null differ diff --git a/Content/Characters/Base/Animations/AM_TH_BS_Attack_2.uasset b/Content/Characters/Base/Animations/AM_TH_BS_Attack_2.uasset deleted file mode 100644 index 47964071..00000000 Binary files a/Content/Characters/Base/Animations/AM_TH_BS_Attack_2.uasset and /dev/null differ diff --git a/Content/Characters/Base/Animations/AS_TH_BS_Attack_1.uasset b/Content/Characters/Base/Animations/AS_TH_BS_Attack_1.uasset deleted file mode 100644 index 95bc0abc..00000000 Binary files a/Content/Characters/Base/Animations/AS_TH_BS_Attack_1.uasset and /dev/null differ diff --git a/Content/Characters/Base/Animations/AS_TH_BS_Attack_2.uasset b/Content/Characters/Base/Animations/AS_TH_BS_Attack_2.uasset deleted file mode 100644 index eb487417..00000000 Binary files a/Content/Characters/Base/Animations/AS_TH_BS_Attack_2.uasset and /dev/null differ diff --git a/Content/Characters/Base/BP_UHL_BaseCharacter.uasset b/Content/Characters/Base/BP_UHL_BaseCharacter.uasset deleted file mode 100644 index c42aba44..00000000 Binary files a/Content/Characters/Base/BP_UHL_BaseCharacter.uasset and /dev/null differ diff --git a/Content/Characters/Enemy/ABP_UHL_Enemy.uasset b/Content/Characters/Enemy/ABP_UHL_Enemy.uasset deleted file mode 100644 index 8ea1b7a8..00000000 Binary files a/Content/Characters/Enemy/ABP_UHL_Enemy.uasset and /dev/null differ diff --git a/Content/Characters/Enemy/BP_UHL_Enemy.uasset b/Content/Characters/Enemy/BP_UHL_Enemy.uasset deleted file mode 100644 index 06335fba..00000000 Binary files a/Content/Characters/Enemy/BP_UHL_Enemy.uasset and /dev/null differ diff --git a/Content/Characters/Enemy/BP_UHL_Enemy_BlueprintsOnly.uasset b/Content/Characters/Enemy/BP_UHL_Enemy_BlueprintsOnly.uasset deleted file mode 100644 index bc26890f..00000000 Binary files a/Content/Characters/Enemy/BP_UHL_Enemy_BlueprintsOnly.uasset and /dev/null differ diff --git a/Content/Characters/Enemy/BP_UHL_Enemy_GameplayFocus.uasset b/Content/Characters/Enemy/BP_UHL_Enemy_GameplayFocus.uasset deleted file mode 100644 index 1c4c8411..00000000 Binary files a/Content/Characters/Enemy/BP_UHL_Enemy_GameplayFocus.uasset and /dev/null differ diff --git a/Content/Characters/Enemy/BP_UHL_Enemy_InAngle.uasset b/Content/Characters/Enemy/BP_UHL_Enemy_InAngle.uasset deleted file mode 100644 index 0415749e..00000000 Binary files a/Content/Characters/Enemy/BP_UHL_Enemy_InAngle.uasset and /dev/null differ diff --git a/Content/Characters/Enemy/BP_UHL_Enemy_Sight_360.uasset b/Content/Characters/Enemy/BP_UHL_Enemy_Sight_360.uasset deleted file mode 100644 index 9fa69fa9..00000000 Binary files a/Content/Characters/Enemy/BP_UHL_Enemy_Sight_360.uasset and /dev/null differ diff --git a/Content/Characters/Enemy/M_GameplayFocus.uasset b/Content/Characters/Enemy/M_GameplayFocus.uasset deleted file mode 100644 index 23d48ed2..00000000 Binary files a/Content/Characters/Enemy/M_GameplayFocus.uasset and /dev/null differ diff --git a/Content/Characters/Player/AbilitySet_DefaultCharacter.uasset b/Content/Characters/Player/AbilitySet_DefaultCharacter.uasset deleted file mode 100644 index 3cb3250d..00000000 Binary files a/Content/Characters/Player/AbilitySet_DefaultCharacter.uasset and /dev/null differ diff --git a/Content/Characters/Player/AbilitySet_Test.uasset b/Content/Characters/Player/AbilitySet_Test.uasset deleted file mode 100644 index 75716576..00000000 Binary files a/Content/Characters/Player/AbilitySet_Test.uasset and /dev/null differ diff --git a/Content/Characters/Player/AbilitySet_UHL_DefaultCharacter.uasset b/Content/Characters/Player/AbilitySet_UHL_DefaultCharacter.uasset deleted file mode 100644 index 41245ca9..00000000 Binary files a/Content/Characters/Player/AbilitySet_UHL_DefaultCharacter.uasset and /dev/null differ diff --git a/Content/Characters/Player/BP_UHL_Player.uasset b/Content/Characters/Player/BP_UHL_Player.uasset deleted file mode 100644 index 2bff9152..00000000 Binary files a/Content/Characters/Player/BP_UHL_Player.uasset and /dev/null differ diff --git a/Content/Characters/Player/DA_AbilitySet.uasset b/Content/Characters/Player/DA_AbilitySet.uasset deleted file mode 100644 index 9fa9158b..00000000 Binary files a/Content/Characters/Player/DA_AbilitySet.uasset and /dev/null differ diff --git a/Content/Characters/Player/DA_AbilitySystem_UHL_Player.uasset b/Content/Characters/Player/DA_AbilitySystem_UHL_Player.uasset deleted file mode 100644 index 53e1de9a..00000000 Binary files a/Content/Characters/Player/DA_AbilitySystem_UHL_Player.uasset and /dev/null differ diff --git a/Content/Core/GM_UnrealHelperLibrary.uasset b/Content/Core/GM_UnrealHelperLibrary.uasset deleted file mode 100644 index db69b223..00000000 Binary files a/Content/Core/GM_UnrealHelperLibrary.uasset and /dev/null differ diff --git a/Content/Core/PC_UnrealHelperLibrary.uasset b/Content/Core/PC_UnrealHelperLibrary.uasset deleted file mode 100644 index 348abdb8..00000000 Binary files a/Content/Core/PC_UnrealHelperLibrary.uasset and /dev/null differ diff --git a/Content/Data/CT_RandomChance_Scalable.uasset b/Content/Data/CT_RandomChance_Scalable.uasset deleted file mode 100644 index fb1ea81b..00000000 Binary files a/Content/Data/CT_RandomChance_Scalable.uasset and /dev/null differ diff --git a/Content/Data/DT_Abilities.uasset b/Content/Data/DT_Abilities.uasset deleted file mode 100644 index 43b46039..00000000 Binary files a/Content/Data/DT_Abilities.uasset and /dev/null differ diff --git a/Content/Gyms/Angles/BP_Dummy.uasset b/Content/Gyms/Angles/BP_Dummy.uasset deleted file mode 100644 index f636a1fa..00000000 Binary files a/Content/Gyms/Angles/BP_Dummy.uasset and /dev/null differ diff --git a/Content/Gyms/Angles/BP_GetPointAtRelativeAngle.uasset b/Content/Gyms/Angles/BP_GetPointAtRelativeAngle.uasset deleted file mode 100644 index 544360d5..00000000 Binary files a/Content/Gyms/Angles/BP_GetPointAtRelativeAngle.uasset and /dev/null differ diff --git a/Content/Gyms/Angles/BP_GetPointAtRelativeAngleBetweenActors.uasset b/Content/Gyms/Angles/BP_GetPointAtRelativeAngleBetweenActors.uasset deleted file mode 100644 index bbb242c9..00000000 Binary files a/Content/Gyms/Angles/BP_GetPointAtRelativeAngleBetweenActors.uasset and /dev/null differ diff --git a/Content/Gyms/Angles/BP_GetPointAtRelativeDirection.uasset b/Content/Gyms/Angles/BP_GetPointAtRelativeDirection.uasset deleted file mode 100644 index 0763d847..00000000 Binary files a/Content/Gyms/Angles/BP_GetPointAtRelativeDirection.uasset and /dev/null differ diff --git a/Content/Gyms/Angles/BP_GetPointAtRelativeDirectionBetweenActors.uasset b/Content/Gyms/Angles/BP_GetPointAtRelativeDirectionBetweenActors.uasset deleted file mode 100644 index f17212b1..00000000 Binary files a/Content/Gyms/Angles/BP_GetPointAtRelativeDirectionBetweenActors.uasset and /dev/null differ diff --git a/Content/Gyms/Angles/BP_GetRelativeAngle.uasset b/Content/Gyms/Angles/BP_GetRelativeAngle.uasset deleted file mode 100644 index 529ef503..00000000 Binary files a/Content/Gyms/Angles/BP_GetRelativeAngle.uasset and /dev/null differ diff --git a/Content/Gyms/Angles/BP_RelativeAngle.uasset b/Content/Gyms/Angles/BP_RelativeAngle.uasset deleted file mode 100644 index 28e6e1f6..00000000 Binary files a/Content/Gyms/Angles/BP_RelativeAngle.uasset and /dev/null differ diff --git a/Content/Gyms/Angles/Gym_UHL_Angles.umap b/Content/Gyms/Angles/Gym_UHL_Angles.umap deleted file mode 100644 index ed213c23..00000000 Binary files a/Content/Gyms/Angles/Gym_UHL_Angles.umap and /dev/null differ diff --git a/Content/Gyms/Gym_UHL_AI.umap b/Content/Gyms/Gym_UHL_AI.umap deleted file mode 100644 index f72c80b2..00000000 Binary files a/Content/Gyms/Gym_UHL_AI.umap and /dev/null differ diff --git a/Content/Gyms/Gym_UHL_Angles.umap b/Content/Gyms/Gym_UHL_Angles.umap deleted file mode 100644 index f7553950..00000000 Binary files a/Content/Gyms/Gym_UHL_Angles.umap and /dev/null differ diff --git a/Content/Gyms/Gym_UHL_GAS.umap b/Content/Gyms/Gym_UHL_GAS.umap deleted file mode 100644 index 705170d8..00000000 Binary files a/Content/Gyms/Gym_UHL_GAS.umap and /dev/null differ diff --git a/Content/Gyms/Gym_UHL_InvokeGameplayAbility.umap b/Content/Gyms/Gym_UHL_InvokeGameplayAbility.umap deleted file mode 100644 index b1b7b34f..00000000 Binary files a/Content/Gyms/Gym_UHL_InvokeGameplayAbility.umap and /dev/null differ diff --git a/Content/Gyms/Gym_UHL_PlayAnimMontage_StressTest.umap b/Content/Gyms/Gym_UHL_PlayAnimMontage_StressTest.umap deleted file mode 100644 index ad016422..00000000 Binary files a/Content/Gyms/Gym_UHL_PlayAnimMontage_StressTest.umap and /dev/null differ diff --git a/Content/Input/Actions/IA_DebugMenu.uasset b/Content/Input/Actions/IA_DebugMenu.uasset deleted file mode 100644 index e6dcd9ac..00000000 Binary files a/Content/Input/Actions/IA_DebugMenu.uasset and /dev/null differ diff --git a/Content/Input/Actions/IA_Jump.uasset b/Content/Input/Actions/IA_Jump.uasset deleted file mode 100644 index fac64cda..00000000 Binary files a/Content/Input/Actions/IA_Jump.uasset and /dev/null differ diff --git a/Content/Input/Actions/IA_LookMouse.uasset b/Content/Input/Actions/IA_LookMouse.uasset deleted file mode 100644 index 70c3e855..00000000 Binary files a/Content/Input/Actions/IA_LookMouse.uasset and /dev/null differ diff --git a/Content/Input/Actions/IA_LookStick.uasset b/Content/Input/Actions/IA_LookStick.uasset deleted file mode 100644 index d47487e4..00000000 Binary files a/Content/Input/Actions/IA_LookStick.uasset and /dev/null differ diff --git a/Content/Input/Actions/IA_Move.uasset b/Content/Input/Actions/IA_Move.uasset deleted file mode 100644 index e6647a49..00000000 Binary files a/Content/Input/Actions/IA_Move.uasset and /dev/null differ diff --git a/Content/Input/Configs/IMC_UHL_GamePad_Default.uasset b/Content/Input/Configs/IMC_UHL_GamePad_Default.uasset deleted file mode 100644 index 9457ebf8..00000000 Binary files a/Content/Input/Configs/IMC_UHL_GamePad_Default.uasset and /dev/null differ diff --git a/Content/Input/Configs/IMC_UHL_KBM_Default.uasset b/Content/Input/Configs/IMC_UHL_KBM_Default.uasset deleted file mode 100644 index 5ac0865b..00000000 Binary files a/Content/Input/Configs/IMC_UHL_KBM_Default.uasset and /dev/null differ diff --git a/Content/Subsystems/DebugSubsystem/DCC_AbilitySystem_Default.uasset b/Content/Subsystems/DebugSubsystem/DCC_AbilitySystem_Default.uasset deleted file mode 100644 index 9a5a6694..00000000 Binary files a/Content/Subsystems/DebugSubsystem/DCC_AbilitySystem_Default.uasset and /dev/null differ diff --git a/Content/Subsystems/DebugSubsystem/DCC_ShowDebugReset.uasset b/Content/Subsystems/DebugSubsystem/DCC_ShowDebugReset.uasset deleted file mode 100644 index e93c6daf..00000000 Binary files a/Content/Subsystems/DebugSubsystem/DCC_ShowDebugReset.uasset and /dev/null differ diff --git a/Content/Tools/ConvertToORM/ExampleTextures/DefaultMaterial_AO.uasset b/Content/Tools/ConvertToORM/ExampleTextures/DefaultMaterial_AO.uasset deleted file mode 100644 index 44c358e1..00000000 Binary files a/Content/Tools/ConvertToORM/ExampleTextures/DefaultMaterial_AO.uasset and /dev/null differ diff --git a/Content/Tools/ConvertToORM/ExampleTextures/DefaultMaterial_metallic.uasset b/Content/Tools/ConvertToORM/ExampleTextures/DefaultMaterial_metallic.uasset deleted file mode 100644 index 6f3c5cc8..00000000 Binary files a/Content/Tools/ConvertToORM/ExampleTextures/DefaultMaterial_metallic.uasset and /dev/null differ diff --git a/Content/Tools/ConvertToORM/ExampleTextures/DefaultMaterial_roughness.uasset b/Content/Tools/ConvertToORM/ExampleTextures/DefaultMaterial_roughness.uasset deleted file mode 100644 index 8d7a3b0a..00000000 Binary files a/Content/Tools/ConvertToORM/ExampleTextures/DefaultMaterial_roughness.uasset and /dev/null differ diff --git a/Content/Tools/ConvertToORM/TG_ConvertToORM.uasset b/Content/Tools/ConvertToORM/TG_ConvertToORM.uasset deleted file mode 100644 index 79b394cb..00000000 Binary files a/Content/Tools/ConvertToORM/TG_ConvertToORM.uasset and /dev/null differ diff --git a/Content/Tools/EUW_UHL_Utils.uasset b/Content/Tools/EUW_UHL_Utils.uasset deleted file mode 100644 index c5a750f2..00000000 Binary files a/Content/Tools/EUW_UHL_Utils.uasset and /dev/null differ diff --git a/Content/UI/SB_DrawDebugBar_Test.uasset b/Content/UI/SB_DrawDebugBar_Test.uasset deleted file mode 100644 index 3ced88d6..00000000 Binary files a/Content/UI/SB_DrawDebugBar_Test.uasset and /dev/null differ diff --git a/Content/UI/UI_DebugMenu.uasset b/Content/UI/UI_DebugMenu.uasset deleted file mode 100644 index ded7848d..00000000 Binary files a/Content/UI/UI_DebugMenu.uasset and /dev/null differ diff --git a/Content/UI/UI_UHL_DebugWidget.uasset b/Content/UI/UI_UHL_DebugWidget.uasset deleted file mode 100644 index 6dba96b2..00000000 Binary files a/Content/UI/UI_UHL_DebugWidget.uasset and /dev/null differ diff --git a/Content/UI/WBP_DrawDebugBar_Test.uasset b/Content/UI/WBP_DrawDebugBar_Test.uasset deleted file mode 100644 index dbb45c1d..00000000 Binary files a/Content/UI/WBP_DrawDebugBar_Test.uasset and /dev/null differ diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 4f0497d1..00000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 Pavel Penkov - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md index e4ac9372..08934185 100644 --- a/README.md +++ b/README.md @@ -14,88 +14,60 @@ Support: `UE5.5 (main)`, `UE5.4 (branch UE5.4)` ![AiModule](https://github.com/user-attachments/assets/4becb592-c02e-423a-bf80-fcfc629ce518) -## ✨ Features +## ✨ Plugins and features -- AI nodes - - `GameplayFocus` - set focus on actor - - `RandomChance` - randomize actions +- [UHL](https://github.com/Ciberusps/UHL) - utility functions like `GetProjectVersion`, `GetAssetsOfClass`, `GetHighestPoint`. Editor - editor customization, e.g. `Custom thumnails`, `Custom class icon` +- [UHLGAS](https://github.com/Ciberusps/UHLGAS) - +- [UHLAI](https://github.com/Ciberusps/UHLAI) - +- [UHLBehaviorTrees](https://github.com/Ciberusps/UHLBehaviorTrees) & [UHLStateTree](https://github.com/Ciberusps/UHLStateTree) - AI nodes + - `SetGameplayFocus` - set focus on actor - `InRange` - check distance to enemy - `InAngle` - check angle to enemy - `PlayAnimMontage` - play attack animation - - `SetBBValue` - set blackboard value - - `DebugPrintBBValue` - print blackboard value - - `DebugPrintString` - print string on screen - `InvokeGameplayAbility` - activate/deactivate GAS Gameplay Ability by tag, with optional "wait for finishing" - `TurnTo` - turn enemy using turn animations -- GAS - Lyra based inputs, ability system component, ability system config, input cache, attribute set, ability sets -- **GAS** strong Lyra based toolset for quick start with GAS and scalable for big projects -- GAS abilities input binding using tags based on Lyra and enhanced with real project needs -- GameplayTags based **DebugSystem** -- Utils - utility functions for your game, e.g. `GetProjectVersion`, `GetAssetsOfClass`, `GetHighestPoint` -- Editor - editor customization, e.g. `Custom thumnails`, `Custom class icon` +- [UHLCommonMaps](https://github.com/Ciberusps/UHLCommonMaps) +- [UHLDebugSystem](https://github.com/Ciberusps/UHLDebugSystem) -## 🚀 Install -#### From source (recommended): +## 🚀 Install & ⬆️ Update -- add git submodule to your plugins folder +### From source (recommended) - ```bash - git submodule add https://github.com/Ciberusps/unreal-helper-library.git ./Plugins/UnrealHelperLibrary - ``` +```bash +// install as git submodule to your plugins folder +git submodule add https://github.com/Ciberusps/unreal-helper-library.git ./Plugins/UnrealHelperLibrary --
- C++ setup, old engine versions - - - to use C++ things add code to file `.Build.cs` - - ```C# - // .Build.cs - public GameName(ReadOnlyTargetRules Target) : base(Target) - { - PublicDependencyModuleNames.AddRange(new string[] { - // add "UnrealHelperLibrary" to use it in C++ - "UnrealHelperLibrary", - }); - - // OPTIONALLY add "UnrealHelperEditor" module to use custom unreal engine editor features - if (Target.bBuildEditor) - { - PrivateDependencyModuleNames.AddRange(new string[] { "UnrealHelperEditor" }); - } - } - ``` - - - to use specific engine version specify branch e.g. `-b UE5.4` - - ```bash - git submodule add -b UE5.4 https://github.com/Ciberusps/unreal-helper-library.git ./Plugins/UnrealHelperLibrary - ``` +// to update plugin +git submodule update --init --recursive --checkout +``` - - to use specific engine version specify branch e.g. `-b UE5.4` +or install all plugins as independent plugins - ```bash - git submodule add -b UE5.4 https://github.com/Ciberusps/unreal-helper-library.git ./Plugins/UnrealHelperLibrary - ``` +```bash +git submodule add https://github.com/Ciberusps/UHL.git ./Plugins/UHL +git submodule add https://github.com/Ciberusps/UHLGAS.git ./Plugins/UHLGAS +git submodule add https://github.com/Ciberusps/UHLAI.git ./Plugins/UHLAI +git submodule add https://github.com/Ciberusps/UHLStateTree.git ./Plugins/UHLStateTree +git submodule add https://github.com/Ciberusps/UHLBehaviorTree.git ./Plugins/UHLBehaviorTree +git submodule add https://github.com/Ciberusps/UHLCharacter.git ./Plugins/UHLCharacter +git submodule add https://github.com/Ciberusps/UHLCommonMaps.git ./Plugins/UHLCommonMaps +git submodule add https://github.com/Ciberusps/UHLDebugSystem.git ./Plugins/UHLDebugSystem - > [!NOTE] - > Don't forget to update your `README.md` with instructions on how to setup - `git submodule update --init --recursive` and how to update submodules/plugin(s) - `git submodule update --remote` +// to update plugins +git submodule update --init --remote --recursive +``` - > [!NOTE] - > Add `Editor Preferences -> Force Compilation on Startup` in `Config/EditorPerProjectUserSettings.ini` your team don't want to recompile plugin manually 😉 +> [!NOTE] +> Don't forget to update your `README.md` with instructions on how to setup - `git submodule update --init --recursive` and how to update submodules/plugin(s) - `git submodule update --remote` -
+> [!NOTE] +> Add `Editor Preferences -> Force Compilation on Startup` in `Config/EditorPerProjectUserSettings.ini` your team don't want to recompile plugin manually 😉 -#### From marketplace: +### From marketplace https://www.fab.com/listings/9f7d82e9-bc72-42ff-b302-b3d6562bd4c8 -## ⬆️ Update - -From source: - -- `git submodule update --remote` to update plugin from source - ## 🧩 Modules UHL consists of 3 modules: @@ -110,746 +82,67 @@ UHL consists of 3 modules: AI nodes for behavior tree, based on `BehaviorTree` and `BehaviorTreeComponent` from `UE5.4` and `UE5.5` with some improvements and additional features -> - Components -> - [AIPerceptionComponent](#uhlaiperceptioncomponent) -> - Composite -> - [RandomSelector](#btc_randomselector) -> - Services -> - [GameplayFocus](#setgameplayfocus) -> - Decorators -> - [CheckGASGameplayTagsOnActor](#checkgasgameplaytagsonactor) -> - [InAngle](#inangle) -> - [InRange](#inrange) -> - [LoopRandomCount](#looprandomcount) -> - [RandomChance](#randomchance) -> - [TimeLimitRandom](#timelimitrandom) -> - Tasks -> - [SetBBValue](#setbbvalue) -> - [DebugPrintBBValue](#debugprintbbvalue) -> - [DebugPrintString](#debugprintstring) -> - [InvokeGameplayAbility](#invokegameplayability) -> - [PlayAnimMontage](#playanimmontage) -> - [TurnTo](#turnto) - **[💪 GAS](#-gas-gameplay-ability-system)** Gameplay Ability System - Lyra based inputs, ability system component, ability system config, input cache, attribute set, ability sets -> - Components -> - [AbilitySystemComponent](#abilitysystemcomponent) -> - [InputConfig (GAS abilities input binding)](#inputconfig-gas-abilities-input-binding) -> - [AbilityInputCache (beta)](#abilityinputcache) -> - [GameplayAbility](#gameplayability) -> - [AttributeSet](#attributeset) -> - [AbilitySet](#abilityset) -> - [AbilitySystem Config](#abilitysystem-config) -> - Tasks -> - [InterpolateToPosition](#interpolatetoposition) -> - AbilityAsync tasks (AbilityAsync versions of GAS UAbilityTask's, AbilityAsync available in blueprints) -> - WaitForAbilityActivate -> - WaitForAbilityActivateWithTagRequirements -> - WaitForAbilityActivate_Query -> - [UHLGASBlueprintLibrary](#uhlgasblueprintlibrary) -> - [TryActivateAbilityWithTag](#tryactivateabilitywithtag) -> - [TryCancelAbilityWithTag](#trycancelabilitywithtag) -> - [TryCancelAbilitiesWithTags](#trycancelabilitieswithtags) -> - [FireGameplayEvent](#firegameplayevent) -> - [UpdateStateGameplayTags](#updatestategameplaytags) -> - [FindTagByString](#findtagbystring) -> - [GetUHLAbilitySystemComponent](#getuhlabilitysystemcomponent) -> - [CreateGenericGASGameplayEffectSpec](#creategenericgasgameplayeffectspec) **[🦸 Character](#character)** Default character class with UHL interfaces implemented, so you don't need to do it by yourself -> - [BaseCharacterWithASC](#basecharacterwithasc) (recommended for start) -> - [BaseCharacter](#basecharacter) **[🪲 DebugSystem](#-debugsystem)** Debug system for your game, in mid-size commands you always use limited set of debugging tools -> - Settings -> - [DebugSystemSettings](#debugsystemsettings) -> - Subsystem -> - [UHLDebugSystemSubsystem](#uhldebugsystemsubsystem) -> - AsyncActions -> - [WaitDebugCategoryChange](#aa_waitdebugcategorychange) -> - [DebugBlueprintLibrary](#debugblueprintlibrary) -> - [IsUHLDebugCategoryEnabled](#isuhldebugcategoryenabled) - **[📚 UnrealHelperLibrary](#unrealhelperlibrarybpl)** -> - [UnrealHelperLibraryBPL](#unrealhelperlibrarybpl) -> - Gameplay -> - GetActorClosestToCenterOfScreen -> - GetMostDistantActor -> -> - RelativeAngles -> - [RelativeAngleToActor](#relativeangletoactor) -> - [GetPointAtRelativeAngle](#getpointatrelativeangle) -> - [GetPointAtRelativeDirection](#getpointatrelativedirection) -> - [GetPointAtAngleRelativeToOtherActor](#getpointatanglerelativetootheractor) -> - [GetPointAtDirectionRelativeToOtherActor](#getpointatdirectionrelativetootheractor) -> - [DirectionToAngle](#directiontoangle) -> - UI/Screen -> - GetViewportSizeUnscaled -> - Misc -> - [GetProjectVersion](#getprojectversion) -> - [GetNamesOfComponentsOnObject](#getnamesofcomponentsonobject) -> - [GetAssetsOfClass](#getassetsofclass) -> - GetBuildType -> -> -> - Debug -> - DrawDebugLineOnCanvas -> - Other -> - [GetHighestPoint](#gethighestpoint) -> - [LoadingUtilLibrary](#loadingutillibrary) -> - [ApplyDefaultPriorityLoading](#applydefaultpriorityloading) -> - [ApplyStreamingPriorityLoading](#applystreamingpriorityloading) -> - [ApplyHighestPriorityLoading](#applyhighestpriorityloading) -> - [ApplyCustomPriorityLoading](#applycustompriorityloading) -> - [ForceGarbageCollection](#forcegarbagecollection) -> - [FlushLevelStreaming](#flushlevelstreaming) -> - [TraceUtilsBPL](#traceutilsbpl) -> - SweepCapsuleSingleByChannel -> - [Settings](#settings) -> - [UHL Settings](#uhl-settings) -> - [Subsystems](#subsystems) -> - [UHLHUD](#uhlhud) -> - AnimNotifyState (ANS) -> - [ANS_UHL_Base](#ans_uhl_base) -> - [ANS_ActivateAbility](#ans_activateability) **[⌨ Editor](#-uhl-editor)** -> - [Custom thumnails](#custom-thumnails) -> - [Custom class icon](#custom-class-icon) -> - [UHL Utils (Editor Utility Widget)](#uhl-utils-editor-utility-widget) -> - [ConvertToORM](#converttoorm) - ---- - -### 🧠 AI - -UHL provides most needed AI nodes toolset for developing at least 3d-action AI - GameplayFocus, Random choices using RandomChance and RandomSelector, PlayAnimMontage to play attacks animations, InRange and InAngle to check distance to enemy and required angle -![AI_nodes](https://github.com/user-attachments/assets/1a00afdf-ab36-4e1c-9bd1-1b29c46cd8ac) - -#### `UHLAIPerceptionComponent` - -⚒️ InProgress - -#### `BTC_RandomSelector` - -Select random child node using weights - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/ad19828d-032f-4938-9106-2763ec6fb1fd) - -
- With cool validations - -#### Warns if summary of weights > 1 - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/78c62bb9-1b1e-4f5a-89b2-68ea4b445ec2) - -#### Warns if chances array have more items then child nodes - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/8dc579a0-7f89-4f27-8a1b-a43fa9889496) - -#### Shows error if child nodes count > than chances count - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/b8416859-a557-4378-85e3-27091f631b54) - -
- -#### `CheckGASGameplayTagsOnActor` - -**BTD_CheckGASGameplayTagsOnActor** - checks that actor has GAS gameplay tags specified. - -> [!WARNING] -> Don't mess with `UBTDecorator_CheckGameplayTagsOnActor` - its only checks `GameplayTags` on actor itself not on `AbilitySystem`. - -Requirements: - -- actor should implement `IAbilitySystemInterface` to get `AbilitySystemComponent` - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/f1581009-b9cd-408f-84de-2475b43012ae) - -#### `InAngle` - -**BTD_InAngle** - decorator to check is enemy in one of specified angle ranges. Useful in developing big enemies, for example we developing dragon we want to know is player under the right wing or leg, is player in front of dragon or behind and so on. - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/20f95715-a013-4b5f-8107-cd72d3163f4a) - -#### `InRange` - -**BTD_InRange** - decorator to check distance between actors. Compliant with "MoveTo" node have same settings `bIncludeSelfCapsuleRadius` and `bIncludeTargetCapsuleRadius` to check distance excluding capsules radiuses - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/5ee47572-0fdb-4afa-bbd1-d18eafb86807) -![InRange](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/e32b5d05-de82-4dfb-80d1-539c866008ff) - -#### `LoopRandomCount` - -**BTD_LoopRandomCount** - randomized version of decorator `Loop` - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/9a97dd83-d5d3-4cfd-a9bb-830ce7f4c450) - -#### `TimeLimitRandom` - -**BTD_TimeLimitRandom** - randomized version of decorator `TimeLimit` - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/4fd5b54f-5066-4b47-9425-fac0f92b1b07) - -#### `RandomChance` - -**BTD_RandomChance** - commonly used decorator to randomize actions. Fine for single child node, extra bad for multiple nodes due to chance regression, for randomization between multiple child nodes better to use [RandomSelector](#btc_randomselector) - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/b469a200-5655-440a-a754-8f8f544a38a2) - -#### `SetGameplayFocus` - -**BTS_SetGameplayFocus** - alternative for "Set default focus". SetGameplayFocus made right way - prevents rotation jittering while enemy rotation. -One of most common problems that anybody stucks when starting developing AI - "focus dont work"/"focus works wrong". - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/c0add45c-76ef-44bc-b97c-0c56901e6e03) -![GameplayFocus](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/0126fc2b-8a20-4b61-93d8-b1ead6802057) - -Requirements: - -- turn on `UseControllerDesiredRotation` -- turn off - - `bOrientRotationToMovement` - - `UseControllerRotationYaw` - - `UseControllerRotationPitch` - - `UseControllerRotationRoll` - - -Troubleshooting: - -- check that nothing "ClearFocus" -- check that MoveTo uses "AllowStafe" - -#### `SetBBValue` - -**BTT_SetBBValue** - helps settings values in blackboard, supports all blackboard types and for some values event provides opportunity to make calculations like `int` - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/baf4ea25-5d19-482d-a60c-799663def759) - -#### `DebugPrintBBValue` - -**BTT_DebugPrintBBValue** - prints BB value of any type - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/d138c011-fc9a-438e-bd39-658480cd95bf) - -#### `DebugPrintString` - -**BTT_DebugPrintString** - simple task for printing debug info on screen - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/510e9766-37be-4f43-a60f-e0e012521841) - -#### `InvokeGameplayAbility` - -**BTT_InvokeGameplayAbility** - activate/deactivate GAS Gameplay Ability by tag, with optional "wait for finishing" - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/1916c411-7068-43db-9e69-3e6190874de5) - -#### `PlayAnimMontage` - -**BTT_PlayAnimMontage** - play anim montage with option to customize PlayRate, Starting Position, Start Section Name and stopping montage on task abort - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/5026ebdc-689d-4dba-a168-22ae8d6850bf) - -#### `TurnTo` - -**BTT_TurnTo** - turn to enemy using turn animations -Drop in replacement for "RotateToFaceBBEntry" but with option to "RotateTo" with animations -To get settings from actor requires `IUHLActorSettings` to be implemented on character - ---- - -### 💪 GAS (Gameplay Ability System) - -Many GAS-related things based on "Lyra" sample project. - -#### `AbilitySystemComponent` - -![UHLAbilitySystemComponent](https://github.com/user-attachments/assets/fe56c7a2-43e6-484a-ac65-635e3670204e) - -**UHLAbilitySystemComponent** - for quick start with GAS. You can nest from it on start and than turn off its functions when you ready to replace them with your custom solution. - -Features: - -- set `InitialAttributes` -- give `Abilities` on start -- activate `InitialActiveAbilities` -- apply `InitialGameplayTags` -- "Lyra"-like "InputConfig", GAS abilities input binding - -Setup: - -##### Option 1 - zero setup - -Easy way with zero setup, just nest your character from `AUHLBaseCharacterWithASC`, fits new projects -there you don't want to waste time at all. - -##### Option 2 - BP way - -Easy way - just add `UHLAbilitySystemComponent` to your character and call `InitAbilitySystem` on `BeginPlay`/`Possessed` - -![image](https://github.com/user-attachments/assets/781e3b92-7af2-42db-a47a-b19f6bdd1b71) - -##### Option 3 - C++ - -A bit harder and requires small C++ work, fits for projects with GAS already integrated. -Follow instructions below or just check `AUHLBaseCharacterWithASC` example - -```C++ -AUHLBaseCharacterWithASC::AUHLBaseCharacterWithASC(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - // create AbilitySystemComponent if you don't have it - AbilitySystemComponent = CreateDefaultSubobject(TEXT("UHLAbilitySystem")); -} - -void AUHLBaseCharacterWithASC::PossessedBy(AController* NewController) -{ - Super::PossessedBy(NewController); - - // init AbilitySystem - AbilitySystemComponent->InitAbilitySystem(NewController, this); -} -``` - -If you want custom attributes init you can do it - -- by overriding `InitAttributes_Implementation` - recommended -- or just don't activate abilities `AbilitySystemComponent->InitAbilitySystem(NewController, this, false)` and make your own attributes init, and then call `AbilitySystemComponent->ActivateInitialAbilities()` - -You have 3 levels of advancement using GAS with UHL - -1) entry - just using abilities/attributes in your character on start of a project -2) when you understand that you want to share some abilities to other characters - use [AbilitySets](#abilityset) -3) when your team grows and you understand that locking whole character just to add ability is or change some ability system settings is too much - use [AbilitySystem Config](#abilitysystem-config) and optionally defaults in UHLSettings - -![image](https://github.com/user-attachments/assets/d0a47867-dacc-4fbf-bd52-dafa70c8939d) - - -#### InputConfig (GAS abilities input binding) - -Binding InputActions to GameplayAbilities using tags, based on `Lyra` but enhanced and adopted for 3D action game. - -![image](https://github.com/user-attachments/assets/78355f0a-bd98-430d-acda-c98405f4017d) - -##### Setup - -- turn on `bUseInputConfig` on `UHLAbilitySystemComponent` -- create `InputConfig` - `DataAsset` nested from `UHLInputConfig` -- add `InputConfig` to your character `UHLAbilitySystemComponent` -- in `Project Settings -> Input -> Default Input Component Class` -> set `UHLInputComponent` -- in your PlayerCharacter class add lines in `SetupPlayerInputComponent` for binding actions from `InputConfig` - -For now only C++ setup tested (blueprint option will be later) - -```C++ -// Your PlayerCharacter class -void AUHLPlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) -{ - Super::SetupPlayerInputComponent(PlayerInputComponent); - - UUHLInputComponent* UHLInputComponent = CastChecked(PlayerInputComponent); - UUHLInputConfig* UHLInputConfig = AbilitySystemComponent->InputConfig; - TArray BindHandles; - UHLInputComponent->BindAbilityActions(UHLInputConfig, AbilitySystemComponent, &UUHLAbilitySystemComponent::AbilityInputTagPressed, &UUHLAbilitySystemComponent::AbilityInputTagReleased, BindHandles); - - // optional - // if (UHLInputComponent) - // { - // UHLInputComponent->BindAction(UHLInputConfig->NativeInputAction_Move.InputAction, ETriggerEvent::Triggered, this, &AUHLPlayerCharacter::InputMove); - // UHLInputComponent->BindAction(UHLInputConfig->NativeInputAction_Move.InputAction, ETriggerEvent::Completed, this, &AUHLPlayerCharacter::InputStopMove); - - // UHLInputComponent->BindAction(UHLInputConfig->NativeInputAction_LookMouse.InputAction, ETriggerEvent::Triggered, this, &AUHLPlayerCharacter::InputLook); - // UHLInputComponent->BindAction(UHLInputConfig->NativeInputAction_LookStick.InputAction, ETriggerEvent::Triggered, this, &AUHLPlayerCharacter::InputLook); - // } -} -``` - -- in your PlayerController class add - -```c++ -// Your PlayerController.cpp -void AUHLPlayerController::OnPossess(APawn* InPawn) -{ - Super::OnPossess(InPawn); - - CachedPlayerCharacter = Cast(InPawn); -} - -void AUHLPlayerController::PostProcessInput(const float DeltaTime, const bool bGamePaused) -{ - Super::PostProcessInput(DeltaTime, bGamePaused); - - if (!CachedPlayerCharacter.IsValid()) return; - - if (UUHLAbilitySystemComponent* ASC = CachedPlayerCharacter.Get()->GetUHLAbilitySystemComponent()) - { - ASC->ProcessAbilityInput(DeltaTime, bGamePaused); - } -} - - -// Your PlayerController.h -UCLASS() -class UHL_API AUHLPlayerController : public APlayerController -{ - GENERATED_BODY() - -protected: - virtual void OnPossess(APawn* InPawn) override; - virtual void PostProcessInput(const float DeltaTime, const bool bGamePaused) override; - -private: - TWeakObjectPtr CachedPlayerCharacter; -}; -``` - -- now create `InputAction`(IA) and map it in your `InputMappingContext`(IMC) -- add `InputAction` to created `InputConfig` and map it to `AbilityTags` -- now Abilities associated with `AbilityTags` will activates when `InputAction` triggered -- WARN! abilities should nest from `UHLGameplayAbility` for `ActivationPolicy` work correctly -- to controll ability activation, every `UHLGameplayAbility` have `ActivationPolicy` - - `OnInputTriggered` - will activate when InputAction triggered - - `WhileInputActive` - activates ability when input pressed and deactivates when input released - - `OnSpawn` - activates ability when it gived(granted) to character - -#### AbilityInputCache - -`AbilityInputCache` (beta) - caches abilities activation. If you want to have input quality like in AAA games when you need cache some inputs and fire whem when its available. Abilities/Inputs to cache may vary depending on project e.g. for 3D actions(souls-likes, slashers) its critical, for shooters less important - -> [!WARN] -> dont work without [UHLAbilitySystemComponent](#abilitysystemcomponent) and [InputConfig](#inputconfig-gas-abilities-input-binding) enabled - -![image](https://github.com/user-attachments/assets/ecc013bf-cc5a-4211-a51c-ced5fe557ec2) - -##### Setup: - -Instructions here provided with souls-like developing background. Remember you can control `AbilityInputCache` wherever `ASC(AbilitySystemComponent)` is available just take `AbilityInputCache` from `ASC` and call `AddTagToCache`, `CheckCache`, `ClearCache`.... If you need "input window" just add `UHL.AbilityInputCache.Catching` on your character by hand and remove when window not required - -- activate `bUseAbilityInputCache` in `UHLAbilitySystemComponent` -- [optionaly] strongly recommended to activate `bUseInputCacheWindows` also. If `bUseInputCacheWindows` not activated any GameplayAbility marked with `bInputCache` that you try to activate in any time on fail will be added to `AbilityInputCache` thats not what you want in 3D action game -- in `GameplayAbility` that you want to cache activate `bInputCache` and fill if required - - `AddingToCacheInputRequiredTags` - tags that required to be on your character for this ability to be added to `AbilityInputCache` - - `AddingToCacheInputBlockedTags` - tags that blocks adding this ability to `AbilityInputCache` -- prepare you attack animation - add anim notifies - - `ANS_CatchToAbilityInputCache` - to mark when its possible to cache ability. Best practice - leave some frames on start(5-10frames at least) and finish when your "BlockAction" end - - `ANS_CheckAbilityInputCache` - when you want to check cache and activate ability. Best practice - on end of "BlockAction" with 5-10frames duration - -##### Debug: - -- activate `AbilityInputCache` debug category in [DebugSystem](#-debugsystem) from - - `ProjectSettings -> UHL DebugSubsystem Settings` - - or in runtime via `UHLDebugCategoriesListWidget` -- write in console `ToggleAbilityInputDebug`, don't forget to add `ProcessConsoleExec` to your `GameInstance` or it won't work - -#### AttributeSet - -Just class with default things that every `AttributeSet` wants like `ATTRIBUTE_ACCESSORS`. Nest your `AttributeSets` from it to not duplicate same things other and other again. - -#### AbilitySet - -"Lyra"-like set of `Abilities, AttributeSets, GameplayEffects`, that can be added to character and removed later by tag - -![image](https://github.com/user-attachments/assets/7f7a54dc-3276-4bc3-a866-ba992f506efc) - -AbilitySet - is second level of advancement of using GAS in UHL, when you understand that you want to -share some abilities to other characters - use AbilitySets - -Use cases: - -- gived by external source using or `AbilitySet->GiveToAbilitySystem` and removed by external source via `AbilitySetGrantedHandles.TakeFromAbilitySystem` -- gived by external source using `ASC->GiveAbilitySet(UUHLAbilitySet* AbilitySet)` and removed by tag calling `ASC->RemoveAbilitySetByTag()`, of course if tag associated with set by defining `AbilitySetTags` in `AbilitySet` - -#### AbilitySystem Config - -DataAsset - option for teams to edit `AbilitySystem` config externally to not locking character -for just changing abilities/initial attributes - -![image](https://github.com/user-attachments/assets/1cfe4ebd-da39-44b3-9955-73ff6e4708ac) - -Defaults can be changed in `ProjectSettings -> UHL Settings` - -#### GameplayAbility - -Additional events - OnSpawn - -Activation policy - InputTriggered, WhileInputActive, OnSpawn - -InputCache - to use it required to nest from GameplayAbility - -#### `InterpolateToPosition` - -**AT_InterpolateToPosition** - interpolate actor to specified position/rotation at a predetermined amount of time - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/764ddf72-595e-4316-9149-b7b0accc2b89) - -#### `UHLGASBlueprintLibrary` - -##### TryActivateAbilityWithTag - -##### TryCancelAbilityWithTag - -##### TryCancelAbilitiesWithTags - -##### FireGameplayEvent - -##### UpdateStateGameplayTags - -##### FindTagByString - -##### GetUHLAbilitySystemComponent - -##### CreateGenericGASGameplayEffectSpec - -#### `ANS_ActivateAbility` - -**ANS_ActivateAbility** - commonly used ANS that just activate ability on start and deactivate on end - -![image](https://github.com/user-attachments/assets/a1212bb9-dc09-45a7-8f3d-354ac8f2afa6) - -- `GameplayAbilityTag` - tag associated with ability to activate -- `bDeactivateOnMontageBlendingOut` - should ability deactivates on montage blends out -- `bAllowRemoteActivation` - you can allow remote activation - - - --- -### 🦸 Character - -Default characters classess with UHL interfaces implemented, so you don't need to do it by yourself - -#### `BaseCharacterWithASC` - -**UHLBaseCharacterWithASC** - recommended BaseCharacter for start - ASC created on start and -inited on `PossessedBy`. Can be turned off by disabling `bInitUHLAbilitySystemOnPosses` - -#### `BaseCharacter` - -**UHLBaseCharacter** - simplest BaseCharacter with only UHL interfaces implemented, so you don't need to do it by yourself - ---- - -### UnrealHelperLibraryBPL - -#### > RelativeAngles - -#### `RelativeAngleToActor` - -for most cases you want to use "InRange" like `IsOtherActorInAngle` (or `IsOtherCharacterInRange` if you want to check distance) - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/4a695df4-9583-451c-801b-98e63c8ad5c8) - -#### `GetPointAtRelativeAngle` - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/4c2f5e47-9f5c-4e70-8d77-57cb7383290a) -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/c0026be0-ce3a-4ee5-84e6-b8e90474fdb9) - -#### `GetPointAtRelativeDirection` - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/c1ea6dda-4ccf-4441-a7d0-dc83ac977a9c) -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/a33a93ad-f470-4dec-8c2c-6c76b275207f) - -#### `GetPointAtAngleRelativeToOtherActor` - -#### `GetPointAtDirectionRelativeToOtherActor` - -#### `DirectionToAngle` - -#### > Misc +### Migration to UHL 2.0, NEW multi-plugins version -#### `GetProjectVersion` +if already have plugin +- checkout main +- commit UnrealHelperLibrary change +- run command - `git submodule update --init --recursive` -Get project version from "Project Settings" +- UHL CommonMaps - in `Config/DefaultGame` rename section from [/Script/CommonMaps.UHLCommonMapsDeveloperSettings] -> [/Script/UHLCommonMaps.UHLCommonMapsDeveloperSettings] -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/c15d4c68-48d2-4d49-bee6-438f18064f9f) - -![image](https://github.com/Ciberusps/unreal-helper-library/assets/14001879/d9e7e53c-b0ba-47cc-b63a-099423a89346) - -#### `GetNamesOfComponentsOnObject` - -Get names of actor components on object, usefull for [`GetOptions` UPROPERTY](https://benui.ca/unreal/uproperty/#getoptions) - -#### `GetAssetsOfClass` - -#### > Other - -#### `GetHighestPoint` - -#### `ANS_UHL_Base` - -**ANS_UHL_Base** - base `AnimNotifyState` class with commonly used features like - -- subscribing `OnMontageBlendingOut` by overriding `OnMontageBlendingOut` can be disabled by `bUseOnMontageBlendingOut=false(true by default)` -- more come later - -### 🪲 DebugSystem - -Powerful debug system for gameplay based on GameplayTags. So any game needs debug system, in mid-size commands you always use limited set of debugging tools -more always than others, so **DebugSystem** is as tool for creating your debug system as fast as possible by providing `DebugCategories`(gameplaytags) that can be enabled/disabled - -Use case: -I want to have debug for AbilitySystem, it should turn on/off, available in editor between sessions and..... - -Components: - -##### DebugSystemSettings - -- add new categories, turn on/off default state, every debug category is a tag -- `DebugCategoryComponents` (DCC) - -##### Check is category enabled/subscribe on debug category state change - -- `WaitDebugCategoryChange` - blueprint node to easier check `isDebugCategoryEnabled` or not and wait for its changes -- `IsUHLDebugSystemEnabled` - blueprint node -- `DebugCategoriesList` - UI component for quick integration in your debug menu - -**Features:** - -- you can create DebugCategoryComponents that activate/deactivate console commands, event in blueprints like GAS abilities -- you can even compose DebugCategoryComponents e.g. you want Collisions + HitBoxes, so you can create combined DebugCategory and add "DCC_Collisions" and "DCC_HitBoxes" -- you can "Block" other DebugCategories by tag -- WaitDebugCategoryChange - -**How to add DebugCategory:** -1) ... -2) ... - -How to subscribe on debug category change in C++ - -```c++ - UAA_WaitDebugCategoryChange* WaitDebugCategoryChangeTask = UAA_WaitDebugCategoryChange::WaitDebugCategoryChange( - Actor->GetWorld(), - YourGameplayTags::TAG_DebugCategory_Combat // same as FGameplayTag("DebugCategory.Something") - ); - WaitDebugCategoryChangeTask->OnChange.AddUniqueDynamic(this, &UCombatSubsystem::OnDebugCategoryChanged); - // on activation "OnDebugCategoryChanged" will be fired - WaitDebugCategoryChangeTask->Activate(); -``` - -##### DebugSystemSubsystem - -##### `UHLDebugSystemSubsystem` - -**UHLDebugSystemSubsystem** - subsystem that provides interaction with debug categories - -##### DebugBlueprintLibrary - -###### `IsUHLDebugCategoryEnabled` - -Check is debug category enabled or not - -### Subsystems - -#### UHLHUD - -HUD with debugging abilities, for now used to display debug bars(e.g. HP/hidden attributes) - -### 🔃 LoadingUtilLibrary - -**UHLLoadingUtilLibrary** - loading utils from Lyra - -#### ApplyDefaultPriorityLoading - -#### ApplyStreamingPriorityLoading - -#### ApplyHighestPriorityLoading - -#### ApplyCustomPriorityLoading - -#### ForceGarbageCollection - -#### FlushLevelStreaming - -### 🎯 TraceUtilsBPL - -**UHLTraceUtilsBPL** - trace utils - -### ⚙️ Settings - -#### UHL Settings - -- You can set defaults for all [AbilitySystem](#abilitysystemcomponent) and [AbilitySystem Config](#abilitysystem-config) in your project its can be usefull -if you don't want to copy paste your `AttributeSets` - -### ⌨ UHL Editor - -**UHL Editor** - optional module with editor customization, e.g. custom thumnails, custom class icons - -#### `Custom thumnails` - -![image](https://github.com/user-attachments/assets/c24fd8bb-0ffe-4666-afd5-8800df650c35) - -**Custom thumnails** - to override thumbnail by your own, just implement `IUHLEditorCustomThumbnail` interface and define your own icon using `GetCustomThumbnailIcon()` - -> [!WARNING] -> ⚠️ NOT sure that blueprints supported for now +#### Install separately ```C++ -// UInventoryItem.h -#if WITH_EDITOR -#include "UHLEditorCustomThumbnail.h" -#endif - -// IUHLEditorCustomThumbnail not available in production build -#if !WITH_EDITOR -class IUHLEditorCustomThumbnail {}; -#endif - -class GAMECODE_API UInventoryItem : public UObject, - public IUHLEditorCustomThumbnail -{ -/** IUHLEditorCustomThumbnail **/ -#if WITH_EDITOR - virtual UTexture2D* GetCustomThumbnailIcon_Implementation() const override; -#endif -/** ~IUHLEditorCustomThumbnail **/ -} - ------------------------------------------------------------------- - -// UInventoryItem.cpp -#if WITH_EDITOR -UTexture2D* UInventoryItem::GetCustomThumbnailIcon_Implementation() -{ - return Description.Icon; -} -#endif +git submodule add https://github.com/Ciberusps/UHL.git ./Plugins/UHL +git submodule add https://github.com/Ciberusps/UHLAI.git ./Plugins/UHLAI +git submodule add https://github.com/Ciberusps/UHLBehaviorTree.git ./Plugins/UHLBehaviorTree +git submodule add https://github.com/Ciberusps/UHLStateTree.git ./Plugins/UHLStateTree +git submodule add https://github.com/Ciberusps/UHLCharacter.git ./Plugins/UHLCharacter +git submodule add https://github.com/Ciberusps/UHLCommonMaps.git ./Plugins/UHLCommonMaps +git submodule add https://github.com/Ciberusps/UHLDebugSystem.git ./Plugins/UHLDebugSystem +git submodule add https://github.com/Ciberusps/UHLGAS.git ./Plugins/UHLGAS ``` -Thanks to [this post](https://forums.unrealengine.com/t/custom-thumbnail-not-display-asset-is-never-loaded/143155/2?u=ciberus) and [this](https://forums.unrealengine.com/t/custom-thumbnail-on-blueprint/337532/3?u=ciberus) - -#### `Custom class icon` - -**Custom class icon** - to override classes icons on your own, just set settings in `Project Settings -> Editor -> UnrealHelperEditor Settings` - -![image](https://github.com/user-attachments/assets/da940018-2120-4b81-84da-5237e97e9c86) - -[List of default Unreal Engine Editor icons](https://github.com/EpicKiwi/unreal-engine-editor-icons) - -Thanks to [this post](https://www.quodsoler.com/blog/customize-your-unreal-class-icons) and [this](https://forums.unrealengine.com/t/how-to-load-a-font-uasset-and-use-it-for-fslatefontinfo/1548466/3?u=ciberus) - -### UHL Utils (Editor Utility Widget) - -⚒️ InProgress - -### ConvertToORM - -Combines separate `Occlusion`, `Roughness`, `Metalic` textures into one `ORM` - -TODO check ref - https://github.com/Atulin/ChannelMerger +### Changelog + +- all modules moved to separate plugins and made as independent as possible now dependency tree looks like +- **TODO: draw dependency tree using schemas** + - UHLAI + - UHLBehaviorTree + - UHLStateTree + - UHLCharacter + - UHLGAS + - UHLCharacter + - UHL + - UHLCharacter + - UHLCommonMaps + - UHLDebugSystem + - UHLCharacter +- UHLSettings moved to UHLAISettings now UHLStateTree and UHLBehaviorTree independent from core "UHL" plugin +and can be used completly separatly from it. UHLStateTree and UHLBehaviorTree depends only on UHLAI +- ## Special Thanks diff --git a/Resources/Icon128.png b/Resources/Icon128.png deleted file mode 100644 index e7f78e47..00000000 Binary files a/Resources/Icon128.png and /dev/null differ diff --git a/Resources/PlaceholderButtonIcon.svg b/Resources/PlaceholderButtonIcon.svg deleted file mode 100644 index 73024476..00000000 --- a/Resources/PlaceholderButtonIcon.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/Source/CommonMaps/CommonMaps.Build.cs b/Source/CommonMaps/CommonMaps.Build.cs deleted file mode 100644 index de27ea43..00000000 --- a/Source/CommonMaps/CommonMaps.Build.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -using UnrealBuildTool; - -public class CommonMaps : ModuleRules -{ - public CommonMaps(ReadOnlyTargetRules Target) : base(Target) - { - PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; - - PublicDependencyModuleNames.AddRange(new string[] - { - "Core", - "DeveloperSettings", - "PropertyEditor", - } - ); - - PrivateDependencyModuleNames.AddRange(new string[] - { - "CoreUObject", - "Engine", - "Slate", - "SlateCore", - "UnrealEd", - "AssetTools", - "ToolMenus", - "DesktopWidgets", - } - ); - } -} diff --git a/Source/CommonMaps/Private/CommonMaps.cpp b/Source/CommonMaps/Private/CommonMaps.cpp deleted file mode 100644 index 1b42fb17..00000000 --- a/Source/CommonMaps/Private/CommonMaps.cpp +++ /dev/null @@ -1,301 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "CommonMaps.h" -#include "AssetSelection.h" -#include "CommonMapsDeveloperSettings.h" -#include "FileHelpers.h" -#include "AssetRegistry/AssetRegistryModule.h" - -#define LOCTEXT_NAMESPACE "FCommonMapsModule" - -namespace CommonMapsFunctionLibrary -{ - static bool HasPlayWorld() - { - return GEditor->PlayWorld != nullptr; - } - - static bool HasNoPlayWorld() - { - return !HasPlayWorld(); - } - - static void OpenCommonMap_Clicked(const FString MapPath) - { - constexpr bool bPromptUserToSave = true; - constexpr bool bSaveMapPackages = true; - constexpr bool bSaveContentPackages = true; - constexpr bool bFastSave = false; - constexpr bool bNotifyNoPackagesSaved = false; - constexpr bool bCanBeDeclined = true; - if (FEditorFileUtils::SaveDirtyPackages(bPromptUserToSave, bSaveMapPackages, bSaveContentPackages, bFastSave, - bNotifyNoPackagesSaved, bCanBeDeclined)) - { - if (ensure(MapPath.Len())) - { - GEditor->GetEditorSubsystem()->OpenEditorForAsset(MapPath); - } - } - } - - // Recursive helper to either add entries or deeper sub-menus. - static void PopulateRecursive( - FMenuBuilder& Builder, - TArray Assets, // captured by value - const FString RootPath, // e.g. "/Game/GameName/Characters" - int32 MaxDepth, // SubmenuDepth - int32 CurrentDepth // 0 on first call - ) - { - // Base case: we have descended MaxDepth levels, so just list maps here - if (CurrentDepth >= MaxDepth) - { - for (const FAssetData& Asset : Assets) - { - const FString AssetPathString = Asset.GetSoftObjectPath().ToString(); - const FText DisplayName = FText::FromString(Asset.AssetName.ToString()); - - Builder.AddMenuEntry( - DisplayName, - FText::FromString(AssetPathString), - FSlateIcon(), - FUIAction( - FExecuteAction::CreateStatic(&CommonMapsFunctionLibrary::OpenCommonMap_Clicked, AssetPathString), - FCanExecuteAction::CreateStatic(&CommonMapsFunctionLibrary::HasNoPlayWorld), - FIsActionChecked(), - FIsActionButtonVisible::CreateStatic(&CommonMapsFunctionLibrary::HasNoPlayWorld) - ) - ); - } - return; - } - - // Otherwise, bucket by the folder name at this level - TMap> Buckets; - const FString Prefix = RootPath + TEXT("/"); - - for (const FAssetData& Asset : Assets) - { - // Only World assets - if (Asset.AssetClassPath.GetAssetName() != FName("World")) - continue; - - // "/Game/Root/Folder1/Folder2" => "Folder1/Folder2" - FString Rel = Asset.PackagePath.ToString(); - if (Rel.StartsWith(Prefix)) - { - Rel = Rel.Mid(Prefix.Len()); - } - else - { - Rel.Empty(); - } - - // Split into ["Folder1","Folder2",...] - TArray Parts; - Rel.ParseIntoArray(Parts, TEXT("/"), /*CullEmpty=*/ true); - - // Grab the segment at our current depth (0-based) - FString Key = Parts.IsValidIndex(CurrentDepth) ? Parts[CurrentDepth] : TEXT(""); - Buckets.FindOrAdd(Key).Add(Asset); - } - - // Create one submenu per bucket, capturing each subgroup by value - for (auto& Pair : Buckets) - { - const FString& FolderName = Pair.Key.IsEmpty() ? TEXT("") : Pair.Key; - TArray SubAssets = MoveTemp(Pair.Value); - int32 NextDepth = CurrentDepth + 1; - - Builder.AddSubMenu( - FText::FromString(FolderName), - FText(), // no extra tooltip - FNewMenuDelegate::CreateLambda( - [SubAssets, RootPath, MaxDepth, NextDepth](FMenuBuilder& SubMenuBuilder) - { - // recurse with copies only - CommonMapsFunctionLibrary::PopulateRecursive( - SubMenuBuilder, - SubAssets, - RootPath, - MaxDepth, - NextDepth - ); - } - ) - ); - } - } - - static TSharedRef GetCommonMapsDropdown() - { - FMenuBuilder MenuBuilder(true, nullptr); - - for (const FCommonMapCategory& MapCategory : GetDefault()->MapsCategories) - { - TAttribute SectionText; - SectionText.Set(FText::FromName(MapCategory.Name)); - MenuBuilder.BeginSection(NAME_None, SectionText); - - for (const FSoftObjectPath& Map : MapCategory.Maps) - { - if (!Map.IsValid()) - { - continue; - } - - const FText DisplayName = FText::FromString(Map.GetAssetName()); - MenuBuilder.AddMenuEntry( - DisplayName, - FText::Format(LOCTEXT("CommonPathDescription", "{0}"), FText::FromString(Map.ToString())), - FSlateIcon(), - FUIAction( - FExecuteAction::CreateStatic(&CommonMapsFunctionLibrary::OpenCommonMap_Clicked, Map.ToString()), - FCanExecuteAction::CreateStatic(&CommonMapsFunctionLibrary::HasNoPlayWorld), - FIsActionChecked(), - FIsActionButtonVisible::CreateStatic(&CommonMapsFunctionLibrary::HasNoPlayWorld) - ) - ); - } - - if (MapCategory.bAutoSearchMapsInFolder) - { - // 1) Normalize root (assume always "/Game/..."), strip trailing slash - FString RootPath = MapCategory.SearchFolder.Path.TrimStartAndEnd(); - RootPath.RemoveFromEnd("/"); - - // Gather all map assets under that path - FAssetRegistryModule& AR = FModuleManager::LoadModuleChecked("AssetRegistry"); - TArray AllAssets; - AR.Get().GetAssetsByPath(FName(*RootPath), AllAssets, /*bRecursive=*/ true); - - // Kick off the recursive submenu build at depth=0 - CommonMapsFunctionLibrary::PopulateRecursive( - MenuBuilder, - MoveTemp(AllAssets), - RootPath, - MapCategory.SubmenuDepth, - /*CurrentDepth=*/ 0 - ); - } - - MenuBuilder.EndSection(); - } - - return MenuBuilder.MakeWidget(); - } - - static bool CanShowCommonMaps() - { - return HasNoPlayWorld() && !GetDefault()->MapsCategories.IsEmpty(); - } - - static void RegisterGameEditorMenus() - { - UToolMenu* Menu = UToolMenus::Get()->ExtendMenu("LevelEditor.LevelEditorToolBar.PlayToolBar"); - FToolMenuSection& Section = Menu->AddSection("PlayGameExtensions", TAttribute(), - FToolMenuInsert("Play", EToolMenuInsertType::Default)); - - - FToolMenuEntry CommonMapEntry = FToolMenuEntry::InitComboButton( - "CommonMapOptions", - FUIAction( - FExecuteAction(), - FCanExecuteAction::CreateStatic(&CommonMapsFunctionLibrary::HasNoPlayWorld), - FIsActionChecked(), - FIsActionButtonVisible::CreateStatic(&CommonMapsFunctionLibrary::CanShowCommonMaps)), - FOnGetContent::CreateStatic(&CommonMapsFunctionLibrary::GetCommonMapsDropdown), - LOCTEXT("CommonMaps_Label", "Common Maps"), - LOCTEXT("CommonMaps_ToolTip", "Some commonly desired maps while using the editor"), - FSlateIcon(FAppStyle::GetAppStyleSetName(), "Icons.Level") - ); - CommonMapEntry.StyleNameOverride = "CalloutToolbar"; - Section.AddEntry(CommonMapEntry); - } -} - -void FCommonMapsModule::StartupModule() -{ - ExtendContextMenu(); - - if (!IsRunningGame()) - { - if (FSlateApplication::IsInitialized()) - { - UToolMenus::RegisterStartupCallback( - FSimpleMulticastDelegate::FDelegate::CreateStatic(&CommonMapsFunctionLibrary::RegisterGameEditorMenus)); - } - } - - // customization of "SearchFolder" to make "meta=(RelativePath)" work - // FPropertyEditorModule& PropEd = FModuleManager::LoadModuleChecked("PropertyEditor"); - // PropEd.RegisterCustomPropertyTypeLayout( - // "CommonMapCategory", - // FOnGetPropertyTypeCustomizationInstance::CreateStatic(&FCommonMapCategoryCustomization::MakeInstance) - // ); -} - -void FCommonMapsModule::ExtendContextMenu() -{ - UToolMenu* WorldAssetMenu = UToolMenus::Get()->ExtendMenu("ContentBrowser.AssetContextMenu.World"); - if (!WorldAssetMenu) return; - - FToolMenuSection& Section = WorldAssetMenu->AddSection("AssetContextCommonMaps", - LOCTEXT("CommonMapsOptionsMenuHeading", "Common Maps")); - - Section.AddSubMenu(FName("Common Maps"), - LOCTEXT("AddToCommonMapsFromMenu", "Add to Common Maps"), - LOCTEXT("AddToCommonMapsFromMenuTooltip", "Add this map into Common Maps list."), - FNewMenuDelegate::CreateRaw(this, &FCommonMapsModule::CreateCategorySelectionSubmenu), - FToolUIActionChoice(), - EUserInterfaceActionType::None, - false, - FSlateIcon(FAppStyle::GetAppStyleSetName(), "Icons.Star")); -} - -void FCommonMapsModule::AddToCommonMapsFromMenu(FName CategoryName) -{ - TArray SelectedAssets; - AssetSelectionUtils::GetSelectedAssets(SelectedAssets); - if (auto* Settings = GetMutableDefault()) - { - for (const auto& AssetData : SelectedAssets) - { - if (FCommonMapCategory* CurrentCategory = Settings->MapsCategories.FindByKey(CategoryName)) - { - CurrentCategory->Maps.Add({ AssetData.GetSoftObjectPath() }); - } - else - { - Settings->MapsCategories.Add(FCommonMapCategory(CategoryName, { AssetData.GetSoftObjectPath() })); - } - } - - Settings->SaveConfig(CPF_Config); - FMessageDialog::Open(EAppMsgType::Ok, FText::FromString("All maps added to Common Maps!")); - } -} - -void FCommonMapsModule::CreateCategorySelectionSubmenu(FMenuBuilder& MenuBuilder) -{ - const UCommonMapsDeveloperSettings* DevSettings = GetDefault(); - if (!DevSettings) return; - - for (const FCommonMapCategory& Category : DevSettings->MapsCategories) - { - MenuBuilder.AddMenuEntry( - FText::Format(LOCTEXT("CategoryLabel", "{0}"), FText::FromName(Category.Name)), - FText::Format(LOCTEXT("CategoryTooltip", "Add this map to \"{0}\" category."), FText::FromName(Category.Name)), - FSlateIcon(), FUIAction(FExecuteAction::CreateRaw(this, &FCommonMapsModule::AddToCommonMapsFromMenu, Category.Name))); - } -} - - -void FCommonMapsModule::ShutdownModule() -{ - UToolMenus::UnRegisterStartupCallback(this); -} - -#undef LOCTEXT_NAMESPACE - -IMPLEMENT_MODULE(FCommonMapsModule, CommonMaps) diff --git a/Source/CommonMaps/Private/CommonMapsDeveloperSettings.cpp b/Source/CommonMaps/Private/CommonMapsDeveloperSettings.cpp deleted file mode 100644 index 6fc623a0..00000000 --- a/Source/CommonMaps/Private/CommonMapsDeveloperSettings.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "CommonMapsDeveloperSettings.h" - diff --git a/Source/CommonMaps/Public/CommonMaps.h b/Source/CommonMaps/Public/CommonMaps.h deleted file mode 100644 index 04001dbd..00000000 --- a/Source/CommonMaps/Public/CommonMaps.h +++ /dev/null @@ -1,19 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Modules/ModuleManager.h" - -class FCommonMapsModule : public IModuleInterface -{ -public: - /** IModuleInterface implementation */ - virtual void StartupModule() override; - virtual void ShutdownModule() override; - -private: - void ExtendContextMenu(); - void AddToCommonMapsFromMenu(FName CategoryName); - void CreateCategorySelectionSubmenu(FMenuBuilder& MenuBuilder); -}; diff --git a/Source/CommonMaps/Public/CommonMapsDeveloperSettings.h b/Source/CommonMaps/Public/CommonMapsDeveloperSettings.h deleted file mode 100644 index ad6e8586..00000000 --- a/Source/CommonMaps/Public/CommonMapsDeveloperSettings.h +++ /dev/null @@ -1,58 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "CommonMapsDeveloperSettings.generated.h" - -USTRUCT(BlueprintType) -struct FCommonMapCategory -{ - GENERATED_BODY() - -public: - FCommonMapCategory() = default; - explicit FCommonMapCategory(FName CategoryName_In, const TArray& InPaths) - : Name(CategoryName_In), Maps({ InPaths }) {}; - - UPROPERTY(EditAnywhere, Category="CommonMapCategory") - FName Name = ""; - - UPROPERTY(EditAnywhere, Category="CommonMapCategory") - bool bAutoSearchMapsInFolder = false; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="CommonMapCategory", meta=(ContentDir, EditCondition="bAutoSearchMapsInFolder", EditConditionHides)) - FDirectoryPath SearchFolder; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="CommonMapCategory", meta=(EditCondition="bAutoSearchMapsInFolder", EditConditionHides)) - int32 SubmenuDepth = 1; - - UPROPERTY(EditAnywhere, Category="CommonMapCategory", meta=(AllowedClasses="/Script/Engine.World", TitleProperty="Name")) - TArray Maps = {}; - - bool operator==(const FCommonMapCategory& Other) const - { - return Name == Other.Name; - } - bool operator==(const FName& Other) const - { - return Name == Other; - } -}; - -/** - * TODO: add rescan folders button - */ -UCLASS(config="Game", DefaultConfig, DisplayName="Common Maps") -class COMMONMAPS_API UCommonMapsDeveloperSettings : public UDeveloperSettings -{ - GENERATED_BODY() - -public: - virtual FName GetCategoryName() const override { return FName("Plugins"); } - -#if WITH_EDITORONLY_DATA - UPROPERTY(Config,EditAnywhere, Category="Common Maps", meta=(ForceInlineRow)) - TArray MapsCategories; -#endif -}; diff --git a/Source/UHLAI/Private/Components/UHLAIPerceptionComponent.cpp b/Source/UHLAI/Private/Components/UHLAIPerceptionComponent.cpp deleted file mode 100644 index 52cf949a..00000000 --- a/Source/UHLAI/Private/Components/UHLAIPerceptionComponent.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Components/UHLAIPerceptionComponent.h" - -#include "Perception/AISense_Sight.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLAIPerceptionComponent) - -void UUHLAIPerceptionComponent::HandleExpiredStimulus(FAIStimulus& StimulusStore) -{ - Super::HandleExpiredStimulus(StimulusStore); - - TSubclassOf StimulusClass = UAIPerceptionSystem::GetSenseClassForStimulus(GetWorld(), StimulusStore); - if (StimulusClass == UAISense_Sight::StaticClass()) - { - if (OnSightStimulusExpired.IsBound()) - { - OnSightStimulusExpired.Broadcast(StimulusStore); - } - } -} diff --git a/Source/UHLAI/Private/Composite/BTC_RandomSelector.cpp b/Source/UHLAI/Private/Composite/BTC_RandomSelector.cpp deleted file mode 100644 index d818acda..00000000 --- a/Source/UHLAI/Private/Composite/BTC_RandomSelector.cpp +++ /dev/null @@ -1,160 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Composite/BTC_RandomSelector.h" - -#include "BehaviorTree/BTTaskNode.h" -#include "BehaviorTree/BTCompositeNode.h" -#include "BehaviorTree/BehaviorTreeComponent.h" -#include "BehaviorTree/BlackboardComponent.h" -#include "Misc/EngineVersionComparison.h" -#include "GameFramework/Actor.h" -#include "VisualLogger/VisualLogger.h" -#include "BehaviorTree/BTTaskNode.h" -#include "BehaviorTree/BTAuxiliaryNode.h" -#include "Kismet/KismetMathLibrary.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTC_RandomSelector) - -UBTC_RandomSelector::UBTC_RandomSelector(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - NodeName = "RandomSelector"; -} - -void UBTC_RandomSelector::RemoveUnusedChances() -{ - if (ChancesArray.Num() > GetChildrenNum()) - { - int32 CountToRemove = ChancesArray.Num() - GetChildrenNum(); - ChancesArray.RemoveAt(ChancesArray.Num() - CountToRemove, CountToRemove); - } -} - -int32 UBTC_RandomSelector::GetNextChildHandler(FBehaviorTreeSearchData& SearchData, int32 PrevChild, EBTNodeResult::Type LastResult) const -{ - // success = quit - int32 NextChildIdx = BTSpecialChild::ReturnToParent; - - if (PrevChild == BTSpecialChild::NotInitialized) - { - // newly activated: start from first - NextChildIdx = GetRandomChildIdx(); - } - else if (LastResult == EBTNodeResult::Failed && (PrevChild + 1) < GetChildrenNum()) - { - // failed = choose next child - NextChildIdx = GetRandomChildIdx(); - } - - return NextChildIdx; -} - -FString UBTC_RandomSelector::GetStaticDescription() const -{ - // Chances Array - FString Result = ""; - - float ChancesSum = 0.0f; - FString ChancesString = ""; - for (int32 i = 0; i < Children.Num(); i++) - { - FBTCompositeChild ChildNode = Children[i]; - - FString Name = ""; - if (ChildNode.ChildComposite) - { - Name = ChildNode.ChildComposite->NodeName; - } - else if (ChildNode.ChildTask) - { - Name = ChildNode.ChildTask->NodeName; - } - if (!ChancesArray.IsValidIndex(i)) continue; - - float CurrentChance = ChancesArray[i]; - ChancesSum += CurrentChance; - Result += FString::Printf(TEXT("- %s: %.2f \n"), *Name, CurrentChance); - } - - FString SumWarning = ChancesSum != 1.0f ? FString(TEXT("⚠️")) : FString(); - Result = FString::Printf(TEXT("%s \n\nSum: %.2f %s \nChances: \n%s"), *Super::GetStaticDescription(), ChancesSum, *SumWarning, *Result); - Result += GetErrorOrWarning(); - - return Result; -} - -#if WITH_EDITOR -FName UBTC_RandomSelector::GetNodeIconName() const -{ - return IsValidSelector() ? FName("BTEditor.Graph.BTNode.Composite.Selector.Icon") : FName("Graph.ConnectorFeedback.Error"); -} -#endif - -#if UE_VERSION_NEWER_THAN(5, 4, 0) -void UBTC_RandomSelector::InitializeMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, - EBTMemoryInit::Type InitType) const -{ - InitializeNodeMemory(NodeMemory, InitType); -} - -void UBTC_RandomSelector::CleanupMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, - EBTMemoryClear::Type CleanupType) const -{ - CleanupNodeMemory(NodeMemory, CleanupType); -} -#endif - -FString UBTC_RandomSelector::GetErrorOrWarning() const -{ - if (!IsValidSelector()) - { - if (GetChildrenNum() > ChancesArray.Num()) - { - return FString::Printf(TEXT("\n ❌ERROR❌ \nAdd chances for rest child nodes")); - } - // if RandomSelector have only one child, unreal somehow can crash randomly in different places Anims/AI/random components - if (Children.Num() <= 1) - { - return FString::Printf(TEXT("\n ❌ERROR❌ \nUse with at least two childs, one child can lead to random crash in child nodes")); - } - } - - if (GetChildrenNum() < ChancesArray.Num()) - { - return FString::Printf(TEXT("\n ⚠️WARNING⚠️ \nNot all chances have their child nodes")); - } - - return FString(); -} - -int32 UBTC_RandomSelector::GetRandomChildIdx() const -{ - int32 ResultIdx = BTSpecialChild::ReturnToParent; - - TArray ChancesRanges = {}; - - float SumChances = 0.0f; - for (int32 i = 0; i < GetChildrenNum(); i++) - { - float MinValue = SumChances; - - float Chance = ChancesArray.IsValidIndex(i) ? ChancesArray[i] : 999999.0f; - SumChances += Chance; - - FFloatRange ChanceRange = FFloatRange(MinValue, SumChances); - ChancesRanges.Add(ChanceRange); - } - - float RandomFloat = UKismetMathLibrary::RandomFloatInRange(0.0f, SumChances); - - for (FFloatRange ChanceRange : ChancesRanges) - { - if (ChanceRange.Contains(RandomFloat)) - { - ResultIdx = ChancesRanges.IndexOfByKey(ChanceRange); - } - } - - return ResultIdx; -} diff --git a/Source/UHLAI/Private/Core/UHLAIActorSettings.cpp b/Source/UHLAI/Private/Core/UHLAIActorSettings.cpp deleted file mode 100644 index d010faf3..00000000 --- a/Source/UHLAI/Private/Core/UHLAIActorSettings.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Core/UHLAIActorSettings.h" - -// Add default functionality here for any IUHLActorSettings functions that are not pure virtual. -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLAIActorSettings) \ No newline at end of file diff --git a/Source/UHLAI/Private/Core/UHLAIDebugSettings.cpp b/Source/UHLAI/Private/Core/UHLAIDebugSettings.cpp deleted file mode 100644 index 33285cac..00000000 --- a/Source/UHLAI/Private/Core/UHLAIDebugSettings.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "Core/UHLAIDebugSettings.h" - diff --git a/Source/UHLAI/Private/Core/UHLBlackboardValueType.cpp b/Source/UHLAI/Private/Core/UHLBlackboardValueType.cpp deleted file mode 100644 index bcf93eea..00000000 --- a/Source/UHLAI/Private/Core/UHLBlackboardValueType.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Core/UHLBlackboardValueType.h" \ No newline at end of file diff --git a/Source/UHLAI/Private/Core/UHLMathOperations.cpp b/Source/UHLAI/Private/Core/UHLMathOperations.cpp deleted file mode 100644 index 3453f3d7..00000000 --- a/Source/UHLAI/Private/Core/UHLMathOperations.cpp +++ /dev/null @@ -1,211 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "Core/UHLMathOperations.h" - -#include "BehaviorTree/BehaviorTreeComponent.h" -#include "BehaviorTree/BlackboardComponent.h" - - -void FOperationOnBBValue::SetCurrentBBKeyValueType(EBlackboardValueType CurrentBBKeyValueType_In) -{ - CurrentBBKeyValueType = CurrentBBKeyValueType_In; -} - -int32 FOperationOnBBValue::CalculateIntResult(UBehaviorTreeComponent& OwnerComp, int32 CurrentValue) const -{ - int32 Result = CurrentValue; - - UBlackboardComponent* BlackboardComponent = OwnerComp.GetBlackboardComponent(); - if (!BlackboardComponent) return Result; - - if (MathOperation == EUHL_MathOperations::Set) - { - Result = IntValue.GetValue(OwnerComp); - } - else if (MathOperation == EUHL_MathOperations::Add) - { - Result = CurrentValue + IntValue.GetValue(OwnerComp); - } - else if (MathOperation == EUHL_MathOperations::Multiply) - { - Result = CurrentValue * IntValue.GetValue(OwnerComp); - } - else if (MathOperation == EUHL_MathOperations::Divide) - { - Result = CurrentValue / IntValue.GetValue(OwnerComp); - } - - return Result; -} - -float FOperationOnBBValue::CalculateFloatResult( - UBehaviorTreeComponent& OwnerComp, float CurrentValue) const -{ - float Result = CurrentValue; - - UBlackboardComponent* BlackboardComponent = OwnerComp.GetBlackboardComponent(); - if (!BlackboardComponent) return Result; - - if (MathOperation == EUHL_MathOperations::Set) - { - Result = FloatValue.GetValue(OwnerComp); - } - else if (MathOperation == EUHL_MathOperations::Add) - { - Result = CurrentValue + FloatValue.GetValue(OwnerComp); - } - else if (MathOperation == EUHL_MathOperations::Multiply) - { - Result = CurrentValue * FloatValue.GetValue(OwnerComp); - } - else if (MathOperation == EUHL_MathOperations::Divide) - { - Result = CurrentValue / FloatValue.GetValue(OwnerComp); - } - - return Result; -} - -FVector FOperationOnBBValue::CalculateVectorResult( - UBehaviorTreeComponent& OwnerComp, FVector CurrentValue) const -{ - FVector Result = CurrentValue; - - UBlackboardComponent* BlackboardComponent = OwnerComp.GetBlackboardComponent(); - if (!BlackboardComponent) return Result; - - if (MathOperation == EUHL_MathOperations::Set) - { - Result = VectorValue.GetValue(OwnerComp); - } - else if (MathOperation == EUHL_MathOperations::Add) - { - Result = CurrentValue + VectorValue.GetValue(OwnerComp); - } - else if (MathOperation == EUHL_MathOperations::Multiply) - { - Result = CurrentValue * VectorValue.GetValue(OwnerComp); - } - else if (MathOperation == EUHL_MathOperations::Divide) - { - Result = CurrentValue / VectorValue.GetValue(OwnerComp); - } - - return Result; -} - -FRotator FOperationOnBBValue::CalculateRotatorResult( - UBehaviorTreeComponent& OwnerComp, FRotator CurrentValue) const -{ - FRotator Result = CurrentValue; - - UBlackboardComponent* BlackboardComponent = OwnerComp.GetBlackboardComponent(); - if (!BlackboardComponent) return Result; - - if (MathOperation == EUHL_MathOperations::Set) - { - Result = RotatorValue.GetValue(OwnerComp); - } - else if (MathOperation == EUHL_MathOperations::Add) - { - Result = CurrentValue + RotatorValue.GetValue(OwnerComp); - } - else if (MathOperation == EUHL_MathOperations::Multiply) - { - Result = (CurrentValue.Euler() * RotatorValue.GetValue(OwnerComp).Euler()).ToOrientationRotator(); - } - else if (MathOperation == EUHL_MathOperations::Divide) - { - Result = (CurrentValue.Euler() / RotatorValue.GetValue(OwnerComp).Euler()).ToOrientationRotator(); - } - - return Result; -} - -FString FOperationOnBBValue::ToStringIntValue(FString KeyName) const -{ - FString Result = ""; - if (MathOperation == EUHL_MathOperations::Set) - { - Result = FString::Printf(TEXT("Set \"%s\" to %s"), *KeyName, *IntValue.ToString()); - } - else if (MathOperation == EUHL_MathOperations::Add) - { - Result = FString::Printf(TEXT("Add \"%s\" to %s"), *IntValue.ToString(), *KeyName); - } - else if (MathOperation == EUHL_MathOperations::Multiply) - { - Result = FString::Printf(TEXT("Multiply \"%s\" by %s"), *KeyName, *IntValue.ToString()); - } - else if (MathOperation == EUHL_MathOperations::Divide) - { - Result = FString::Printf(TEXT("Divide \"%s\" by %s"), *KeyName, *IntValue.ToString()); - } - return Result; -} - -FString FOperationOnBBValue::ToStringFloatValue(FString KeyName) const -{ - FString Result = ""; - if (MathOperation == EUHL_MathOperations::Set) - { - Result = FString::Printf(TEXT("Set \"%s\" to %sf"), *KeyName, *FloatValue.ToString()); - } - else if (MathOperation == EUHL_MathOperations::Add) - { - Result = FString::Printf(TEXT("Add \"%s\" to %s"), *FloatValue.ToString(), *KeyName); - } - else if (MathOperation == EUHL_MathOperations::Multiply) - { - Result = FString::Printf(TEXT("Multiply \"%s\" by %sf"), *KeyName, *FloatValue.ToString()); - } - else if (MathOperation == EUHL_MathOperations::Divide) - { - Result = FString::Printf(TEXT("Divide \"%s\" by %sf"), *KeyName, *FloatValue.ToString()); - } - return Result; -} - -FString FOperationOnBBValue::ToStringVectorValue(FString KeyName) const -{ - FString Result = ""; - if (MathOperation == EUHL_MathOperations::Set) - { - Result = FString::Printf(TEXT("Set \"%s\" to %sf"), *KeyName, *VectorValue.ToString()); - } - else if (MathOperation == EUHL_MathOperations::Add) - { - Result = FString::Printf(TEXT("Add \"%s\" to %s"), *VectorValue.ToString(), *KeyName); - } - else if (MathOperation == EUHL_MathOperations::Multiply) - { - Result = FString::Printf(TEXT("Multiply \"%s\" by %sf"), *KeyName, *VectorValue.ToString()); - } - else if (MathOperation == EUHL_MathOperations::Divide) - { - Result = FString::Printf(TEXT("Divide \"%s\" by %sf"), *KeyName, *VectorValue.ToString()); - } - return Result; -} - -FString FOperationOnBBValue::ToStringRotatorValue(FString KeyName) const -{ - FString Result = ""; - if (MathOperation == EUHL_MathOperations::Set) - { - Result = FString::Printf(TEXT("Set \"%s\" to %sf"), *KeyName, *RotatorValue.ToString()); - } - else if (MathOperation == EUHL_MathOperations::Add) - { - Result = FString::Printf(TEXT("Add \"%s\" to %s"), *RotatorValue.ToString(), *KeyName); - } - else if (MathOperation == EUHL_MathOperations::Multiply) - { - Result = FString::Printf(TEXT("Multiply \"%s\" by %sf"), *KeyName, *RotatorValue.ToString()); - } - else if (MathOperation == EUHL_MathOperations::Divide) - { - Result = FString::Printf(TEXT("Divide \"%s\" by %sf"), *KeyName, *RotatorValue.ToString()); - } - return Result; -} diff --git a/Source/UHLAI/Private/Data/TurnSettings.cpp b/Source/UHLAI/Private/Data/TurnSettings.cpp deleted file mode 100644 index 9358100b..00000000 --- a/Source/UHLAI/Private/Data/TurnSettings.cpp +++ /dev/null @@ -1,230 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Data/TurnSettings.h" -#include "Animation/AnimMontage.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(TurnSettings) - -void FTurnSettings::Cleanup() -{ - TurnRangesGroups.Empty(); -} - -void FTurnSettings::SetupPreset_Default_90_180() -{ - bTurnOnlyWithAnims = false; - bStopMontageOnGoalReached = true; - // order is important because ranges might overlap - TurnRangesGroups = { - { - "180deg", - { - { - { "Turn 180 L", FFloatRange(-225, -115) }, - { "Turn 180 R", FFloatRange(115, 225) }, - } - } - }, - { - "90deg", - { - { - { "Turn 90 L", FFloatRange(-115, -45) }, - { "Turn 90 R", FFloatRange(45, 115) }, - } - } - }, - }; -} - -void FTurnSettings::SetupPreset_BigEnemy_90_180() -{ - bTurnOnlyWithAnims = true; - bStopMontageOnGoalReached = true; - // order is important because ranges might overlap - TurnRangesGroups = { - { - "180deg", - { - { - { "Turn 180 L", FFloatRange(-225, -135) }, - { "Turn 180 R", FFloatRange(135, 225) }, - } - } - }, - { - "90deg", - { - { - { "Turn 90 L", FFloatRange(-135, -45) }, - { "Turn 90 R", FFloatRange(45, 135) }, - } - } - }, - }; -} - -void FTurnSettings::SetupPreset_45_90_180() -{ - bTurnOnlyWithAnims = true; - bStopMontageOnGoalReached = true; - // order is important because ranges might overlap - TurnRangesGroups = { - { - "180deg", - { - { - { "Turn 180 L", FFloatRange(-225, -135) }, - { "Turn 180 R", FFloatRange(135, 225) }, - } - } - }, - { - "90deg", - { - { - { "Turn 90 L", FFloatRange(-135, -67.5) }, - { "Turn 90 R", FFloatRange(67.5, 135) }, - } - } - }, - { - "45deg", - { - { - { "Turn 45 L", FFloatRange(-67.5, -22.5) }, - { "Turn 45 R", FFloatRange(22.5, 67.5) }, - } - } - }, - }; -} - -void FTurnSettings::SetupPreset_15_45_90_180() -{ - bTurnOnlyWithAnims = true; - bStopMontageOnGoalReached = true; - // order is important because ranges might overlap - TurnRangesGroups = { - { - "180deg", - { - { - { "Turn 180 L", FFloatRange(-225, -135) }, - { "Turn 180 R", FFloatRange(135, 225) }, - } - } - }, - { - "90deg", - { - { - { "Turn 90 L", FFloatRange(-135, -67.5) }, - { "Turn 90 R", FFloatRange(67.5, 135) }, - } - } - }, - { - "45deg", - { - { - { "Turn 45 L", FFloatRange(-67.5, -30) }, - { "Turn 45 R", FFloatRange(30, 67.5) }, - } - } - }, - { - "15deg", - { - { - { "Turn 15 L", FFloatRange(-30, -7.5) }, - { "Turn 15 R", FFloatRange(7.5, 30) }, - } - } - }, - }; -} - -void FTurnSettings::SetupPreset_15_30_45_90_180() -{ - bTurnOnlyWithAnims = true; - bStopMontageOnGoalReached = true; - TurnRangesGroups = { - { - "180deg", - { - { - { "Turn 180 L", FFloatRange(-225, -135) }, - { "Turn 180 R", FFloatRange(135, 225) }, - } - } - }, - { - "90deg", - { - { - { "Turn 90 L", FFloatRange(-135, -67.5) }, - { "Turn 90 R", FFloatRange(67.5, 135) }, - } - } - }, - { - "45deg", - { - { - { "Turn 45 L", FFloatRange(-67.5, -30) }, - { "Turn 45 R", FFloatRange(30, 67.5) }, - } - } - }, - { - "30deg", - { - { - { "Turn 30 L", FFloatRange(-37.5, -22.5) }, - { "Turn 30 R", FFloatRange(22.5, 37.5) }, - } - } - }, - { - "15deg", - { - { - { "Turn 15 L", FFloatRange(-22.5, -7.5) }, - { "Turn 15 R", FFloatRange(7.5, 22.5) }, - } - } - }, - }; -} - -void UTurnSettingsDataAsset::Cleanup() -{ - TurnSettings.Cleanup(); -} - -void UTurnSettingsDataAsset::SetupPreset_Default_90_180() -{ - TurnSettings.SetupPreset_Default_90_180(); -} - -void UTurnSettingsDataAsset::SetupPreset_BigEnemy_90_180() -{ - TurnSettings.SetupPreset_BigEnemy_90_180(); -} - -void UTurnSettingsDataAsset::SetupPreset_45_90_180() -{ - TurnSettings.SetupPreset_45_90_180(); -} - -void UTurnSettingsDataAsset::SetupPreset_15_45_90_180() -{ - TurnSettings.SetupPreset_15_45_90_180(); -} - -void UTurnSettingsDataAsset::SetupPreset_15_30_45_90_180() -{ - TurnSettings.SetupPreset_15_30_45_90_180(); -} diff --git a/Source/UHLAI/Private/Decorators/BTD_Base.cpp b/Source/UHLAI/Private/Decorators/BTD_Base.cpp deleted file mode 100644 index d24c6749..00000000 --- a/Source/UHLAI/Private/Decorators/BTD_Base.cpp +++ /dev/null @@ -1,151 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Decorators/BTD_Base.h" - -#include "BlueprintNodeHelpers.h" -#include "BehaviorTree/BlackboardComponent.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTD_Base) - -UBTD_Base::UBTD_Base(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - bIsObservingBB = false; -} - -void UBTD_Base::InitializeProperties() -{ - if (HasAnyFlags(RF_ClassDefaultObject)) - { - UClass* StopAtClass = UBTD_Base::StaticClass(); - BlueprintNodeHelpers::CollectPropertyData(this, StopAtClass, PropertyData); - - bIsObservingBB = BlueprintNodeHelpers::HasAnyBlackboardSelectors(this, StopAtClass); - } - else - { - // Make sure if the users started to observe a BB key after we instantiated this node, that this value get propagated correctly - bIsObservingBB = GetClass()->GetDefaultObject()->bIsObservingBB; - } -} - -void UBTD_Base::PostInitProperties() -{ - Super::PostInitProperties(); - - InitializeProperties(); -} - -FString UBTD_Base::GetPropertiesDetails() const -{ - FString ReturnDesc = ""; - UBTD_Base* CDO = (UBTD_Base*)(GetClass()->GetDefaultObject()); - if (bShowPropertyDetails && CDO) - { - UClass* StopAtClass = UBTD_Base::StaticClass(); - FString PropertyDesc = BlueprintNodeHelpers::CollectPropertyDescription(this, StopAtClass, CDO->PropertyData); - if (PropertyDesc.Len()) - { - ReturnDesc += TEXT(":\n\n"); - ReturnDesc += PropertyDesc; - } - } - return ReturnDesc; -} - -void UBTD_Base::RequestAbort(UBehaviorTreeComponent& OwnerComp, const EAbortType Type) -{ - switch (Type) - { - case EAbortType::NoAbort: - // Nothing to abort, continue - break; - case EAbortType::ActivateBranch: - OwnerComp.RequestBranchActivation(*this, false); - break; - case EAbortType::DeactivateBranch: - OwnerComp.RequestBranchDeactivation(*this); - break; - case EAbortType::Unknown: - checkf(false, TEXT("If decorator is active, it must know whether it needs to abort or not")) - break; - } -} - -EBlackboardNotificationResult UBTD_Base::OnBlackboardKeyValueChange(const UBlackboardComponent& Blackboard, - FBlackboard::FKey ChangedKeyID) -{ - UBehaviorTreeComponent* BehaviorComp = Cast(Blackboard.GetBrainComponent()); - if (BehaviorComp) - { - const EAbortType Type = EvaluateAbortType(*BehaviorComp); - if (Type != EAbortType::Unknown) - { - RequestAbort(*BehaviorComp, Type); - } - } - return BehaviorComp ? EBlackboardNotificationResult::ContinueObserving : EBlackboardNotificationResult::RemoveObserver; -} - -void UBTD_Base::PostLoad() -{ - Super::PostLoad(); - - if (GetFlowAbortMode() != EBTFlowAbortMode::None && bIsObservingBB) - { - ObservedKeyNames.Reset(); - UClass* StopAtClass = UBTD_Base::StaticClass(); - BlueprintNodeHelpers::CollectBlackboardSelectors(this, StopAtClass, ObservedKeyNames); - ensure(ObservedKeyNames.Num() > 0); - } -} - -void UBTD_Base::OnBecomeRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) -{ - UBlackboardComponent* BlackboardComp = OwnerComp.GetBlackboardComponent(); - if (BlackboardComp) - { - for (int32 NameIndex = 0; NameIndex < ObservedKeyNames.Num(); NameIndex++) - { - const FBlackboard::FKey KeyID = BlackboardComp->GetKeyID(ObservedKeyNames[NameIndex]); - if (KeyID != FBlackboard::InvalidKey) - { - BlackboardComp->RegisterObserver(KeyID, this, FOnBlackboardChangeNotification::CreateUObject(this, &UBTD_Base::OnBlackboardKeyValueChange)); - } - } - } -} - -UBTD_Base::EAbortType UBTD_Base::EvaluateAbortType(UBehaviorTreeComponent& OwnerComp) const -{ - // if (PerformConditionCheckImplementations == 0) - // { - // return EAbortType::Unknown; - // } - - if (FlowAbortMode == EBTFlowAbortMode::None) - { - return EAbortType::NoAbort; - } - - const bool bIsOnActiveBranch = OwnerComp.IsExecutingBranch(GetMyNode(), GetChildIndex()); - - EAbortType AbortType = EAbortType::NoAbort; - if (bIsOnActiveBranch) - { - if ((FlowAbortMode == EBTFlowAbortMode::Self || FlowAbortMode == EBTFlowAbortMode::Both) && CalculateRawConditionValue(OwnerComp, /*NodeMemory*/nullptr) == IsInversed()) - { - AbortType = EAbortType::DeactivateBranch; - } - } - else - { - if ((FlowAbortMode == EBTFlowAbortMode::LowerPriority || FlowAbortMode == EBTFlowAbortMode::Both) && CalculateRawConditionValue(OwnerComp, /*NodeMemory*/nullptr) != IsInversed()) - { - AbortType = EAbortType::ActivateBranch; - } - } - - return AbortType; -} diff --git a/Source/UHLAI/Private/Decorators/BTD_CheckGASGameplayTagsOnActor.cpp b/Source/UHLAI/Private/Decorators/BTD_CheckGASGameplayTagsOnActor.cpp deleted file mode 100644 index d507fe0d..00000000 --- a/Source/UHLAI/Private/Decorators/BTD_CheckGASGameplayTagsOnActor.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Decorators/BTD_CheckGASGameplayTagsOnActor.h" - -#include "AbilitySystemComponent.h" -#include "AbilitySystemInterface.h" -#include "BehaviorTree/BlackboardComponent.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Object.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTD_CheckGASGameplayTagsOnActor) - -UBTD_CheckGASGameplayTagsOnActor::UBTD_CheckGASGameplayTagsOnActor(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - NodeName = "GAS Gameplay Tag Condition"; - INIT_DECORATOR_NODE_NOTIFY_FLAGS(); - - // Accept only actors - ActorToCheck.AddObjectFilter(this, GET_MEMBER_NAME_CHECKED(UBTD_CheckGASGameplayTagsOnActor, ActorToCheck), AActor::StaticClass()); - - // Default to using Self Actor - ActorToCheck.SelectedKeyName = FBlackboard::KeySelf; - - bAllowAbortNone = true; - bAllowAbortLowerPri = true; - bAllowAbortChildNodes = true; -} - -bool UBTD_CheckGASGameplayTagsOnActor::CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const -{ - const UBlackboardComponent* BlackboardComp = OwnerComp.GetBlackboardComponent(); - if (BlackboardComp == nullptr) - { - return false; - } - - IAbilitySystemInterface* AbilitySystemInterface = Cast(BlackboardComp->GetValue(ActorToCheck.GetSelectedKeyID())); - if (AbilitySystemInterface == nullptr) - { - return false; - } - UAbilitySystemComponent* ASC = AbilitySystemInterface->GetAbilitySystemComponent(); - if (!IsValid(ASC)) return false; - - switch (TagsToMatch) - { - case EGameplayContainerMatchType::All: - return ASC->HasAllMatchingGameplayTags(GameplayTags); - - case EGameplayContainerMatchType::Any: - return ASC->HasAnyMatchingGameplayTags(GameplayTags); - - default: - { - UE_LOG(LogBehaviorTree, Warning, TEXT("Invalid value for TagsToMatch (EGameplayContainerMatchType) %d. Should only be Any or All."), static_cast(TagsToMatch)); - return false; - } - } -} - -void UBTD_CheckGASGameplayTagsOnActor::DescribeRuntimeValues(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTDescriptionVerbosity::Type Verbosity, TArray& Values) const -{ - Super::DescribeRuntimeValues(OwnerComp, NodeMemory, Verbosity, Values); -} - -FString UBTD_CheckGASGameplayTagsOnActor::GetStaticDescription() const -{ - return FString::Printf(TEXT("%s: %s"), *Super::GetStaticDescription(), *CachedDescription); -} - -#if WITH_EDITOR -void UBTD_CheckGASGameplayTagsOnActor::BuildDescription() -{ - CachedDescription = TEXT("\n") + GameplayTags.ToMatchingText(TagsToMatch, IsInversed()).ToString() - .Replace(TEXT("),"), TEXT("\n - ")) - // .Replace(TEXT(": "), TEXT("")) - .Replace(TEXT("=("), TEXT("\n - ")) - .Replace(TEXT("(GameplayTags"), TEXT("")) - .Replace(TEXT("(TagName="), TEXT("")) - .Replace(TEXT(")))"), TEXT("")) - .Replace(TEXT("\""), TEXT("")) - .Replace(TEXT("=)"), TEXT("")); - // CachedDescription = FString::Printf(TEXT(" %s"), *GameplayTags.ToStringSimple(true)); -} - -void UBTD_CheckGASGameplayTagsOnActor::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) -{ - Super::PostEditChangeProperty(PropertyChangedEvent); - if (PropertyChangedEvent.Property == NULL) - { - return; - } - - BuildDescription(); -} -#endif - -void UBTD_CheckGASGameplayTagsOnActor::InitializeFromAsset(UBehaviorTree& Asset) -{ - Super::InitializeFromAsset(Asset); - - UBlackboardData* BBAsset = GetBlackboardAsset(); - if (ensure(BBAsset)) - { - ActorToCheck.ResolveSelectedKey(*BBAsset); - } - -#if WITH_EDITOR - BuildDescription(); -#endif // WITH_EDITOR -} - -void UBTD_CheckGASGameplayTagsOnActor::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) -{ - Super::TickNode(OwnerComp, NodeMemory, DeltaSeconds); - - RequestAbort(OwnerComp, EvaluateAbortType(OwnerComp)); -} - diff --git a/Source/UHLAI/Private/Decorators/BTD_GameplayEffectCooldown.cpp b/Source/UHLAI/Private/Decorators/BTD_GameplayEffectCooldown.cpp deleted file mode 100644 index 17ce6e40..00000000 --- a/Source/UHLAI/Private/Decorators/BTD_GameplayEffectCooldown.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2024 NextGenium - - -#include "Decorators/BTD_GameplayEffectCooldown.h" - -#include "Engine/World.h" -#include "AIController.h" -#include "AbilitySystemBlueprintLibrary.h" -#include "AbilitySystemComponent.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTD_GameplayEffectCooldown) - -UBTD_GameplayEffectCooldown::UBTD_GameplayEffectCooldown(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - NodeName = "GameplayEffect Cooldown"; - INIT_DECORATOR_NODE_NOTIFY_FLAGS(); - - // aborting child nodes doesn't makes sense, cooldown starts after leaving this branch - bAllowAbortChildNodes = false; -} - -bool UBTD_GameplayEffectCooldown::CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const -{ - // FBTGameplayEffectCooldownDecoratorMemory* DecoratorMemory = CastInstanceNodeMemory(NodeMemory); - // const double RecalcTime = (OwnerComp.GetWorld()->GetTimeSeconds() - CoolDownTime.GetValue(OwnerComp)); - // return RecalcTime >= DecoratorMemory->LastUseTimestamp; - - AAIController* OwnerController = OwnerComp.GetAIOwner(); - AActor* OwnerActor = OwnerController ? OwnerController->GetPawn() : nullptr; - if (!OwnerActor) return true; - - UAbilitySystemComponent* ASC = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(OwnerActor); - if (!ASC) return true; - - FGameplayEffectQuery const ActiveGameplayEffectsQuery = FGameplayEffectQuery::MakeQuery_MatchAnyOwningTags(FGameplayTagContainer(CooldownGameplayEffectTag)); - TArray EffectsTimeRemaining = ASC->GetActiveEffectsTimeRemaining(ActiveGameplayEffectsQuery); - if (EffectsTimeRemaining.Num() > 0) - { - return EffectsTimeRemaining[0] > 0.0f ? false : true; - } - return true; -} - -void UBTD_GameplayEffectCooldown::OnNodeDeactivation(FBehaviorTreeSearchData& SearchData, EBTNodeResult::Type NodeResult) -{ - FBTGameplayEffectCooldownDecoratorMemory* DecoratorMemory = GetNodeMemory(SearchData); - DecoratorMemory->LastUseTimestamp = SearchData.OwnerComp.GetWorld()->GetTimeSeconds(); - DecoratorMemory->bRequestedRestart = false; -} - -void UBTD_GameplayEffectCooldown::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) -{ - // FBTGameplayEffectCooldownDecoratorMemory* DecoratorMemory = CastInstanceNodeMemory(NodeMemory); - // if (!DecoratorMemory->bRequestedRestart) - // { - // const double RecalcTime = (OwnerComp.GetWorld()->GetTimeSeconds() - CoolDownTime.GetValue(OwnerComp)); - // if (RecalcTime >= DecoratorMemory->LastUseTimestamp) - // { - // DecoratorMemory->bRequestedRestart = true; - // OwnerComp.RequestExecution(this); - // } - // } -} - -FString UBTD_GameplayEffectCooldown::GetStaticDescription() const -{ - return ""; - // // basic info: result after time - // return FString::Printf(TEXT("%s: lock for %s s after execution and return %s"), *Super::GetStaticDescription(), - // *CoolDownTime.ToString(), *UBehaviorTreeTypes::DescribeNodeResult(EBTNodeResult::Failed)); -} - -void UBTD_GameplayEffectCooldown::DescribeRuntimeValues(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTDescriptionVerbosity::Type Verbosity, TArray& Values) const -{ - Super::DescribeRuntimeValues(OwnerComp, NodeMemory, Verbosity, Values); - - // FBTGameplayEffectCooldownDecoratorMemory* DecoratorMemory = CastInstanceNodeMemory(NodeMemory); - // const double TimePassed = OwnerComp.GetWorld()->GetTimeSeconds() - DecoratorMemory->LastUseTimestamp; - // - // if (TimePassed < CoolDownTime.GetValue(OwnerComp)) - // { - // Values.Add(FString::Printf(TEXT("%s in %ss"), - // (FlowAbortMode == EBTFlowAbortMode::None) ? TEXT("unlock") : TEXT("restart"), - // *FString::SanitizeFloat(CoolDownTime.GetValue(OwnerComp) - TimePassed))); - // } -} - -uint16 UBTD_GameplayEffectCooldown::GetInstanceMemorySize() const -{ - return sizeof(FBTGameplayEffectCooldownDecoratorMemory); -} - -void UBTD_GameplayEffectCooldown::InitializeMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryInit::Type InitType) const -{ - FBTGameplayEffectCooldownDecoratorMemory* DecoratorMemory = InitializeNodeMemory(NodeMemory, InitType); - if (InitType == EBTMemoryInit::Initialize) - { - DecoratorMemory->LastUseTimestamp = TNumericLimits::Lowest(); - } - - DecoratorMemory->bRequestedRestart = false; ; -} - -void UBTD_GameplayEffectCooldown::CleanupMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryClear::Type CleanupType) const -{ - CleanupNodeMemory(NodeMemory, CleanupType); -} - -#if WITH_EDITOR - -FName UBTD_GameplayEffectCooldown::GetNodeIconName() const -{ - return FName("BTEditor.Graph.BTNode.Decorator.Cooldown.Icon"); -} - -#endif // WITH_EDITOR - diff --git a/Source/UHLAI/Private/Decorators/BTD_InAngle.cpp b/Source/UHLAI/Private/Decorators/BTD_InAngle.cpp deleted file mode 100644 index 706ad078..00000000 --- a/Source/UHLAI/Private/Decorators/BTD_InAngle.cpp +++ /dev/null @@ -1,180 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Decorators/BTD_InAngle.h" - -#include "AIController.h" -#include "Utils/UnrealHelperLibraryBPL.h" -#include "BehaviorTree/BlackboardComponent.h" -#include "BehaviorTree/BTCompositeNode.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Object.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Vector.h" -#include "Components/CapsuleComponent.h" -#include "GameFramework/Character.h" -#include "GameFramework/Controller.h" -#include "DrawDebugHelpers.h" -#include "Kismet/KismetMathLibrary.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTD_InAngle) - -UBTD_InAngle::UBTD_InAngle(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - NodeName = "InAngle"; - INIT_DECORATOR_NODE_NOTIFY_FLAGS(); - - // Accept only actors and vectors - Target.AddObjectFilter(this, GET_MEMBER_NAME_CHECKED(UBTD_InAngle, Target), AActor::StaticClass()); - Target.AddVectorFilter(this, GET_MEMBER_NAME_CHECKED(UBTD_InAngle, Target)); - - bAllowAbortNone = true; - bAllowAbortLowerPri = true; - bAllowAbortChildNodes = true; -} - -bool UBTD_InAngle::CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const -{ - float CurrentAngle = GetCurrentAngle(OwnerComp, NodeMemory, bDrawDebug); - - return bDebugForceFalseCondition ? false : IsInAngle(CurrentAngle); -} - -void UBTD_InAngle::InitializeFromAsset(UBehaviorTree& Asset) -{ - Super::InitializeFromAsset(Asset); - - UBlackboardData* BBAsset = GetBlackboardAsset(); - if (ensure(BBAsset)) - { - Target.ResolveSelectedKey(*BBAsset); - } -} - -void UBTD_InAngle::InitializeMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, - EBTMemoryInit::Type InitType) const -{ - InitializeNodeMemory(NodeMemory, InitType); -} - -void UBTD_InAngle::CleanupMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryClear::Type CleanupType) const -{ - CleanupNodeMemory(NodeMemory, CleanupType); -} - -FString UBTD_InAngle::GetStaticDescription() const -{ - return Super::GetStaticDescription(); -} - -void UBTD_InAngle::DescribeRuntimeValues(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, - EBTDescriptionVerbosity::Type Verbosity, TArray& Values) const -{ - Super::DescribeRuntimeValues(OwnerComp, NodeMemory, Verbosity, Values); - Values.Add(FString::Printf(TEXT("CurrentAngle: %.2f"), GetCurrentAngle(OwnerComp, NodeMemory))); -} - -#if WITH_EDITOR -FName UBTD_InAngle::GetNodeIconName() const -{ - return FName("GenericCommands.Redo"); -} -#endif - -float UBTD_InAngle::GetCurrentAngle(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, bool bDrawDebug_In) const -{ - float CurrentAngle = 0.0f; - - const UBlackboardComponent* BlackboardComponent = OwnerComp.GetBlackboardComponent(); - if (!BlackboardComponent) return CurrentAngle; - - AAIController* OwnerController = OwnerComp.GetAIOwner(); - AActor* OwnerActor = OwnerController ? OwnerController->GetPawn() : nullptr; - ACharacter* OwnerCharacter = IsValid(OwnerController) ? OwnerController->GetCharacter() : nullptr; - AActor* TargetActor = nullptr; - bool bTargetActorRequiredButNotSet = false; - - FVector TargetVector = FVector::ZeroVector; - if (Target.SelectedKeyType == UBlackboardKeyType_Object::StaticClass()) - { - UObject* BBValue = BlackboardComponent->GetValueAsObject(Target.SelectedKeyName); - TargetActor = IsValid(BBValue) ? Cast(BBValue) : nullptr; - bTargetActorRequiredButNotSet = !IsValid(TargetActor); - TargetVector = IsValid(TargetActor) ? TargetActor->GetActorLocation() : FVector::ZeroVector; - } - if (Target.SelectedKeyType == UBlackboardKeyType_Vector::StaticClass()) - { - TargetVector = BlackboardComponent->GetValueAsVector(Target.SelectedKeyName); - } - - if (!IsValid(OwnerActor) || bTargetActorRequiredButNotSet) return CurrentAngle; - - CurrentAngle = UUnrealHelperLibraryBPL::RelativeAngleToVector(OwnerActor, TargetVector); - - if (bDrawDebug) - { - FVector LineStart = OwnerActor->GetActorLocation(); - FVector LineEnd = TargetVector; - FVector TextLocation = (LineEnd - LineStart) / 2 + LineStart; - bool bInAngle = IsInAngle(CurrentAngle); - - FAngleRange* InAngleRange = nullptr; - - if(IsValid(OwnerCharacter)) - { - float CapsuleSizeMultiplier = 6.0f; - float AngleLineLength = OverrideDebugLinesDistance > 0.0f - ? OverrideDebugLinesDistance - : OwnerCharacter->GetCapsuleComponent()->GetScaledCapsuleRadius() * CapsuleSizeMultiplier; - for (FAngleRange IncludeRange : IncludeRanges) - { - bool bInThisAngle = UKismetMathLibrary::InRange_FloatFloat(CurrentAngle, IncludeRange.Range.GetLowerBoundValue(), IncludeRange.Range.GetUpperBoundValue(), true, true); - float RangeAngle = IncludeRange.Range.GetLowerBoundValue() > 0.0f - ? IncludeRange.Range.GetUpperBoundValue() / 2 - : IncludeRange.Range.GetLowerBoundValue() / 2; - - // TODO bDebugUseSuccessColorFromRange - // if (bInThisAngle) - // { - // InAngleRange = &IncludeRange; - // } - - FVector StartRangeLine = LineStart + OwnerCharacter->GetActorForwardVector().RotateAngleAxis(IncludeRange.Range.GetLowerBoundValue(), FVector(0, 0, 1)) * AngleLineLength; - FVector EndRangeLine = LineStart + OwnerCharacter->GetActorForwardVector().RotateAngleAxis(IncludeRange.Range.GetUpperBoundValue(), FVector(0, 0, 1)) * AngleLineLength; - // FVector RangeDirection = LineStart + CachedOwnerCharacter->GetActorForwardVector().RotateAngleAxis(RangeAngle, FVector(0, 0, 1)) * AngleLineLength * 0.3f; - - // DrawDebugCone(OwnerComp.GetWorld(), CachedOwnerCharacter->GetActorLocation(), RangeDirection, 500.0f, RangeAngle, 2.0f, 2, IncludeRange.DebugColor, false, -1, -1, 1.0f); - DrawDebugLine(OwnerComp.GetWorld(), LineStart, StartRangeLine, bInThisAngle ? FColor::Green : IncludeRange.DebugColor, false, -1, -1, 4.0f); - DrawDebugLine(OwnerComp.GetWorld(), LineStart, EndRangeLine, bInThisAngle ? FColor::Green : IncludeRange.DebugColor, false, -1, -1, 4.0f); - // DrawDebugDirectionalArrow(OwnerComp.GetWorld(), LineStart, RangeDirection, 15.0f, bInThisAngle ? FColor::Green : IncludeRange.DebugColor, false, -1, -1, 3.0f); - } - } - - FColor AngleTextColor = bInAngle ? FColor::Green : FColor::Red; - // if (InAngleRange != nullptr) - // { - // AngleTextColor = InAngleRange->DebugColor; - // } - - DrawDebugLine(OwnerComp.GetWorld(), LineStart, LineEnd, bInAngle ? FColor::Green : FColor::Red, false, -1, -1, 2.0f); - DrawDebugSphere(OwnerComp.GetWorld(), LineStart, 4.0f, 16, FColor::Blue, false, -1, -1, 2.0f); - DrawDebugSphere(OwnerComp.GetWorld(), LineEnd, 4.0f, 16, FColor::Blue, false, -1, -1, 2.0f); - DrawDebugString(OwnerComp.GetWorld(), TextLocation, FString::Printf(TEXT("Angle: %.2f"), CurrentAngle), nullptr, AngleTextColor, 0, true); - DrawDebugString(OwnerComp.GetWorld(), OwnerActor->GetActorLocation(), FString::Printf(TEXT("ParentNode:\n%s \n\nNodeName:\n%s"), *GetParentNode()->NodeName, *GetMyNode()->NodeName), nullptr, FColor::White, 0, true); - } - - return CurrentAngle; -} - -bool UBTD_InAngle::IsInAngle(float CurrentAngle) const -{ - bool bInThisAngle = false; - for (FAngleRange IncludeRange : IncludeRanges) - { - bInThisAngle = UKismetMathLibrary::InRange_FloatFloat(CurrentAngle, IncludeRange.Range.GetLowerBoundValue(), IncludeRange.Range.GetUpperBoundValue(), true, true); - if (bInThisAngle) - { - break; - } - } - return bInThisAngle; -} diff --git a/Source/UHLAI/Private/Decorators/BTD_InRange.cpp b/Source/UHLAI/Private/Decorators/BTD_InRange.cpp deleted file mode 100644 index 59f75798..00000000 --- a/Source/UHLAI/Private/Decorators/BTD_InRange.cpp +++ /dev/null @@ -1,178 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Decorators/BTD_InRange.h" - -#include "AIController.h" -#include "BehaviorTree/BlackboardComponent.h" -#include "BehaviorTree/BTFunctionLibrary.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Object.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Vector.h" -#include "Components/CapsuleComponent.h" -#include "GameFramework/Character.h" -#include "DrawDebugHelpers.h" -#include "Kismet/KismetMathLibrary.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTD_InRange) - -UBTD_InRange::UBTD_InRange(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - NodeName = "InRange"; - INIT_DECORATOR_NODE_NOTIFY_FLAGS(); - - // Accept only actors and vectors - Target.AddObjectFilter(this, GET_MEMBER_NAME_CHECKED(UBTD_InRange, Target), AActor::StaticClass()); - Target.AddVectorFilter(this, GET_MEMBER_NAME_CHECKED(UBTD_InRange, Target)); - - bAllowAbortNone = true; - bAllowAbortLowerPri = true; - bAllowAbortChildNodes = true; -} - -#if WITH_EDITOR -FName UBTD_InRange::GetNodeIconName() const -{ - return FName("SoftwareCursor_UpDown"); -} -#endif - -float UBTD_InRange::GetCurrentDistance(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, bool bDrawDebug_In) const -{ - float CurrentDistance = 0.0f; - - const UBlackboardComponent* BlackboardComponent = OwnerComp.GetBlackboardComponent(); - if (!BlackboardComponent) return CurrentDistance; - - AAIController* OwnerController = OwnerComp.GetAIOwner(); - AActor* OwnerActor = OwnerController ? OwnerController->GetPawn() : nullptr; - AActor* TargetActor = nullptr; - bool bTargetActorRequiredButNotSet = false; - - FVector TargetVector = FVector::ZeroVector; - if (Target.SelectedKeyType == UBlackboardKeyType_Object::StaticClass()) - { - UObject* BBValue = BlackboardComponent->GetValueAsObject(Target.SelectedKeyName); - TargetActor = IsValid(BBValue) ? Cast(BBValue) : nullptr; - bTargetActorRequiredButNotSet = !IsValid(TargetActor); - TargetVector = IsValid(TargetActor) ? TargetActor->GetActorLocation() : FVector::ZeroVector; - } - if (Target.SelectedKeyType == UBlackboardKeyType_Vector::StaticClass()) - { - TargetVector = BlackboardComponent->GetValueAsVector(Target.SelectedKeyName); - } - - if (!IsValid(OwnerActor) || bTargetActorRequiredButNotSet) return CurrentDistance; - - ACharacter* OwnerCharacter = IsValid(OwnerController) ? OwnerController->GetCharacter() : nullptr; - CurrentDistance = bCalculateDistanceIn2D - ? FVector::Dist2D(OwnerActor->GetActorLocation(), TargetVector) - : FVector::Distance(OwnerActor->GetActorLocation(), TargetVector); - - if (bIncludeSelfCapsuleRadius && IsValid(OwnerCharacter)) - { - CurrentDistance -= OwnerCharacter->GetCapsuleComponent()->GetScaledCapsuleRadius(); - } - - // TODO cache TargetCharacter when possible (on BBValue change?) - ACharacter* TargetCharacter = Cast(TargetActor); - if (IsValid(TargetCharacter) && bIncludeTargetCapsuleRadius) - { - CurrentDistance -= TargetCharacter->GetCapsuleComponent()->GetScaledCapsuleRadius(); - } - - if (bDrawDebug_In) - { - FVector LineStart = OwnerActor->GetActorLocation(); - FVector LineEnd = TargetVector; - FVector TextLocation = (LineEnd - LineStart) / 2 + LineStart; - bool bInRange = UKismetMathLibrary::InRange_FloatFloat(CurrentDistance, Min, Max); - - if (bIncludeSelfCapsuleRadius && IsValid(OwnerCharacter)) - { - UCapsuleComponent* OwnerCharacterCapsule = OwnerCharacter->GetCapsuleComponent(); - DrawDebugCapsule(OwnerComp.GetWorld(), OwnerCharacterCapsule->GetComponentLocation(), - OwnerCharacterCapsule->GetScaledCapsuleHalfHeight(), - OwnerCharacterCapsule->GetScaledCapsuleRadius(), - OwnerCharacterCapsule->GetComponentRotation().Quaternion(), FColor::Blue, - false,DebugLifetime, 0, 2.0f); - LineStart = (LineEnd - LineStart).GetSafeNormal() * OwnerCharacterCapsule->GetScaledCapsuleRadius() + OwnerCharacter->GetActorLocation(); - } - - if (bIncludeTargetCapsuleRadius && IsValid(TargetCharacter)) - { - UCapsuleComponent* TargetCharacterCapsule = TargetCharacter->GetCapsuleComponent(); - DrawDebugCapsule(OwnerComp.GetWorld(), TargetCharacterCapsule->GetComponentLocation(), - TargetCharacterCapsule->GetScaledCapsuleHalfHeight(), - TargetCharacterCapsule->GetScaledCapsuleRadius(), - TargetCharacterCapsule->GetComponentRotation().Quaternion(), FColor::Blue, - false,DebugLifetime, 0, 2.0f); - LineEnd = (LineStart - LineEnd).GetSafeNormal() * TargetCharacterCapsule->GetScaledCapsuleRadius() + TargetVector; - } - - DrawDebugLine(OwnerComp.GetWorld(), LineStart, LineEnd, bInRange ? FColor::Green : FColor::Red, false, DebugLifetime, -1, 2.0f); - DrawDebugSphere(OwnerComp.GetWorld(), LineStart, 5.0f, 16, FColor::Blue, false, DebugLifetime, DebugLifetime, 2.0f); - DrawDebugSphere(OwnerComp.GetWorld(), LineEnd, 5.0f, 16, FColor::Blue, false, DebugLifetime, DebugLifetime, 2.0f); - DrawDebugString(OwnerComp.GetWorld(), TextLocation, FString::Printf(TEXT("Distance%s: %.2f"), bCalculateDistanceIn2D ? TEXT("(2D)") : TEXT("(3D)"), CurrentDistance), nullptr, bInRange ? FColor::Green : FColor::Red, DebugLifetime < 0 ? 0 : DebugLifetime, true); - DrawDebugString(OwnerComp.GetWorld(), OwnerCharacter->GetActorLocation(), FString::Printf(TEXT("ParentNode:\n%s \n\nNodeName:\n%s"), *GetParentNode()->NodeName, *GetMyNode()->NodeName), nullptr, FColor::White, DebugLifetime < 0 ? 0 : DebugLifetime, true); - } - - return CurrentDistance; -} - -void UBTD_InRange::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) -{ - Super::TickNode(OwnerComp, NodeMemory, DeltaSeconds); - - RequestAbort(OwnerComp, EvaluateAbortType(OwnerComp)); -} - -bool UBTD_InRange::CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const -{ - float CurrentDistance = GetCurrentDistance(OwnerComp, NodeMemory, bDrawDebug); - bool bIsInRange = UKismetMathLibrary::InRange_FloatFloat(CurrentDistance, Min, Max); - return bIsInRange; -} - -void UBTD_InRange::InitializeFromAsset(UBehaviorTree& Asset) -{ - Super::InitializeFromAsset(Asset); - - UBlackboardData* BBAsset = GetBlackboardAsset(); - if (ensure(BBAsset)) - { - Target.ResolveSelectedKey(*BBAsset); - } -} - -void UBTD_InRange::InitializeMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, - EBTMemoryInit::Type InitType) const -{ - InitializeNodeMemory(NodeMemory, InitType); -} - -void UBTD_InRange::CleanupMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, - EBTMemoryClear::Type CleanupType) const -{ - CleanupNodeMemory(NodeMemory, CleanupType); -} - -FString UBTD_InRange::GetStaticDescription() const -{ - FString NodeDescription = GetPropertiesDetails(); - // NodeDescription += FString::Printf(TEXT("Target: %s\n"), *Target.SelectedKeyName.ToString()); - // NodeDescription += FString::Printf(TEXT("Min: %2f\n"), Min); - // NodeDescription += FString::Printf(TEXT("Max: %2f\n"), Max); - // NodeDescription += FString::Printf(TEXT("bIncludeSelfCapsuleRadius: %hs\n"), BTOA(bIncludeSelfCapsuleRadius)); - // NodeDescription += FString::Printf(TEXT("bIncludeTargetCapsuleRadius: %hs\n"), BTOA(bIncludeTargetCapsuleRadius)); - return FString::Printf(TEXT("%s%s"), *Super::GetStaticDescription(), *NodeDescription); -} - -void UBTD_InRange::DescribeRuntimeValues(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, - EBTDescriptionVerbosity::Type Verbosity, TArray& Values) const -{ - Super::DescribeRuntimeValues(OwnerComp, NodeMemory, Verbosity, Values); - - // no need to cache value its only works in editor - Values.Add(FString::Printf(TEXT("CurrentDistance: %.2f"), GetCurrentDistance(OwnerComp, NodeMemory, false))); -} diff --git a/Source/UHLAI/Private/Decorators/BTD_LoopRandomCount.cpp b/Source/UHLAI/Private/Decorators/BTD_LoopRandomCount.cpp deleted file mode 100644 index 6c27451a..00000000 --- a/Source/UHLAI/Private/Decorators/BTD_LoopRandomCount.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Decorators/BTD_LoopRandomCount.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTD_LoopRandomCount) - -UBTD_LoopRandomCount::UBTD_LoopRandomCount(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - NodeName = "Loop_RandomCount"; - NumLoops = 3; -} - -FString UBTD_LoopRandomCount::GetStaticDescription() const -{ - return FString::Printf(TEXT("Loops: %d-%d loops"), Range.Min, Range.Max); -} - -void UBTD_LoopRandomCount::OnNodeActivation(FBehaviorTreeSearchData& SearchData) -{ - NumLoops = FMath::RandRange(Range.Min, Range.Max); - Super::OnNodeActivation(SearchData); -} diff --git a/Source/UHLAI/Private/Decorators/BTD_RandomChance.cpp b/Source/UHLAI/Private/Decorators/BTD_RandomChance.cpp deleted file mode 100644 index c3f16a42..00000000 --- a/Source/UHLAI/Private/Decorators/BTD_RandomChance.cpp +++ /dev/null @@ -1,157 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Decorators/BTD_RandomChance.h" - -#include "BehaviorTree/BTCompositeNode.h" -#include "Engine/Engine.h" -#include "UObject/UObjectGlobals.h" -#include "UObject/UnrealType.h" -#include "BehaviorTree/BlackboardData.h" -#include "Kismet/KismetMathLibrary.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTD_RandomChance) - -UBTD_RandomChance::UBTD_RandomChance(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - bAllowAbortNone = false; - bAllowAbortLowerPri = false; - bAllowAbortChildNodes = false; - - ScalableChanceLevelInBB.AddFloatFilter(this, GET_MEMBER_NAME_CHECKED(UBTD_RandomChance, ScalableChanceLevelInBB)); - -#if WITH_EDITOR - FProperty* StructProp = FindFProperty( - GetClass(), GET_MEMBER_NAME_CHECKED(UBTD_RandomChance, ChanceChangePerStep)); - - FStructProperty* StructProperty = CastField(StructProp); - if (StructProperty) - { - FProperty* PotentiallyFloatProperty = StructProperty->Struct->FindPropertyByName(GET_MEMBER_NAME_CHECKED(FOperationOnBBValue, FloatValue)); - FStructProperty* FloatProperty = CastField(PotentiallyFloatProperty); - if (FloatProperty) - { - FloatProperty->SetMetaData(TEXT("ClampMin"), TEXT("0.0")); - FloatProperty->SetMetaData(TEXT("ClampMax"), TEXT("1.0")); - FloatProperty->SetMetaData(TEXT("UIMin"), TEXT("0.0")); - FloatProperty->SetMetaData(TEXT("UIMax"), TEXT("1.0")); - } - } -#endif -} - -bool UBTD_RandomChance::CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const -{ - float CurrentChance = GetCurrentChance(OwnerComp); - bool bResult = UKismetMathLibrary::RandomBoolWithWeight(CurrentChance); - - float DrawDebugTime = DebugSettings.DrawDebugTime.GetValue(OwnerComp); - FString ResultString = bResult ? "Success" : "Fail"; - FString ScalabilitySetting = ""; - if (ScaleType == EScalableChanceType::ScalableFloat) - { - UBlackboardData* BBAsset = GetBlackboardAsset(); - if (BBAsset->IsValid()) - { - float ScaleLevel = OwnerComp.GetBlackboardComponent()->GetValueAsFloat(ScalableChanceLevelInBB.SelectedKeyName); - ScalabilitySetting = FString::SanitizeFloat(ScaleLevel); - } - } - else if (ScaleType == EScalableChanceType::BBDependantWithSteps) - { - UBlackboardData* BBAsset = GetBlackboardAsset(); - if (BBAsset->IsValid()) - { - float ScaleLevel = OwnerComp.GetBlackboardComponent()->GetValueAsFloat(StepsCount.SelectedKeyName); - ScalabilitySetting = FString::SanitizeFloat(ScaleLevel); - } - } - - if (DebugSettings.bEnableDebug) - { - GEngine->AddOnScreenDebugMessage(-1, - DrawDebugTime, bResult ? FColor::Green : FColor::White, - FString::Printf(TEXT("[UBTD_RandomChance] %s on \"%s\" with chance %.2f scaled by %s (%s)"), *ResultString, *GetParentNode()->GetName(), CurrentChance, *ScalabilitySetting, *UEnum::GetDisplayValueAsText(ScaleType).ToString()) - ); - } - - return bResult; -} - -FString UBTD_RandomChance::GetStaticDescription() const -{ - // TODO BB value preview? - // float CurrentChance = bUseBlackboardValue ? GetBlackboardAsset()->GetKey(ChanceInBB.GetSelectedKeyID()) : Chance; - return FString::Printf(TEXT("Chance - %.2f%% (%s)"), Chance * 100.0f, *Chance.ToString()); -} - -void UBTD_RandomChance::InitializeFromAsset(UBehaviorTree& Asset) -{ - Super::InitializeFromAsset(Asset); - - ChanceChangePerStep.SetCurrentBBKeyValueType(EBlackboardValueType::Float); -} - -#if WITH_EDITOR -FName UBTD_RandomChance::GetNodeIconName() const -{ - // return FName("CodeView.ClassIcon"); - return FName("GraphEditor.StructGlyph"); -} -#endif - -float UBTD_RandomChance::GetCurrentChance(UBehaviorTreeComponent& OwnerComp) const -{ - float Result = 0.0f; - switch (ScaleType) - { - case EScalableChanceType::None: - { - Result = Chance.GetValue(OwnerComp); - break; - } - case EScalableChanceType::ScalableFloat: - { - float ScalableChanceLevel = 0.0f; - UBlackboardData* BBAsset = GetBlackboardAsset(); - if (BBAsset->IsValid()) - { - ScalableChanceLevel = OwnerComp.GetBlackboardComponent()->GetValueAsFloat(ScalableChanceLevelInBB.SelectedKeyName); - } - ScalableChanceLevel = ScalableChanceLevelInBB.IsNone() ? 0.0f : ScalableChanceLevel; - Result = ScalableChance.GetValueAtLevel(ScalableChanceLevel); - break; - } - case EScalableChanceType::BBDependantWithSteps: - { - Result = Chance.GetValue(OwnerComp); - float StepsCountValue = 0.0f; - UBlackboardData* BBAsset = GetBlackboardAsset(); - if (BBAsset->IsValid()) - { - StepsCountValue = OwnerComp.GetBlackboardComponent()->GetValueAsFloat(StepsCount.SelectedKeyName); - } - // for every step calculate float value - int32 StepsCountInt = FMath::RoundToInt(StepsCountValue); - for (int32 i = 0; i < StepsCountInt; i++) - { - Result = ChanceChangePerStep.CalculateFloatResult(OwnerComp, Result); - } - break; - } - default: - break; - } - - // clamp if MaxChance defined it could be 0.6f or something like that - if (ScaleType != EScalableChanceType::None) - { - Result = FMath::Clamp(Result, 0.0f, MaxChance.GetValue(OwnerComp)); - } - - // clamp anything chance range 0.0f-1.0f - Result = FMath::Clamp(Result, 0.0f, 1.0f); - - return Result; -} \ No newline at end of file diff --git a/Source/UHLAI/Private/Decorators/BTD_TimeLimitRandom.cpp b/Source/UHLAI/Private/Decorators/BTD_TimeLimitRandom.cpp deleted file mode 100644 index 367ac294..00000000 --- a/Source/UHLAI/Private/Decorators/BTD_TimeLimitRandom.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Decorators/BTD_TimeLimitRandom.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTD_TimeLimitRandom) - -#if UE_VERSION_NEWER_THAN(5, 4, 0) -struct FBTimeLimitRandomMemory -{ - bool bElapsed = false; -}; -#endif - -UBTD_TimeLimitRandom::UBTD_TimeLimitRandom(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - NodeName = "TimeLimit_Random"; - TimeLimit = 5.0f; - -#if UE_VERSION_NEWER_THAN(5, 4, 0) - INIT_DECORATOR_NODE_NOTIFY_FLAGS(); - bTickIntervals = true; - - // time limit always abort current branch - bAllowAbortLowerPri = false; - bAllowAbortNone = false; - FlowAbortMode = EBTFlowAbortMode::Self; -#endif -} - -FString UBTD_TimeLimitRandom::GetStaticDescription() const -{ - // basic info: result after time - return FString::Printf(TEXT("TimeLimit: %s after %.1fs-%.1fs"), - *UBehaviorTreeTypes::DescribeNodeResult(EBTNodeResult::Failed), TimeLimitRange.Min, TimeLimitRange.Max); -} - -#if UE_VERSION_NEWER_THAN(5, 4, 0) -void UBTD_TimeLimitRandom::DescribeRuntimeValues(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTDescriptionVerbosity::Type Verbosity, TArray& Values) const -{ - Super::DescribeRuntimeValues(OwnerComp, NodeMemory, Verbosity, Values); - - const FBTAuxiliaryMemory* DecoratorMemory = GetSpecialNodeMemory(NodeMemory); - if (OwnerComp.GetWorld()) - { - const float TimeLeft = DecoratorMemory->NextTickRemainingTime > 0.f ? DecoratorMemory->NextTickRemainingTime : 0.f; - Values.Add(FString::Printf(TEXT("%s in %ss"), - *UBehaviorTreeTypes::DescribeNodeResult(EBTNodeResult::Failed), - *FString::SanitizeFloat(TimeLeft))); - } -} - -#if WITH_EDITOR -FName UBTD_TimeLimitRandom::GetNodeIconName() const -{ - return FName("BTEditor.Graph.BTNode.Decorator.TimeLimit.Icon"); -} -#endif -#endif - -void UBTD_TimeLimitRandom::OnNodeActivation(FBehaviorTreeSearchData& SearchData) -{ - TimeLimit = bUseIntegers - ? FMath::RandRange((int32)TimeLimitRange.Min, (int32)TimeLimitRange.Max) - : FMath::RandRange(TimeLimitRange.Min, TimeLimitRange.Max); - Super::OnNodeActivation(SearchData); -} - -#if UE_VERSION_NEWER_THAN(5, 4, 0) -void UBTD_TimeLimitRandom::OnBecomeRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) -{ - Super::OnBecomeRelevant(OwnerComp, NodeMemory); - - SetNextTickTime(NodeMemory, TimeLimit); -} - -void UBTD_TimeLimitRandom::OnCeaseRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) -{ - Super::OnCeaseRelevant(OwnerComp, NodeMemory); - - reinterpret_cast(NodeMemory)->bElapsed = false; -} - -bool UBTD_TimeLimitRandom::CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const -{ - return !reinterpret_cast(NodeMemory)->bElapsed; -} - -void UBTD_TimeLimitRandom::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) -{ - ensureMsgf(DeltaSeconds >= TimeLimit || FMath::IsNearlyEqual(DeltaSeconds, TimeLimit, UE_KINDA_SMALL_NUMBER), - TEXT("Using SetNextTickTime in OnBecomeRelevant should guarantee that we are only getting ticked when the time limit is finished. DT=%f, TimeLimit=%f"), - DeltaSeconds, - TimeLimit); - - // Mark this decorator instance as Elapsed for calls to CalculateRawConditionValue - reinterpret_cast(NodeMemory)->bElapsed = true; - - // Set our next tick time to large value so we don't get ticked again in case the decorator - // is still active after requesting execution (e.g. latent abort) - SetNextTickTime(NodeMemory, FLT_MAX); - - OwnerComp.RequestExecution(this); -} - -uint16 UBTD_TimeLimitRandom::GetInstanceMemorySize() const -{ - return sizeof(FBTimeLimitMemoryRandom); -} - -void UBTD_TimeLimitRandom::InitializeMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, const EBTMemoryInit::Type InitType) const -{ - InitializeNodeMemory(NodeMemory, InitType); -} - -void UBTD_TimeLimitRandom::CleanupMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, const EBTMemoryClear::Type CleanupType) const -{ - CleanupNodeMemory(NodeMemory, CleanupType); -} -#endif diff --git a/Source/UHLAI/Private/Services/BTS_GameplayFocus.cpp b/Source/UHLAI/Private/Services/BTS_GameplayFocus.cpp deleted file mode 100644 index 7e78421a..00000000 --- a/Source/UHLAI/Private/Services/BTS_GameplayFocus.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Services/BTS_GameplayFocus.h" - -#include "GameFramework/Actor.h" -#include "BehaviorTree/BlackboardComponent.h" -#include "BehaviorTree/BehaviorTreeComponent.h" -#include "BehaviorTree/BehaviorTreeTypes.h" -#include "BehaviorTree/Services/BTService_DefaultFocus.h" -#include "AIController.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTS_GameplayFocus) - -UBTS_GameplayFocus::UBTS_GameplayFocus(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - NodeName = "Set Gameplay Focus"; - FocusPriority = EAIFocusPriority::Gameplay; -} - -#if UE_VERSION_NEWER_THAN(5, 4, 0) -void UBTS_GameplayFocus::InitializeMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryInit::Type InitType) const -{ - InitializeNodeMemory(NodeMemory, InitType); -} - -void UBTS_GameplayFocus::CleanupMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryClear::Type CleanupType) const -{ - CleanupNodeMemory(NodeMemory, CleanupType); -} -#endif diff --git a/Source/UHLAI/Private/Tasks/BTT_ClearFocus.cpp b/Source/UHLAI/Private/Tasks/BTT_ClearFocus.cpp deleted file mode 100644 index 2615335b..00000000 --- a/Source/UHLAI/Private/Tasks/BTT_ClearFocus.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Tasks/BTT_ClearFocus.h" -#include "AIController.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTT_ClearFocus) - -UBTT_ClearFocus::UBTT_ClearFocus(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - NodeName = "ClearFocus"; -} - -EBTNodeResult::Type UBTT_ClearFocus::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) -{ - TObjectPtr AIOwner = OwnerComp.GetAIOwner(); - if (!AIOwner.Get()) - { - AIOwner.Get()->ClearFocus(EAIFocusPriority::Gameplay); - } - - return Super::ExecuteTask(OwnerComp, NodeMemory); -} diff --git a/Source/UHLAI/Private/Tasks/BTT_DebugPrintBBValue.cpp b/Source/UHLAI/Private/Tasks/BTT_DebugPrintBBValue.cpp deleted file mode 100644 index 5a2004f1..00000000 --- a/Source/UHLAI/Private/Tasks/BTT_DebugPrintBBValue.cpp +++ /dev/null @@ -1,132 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Tasks/BTT_DebugPrintBBValue.h" - -#include "UHLAIBlueprintLibrary.h" -#include "BehaviorTree/BlackboardComponent.h" -#include "BehaviorTree/BlackboardData.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Enum.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_NativeEnum.h" -#include "Kismet/KismetSystemLibrary.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTT_DebugPrintBBValue) - -UBTT_DebugPrintBBValue::UBTT_DebugPrintBBValue(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - NodeName = "DebugPrintBBValue"; -} - -EBTNodeResult::Type UBTT_DebugPrintBBValue::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) -{ - UKismetSystemLibrary::PrintString( - nullptr, GetBBKeyDescription(OwnerComp), - true, true, - Color, Duration, Key - ); - return Super::ExecuteTask(OwnerComp, NodeMemory); -} - -FString UBTT_DebugPrintBBValue::GetBBKeyDescription(UBehaviorTreeComponent& OwnerComp) -{ - const UBlackboardData* BlackboardAsset = GetBlackboardAsset(); - BlackboardKey.ResolveSelectedKey(*BlackboardAsset); - - const FBlackboardEntry* EntryInfo = BlackboardAsset ? BlackboardAsset->GetKey(BlackboardKey.GetSelectedKeyID()) : NULL; - - UBlackboardComponent* BlackboardComponent = OwnerComp.GetBlackboardComponent(); - - EBlackboardValueType BBValueType = UUHLAIBlueprintLibrary::BlackboardKeyToBBValueType(BlackboardKey); - - FString Description = FString(); - - switch (BBValueType) - { - case EBlackboardValueType::Bool: - { - bool BoolValue = BlackboardComponent->GetValueAsBool(BlackboardKey.SelectedKeyName); - Description = FString::Printf(TEXT("\"%s\" is %hhd"), *BlackboardKey.SelectedKeyName.ToString(), BoolValue); - } - break; - case EBlackboardValueType::Int: - { - int32 IntValue = BlackboardComponent->GetValueAsInt(BlackboardKey.SelectedKeyName); - Description = FString::Printf(TEXT("\"%s\" is %d"), *BlackboardKey.SelectedKeyName.ToString(), IntValue); - } - break; - case EBlackboardValueType::Float: - { - float FloatValue = BlackboardComponent->GetValueAsFloat(BlackboardKey.SelectedKeyName); - Description = FString::Printf(TEXT("\"%s\" is %f"), *BlackboardKey.SelectedKeyName.ToString(), FloatValue); - } - break; - case EBlackboardValueType::String: - { - FString StringValue = BlackboardComponent->GetValueAsString(BlackboardKey.SelectedKeyName); - Description = FString::Printf(TEXT("\"%s\" is %s"), *BlackboardKey.SelectedKeyName.ToString(), *StringValue); - } - break; - case EBlackboardValueType::Name: - { - FName NameValue = BlackboardComponent->GetValueAsName(BlackboardKey.SelectedKeyName); - Description = FString::Printf(TEXT("\"%s\" is %s"), *BlackboardKey.SelectedKeyName.ToString(), *NameValue.ToString()); - } - break; - case EBlackboardValueType::Vector: - { - FVector VectorValue = BlackboardComponent->GetValueAsVector(BlackboardKey.SelectedKeyName); - Description = FString::Printf(TEXT("\"%s\" is %s"), *BlackboardKey.SelectedKeyName.ToString(), *VectorValue.ToString()); - } - break; - case EBlackboardValueType::Rotator: - { - FRotator RotatorValue = BlackboardComponent->GetValueAsRotator(BlackboardKey.SelectedKeyName); - Description = FString::Printf(TEXT("\"%s\" is %s"), *BlackboardKey.SelectedKeyName.ToString(), *RotatorValue.ToString()); - } - break; - case EBlackboardValueType::Enum: - { - UEnum* Enum = (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Enum::StaticClass()) - ? ((UBlackboardKeyType_Enum*)(EntryInfo->KeyType))->EnumType - : ((UBlackboardKeyType_NativeEnum*)(EntryInfo->KeyType))->EnumType; - uint8 EnumValue = BlackboardComponent->GetValueAsEnum(BlackboardKey.SelectedKeyName); - - FString EnumStringValue = Enum->GetNameStringByValue(EnumValue); - Description = FString::Printf(TEXT("\"%s\" is %s"), *BlackboardKey.SelectedKeyName.ToString(), *EnumStringValue); - } - break; - case EBlackboardValueType::NativeEnum: - { - UEnum* Enum = (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Enum::StaticClass()) - ? ((UBlackboardKeyType_Enum*)(EntryInfo->KeyType))->EnumType - : ((UBlackboardKeyType_NativeEnum*)(EntryInfo->KeyType))->EnumType; - uint8 EnumValue = BlackboardComponent->GetValueAsEnum(BlackboardKey.SelectedKeyName); - FString EnumStringValue = Enum->GetNameStringByValue(EnumValue); - Description = FString::Printf(TEXT("\"%s\" is %s"), *BlackboardKey.SelectedKeyName.ToString(), *EnumStringValue); - } - break; - case EBlackboardValueType::Object: - { - FBlackboardKeySelector ObjectValue = BlackboardKey; - Description = FString::Printf(TEXT("\"%s\" is %s"), *BlackboardKey.SelectedKeyName.ToString(), *ObjectValue.SelectedKeyName.ToString()); - } - break; - case EBlackboardValueType::Class: - { - UClass* ClassValue = BlackboardComponent->GetValueAsClass(BlackboardKey.SelectedKeyName); - Description = FString::Printf(TEXT("\"%s\" is %s"), *BlackboardKey.SelectedKeyName.ToString(), ClassValue ? *ClassValue->GetName() : TEXT("")); - } - break; - - default: - break; - } - - return FString::Printf(TEXT("%s"), *Description); -} - -FString UBTT_DebugPrintBBValue::GetStaticDescription() const -{ - return FString::Printf(TEXT("%s: %s"), *Super::GetStaticDescription(), *BlackboardKey.SelectedKeyName.ToString()); -} diff --git a/Source/UHLAI/Private/Tasks/BTT_DebugPrintString.cpp b/Source/UHLAI/Private/Tasks/BTT_DebugPrintString.cpp deleted file mode 100644 index 8c7849ba..00000000 --- a/Source/UHLAI/Private/Tasks/BTT_DebugPrintString.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Tasks/BTT_DebugPrintString.h" -#include "Kismet/KismetSystemLibrary.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTT_DebugPrintString) - -UBTT_DebugPrintString::UBTT_DebugPrintString(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - NodeName = "DebugPrintString"; -} - -EBTNodeResult::Type UBTT_DebugPrintString::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) -{ - UKismetSystemLibrary::PrintString( - nullptr, GetFinalString(), - true, true, - Color, Duration.GetValue(OwnerComp), Key.GetValue(OwnerComp) - ); - return Super::ExecuteTask(OwnerComp, NodeMemory); -} - -FString UBTT_DebugPrintString::GetStaticDescription() const -{ - return FString::Printf(TEXT("%s: \"%s\""), *Super::GetStaticDescription(), *GetFinalString()); -} - -FString UBTT_DebugPrintString::GetFinalString() const -{ - FString Result = ""; - for (FValueOrBBKey_String PrintString : PrintStrings) - { - Result.Append(PrintString.ToString()); - } - return Result; -} diff --git a/Source/UHLAI/Private/Tasks/BTT_FireGameplayEvent.cpp b/Source/UHLAI/Private/Tasks/BTT_FireGameplayEvent.cpp deleted file mode 100644 index d570c9b3..00000000 --- a/Source/UHLAI/Private/Tasks/BTT_FireGameplayEvent.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Tasks/BTT_FireGameplayEvent.h" - -#include "AbilitySystemComponent.h" -#include "AbilitySystemGlobals.h" -#include "AbilitySystemInterface.h" -#include "BehaviorTree/BlackboardComponent.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTT_FireGameplayEvent) - -UBTT_FireGameplayEvent::UBTT_FireGameplayEvent(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - Target.AddObjectFilter(this, GET_MEMBER_NAME_CHECKED(UBTT_FireGameplayEvent, Target), AActor::StaticClass()); - Instigator.AddObjectFilter(this, GET_MEMBER_NAME_CHECKED(UBTT_FireGameplayEvent, Instigator), AActor::StaticClass()); - - Target.SelectedKeyName = FBlackboard::KeySelf; - Instigator.SelectedKeyName = FBlackboard::KeySelf; - - OptionalObject.AddObjectFilter(this, GET_MEMBER_NAME_CHECKED(UBTT_FireGameplayEvent, OptionalObject), UObject::StaticClass()); - OptionalObject.AllowNoneAsValue(true); - OptionalObject2.AddObjectFilter(this, GET_MEMBER_NAME_CHECKED(UBTT_FireGameplayEvent, OptionalObject2), UObject::StaticClass()); - OptionalObject2.AllowNoneAsValue(true); -} - -EBTNodeResult::Type UBTT_FireGameplayEvent::ExecuteTask( - UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) -{ - const UBlackboardData* BlackboardAsset = GetBlackboardAsset(); - UBlackboardComponent* BlackboardComponent = OwnerComp.GetBlackboardComponent(); - if (!BlackboardAsset) return EBTNodeResult::Failed; - - Target.ResolveSelectedKey(*BlackboardAsset); - Instigator.ResolveSelectedKey(*BlackboardAsset); - OptionalObject.ResolveSelectedKey(*BlackboardAsset); - OptionalObject2.ResolveSelectedKey(*BlackboardAsset); - - if (!Target.IsSet() || !Instigator.IsSet()) - { - return EBTNodeResult::Failed; - } - - UObject* TargetValue = BlackboardComponent->GetValueAsObject(Target.SelectedKeyName); - UObject* InstigatorValue = BlackboardComponent->GetValueAsObject(Instigator.SelectedKeyName); - if (!TargetValue || !InstigatorValue) return EBTNodeResult::Failed; - - AActor* TargetActor = Cast(TargetValue); - AActor* InstigatorActor = Cast(InstigatorValue); - if (!TargetActor || !InstigatorActor) return EBTNodeResult::Failed; - - UAbilitySystemComponent* TargetASC = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(TargetActor); - - FGameplayEventData EventData; - EventData.Target = TargetActor; - EventData.Instigator = InstigatorActor; - EventData.EventMagnitude = EventMagnitude; - EventData.OptionalObject = BlackboardComponent->GetValueAsObject(OptionalObject.SelectedKeyName); - EventData.OptionalObject2 = BlackboardComponent->GetValueAsObject(OptionalObject2.SelectedKeyName); - EventData.TargetTags = TargetTags; - EventData.InstigatorTags = InstigatorTags; - TargetASC->HandleGameplayEvent(EventTag, &EventData); - - return Super::ExecuteTask(OwnerComp, NodeMemory); -} - -FString UBTT_FireGameplayEvent::GetStaticDescription() const -{ - return Super::GetStaticDescription(); -} - diff --git a/Source/UHLAI/Private/Tasks/BTT_InvokeGameplayAbility.cpp b/Source/UHLAI/Private/Tasks/BTT_InvokeGameplayAbility.cpp deleted file mode 100644 index 0a365863..00000000 --- a/Source/UHLAI/Private/Tasks/BTT_InvokeGameplayAbility.cpp +++ /dev/null @@ -1,186 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Tasks/BTT_InvokeGameplayAbility.h" - -#include "AbilitySystemComponent.h" -#include "AbilitySystemInterface.h" -#include "AIController.h" -#include "AbilitySystemGlobals.h" -#include "Utils/UnrealHelperLibraryBPL.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTT_InvokeGameplayAbility) - -UBTT_InvokeGameplayAbility::UBTT_InvokeGameplayAbility(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - NodeName = "InvokeGameplayAbility"; - - bNotifyTaskFinished = true; - // TODO probably instancing required or won't work with multiple InvokeGameplayAbilities/multiple enemies - // as in PlayAnimMontage - yep its required - // TODO try to remove instancing, to reproduce issue with stucking on "InvokeGameplayAbility" - // create room with enemy only attacking infinitely - // bCreateNodeInstance = true; -} - -EBTNodeResult::Type UBTT_InvokeGameplayAbility::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) -{ - EBTNodeResult::Type Result = EBTNodeResult::Failed; - bool GameplayAbilitySpecFound = false; - - TObjectPtr AIOwner = OwnerComp.GetAIOwner(); - if (!AIOwner) return EBTNodeResult::Failed; - - UAbilitySystemComponent* ASC = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(AIOwner->GetPawn()); - if (!ASC) - { - if (bDebugMessages.GetValue(OwnerComp)) - { - UUnrealHelperLibraryBPL::DebugPrintStrings(FString::Printf(TEXT("[BTT_InvokeGameplayAbility] OwnerActor \"%s\" don't have AbilitySystem(implements IAbilitySystemInterface) add it"), *AIOwner->GetPawn()->GetName())); - } - return EBTNodeResult::Failed; - } - - FGameplayAbilitySpec* AbilitySpec = nullptr; - FGameplayAbilitySpecHandle* GameplayAbilitiesSpecHandle = nullptr; - - // TODO UHL->FindAbilitySpecByTags? - TArray GameplayAbilitiesSpecs = {}; - ASC->GetAllAbilities(GameplayAbilitiesSpecs); - for (FGameplayAbilitySpecHandle GameplayAbilitiesSpecSearch : GameplayAbilitiesSpecs) - { - FGameplayAbilitySpec* AbilitySpecSearch = ASC->FindAbilitySpecFromHandle(GameplayAbilitiesSpecSearch); - if (AbilitySpecSearch->Ability->GetAssetTags().HasAny(GameplayTag.GetValue(OwnerComp).GetSingleTagContainer())) - { - AbilitySpec = AbilitySpecSearch; - GameplayAbilitiesSpecHandle = &GameplayAbilitiesSpecSearch; - GameplayAbilitySpecFound = true; - break; - } - } - - if (bActivate) - { - if (GameplayAbilitySpecFound && AbilitySpec != nullptr) - { - if (bWaitForFinishing.GetValue(OwnerComp)) - { - ASC->OnAbilityEnded.AddUObject(this, &UBTT_InvokeGameplayAbility::OnAbilityEnded, &OwnerComp); - } - bool bAbilityActivated = ASC->TryActivateAbility(AbilitySpec->Handle, true); - - Result = bAbilityActivated ? EBTNodeResult::InProgress : EBTNodeResult::Failed; - - if (!bWaitForFinishing.GetValue(OwnerComp)) - { - Result = EBTNodeResult::Succeeded; - } - - if (bDebugMessages.GetValue(OwnerComp)) - { - UUnrealHelperLibraryBPL::DebugPrintStrings(FString::Printf(TEXT("[BTT_InvokeGameplayAbility] TryActivateAbility - \"%s\" - %s"), *GameplayTag.GetValue(OwnerComp).ToString(), bAbilityActivated ? TEXT("activated") : TEXT("failed"))); - } - } - else - { - if (bDebugMessages.GetValue(OwnerComp)) - { - UUnrealHelperLibraryBPL::DebugPrintStrings(FString::Printf(TEXT("[BTT_InvokeGameplayAbility] Ability - \"%s\" - not found, give it to character if forgot"), *GameplayTag.GetValue(OwnerComp).ToString())); - } - } - } - else - { - if (GameplayAbilitySpecFound && GameplayAbilitiesSpecHandle != nullptr) - { - ASC->CancelAbilityHandle(*GameplayAbilitiesSpecHandle); - } - Result = EBTNodeResult::Succeeded; - } - - return Result; -} - -EBTNodeResult::Type UBTT_InvokeGameplayAbility::AbortTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) -{ - bIsAborting = true; - - TObjectPtr AIOwner = OwnerComp.GetAIOwner(); - if (AIOwner) - { - UAbilitySystemComponent* ASC = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(AIOwner->GetPawn()); - - if (ASC) - { - const FGameplayTagContainer TagsContainer = FGameplayTagContainer(GameplayTag.GetValue(OwnerComp)); - ASC->CancelAbilities(&TagsContainer); - if (bWaitForFinishing.GetValue(OwnerComp)) - { - ASC->OnAbilityEnded.RemoveAll(this); - } - - if (bDebugMessages.GetValue(OwnerComp)) - { - UUnrealHelperLibraryBPL::DebugPrintStrings(FString::Printf(TEXT("[BTT_InvokeGameplayAbility] Task was aborted, CancelAbility - %s"), *GameplayTag.GetValue(OwnerComp).ToString())); - } - } - } - - return Super::AbortTask(OwnerComp, NodeMemory); -} - -void UBTT_InvokeGameplayAbility::OnTaskFinished( - UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTNodeResult::Type TaskResult) -{ - FInvokeGameplayAbilityMemory* MyMemory = CastInstanceNodeMemory(NodeMemory); - check(MyMemory); - - if (TaskResult != EBTNodeResult::InProgress && MyMemory->AbilityEndHandle.IsValid()) - { - const AAIController* AIController = OwnerComp.GetAIOwner(); - if (IsValid(AIController)) - { - UAbilitySystemComponent* AbilityComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(AIController->GetPawn()); - if (IsValid(AbilityComponent)) - { - AbilityComponent->OnAbilityEnded.Remove(MyMemory->AbilityEndHandle); - MyMemory->AbilityEndHandle.Reset(); - } - } - } -} - -void UBTT_InvokeGameplayAbility::InitializeMemory( - UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryInit::Type InitType) const -{ - FInvokeGameplayAbilityMemory* MyMemory = CastInstanceNodeMemory(NodeMemory); - check(MyMemory); - - MyMemory->AbilityEndHandle.Reset(); -} - -FString UBTT_InvokeGameplayAbility::GetStaticDescription() const -{ - return FString::Printf(TEXT("%s: \n%s"), *Super::GetStaticDescription(), !GameplayTag.ToString().IsEmpty() ? *GameplayTag.ToString() : TEXT("")); -} - -void UBTT_InvokeGameplayAbility::OnAbilityEnded( - const FAbilityEndedData& AbilityEndedData, UBehaviorTreeComponent* OwnerComp) -{ - // if not works check "AbilitySystemComponentTests.IsSameAbility" - if (!AbilityEndedData.AbilityThatEnded->GetAssetTags().HasAllExact(FGameplayTagContainer(GameplayTag.GetValue(OwnerComp)))) return; - - const EBTNodeResult::Type NodeResult(EBTNodeResult::Succeeded); - - const AAIController* AIController = OwnerComp->GetAIOwner(); - const AActor* BehaviorOwner = IsValid(AIController) ? AIController->GetPawn() : nullptr; - const AActor* AbilityOwner = AbilityEndedData.AbilityThatEnded->GetAvatarActorFromActorInfo(); - - if (AbilityOwner == BehaviorOwner) - { - const EBTNodeResult::Type CancelResult = bTreatCancelledAbilityAsSuccess.GetValue(OwnerComp) ? EBTNodeResult::Succeeded : EBTNodeResult::Failed; - const EBTNodeResult::Type TaskResult = AbilityEndedData.bWasCancelled ? CancelResult : EBTNodeResult::Succeeded; - FinishLatentTask(*OwnerComp, TaskResult); - } -} diff --git a/Source/UHLAI/Private/Tasks/BTT_PlayAnimMontage.cpp b/Source/UHLAI/Private/Tasks/BTT_PlayAnimMontage.cpp deleted file mode 100644 index 1a35d315..00000000 --- a/Source/UHLAI/Private/Tasks/BTT_PlayAnimMontage.cpp +++ /dev/null @@ -1,175 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Tasks/BTT_PlayAnimMontage.h" - -#include "AIController.h" -#include "Engine/World.h" -#include "TimerManager.h" -#include "Animation/AnimMontage.h" -#include "Components/SkeletalMeshComponent.h" -#include "GameFramework/Character.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTT_PlayAnimMontage) - -DEFINE_LOG_CATEGORY(LogBTT_PlayAnimMontage); - -UBTT_PlayAnimMontage::UBTT_PlayAnimMontage(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - NodeName = "PlayAnimMontage"; - // instantiating to be able to use Timers - bCreateNodeInstance = true; -} - -EBTNodeResult::Type UBTT_PlayAnimMontage::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) -{ - AIOwner = OwnerComp.GetAIOwner(); - ACharacter* Character = AIOwner.IsValid() ? AIOwner->GetCharacter() : nullptr; - - bool bPlayMontage = PlayMontage( - Character ? Character->GetMesh() : nullptr, - AnimMontage, - PlayRate, - StartingPosition, - StartSectionName - ); - - return bPlayMontage ? EBTNodeResult::InProgress : EBTNodeResult::Failed; -} - -EBTNodeResult::Type UBTT_PlayAnimMontage::AbortTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) -{ - ClearMontageDelegate(); - - if (StopMontageOnAbort && AIOwner.IsValid()) - { - if (ACharacter* Character = AIOwner->GetCharacter()) - { - Character->StopAnimMontage(); - } - } - return Super::AbortTask(OwnerComp, NodeMemory); -} - -void UBTT_PlayAnimMontage::OnTaskFinished(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory,EBTNodeResult::Type TaskResult) -{ - ClearMontageDelegate(); - Super::OnTaskFinished(OwnerComp, NodeMemory, TaskResult); -} - -FString UBTT_PlayAnimMontage::GetStaticDescription() const -{ - return FString::Printf( - TEXT( - "AnimMontage: %s\n" - "PlayRate: %f\n" - "StartingPosition: %f\n" - "StartSectionName: %s\n" - "StopMontageOnAbort: %s\n" - "TaskNodeEndPolicy: %s"), - AnimMontage ? *AnimMontage->GetName() : TEXT("None"), - PlayRate, - StartingPosition, - *StartSectionName.ToString(), - StopMontageOnAbort ? TEXT("True") : TEXT("False"), - TaskNodeEndPolicy == ETaskNodeEndPolicy::OnMontageEnded ? TEXT("OnMontageEnded") : TEXT("OnMontageBlendingOut") - ); -} - - -bool UBTT_PlayAnimMontage::PlayMontage(USkeletalMeshComponent* InSkeletalMeshComponent, UAnimMontage* MontageToPlay, - float InPlayRate, float InStartingPosition, FName InStartingSection) -{ - bool bPlayedSuccessfully = false; - - if (UAnimInstance* AnimInstance = InSkeletalMeshComponent ? InSkeletalMeshComponent->GetAnimInstance() : nullptr) - { - const float MontageLength = AnimInstance->Montage_Play(MontageToPlay, InPlayRate,EMontagePlayReturnType::MontageLength,InStartingPosition); - - bPlayedSuccessfully = (MontageLength > 0.f); - - if (bPlayedSuccessfully) - { - if (InStartingSection != NAME_None) - { - AnimInstance->Montage_JumpToSection(InStartingSection, MontageToPlay); - } - - /** - * If a callback is set within this Tick, the notification of the previous montage interrupted will be called! - * We need to consume a Tick to prevent the notification of the previous montage interrupted - * from triggering on the current launched montage - */ - GetWorld()->GetTimerManager().SetTimerForNextTick([&]() - { - ACharacter* Character = AIOwner.IsValid() ? AIOwner->GetCharacter() : nullptr; - USkeletalMeshComponent* MeshComponent = Character ? Character->GetMesh() : nullptr; - UAnimInstance* AnimIns = MeshComponent ? MeshComponent->GetAnimInstance() : nullptr; - if (AnimIns) - { - if (TaskNodeEndPolicy == ETaskNodeEndPolicy::OnMontageBlendingOut) - { - AnimIns->OnMontageBlendingOut.AddUniqueDynamic( - this, &UBTT_PlayAnimMontage::OnMontageBlendingOut); - } - else if (TaskNodeEndPolicy == ETaskNodeEndPolicy::OnMontageEnded) - { - AnimIns->OnMontageEnded.AddUniqueDynamic(this, &UBTT_PlayAnimMontage::OnMontageEnded); - } - } - }); - } - } - - return bPlayedSuccessfully; -} - - -void UBTT_PlayAnimMontage::OnMontageEnded(UAnimMontage* InAnimMontage, bool bInterrupted) -{ - if (InAnimMontage != AnimMontage) - { - return; - } - - FinishTaskNode(); -} - -void UBTT_PlayAnimMontage::OnMontageBlendingOut(UAnimMontage* InAnimMontage, bool bInterrupted) -{ - if (InAnimMontage != AnimMontage) - { - return; - } - - FinishTaskNode(); -} - -void UBTT_PlayAnimMontage::FinishTaskNode() -{ - UBehaviorTreeComponent* OwnerComp = AIOwner.IsValid()? Cast(AIOwner->BrainComponent): nullptr; - - ClearMontageDelegate(); - - if (OwnerComp) - { - FinishLatentTask(*OwnerComp, EBTNodeResult::Succeeded); - } -} - -void UBTT_PlayAnimMontage::ClearMontageDelegate() -{ - if (AIOwner.IsValid()) - { - ACharacter* Character = AIOwner->GetCharacter(); - USkeletalMeshComponent* MeshComponent = Character ? Character->GetMesh() : nullptr; - UAnimInstance* AnimInstance = MeshComponent ? MeshComponent->GetAnimInstance() : nullptr; - - if (AnimInstance) - { - AnimInstance->OnMontageEnded.RemoveAll(this); - AnimInstance->OnMontageBlendingOut.RemoveAll(this); - } - } -} diff --git a/Source/UHLAI/Private/Tasks/BTT_SetBBValue.cpp b/Source/UHLAI/Private/Tasks/BTT_SetBBValue.cpp deleted file mode 100644 index 5a02b1f8..00000000 --- a/Source/UHLAI/Private/Tasks/BTT_SetBBValue.cpp +++ /dev/null @@ -1,266 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Tasks/BTT_SetBBValue.h" - -#include "UHLAIBlueprintLibrary.h" -#include "BehaviorTree/BehaviorTree.h" -#include "Utils/UnrealHelperLibraryBPL.h" -#include "BehaviorTree/BlackboardComponent.h" -#include "BehaviorTree/BlackboardData.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Bool.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Class.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Enum.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Float.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Int.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Name.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_NativeEnum.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Object.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Rotator.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_String.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Vector.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTT_SetBBValue) - -UBTT_SetBBValue::UBTT_SetBBValue(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - ObjectValue.AddObjectFilter(this, GET_MEMBER_NAME_CHECKED(UBTT_SetBBValue, ObjectValue), UObject::StaticClass()); -} - -EBTNodeResult::Type UBTT_SetBBValue::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) -{ - const UBlackboardData* BlackboardAsset = GetBlackboardAsset(); - UBlackboardComponent* BlackboardComponent = OwnerComp.GetBlackboardComponent(); - if (!BlackboardAsset) return EBTNodeResult::Failed; - - BlackboardKey.ResolveSelectedKey(*BlackboardAsset); - - const FBlackboardEntry* EntryInfo = BlackboardAsset ? BlackboardAsset->GetKey(BlackboardKey.GetSelectedKeyID()) : NULL; - - - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Bool::StaticClass()) - { - BlackboardComponent->SetValueAsBool(BlackboardKey.SelectedKeyName, BoolValue); - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Int::StaticClass()) - { - int32 CurrentValue = BlackboardComponent->GetValueAsInt(BlackboardKey.SelectedKeyName); - int32 Result = OperationOnBBValue.CalculateIntResult(OwnerComp, CurrentValue); - BlackboardComponent->SetValueAsInt(BlackboardKey.SelectedKeyName, Result); - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Float::StaticClass()) - { - float CurrentValue = BlackboardComponent->GetValueAsFloat(BlackboardKey.SelectedKeyName); - float Result = OperationOnBBValue.CalculateFloatResult(OwnerComp, CurrentValue); - BlackboardComponent->SetValueAsFloat(BlackboardKey.SelectedKeyName, Result); - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_String::StaticClass()) - { - BlackboardComponent->SetValueAsString(BlackboardKey.SelectedKeyName, StringValue); - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Name::StaticClass()) - { - BlackboardComponent->SetValueAsName(BlackboardKey.SelectedKeyName, NameValue); - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Vector::StaticClass()) - { - FVector CurrentValue = BlackboardComponent->GetValueAsVector(BlackboardKey.SelectedKeyName); - FVector Result = OperationOnBBValue.CalculateVectorResult(OwnerComp, CurrentValue); - BlackboardComponent->SetValueAsVector(BlackboardKey.SelectedKeyName, Result); - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Rotator::StaticClass()) - { - FRotator CurrentValue = BlackboardComponent->GetValueAsRotator(BlackboardKey.SelectedKeyName); - FRotator Result = OperationOnBBValue.CalculateRotatorResult(OwnerComp, CurrentValue); - BlackboardComponent->SetValueAsRotator(BlackboardKey.SelectedKeyName, Result); - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Enum::StaticClass()) - { - CurrentEnum = ((UBlackboardKeyType_Enum*)(EntryInfo->KeyType))->EnumType; - if (CurrentEnum) - { - BlackboardComponent->SetValueAsEnum(BlackboardKey.SelectedKeyName, CurrentEnum->GetValueByNameString(EnumStringValue)); - } - else - { - UUnrealHelperLibraryBPL::DebugPrintStrings("Enum from BB key ", BlackboardKey.SelectedKeyName.ToString(), "not found"); - } - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_NativeEnum::StaticClass()) - { - CurrentEnum = ((UBlackboardKeyType_NativeEnum*)(EntryInfo->KeyType))->EnumType; - if (CurrentEnum) - { - BlackboardComponent->SetValueAsEnum(BlackboardKey.SelectedKeyName, CurrentEnum->GetValueByNameString(EnumStringValue)); - } - else - { - UUnrealHelperLibraryBPL::DebugPrintStrings("Enum from BB key ", BlackboardKey.SelectedKeyName.ToString(), "not found"); - } - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Object::StaticClass()) - { - if (ObjectValue.NeedsResolving()) - { - ObjectValue.ResolveSelectedKey(*BlackboardAsset); - } - BlackboardComponent->SetValueAsObject(BlackboardKey.SelectedKeyName, BlackboardComponent->GetValueAsObject(ObjectValue.SelectedKeyName)); - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Class::StaticClass()) - { - BlackboardComponent->SetValueAsClass(BlackboardKey.SelectedKeyName, ClassValue); - } - - return Super::ExecuteTask(OwnerComp, NodeMemory); -} - -FString UBTT_SetBBValue::GetStaticDescription() const -{ - FString Description = FString(); - - switch (CurrentBBKeyValueType) - { - case EBlackboardValueType::Bool: - Description = FString::Printf(TEXT("Set \"%s\" to %s"), *BlackboardKey.SelectedKeyName.ToString(), BoolValue ? TEXT("true") : TEXT("false")); - break; - case EBlackboardValueType::Int: - Description = OperationOnBBValue.ToStringIntValue(BlackboardKey.SelectedKeyName.ToString()); - break; - case EBlackboardValueType::Float: - Description = OperationOnBBValue.ToStringFloatValue(BlackboardKey.SelectedKeyName.ToString()); - break; - case EBlackboardValueType::String: - Description = FString::Printf(TEXT("Set \"%s\" to %s"), *BlackboardKey.SelectedKeyName.ToString(), *StringValue); - break; - case EBlackboardValueType::Name: - Description = FString::Printf(TEXT("Set \"%s\" to %s"), *BlackboardKey.SelectedKeyName.ToString(), *NameValue.ToString()); - break; - case EBlackboardValueType::Vector: - Description = OperationOnBBValue.ToStringVectorValue(BlackboardKey.SelectedKeyName.ToString()); - break; - case EBlackboardValueType::Rotator: - Description = OperationOnBBValue.ToStringRotatorValue(BlackboardKey.SelectedKeyName.ToString()); - break; - case EBlackboardValueType::Enum: - Description = FString::Printf(TEXT("Set \"%s\" to %s"), *BlackboardKey.SelectedKeyName.ToString(), *EnumStringValue); - break; - case EBlackboardValueType::NativeEnum: - Description = FString::Printf(TEXT("Set \"%s\" to %s"), *BlackboardKey.SelectedKeyName.ToString(), *EnumStringValue); - break; - case EBlackboardValueType::Object: - Description = FString::Printf(TEXT("Set \"%s\" to %s"), *BlackboardKey.SelectedKeyName.ToString(), *ObjectValue.SelectedKeyName.ToString()); - break; - case EBlackboardValueType::Class: - Description = FString::Printf(TEXT("Set \"%s\" to %s"), *BlackboardKey.SelectedKeyName.ToString(), ClassValue ? *ClassValue->GetName() : TEXT("")); - break; - default: - break; - } - - // return FString::Printf(TEXT("%s: \n%s"), *Super::GetStaticDescription(), *Description); - return FString::Printf(TEXT("%s"), *Description); -} - -void UBTT_SetBBValue::InitializeFromAsset(UBehaviorTree& Asset) -{ - Super::InitializeFromAsset(Asset); - - BlackboardKey.ResolveSelectedKey(*Asset.BlackboardAsset); - - CurrentBBKeyValueType = UUHLAIBlueprintLibrary::BlackboardKeyToBBValueType(BlackboardKey); - OperationOnBBValue.SetCurrentBBKeyValueType(CurrentBBKeyValueType); -} - -void UBTT_SetBBValue::PostLoad() -{ - Super::PostLoad(); - - // migrate to FOperationOnBBValue - if (!bMigratedToMathOperation) - { - if (MathOperation != EUHL_MathOperations::None) - { - OperationOnBBValue.MathOperation = MathOperation; - MathOperation = EUHL_MathOperations::None; - } - if (IntValue != 0) - { - OperationOnBBValue.IntValue = IntValue; - IntValue = 0; - }; - if (FloatValue != 0) - { - OperationOnBBValue.FloatValue = FloatValue; - FloatValue = 0; - }; - if (VectorValue != FVector::ZeroVector) - { - OperationOnBBValue.VectorValue = VectorValue; - VectorValue = FVector::ZeroVector; - }; - if (RotatorValue != FRotator::ZeroRotator) - { - OperationOnBBValue.RotatorValue = RotatorValue; - RotatorValue = FRotator::ZeroRotator; - }; - - bMigratedToMathOperation = true; - } -} - -#if WITH_EDITOR -void UBTT_SetBBValue::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) -{ - Super::PostEditChangeProperty(PropertyChangedEvent); - - const UBlackboardData* BlackboardAsset = GetBlackboardAsset(); - if (!BlackboardAsset) return; - - if (!BlackboardKey.IsSet()) return; - BlackboardKey.ResolveSelectedKey(*BlackboardAsset); - - CurrentBBKeyValueType = UUHLAIBlueprintLibrary::BlackboardKeyToBBValueType(BlackboardKey); - OperationOnBBValue.SetCurrentBBKeyValueType(CurrentBBKeyValueType); - - // if (CurrentBBKeyValueType == EBlackboardValueType::Int) - // { - // MathOperation = EUHL_MathOperations::Set; - // } -} -#endif - -TArray UBTT_SetBBValue::GetEnumOptions() -{ - TArray Result = {}; - - const UBlackboardData* BlackboardAsset = GetBlackboardAsset(); - if (!BlackboardAsset) return Result; - - BlackboardKey.ResolveSelectedKey(*BlackboardAsset); - const FBlackboardEntry* EntryInfo = BlackboardAsset ? BlackboardAsset->GetKey(BlackboardKey.GetSelectedKeyID()) : NULL; - - if (BlackboardKey.SelectedKeyType != UBlackboardKeyType_Enum::StaticClass() - || BlackboardKey.SelectedKeyType != UBlackboardKeyType_NativeEnum::StaticClass()) - { - return Result; - } - - if (!EntryInfo) return Result; - - const UEnum* Enum = (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Enum::StaticClass()) - ? ((UBlackboardKeyType_Enum*)(EntryInfo->KeyType))->EnumType - : ((UBlackboardKeyType_NativeEnum*)(EntryInfo->KeyType))->EnumType; - - if (!Enum || !Enum->IsValidLowLevel()) - { - return Result; - } - - for (int32 i = 0; i < Enum->NumEnums(); i++) - { - Result.Add(Enum->GetNameByIndex(i).ToString()); - } - - return Result; -} diff --git a/Source/UHLAI/Private/Tasks/BTT_TurnTo.cpp b/Source/UHLAI/Private/Tasks/BTT_TurnTo.cpp deleted file mode 100644 index 90f5e546..00000000 --- a/Source/UHLAI/Private/Tasks/BTT_TurnTo.cpp +++ /dev/null @@ -1,364 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Tasks/BTT_TurnTo.h" - -#include "AIController.h" -#include "BehaviorTree/BlackboardComponent.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Object.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Rotator.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Vector.h" -#include "GameFramework/Actor.h" -#include "GameFramework/Character.h" -#include "Animation/AnimMontage.h" -#include "DrawDebugHelpers.h" -#include "Core/UHLAIActorSettings.h" -#include "Utils/UnrealHelperLibraryBPL.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(BTT_TurnTo) - -void UBTT_TurnTo::SetupPreset_Default_90_180() -{ - TurnSettings.SetupPreset_Default_90_180(); -} - -void UBTT_TurnTo::SetupPreset_BigEnemy_90_180() -{ - TurnSettings.SetupPreset_BigEnemy_90_180(); -} - -void UBTT_TurnTo::SetupPreset_45_90_180() -{ - TurnSettings.SetupPreset_45_90_180(); -} - -void UBTT_TurnTo::SetupPreset_15_45_90_180() -{ - TurnSettings.SetupPreset_15_45_90_180(); -} - -void UBTT_TurnTo::SetupPreset_15_30_45_90_180() -{ - TurnSettings.SetupPreset_15_30_45_90_180(); -} - -void UBTT_TurnTo::Cleanup() -{ - TurnSettings.Cleanup(); -} - -UBTT_TurnTo::UBTT_TurnTo(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) - , Precision(10.f) -{ - NodeName = "TurnTo"; - INIT_TASK_NODE_NOTIFY_FLAGS(); - - // accept only actors and vectors - BlackboardKey.AddObjectFilter(this, GET_MEMBER_NAME_CHECKED(UBTT_TurnTo, BlackboardKey), AActor::StaticClass()); - // TODO add support for Vectors/Rotators - BlackboardKey.AddVectorFilter(this, GET_MEMBER_NAME_CHECKED(UBTT_TurnTo, BlackboardKey)); - // BlackboardKey.AddRotatorFilter(this, GET_MEMBER_NAME_CHECKED(UBTT_TurnTo, BlackboardKey)); -} - -void UBTT_TurnTo::PostInitProperties() -{ - Super::PostInitProperties(); - - PrecisionDot = FMath::Cos(FMath::DegreesToRadians(Precision)); -} - -void UBTT_TurnTo::PostLoad() -{ - Super::PostLoad(); - - PrecisionDot = FMath::Cos(FMath::DegreesToRadians(Precision)); -} - -EBTNodeResult::Type UBTT_TurnTo::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) -{ - AAIController* AIController = OwnerComp.GetAIOwner(); - - if (AIController == NULL || AIController->GetPawn() == NULL) - { - return EBTNodeResult::Failed; - } - - FBTTurnToMemory* MyMemory = CastInstanceNodeMemory(NodeMemory); - check(MyMemory); - MyMemory->Reset(); - - EBTNodeResult::Type Result = EBTNodeResult::Failed; - - APawn* Pawn = AIController->GetPawn(); - - const FVector PawnLocation = Pawn->GetActorLocation(); - const UBlackboardComponent* MyBlackboard = OwnerComp.GetBlackboardComponent(); - - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Object::StaticClass()) - { - UObject* KeyValue = MyBlackboard->GetValue(BlackboardKey.GetSelectedKeyID()); - AActor* ActorValue = Cast(KeyValue); - - if (ActorValue != NULL) - { - const FVector::FReal AngleDifference = TurnToStatics::CalculateAngleDifferenceDot(Pawn->GetActorForwardVector() - , (ActorValue->GetActorLocation() - PawnLocation)); - - if (AngleDifference >= PrecisionDot) - { - Result = EBTNodeResult::Succeeded; - } - else - { - AIController->SetFocus(ActorValue, EAIFocusPriority::Gameplay); - MyMemory->FocusActorSet = ActorValue; - MyMemory->bActorSet = true; - if (Pawn->GetClass()->ImplementsInterface(UUHLAIActorSettings::StaticClass())) - { - MyMemory->TurnSettings = GetTurnSettings(Pawn, MyMemory->bCurrentTurnSettingsSet); - } - Result = EBTNodeResult::InProgress; - } - } - } - // TODO add support for Vectors/Rotators - else if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Vector::StaticClass()) - { - const FVector KeyValue = MyBlackboard->GetValue(BlackboardKey.GetSelectedKeyID()); - - if (FAISystem::IsValidLocation(KeyValue)) - { - const FVector::FReal AngleDifference = TurnToStatics::CalculateAngleDifferenceDot(Pawn->GetActorForwardVector() - , (KeyValue - PawnLocation)); - - if (AngleDifference >= PrecisionDot) - { - Result = EBTNodeResult::Succeeded; - } - else - { - AIController->SetFocalPoint(KeyValue, EAIFocusPriority::Gameplay); - MyMemory->FocusLocationSet = KeyValue; - MyMemory->bActorSet = false; - if (Pawn->GetClass()->ImplementsInterface(UUHLAIActorSettings::StaticClass())) - { - MyMemory->TurnSettings = GetTurnSettings(Pawn, MyMemory->bCurrentTurnSettingsSet); - } - Result = EBTNodeResult::InProgress; - } - } - } - // else if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Rotator::StaticClass()) - // { - // const FRotator KeyValue = MyBlackboard->GetValue(BlackboardKey.GetSelectedKeyID()); - // - // if (FAISystem::IsValidRotation(KeyValue)) - // { - // const FVector DirectionVector = KeyValue.Vector(); - // const FVector::FReal AngleDifference = CalculateAngleDifferenceDot(Pawn->GetActorForwardVector(), DirectionVector); - // - // if (AngleDifference >= PrecisionDot) - // { - // Result = EBTNodeResult::Succeeded; - // } - // else - // { - // const FVector FocalPoint = PawnLocation + DirectionVector * 10000.0f; - // // set focal somewhere far in the indicated direction - // AIController->SetFocalPoint(FocalPoint, EAIFocusPriority::Gameplay); - // MyMemory->FocusLocationSet = FocalPoint; - // Result = EBTNodeResult::InProgress; - // } - // } - // } - - return Result; -} - -void UBTT_TurnTo::TickTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) -{ - AAIController* AIController = OwnerComp.GetAIOwner(); - - FBTTurnToMemory* MyMemory = CastInstanceNodeMemory(NodeMemory); - check(MyMemory); - - if (AIController == NULL || AIController->GetPawn() == NULL) - { - FinishLatentTask(OwnerComp, EBTNodeResult::Failed); - } - else - { - const FVector PawnDirection = AIController->GetPawn()->GetActorForwardVector(); - const FVector FocalPoint = AIController->GetFocalPointForPriority(EAIFocusPriority::Gameplay); - ACharacter* AICharacter = AIController->GetCharacter(); - - if (FocalPoint != FAISystem::InvalidLocation) - { - float DeltaAngleRad = TurnToStatics::CalculateAngleDifferenceDot(PawnDirection, FocalPoint - AIController->GetPawn()->GetActorLocation()); - // float DeltaAngle = FMath::RadiansToDegrees(FMath::Acos(DeltaAngleRad)); - float DeltaAngle = MyMemory->bActorSet - ? UUnrealHelperLibraryBPL::RelativeAngleToActor(AICharacter, MyMemory->FocusActorSet) - : UUnrealHelperLibraryBPL::RelativeAngleToVector(AICharacter, MyMemory->FocusLocationSet); - UUnrealHelperLibraryBPL::DebugPrintStrings(FString::Printf(TEXT("DeltaAngle %f"), DeltaAngle), "", "", "", "", "", "", "", "", "", -1, FName("Test")); - - if (bDebug) - { - FVector CurrentLocation = MyMemory->bActorSet - ? MyMemory->FocusActorSet->GetActorLocation() - : MyMemory->FocusLocationSet; - DrawDebugSphere(AIController->GetWorld(), CurrentLocation, - 50.0f, 12, FColor::Blue, false, -1); - } - - if (DeltaAngleRad >= PrecisionDot) - { - UUnrealHelperLibraryBPL::DebugPrintStrings(FString::Printf(TEXT("TurnRange->bOverrideStopMontageOnGoalReached %hhd"), MyMemory->CurrentTurnRange.bOverrideStopMontageOnGoalReached)); - bool bCanStopMontage = false; - if (MyMemory->CurrentTurnRange.bOverrideStopMontageOnGoalReached) - { - bCanStopMontage = MyMemory->CurrentTurnRange.bStopMontageOnGoalReached; - } - else - { - bCanStopMontage = MyMemory->TurnSettings.bStopMontageOnGoalReached; - } - - if (MyMemory && bCanStopMontage) - { - AICharacter->StopAnimMontage(); - CleanUp(*AIController, NodeMemory); - FinishLatentTask(OwnerComp, EBTNodeResult::Succeeded); - } - else - { - CleanUp(*AIController, NodeMemory); - FinishLatentTask(OwnerComp, EBTNodeResult::Succeeded); - } - } - else - { - if (TurnToStatics::IsTurnWithAnimationRequired(AICharacter)) - { - MyMemory->CurrentTurnRange = TurnToStatics::GetTurnRange(DeltaAngle, MyMemory->bCurrentTurnRangeSet, MyMemory->TurnSettings); - if (MyMemory->bCurrentTurnRangeSet && MyMemory->CurrentTurnRange.AnimMontage) - { - AICharacter->PlayAnimMontage(MyMemory->CurrentTurnRange.AnimMontage); - } - - // TODO тут ошибка? - // finish if no turn animation found and "bTurnOnlyWithAnims" - if (!MyMemory->bCurrentTurnRangeSet && MyMemory->TurnSettings.bTurnOnlyWithAnims) - { - CleanUp(*AIController, NodeMemory); - FinishLatentTask(OwnerComp, EBTNodeResult::Succeeded); - } - } - } - } - else - { - CleanUp(*AIController, NodeMemory); - FinishLatentTask(OwnerComp, EBTNodeResult::Failed); - } - } -} - -void UBTT_TurnTo::CleanUp(AAIController& AIController, uint8* NodeMemory) -{ - FBTTurnToMemory* MyMemory = (FBTTurnToMemory*)NodeMemory; - check(MyMemory); - - bool bClearFocus = false; - if (MyMemory->bActorSet) - { - bClearFocus = (MyMemory->FocusActorSet == AIController.GetFocusActorForPriority(EAIFocusPriority::Gameplay)); - } - else - { - bClearFocus = (MyMemory->FocusLocationSet == AIController.GetFocalPointForPriority(EAIFocusPriority::Gameplay)); - } - - if (bClearFocus) - { - AIController.ClearFocus(EAIFocusPriority::Gameplay); - } -} - -FTurnSettings UBTT_TurnTo::GetTurnSettings(AActor* Actor, bool& bCurrentTurnSettingsSet) -{ - FTurnSettings Result; - bCurrentTurnSettingsSet = false; - if (SettingsSource == EUHLSettingsSource::Actor) - { - Result = IUHLAIActorSettings::Execute_GetTurnSettings(Actor); - bCurrentTurnSettingsSet = true; - } - if (SettingsSource == EUHLSettingsSource::DataAsset) - { - Result = RotateToAnimationsDataAsset->TurnSettings; - bCurrentTurnSettingsSet = true; - } - if (SettingsSource == EUHLSettingsSource::Node) - { - Result = TurnSettings; - bCurrentTurnSettingsSet = true; - } - return Result; -} - -EBTNodeResult::Type UBTT_TurnTo::AbortTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) -{ - AAIController* AIController = OwnerComp.GetAIOwner(); - - if (AIController != NULL) - { - CleanUp(*AIController, NodeMemory); - } - - return EBTNodeResult::Aborted; -} - -void UBTT_TurnTo::DescribeRuntimeValues(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTDescriptionVerbosity::Type Verbosity, TArray& Values) const -{ - FString KeyDesc = BlackboardKey.SelectedKeyName.ToString(); - Values.Add(FString::Printf(TEXT("%s: %s"), *Super::GetStaticDescription(), *KeyDesc)); - - AAIController* AIController = OwnerComp.GetAIOwner(); - - if (AIController != NULL && AIController->GetPawn() != NULL) - { - const FVector PawnDirection = AIController->GetPawn()->GetActorForwardVector(); - const FVector FocalPoint = AIController->GetFocalPointForPriority(EAIFocusPriority::Gameplay); - - if (FocalPoint != FAISystem::InvalidLocation) - { - const FVector::FReal CurrentAngleRadians = TurnToStatics::CalculateAngleDifferenceDot(PawnDirection, (FocalPoint - AIController->GetPawn()->GetActorLocation())); - Values.Add(FString::Printf(TEXT("Current angle: %.2f"), FMath::RadiansToDegrees(FMath::Acos(CurrentAngleRadians)))); - } - else - { - Values.Add(TEXT("FocalPoint is an Invalid Location")); - } - } - else - { - Values.Add(TEXT("Controller or Pawn is NULL")); - } -} - -FString UBTT_TurnTo::GetStaticDescription() const -{ - FString KeyDesc = BlackboardKey.SelectedKeyName.ToString(); - return FString::Printf(TEXT("%s: %s"), *Super::GetStaticDescription(), *KeyDesc); -} - -void UBTT_TurnTo::InitializeMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryInit::Type InitType) const -{ - InitializeNodeMemory(NodeMemory, InitType); -} - -void UBTT_TurnTo::CleanupMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryClear::Type CleanupType) const -{ - CleanupNodeMemory(NodeMemory, CleanupType); -} diff --git a/Source/UHLAI/Private/UHLAI.cpp b/Source/UHLAI/Private/UHLAI.cpp deleted file mode 100644 index b0ba6de1..00000000 --- a/Source/UHLAI/Private/UHLAI.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UHLAI.h" - -#include "Misc/Paths.h" - -#define LOCTEXT_NAMESPACE "FUHLAIModule" - - -void FUHLAIModule::StartupModule() -{ -} - -void FUHLAIModule::ShutdownModule() -{ - // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, - // we call this function before unloading the module. -} - -#undef LOCTEXT_NAMESPACE - -IMPLEMENT_MODULE(FUHLAIModule, UHLAI) diff --git a/Source/UHLAI/Private/UHLAIBlueprintLibrary.cpp b/Source/UHLAI/Private/UHLAIBlueprintLibrary.cpp deleted file mode 100644 index 4e9f5a8e..00000000 --- a/Source/UHLAI/Private/UHLAIBlueprintLibrary.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UHLAIBlueprintLibrary.h" - -#include "BehaviorTree/Blackboard/BlackboardKeyType_Bool.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Class.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Enum.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Float.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Int.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Name.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_NativeEnum.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Object.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Rotator.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_String.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Vector.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLAIBlueprintLibrary) - - -EBlackboardValueType UUHLAIBlueprintLibrary::BlackboardKeyToBBValueType(FBlackboardKeySelector BlackboardKey) -{ - EBlackboardValueType Result = EBlackboardValueType::None; - - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Bool::StaticClass()) - { - Result = EBlackboardValueType::Bool; - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Int::StaticClass()) - { - Result = EBlackboardValueType::Int; - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Float::StaticClass()) - { - Result = EBlackboardValueType::Float; - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_String::StaticClass()) - { - Result = EBlackboardValueType::String; - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Name::StaticClass()) - { - Result = EBlackboardValueType::Name; - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Vector::StaticClass()) - { - Result = EBlackboardValueType::Vector; - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Rotator::StaticClass()) - { - Result = EBlackboardValueType::Rotator; - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Enum::StaticClass()) - { - Result = EBlackboardValueType::Enum; - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_NativeEnum::StaticClass()) - { - Result = EBlackboardValueType::NativeEnum; - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Object::StaticClass()) - { - Result = EBlackboardValueType::Object; - } - if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Class::StaticClass()) - { - Result = EBlackboardValueType::Class; - } - - return Result; -} \ No newline at end of file diff --git a/Source/UHLAI/Private/UHLAIBlueprintLibrary.h b/Source/UHLAI/Private/UHLAIBlueprintLibrary.h deleted file mode 100644 index 3961138b..00000000 --- a/Source/UHLAI/Private/UHLAIBlueprintLibrary.h +++ /dev/null @@ -1,36 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "Core/UHLBlackboardValueType.h" -#include "Kismet/BlueprintFunctionLibrary.h" -#include "UHLAIBlueprintLibrary.generated.h" - -class UWidget; -struct FBlackboardKeySelector; - -/* - * Function library class. - * Each function in it is expected to be static and represents blueprint node that can be called in any blueprint. - * - * When declaring function you can define metadata for the node. Key function specifiers will be BlueprintPure and BlueprintCallable. - * BlueprintPure - means the function does not affect the owning object in any way and thus creates a node without Exec pins. - * BlueprintCallable - makes a function which can be executed in Blueprints - Thus it has Exec pins. - * DisplayName - full name of the node, shown when you mouse over the node and in the blueprint drop down menu. - * Its lets you name the node using characters not allowed in C++ function names. - * CompactNodeTitle - the word(s) that appear on the node. - * Keywords - the list of keywords that helps you to find node when you search for it using Blueprint drop-down menu. - * Good example is "Print String" node which you can find also by using keyword "log". - * Category - the category your node will be under in the Blueprint drop-down menu. - * - * For more info on custom blueprint nodes visit documentation: - * https://wiki.unrealengine.com/Custom_Blueprint_Node_Creation - */ -UCLASS() -class UHLAI_API UUHLAIBlueprintLibrary : public UBlueprintFunctionLibrary -{ - GENERATED_BODY() - -public: - static EBlackboardValueType BlackboardKeyToBBValueType(FBlackboardKeySelector BlackboardKey); -}; diff --git a/Source/UHLAI/Private/UHLValueOrBBKey_GameplayTag.cpp b/Source/UHLAI/Private/UHLValueOrBBKey_GameplayTag.cpp deleted file mode 100644 index c7b59de3..00000000 --- a/Source/UHLAI/Private/UHLValueOrBBKey_GameplayTag.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "UHLValueOrBBKey_GameplayTag.h" - -#include "GameplayTagContainer.h" -#include "BehaviorTree/ValueOrBBKey.h" -#include "BehaviorTree/Blackboard/BlackboardKeyType_Name.h" -#include "Utils/UnrealHelperLibraryBPL.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLValueOrBBKey_GameplayTag) - -FGameplayTag FUHLValueOrBBKey_GameplayTag::GetValue(const UBlackboardComponent& Blackboard) const -{ - FName TagName = FBlackboard::GetValue(Blackboard, Key, KeyId, DefaultValue.GetTagName()); - FGameplayTag FoundGameplayTag = FGameplayTag::RequestGameplayTag(TagName, false); - if (!FoundGameplayTag.IsValid()) - { - UUnrealHelperLibraryBPL::DebugPrintString(Blackboard.GetWorld(), - FString::Printf(TEXT("FUHLValueOrBBKey_GameplayTag::GetValue GameplayTag %s not found"), *Key.ToString()) - ); - return DefaultValue; - } - return FoundGameplayTag; -} - -FGameplayTag FUHLValueOrBBKey_GameplayTag::GetValue(const UBlackboardComponent* Blackboard) const -{ - return Blackboard ? GetValue(*Blackboard) : DefaultValue; -} - -FGameplayTag FUHLValueOrBBKey_GameplayTag::GetValue(const UBehaviorTreeComponent& BehaviorComp) const -{ - FName TagName = FBlackboard::GetValue(BehaviorComp, Key, KeyId, DefaultValue.GetTagName()); - FGameplayTag FoundGameplayTag = FGameplayTag::RequestGameplayTag(TagName, false); - if (!FoundGameplayTag.IsValid()) - { - UUnrealHelperLibraryBPL::DebugPrintString(BehaviorComp.GetWorld(), - FString::Printf(TEXT("FUHLValueOrBBKey_GameplayTag::GetValue GameplayTag %s not found"), *Key.ToString()) - ); - return DefaultValue; - } - return FoundGameplayTag; -} - -FGameplayTag FUHLValueOrBBKey_GameplayTag::GetValue(const UBehaviorTreeComponent* BehaviorComp) const -{ - return BehaviorComp ? GetValue(*BehaviorComp) : DefaultValue; -} - -bool FUHLValueOrBBKey_GameplayTag::SerializeFromMismatchedTag( - const FPropertyTag& Tag, FStructuredArchive::FSlot Slot) -{ - if (Tag.Type == NAME_StructProperty && Tag.GetType().IsStruct(FGameplayTag::StaticStruct()->GetFName())) - { - FGameplayTag TempTag; - FGameplayTag::StaticStruct()->SerializeItem(Slot, &TempTag, nullptr); - // Slot << TempTag; // Deserialize the data as an FGameplayTag - DefaultValue = TempTag; // Store it in a compatible property - return true; - } - return false; -} - -#if WITH_EDITOR -bool FUHLValueOrBBKey_GameplayTag::IsCompatibleType(const UBlackboardKeyType* KeyType) const -{ - return KeyType && KeyType->GetClass() == UBlackboardKeyType_Name::StaticClass(); -} -#endif - -FString FUHLValueOrBBKey_GameplayTag::ToString() const -{ - if (!Key.IsNone()) - { - return ToStringKeyName(); - } - else - { - return DefaultValue.GetTagName().ToString(); - } -} diff --git a/Source/UHLAI/Public/Components/UHLAIPerceptionComponent.h b/Source/UHLAI/Public/Components/UHLAIPerceptionComponent.h deleted file mode 100644 index 699323f3..00000000 --- a/Source/UHLAI/Public/Components/UHLAIPerceptionComponent.h +++ /dev/null @@ -1,24 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Perception/AIPerceptionComponent.h" -#include "UHLAIPerceptionComponent.generated.h" - -DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnSightStimulusExpired, const FAIStimulus&, StimulusStore); - -/** - * - */ -UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) -class UHLAI_API UUHLAIPerceptionComponent : public UAIPerceptionComponent -{ - GENERATED_BODY() - -public: - virtual void HandleExpiredStimulus(FAIStimulus& StimulusStore) override; - - UPROPERTY(BlueprintAssignable, Category="UHL AIPerceptionComponent") - FOnSightStimulusExpired OnSightStimulusExpired; -}; diff --git a/Source/UHLAI/Public/Composite/BTC_RandomSelector.h b/Source/UHLAI/Public/Composite/BTC_RandomSelector.h deleted file mode 100644 index b821f195..00000000 --- a/Source/UHLAI/Public/Composite/BTC_RandomSelector.h +++ /dev/null @@ -1,65 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "UObject/ObjectMacros.h" -#include "BehaviorTree/BTCompositeNode.h" -#include "BehaviorTree/BehaviorTreeTypes.h" -#include "Misc/EngineVersionComparison.h" -#include "BTC_RandomSelector.generated.h" - -class UBehaviorTreeComponent; - -// Should nest from "FBTCompositeMemory" or build error fail on FAB servers -// struct FBTRandomSelectorMemory : public FBTCompositeMemory -// { -// }; - -/** - * RandomSelector composite node. - * RandomSelector random between child nodes using chances, and will stop executing its children when one of their children succeeds. - * If a Selector's child succeeds, the Selector succeeds. If all the Selector's children fail, the Selector fails. - * P.S. space for improvement - memory, but not sure that its required, - * just random until we get valid node is seems looks like is enough - * https://www.youtube.com/watch?v=wI_kwwvc-pw&t=781s&ab_channel=VeryHotShark - */ -UCLASS(Category = "UnrealHelperLibrary") -class UHLAI_API UBTC_RandomSelector : public UBTCompositeNode -{ - GENERATED_BODY() - -public: - UBTC_RandomSelector(const FObjectInitializer& ObjectInitializer); - - // TODO validate that chances count == ChildrenNum - // if no chance specified, node without chance will win always - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="RandomSelector", meta=(ForceUnits="Multiplier")) - TArray ChancesArray = { 0.5f, 0.5f }; - - UFUNCTION(BlueprintCallable, CallInEditor, Category="RandomSelector") - void RemoveUnusedChances(); - -protected: - virtual int32 GetNextChildHandler(struct FBehaviorTreeSearchData& SearchData, int32 PrevChild, EBTNodeResult::Type LastResult) const override; - virtual FString GetStaticDescription() const override; - -#if WITH_EDITOR - virtual FName GetNodeIconName() const override; -#endif - -#if UE_VERSION_NEWER_THAN(5, 4, 0) - // 5.4.0 and up only code - virtual void InitializeMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryInit::Type InitType) const override; - virtual void CleanupMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryClear::Type CleanupType) const override; -#endif - -private: - UFUNCTION() - bool IsValidSelector() const { return GetChildrenNum() > 1 && GetChildrenNum() <= ChancesArray.Num(); }; - UFUNCTION() - FString GetErrorOrWarning() const; - UFUNCTION() - int32 GetRandomChildIdx() const; - -}; diff --git a/Source/UHLAI/Public/Core/UHLAIActorSettings.h b/Source/UHLAI/Public/Core/UHLAIActorSettings.h deleted file mode 100644 index 6e1e8929..00000000 --- a/Source/UHLAI/Public/Core/UHLAIActorSettings.h +++ /dev/null @@ -1,31 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Data/TurnSettings.h" -#include "UObject/Interface.h" -#include "UHLAIActorSettings.generated.h" - -// This class does not need to be modified. -UINTERFACE(MinimalAPI) -class UUHLAIActorSettings : public UInterface -{ - GENERATED_BODY() -}; - -/** - * - */ -class UHLAI_API IUHLAIActorSettings -{ - GENERATED_BODY() - - // Add interface functions to this class. This is the class that will be inherited to implement this interface. -public: - -/** IUHLActorSettings */ - UFUNCTION(Category="UHLActorSettings", BlueprintCallable, BlueprintNativeEvent) - FTurnSettings GetTurnSettings() const; -/** ~IUHLActorSettings */ -}; diff --git a/Source/UHLAI/Public/Core/UHLAIDebugSettings.h b/Source/UHLAI/Public/Core/UHLAIDebugSettings.h deleted file mode 100644 index eda9c18e..00000000 --- a/Source/UHLAI/Public/Core/UHLAIDebugSettings.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include "BehaviorTree/ValueOrBBKey.h" - -#include "UHLAIDebugSettings.generated.h" - -// struct for easier creating BBValue + BBValue math operations -USTRUCT(BlueprintType) -struct FUHLAIDebugSettings -{ - GENERATED_BODY() - - UPROPERTY(Category="Decorator", EditAnywhere) - bool bEnableDebug = false; - - UPROPERTY(Category="Decorator", EditAnywhere) - FValueOrBBKey_Float DrawDebugTime = 2.0f; - - UPROPERTY(Category="Decorator", EditAnywhere) - FColor Color = FLinearColor(0, 0.66, 1).ToFColor(true); -}; diff --git a/Source/UHLAI/Public/Core/UHLBlackboardValueType.h b/Source/UHLAI/Public/Core/UHLBlackboardValueType.h deleted file mode 100644 index 4690a567..00000000 --- a/Source/UHLAI/Public/Core/UHLBlackboardValueType.h +++ /dev/null @@ -1,23 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#pragma once - -#include "UHLBlackboardValueType.generated.h" - -UENUM() -enum class EBlackboardValueType -{ - None, - Bool, - Int, - Float, - String, - Name, - Vector, - Rotator, - Enum, - NativeEnum, - Object, - Class, -}; \ No newline at end of file diff --git a/Source/UHLAI/Public/Core/UHLMathOperations.h b/Source/UHLAI/Public/Core/UHLMathOperations.h deleted file mode 100644 index c8c96f74..00000000 --- a/Source/UHLAI/Public/Core/UHLMathOperations.h +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once - -#include "UHLBlackboardValueType.h" -#include "BehaviorTree/BehaviorTreeTypes.h" -#include "BehaviorTree/ValueOrBBKey.h" -#include "UHLMathOperations.generated.h" - -UENUM(BlueprintType) -enum class EUHL_MathOperations : uint8 -{ - None UMETA(Hidden), - Set, - Add, - Multiply, - Divide, -}; - -// struct for easier creating BBValue + BBValue math operations -USTRUCT(BlueprintType) -struct FOperationOnBBValue -{ - GENERATED_BODY() - - UPROPERTY(Category="Blackboard", EditAnywhere, meta=(EditCondition="CurrentBBKeyValueType==EBlackboardValueType::Int || CurrentBBKeyValueType==EBlackboardValueType::Float", EditConditionHides)) - EUHL_MathOperations MathOperation = EUHL_MathOperations::Set; - - /** Values */ - // UPROPERTY(Category="Blackboard", EditAnywhere, meta=(DisplayName="Value", EditCondition="CurrentBBKeyValueType==EBlackboardValueType::Bool", EditConditionHides)) - // bool BoolValue; - - UPROPERTY(Category="Blackboard", EditAnywhere, meta=(DisplayName="Value", EditCondition="CurrentBBKeyValueType==EBlackboardValueType::Int", EditConditionHides)) - FValueOrBBKey_Int32 IntValue; - - UPROPERTY(Category="Blackboard", EditAnywhere, meta=(DisplayName="Value", EditCondition="CurrentBBKeyValueType==EBlackboardValueType::Float", EditConditionHides)) - FValueOrBBKey_Float FloatValue; - - // UPROPERTY(Category="Blackboard", EditAnywhere, meta=(DisplayName="Value", EditCondition="CurrentBBKeyValueType==EBlackboardValueType::String", EditConditionHides, MultiLine)) - // FString StringValue; - // UPROPERTY(Category="Blackboard", EditAnywhere, meta=(DisplayName="Value", EditCondition="CurrentBBKeyValueType==EBlackboardValueType::Name", EditConditionHides, MultiLine)) - // FName NameValue; - - UPROPERTY(Category="Blackboard", EditAnywhere, meta=(DisplayName="Value", EditCondition="CurrentBBKeyValueType==EBlackboardValueType::Vector", EditConditionHides)) - FValueOrBBKey_Vector VectorValue; - - UPROPERTY(Category="Blackboard", EditAnywhere, meta=(DisplayName="Value", EditCondition="CurrentBBKeyValueType==EBlackboardValueType::Rotator", EditConditionHides)) - FValueOrBBKey_Rotator RotatorValue; - /** ~Values */ - - void SetCurrentBBKeyValueType(EBlackboardValueType CurrentBBKeyValueType_In); - - int32 CalculateIntResult(UBehaviorTreeComponent& OwnerComp, int32 CurrentValue) const; - float CalculateFloatResult(UBehaviorTreeComponent& OwnerComp, float CurrentValue) const; - FVector CalculateVectorResult(UBehaviorTreeComponent& OwnerComp, FVector CurrentValue) const; - FRotator CalculateRotatorResult(UBehaviorTreeComponent& OwnerComp, FRotator CurrentValue) const; - - FString ToStringIntValue(FString KeyName) const; - FString ToStringFloatValue(FString KeyName) const; - FString ToStringVectorValue(FString KeyName) const; - FString ToStringRotatorValue(FString KeyName) const; - -private: - UPROPERTY() - EBlackboardValueType CurrentBBKeyValueType = EBlackboardValueType::None; -}; diff --git a/Source/UHLAI/Public/Data/TurnSettings.h b/Source/UHLAI/Public/Data/TurnSettings.h deleted file mode 100644 index 8646ed9d..00000000 --- a/Source/UHLAI/Public/Data/TurnSettings.h +++ /dev/null @@ -1,110 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Engine/DataAsset.h" -#include "TurnSettings.generated.h" - -class UAnimMontage; - -USTRUCT(Blueprintable) -struct FTurnRange -{ - GENERATED_BODY() - -public: - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="TurnRange") - FString Name; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="TurnRange") - FFloatRange Range = FFloatRange(-135, -45); - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="TurnRange") - UAnimMontage* AnimMontage = nullptr; - // useful in big enemies cases, Dragon shouldn't cancel 180deg rotate animation - // even if Player somehow teleported - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="TurnRange") - bool bOverrideStopMontageOnGoalReached = false; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="TurnRange", meta=(EditCondition="bOverrideStopMontageOnGoalReached", EditConditionHides)) - bool bStopMontageOnGoalReached = false; -}; - -USTRUCT(Blueprintable) -struct FTurnRanges -{ - GENERATED_BODY() - -public: - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="TurnRanges") - TArray TurnRanges; -}; - - -/** - * - */ -// TODO make warning that not all ranges are covered -// TODO limit TurnAnimations count e.g. max 3 times, then give choice what to do - abort or success? -// TODO limit playing similar animations count e.g. max 3 times ?? and then give choice what to do - abort or success? -// TIPS -// - ranges can overlap, in such cases animation will be fired by order, so order is important -USTRUCT(Blueprintable) -struct FTurnSettings -{ - GENERATED_BODY() - -public: - UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="TurnSettings", meta=(EditCondition="true", MultiLine)) - FString Notes = FString(TEXT( - "Use cases:" - "\n\n1) Big enemy (dragon, etc.) - better to use with \"bTurnOnlyWithAnims\", \"bStopMontageOnGoalReached\" and \"Precision = 1°\", BlendOut settings in AnimMontage becomes critcal for smooth visual ~0.5s blendout + inertionalization recommended" - "\n\n2) Medium enemy (human size) - disable bTurnOnlyWithAnims nobody will mention that medium enemy rotates in place without anim" - "\n\nTips: " - "\n- ranges can overlap, in such cases animation will be fired by order, so order is important" - )); - - // if enabled - turn only with animations, if no ranges fits - consider it as success - // if disabled - turn also with rotating enemy in place - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="TurnSettings") - bool bTurnOnlyWithAnims = true; - // stops AnimMontage when reached goal, even if 180deg turn animation on half of playing - stop it - // BlendOut settings for this option is critical - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="TurnSettings") - bool bStopMontageOnGoalReached = true; - // TODO bChooseClosestInRaceCondition? если подходят 2 ренджа, в чью пользу принимать решение, зач если есть order TurnRange'ей - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="TurnSettings", meta=(ForceInlineRow)) - TMap TurnRangesGroups; - - void Cleanup(); - void SetupPreset_Default_90_180(); - void SetupPreset_BigEnemy_90_180(); - void SetupPreset_45_90_180(); - void SetupPreset_15_45_90_180(); - void SetupPreset_15_30_45_90_180(); -}; - - -UCLASS(Blueprintable) -class UHLAI_API UTurnSettingsDataAsset : public UPrimaryDataAsset -{ - GENERATED_BODY() - -public: - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="TurnSettings") - FTurnSettings TurnSettings; - - // Prefers to rotate 180deg if relative angle >115deg, suits for all medium mobs(human size) - UFUNCTION(BlueprintCallable, Category="Setup", CallInEditor, meta=(EditCondition="bUseTurnAnimations && !bUseTurnSettingsDataAsset", EditConditionHides, DisplayPriority=1)) - void SetupPreset_Default_90_180(); - // All ranges have same proportion - UFUNCTION(BlueprintCallable, Category="Setup", CallInEditor, meta=(EditCondition="bUseTurnAnimations && !bUseTurnSettingsDataAsset", EditConditionHides, DisplayPriority=1)) - void SetupPreset_BigEnemy_90_180(); - UFUNCTION(BlueprintCallable, CallInEditor, Category="Setup", meta = (DisplayPriority=2)) - void SetupPreset_45_90_180(); - UFUNCTION(BlueprintCallable, CallInEditor, Category="Setup", meta = (DisplayPriority=3)) - void SetupPreset_15_45_90_180(); - UFUNCTION(BlueprintCallable, CallInEditor, Category="Setup", meta = (DisplayPriority=4)) - void SetupPreset_15_30_45_90_180(); - UFUNCTION(BlueprintCallable, CallInEditor, Category="Setup", meta = (DisplayPriority=5)) - void Cleanup(); -}; diff --git a/Source/UHLAI/Public/Decorators/BTD_Base.h b/Source/UHLAI/Public/Decorators/BTD_Base.h deleted file mode 100644 index 49ab6301..00000000 --- a/Source/UHLAI/Public/Decorators/BTD_Base.h +++ /dev/null @@ -1,61 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "BehaviorTree/BehaviorTreeTypes.h" -#include "BehaviorTree/BTDecorator.h" -#include "BTD_Base.generated.h" - -/** - * Used to add abort functionality to BTDecorators - */ -UCLASS(Category = "UnrealHelperLibrary", Abstract) -class UHLAI_API UBTD_Base : public UBTDecorator -{ - GENERATED_BODY() - -public: - UBTD_Base(const FObjectInitializer& ObjectInitializer); - - FString GetPropertiesDetails() const; - /** notify about changes in blackboard */ - virtual EBlackboardNotificationResult OnBlackboardKeyValueChange(const UBlackboardComponent& Blackboard, FBlackboard::FKey ChangedKeyID); - -protected: - // BTDecorator_BlueprintBase - enum class EAbortType : uint8 - { - NoAbort, - ActivateBranch, - DeactivateBranch, - Unknown, - }; - /** gets set to true if decorator declared BB keys it can potentially observe */ - uint32 bIsObservingBB : 1; - /** blackboard key names that should be observed */ - UPROPERTY() - TArray ObservedKeyNames; - /** properties with runtime values, stored only in class default object */ - TArray PropertyData; - /** show detailed information about properties */ - UPROPERTY(EditInstanceOnly, Category=Description) - bool bShowPropertyDetails = true; - /** return this decorator abort type in current circumstances */ - EAbortType EvaluateAbortType(UBehaviorTreeComponent& OwnerComp) const; - void RequestAbort(UBehaviorTreeComponent& OwnerComp, const EAbortType Type); - - virtual void PostLoad() override; - virtual void OnBecomeRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override; - - /** initialize data about blueprint defined properties - * copy-paste from UBTDecorator_BlueprintBase - */ - virtual void InitializeProperties(); - - /** setup node name - * copy-paste from UBTDecorator_BlueprintBase - */ - virtual void PostInitProperties() override; - // ~BTDecorator_BlueprintBase -}; diff --git a/Source/UHLAI/Public/Decorators/BTD_CheckGASGameplayTagsOnActor.h b/Source/UHLAI/Public/Decorators/BTD_CheckGASGameplayTagsOnActor.h deleted file mode 100644 index 6e176007..00000000 --- a/Source/UHLAI/Public/Decorators/BTD_CheckGASGameplayTagsOnActor.h +++ /dev/null @@ -1,48 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "BTD_Base.h" -#include "BehaviorTree/BTDecorator.h" -#include "BTD_CheckGASGameplayTagsOnActor.generated.h" - -/** - * Actor should implement "IAbilitySystemInterface" to get AbilitySystemComponent - */ -UCLASS(Category = "UnrealHelperLibrary", DisplayName="Check GAS Gameplay Tags On Actor") -class UHLAI_API UBTD_CheckGASGameplayTagsOnActor : public UBTD_Base -{ - GENERATED_BODY() - -public: - UBTD_CheckGASGameplayTagsOnActor(const FObjectInitializer& ObjectInitializer); - - virtual bool CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const override; - virtual void DescribeRuntimeValues(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTDescriptionVerbosity::Type Verbosity, TArray& Values) const override; - virtual FString GetStaticDescription() const override; - -protected: - UPROPERTY(EditAnywhere, Category="GameplayTagCheck", Meta=(ToolTips="Which Actor (from the blackboard) should be checked for these GAS gameplay tags?")) - struct FBlackboardKeySelector ActorToCheck; - - UPROPERTY(EditAnywhere, Category="GameplayTagCheck") - EGameplayContainerMatchType TagsToMatch; - - UPROPERTY(EditAnywhere, Category="GameplayTagCheck") - FGameplayTagContainer GameplayTags; - - /** cached description */ - UPROPERTY() - FString CachedDescription; - -#if WITH_EDITOR - /** describe decorator and cache it */ - virtual void BuildDescription(); - - virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override; -#endif - - virtual void InitializeFromAsset(UBehaviorTree& Asset) override; - virtual void TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) override; -}; diff --git a/Source/UHLAI/Public/Decorators/BTD_GameplayEffectCooldown.h b/Source/UHLAI/Public/Decorators/BTD_GameplayEffectCooldown.h deleted file mode 100644 index 896a3131..00000000 --- a/Source/UHLAI/Public/Decorators/BTD_GameplayEffectCooldown.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2024 NextGenium - -#pragma once - -#include "CoreMinimal.h" -#include "GameplayEffect.h" -#include "Decorators/BTD_Base.h" -#include "BTD_GameplayEffectCooldown.generated.h" - -struct FBTGameplayEffectCooldownDecoratorMemory -{ - double LastUseTimestamp; - uint8 bRequestedRestart : 1; -}; - -/** - * TODO: finish node StaticDescription, Runtime and so on - * Actor should implement "IAbilitySystemInterface" - */ -UCLASS() -class UHLAI_API UBTD_GameplayEffectCooldown : public UBTD_Base -{ - GENERATED_BODY() - -public: - UBTD_GameplayEffectCooldown(const FObjectInitializer& ObjectInitializer); - - // Tag used in GameplayEffect to check cooldown - UPROPERTY(Category="Decorator", EditAnywhere) - FGameplayTag CooldownGameplayEffectTag; - - // TODO: make option to check cooldowns by this query - // UPROPERTY(Category="Decorator", EditAnywhere) - // FGameplayEffectQuery GameplayEffectQuery; - - virtual bool CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const override; - virtual void InitializeMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryInit::Type InitType) const override; - virtual void CleanupMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryClear::Type CleanupType) const override; - virtual uint16 GetInstanceMemorySize() const override; - virtual void DescribeRuntimeValues(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTDescriptionVerbosity::Type Verbosity, TArray& Values) const override; - virtual FString GetStaticDescription() const override; - -#if WITH_EDITOR - virtual FName GetNodeIconName() const override; -#endif // WITH_EDITOR - -protected: - virtual void OnNodeDeactivation(FBehaviorTreeSearchData& SearchData, EBTNodeResult::Type NodeResult) override; - virtual void TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) override; - -}; diff --git a/Source/UHLAI/Public/Decorators/BTD_InAngle.h b/Source/UHLAI/Public/Decorators/BTD_InAngle.h deleted file mode 100644 index c2d305b4..00000000 --- a/Source/UHLAI/Public/Decorators/BTD_InAngle.h +++ /dev/null @@ -1,79 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Decorators/BTD_Base.h" -#include "BTD_InAngle.generated.h" - -class ACharacter; - -struct FBTInAngleMemory -{ -}; - -USTRUCT(BlueprintType) -struct FAngleRange -{ - GENERATED_BODY() - -public: - UPROPERTY(Category="Decorator", EditAnywhere) - FFloatRange Range = FFloatRange(); - - // ~"FColor::MakeRandomColor()" will lead to non-critical error - // ~unreal don't support random colors from native code. - // ~They should be deterministic but there is no option - UPROPERTY(Category="Decorator", EditAnywhere) - FColor DebugColor = FColor::Blue; -}; - -/** - * - */ -UCLASS(Category = "UnrealHelperLibrary") -class UHLAI_API UBTD_InAngle : public UBTD_Base -{ - GENERATED_BODY() - -public: - UBTD_InAngle(const FObjectInitializer& ObjectInitializer); - - UPROPERTY(Category="Decorator", EditAnywhere, meta=(EditCondition="", EditConditionHides)) - FBlackboardKeySelector Target; - UPROPERTY(Category="Decorator", EditAnywhere, meta=(EditCondition="", EditConditionHides)) - TArray IncludeRanges; - // UPROPERTY(Category=Decorator, EditAnywhere, meta=(EditCondition="", EditConditionHides)) - // TArray ExcludeRanges; - - // TODO bIncludeTargetCharacterCapsule - checks not only angle to actor - // but also that TargetCharacter capsule in angle - - UPROPERTY(Category="Decorator", EditAnywhere) - bool bDrawDebug = false; - // helpful for testing ranges - UPROPERTY(Category="Decorator", EditAnywhere) - bool bDebugForceFalseCondition = false; - UPROPERTY(Category="Decorator", EditAnywhere) - float OverrideDebugLinesDistance = 0.0f; - - virtual void InitializeFromAsset(UBehaviorTree& Asset) override; - - virtual uint16 GetInstanceMemorySize() const override { return sizeof(FBTInAngleMemory); }; - virtual void InitializeMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryInit::Type InitType) const override; - virtual void CleanupMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryClear::Type CleanupType) const override; - - virtual FString GetStaticDescription() const override; - virtual void DescribeRuntimeValues(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTDescriptionVerbosity::Type Verbosity, TArray& Values) const override; -#if WITH_EDITOR - virtual FName GetNodeIconName() const override; -#endif - - virtual bool CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const override; - bool IsInAngle(float CurrentAngle) const; - -private: - TWeakObjectPtr CachedOwnerCharacter; - - float GetCurrentAngle(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, bool bDrawDebug_In = false) const; -}; diff --git a/Source/UHLAI/Public/Decorators/BTD_InRange.h b/Source/UHLAI/Public/Decorators/BTD_InRange.h deleted file mode 100644 index fe823fa8..00000000 --- a/Source/UHLAI/Public/Decorators/BTD_InRange.h +++ /dev/null @@ -1,67 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "BTD_Base.h" -#include "BehaviorTree/BTCompositeNode.h" -#include "BTD_InRange.generated.h" - -struct FBTInRangeMemory -{ -}; - -/** - * - */ -UCLASS(Category = "UnrealHelperLibrary") -class UHLAI_API UBTD_InRange : public UBTD_Base -{ - GENERATED_BODY() - -public: - UBTD_InRange(const FObjectInitializer& ObjectInitializer); - - UPROPERTY(Category="Decorator", EditAnywhere, meta=(EditCondition="", EditConditionHides)) - FBlackboardKeySelector Target; - UPROPERTY(Category="Decorator", EditAnywhere, meta=(EditCondition="", EditConditionHides)) - float Min = 0.0f; - UPROPERTY(Category="Decorator", EditAnywhere, meta=(EditCondition="", EditConditionHides)) - float Max = 500.0f; - // Should we exclude Self character capsule radius from distance - // mostly for big enemies - // compliant with "MoveTo" - /** if set, radius of AI's capsule will be added to threshold between AI and goal location in destination reach test */ - UPROPERTY(Category="Decorator", EditAnywhere) - bool bIncludeSelfCapsuleRadius = true; - // Should we exclude Target character capsule radius from distance - /** if set, radius of Target's capsule will be added to threshold between AI and goal location */ - UPROPERTY(Category="Decorator", EditAnywhere) - bool bIncludeTargetCapsuleRadius = true; - UPROPERTY(Category="Decorator", EditAnywhere) - bool bCalculateDistanceIn2D = true; - - UPROPERTY(Category="Decorator", EditAnywhere) - bool bDrawDebug = false; - // TODO: if -1 or 0, when should be overriden by UHLGlobalSettings.DebugLifeTime, by default should be -1 or 0? - UPROPERTY(Category="Decorator", EditAnywhere, meta=(EditCondition="bDrawDebug", EditConditionHides)) - float DebugLifetime = -1.0f; - - virtual void InitializeFromAsset(UBehaviorTree& Asset) override; - virtual bool CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const override; - - virtual uint16 GetInstanceMemorySize() const override { return sizeof(FBTInRangeMemory); }; - virtual void InitializeMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryInit::Type InitType) const override; - virtual void CleanupMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryClear::Type CleanupType) const override; - - virtual FString GetStaticDescription() const override; - // TODO should be only "WITH_EDITOR"??? - virtual void DescribeRuntimeValues(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTDescriptionVerbosity::Type Verbosity, TArray& Values) const override; -#if WITH_EDITOR - virtual FName GetNodeIconName() const override; -#endif - - float GetCurrentDistance(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, bool bDrawDebug_In = false) const; - - virtual void TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) override; -}; diff --git a/Source/UHLAI/Public/Decorators/BTD_LoopRandomCount.h b/Source/UHLAI/Public/Decorators/BTD_LoopRandomCount.h deleted file mode 100644 index 1d323155..00000000 --- a/Source/UHLAI/Public/Decorators/BTD_LoopRandomCount.h +++ /dev/null @@ -1,28 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "BehaviorTree/Decorators/BTDecorator_Loop.h" -#include "BTD_LoopRandomCount.generated.h" - -/** - * - */ -UCLASS(Category = "UnrealHelperLibrary", hidecategories="Decorator") -class UHLAI_API UBTD_LoopRandomCount : public UBTDecorator_Loop -{ - GENERATED_BODY() - -public: - UBTD_LoopRandomCount(const FObjectInitializer& ObjectInitializer); - - /** number of executions */ - UPROPERTY(EditAnywhere, Category="LoopRandomCount", meta=(EditCondition="!bInfiniteLoop", ClampMin="1", ClampMax="255")) - FInt32Interval Range = FInt32Interval(2, 4); - -protected: - virtual void OnNodeActivation(FBehaviorTreeSearchData& SearchData) override; - virtual FString GetStaticDescription() const override; - -}; diff --git a/Source/UHLAI/Public/Decorators/BTD_RandomChance.h b/Source/UHLAI/Public/Decorators/BTD_RandomChance.h deleted file mode 100644 index dc9adf3c..00000000 --- a/Source/UHLAI/Public/Decorators/BTD_RandomChance.h +++ /dev/null @@ -1,71 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "ScalableFloat.h" -#include "BehaviorTree/BTDecorator.h" -#include "BehaviorTree/ValueOrBBKey.h" -#include "Core/UHLAIDebugSettings.h" -#include "Core/UHLMathOperations.h" -#include "BTD_RandomChance.generated.h" - -UENUM(BlueprintType) -enum class EScalableChanceType : uint8 -{ - None, - ScalableFloat UMETA(ToolTip = "with FScalableFloat value level getted from blackboard ScalableChanceLevelInBB"), - BBDependantWithSteps UMETA(ToolTip = "Chance changes by math operation that applies every step e.g. step 0 - \"BaseChance\", step 1 - \"BaseChance\" + 20%, step 2 - \"BaseChance\" + 40% with math operation \"Add\" 20%"), -}; - -/** - * TODO: blackboard based random chances - */ -UCLASS(Category = "UnrealHelperLibrary") -class UHLAI_API UBTD_RandomChance : public UBTDecorator -{ - GENERATED_BODY() - -public: - UBTD_RandomChance(const FObjectInitializer& ObjectInitializer); - - UPROPERTY(Category="Decorator", EditAnywhere) - EScalableChanceType ScaleType = EScalableChanceType::None; - - UPROPERTY(Category="Decorator", EditAnywhere, meta=(UIMin=0.0f, UIMax=1.0f, ClampMin=0.0f, ClampMax=1.0f, EditCondition="ScaleType != EScalableChanceType::ScalableFloat", EditConditionHides)) - FValueOrBBKey_Float Chance = 1.0f; - - UPROPERTY(Category="Decorator", EditAnywhere, meta=(EditCondition="ScaleType == EScalableChanceType::ScalableFloat", EditConditionHides)) - FScalableFloat ScalableChance; - - UPROPERTY(Category="Decorator", EditAnywhere, meta=(EditCondition="ScaleType == EScalableChanceType::ScalableFloat", EditConditionHides)) - FBlackboardKeySelector ScalableChanceLevelInBB; - - UPROPERTY(Category="Decorator", EditAnywhere, meta=(EditCondition="ScaleType == EScalableChanceType::BBDependantWithSteps", EditConditionHides)) - FOperationOnBBValue ChanceChangePerStep = {}; - - UPROPERTY(Category="Decorator", EditAnywhere, meta=(EditCondition="ScaleType == EScalableChanceType::BBDependantWithSteps", EditConditionHides)) - FBlackboardKeySelector StepsCount; - - UPROPERTY(Category="Decorator", EditAnywhere, meta=(UIMin=0.0f, UIMax=1.0f, ClampMin=0.0f, ClampMax=1.0f, EditCondition="ScaleType != EScalableChanceType::None", EditConditionHides)) - FValueOrBBKey_Float MaxChance = 1.0f; - - UPROPERTY(Category="Decorator", EditAnywhere, AdvancedDisplay, meta=(ShowOnlyInnerProperties)) - FUHLAIDebugSettings DebugSettings; - - virtual bool CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const override; - - virtual FString GetStaticDescription() const override; - - virtual void InitializeFromAsset(UBehaviorTree& Asset) override; - - // TODO value preview? - // virtual void DescribeRuntimeValues(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTDescriptionVerbosity::Type Verbosity, TArray& Values) const override; - -#if WITH_EDITOR - virtual FName GetNodeIconName() const override; -#endif // WITH_EDITOR - -private: - float GetCurrentChance(UBehaviorTreeComponent& OwnerComp) const; -}; diff --git a/Source/UHLAI/Public/Decorators/BTD_TimeLimitRandom.h b/Source/UHLAI/Public/Decorators/BTD_TimeLimitRandom.h deleted file mode 100644 index b0060910..00000000 --- a/Source/UHLAI/Public/Decorators/BTD_TimeLimitRandom.h +++ /dev/null @@ -1,64 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "BehaviorTree/Decorators/BTDecorator_TimeLimit.h" -#include "Misc/EngineVersionComparison.h" -#include "BehaviorTree/BTDecorator.h" -#include "UObject/ObjectMacros.h" -#include "BehaviorTree/BehaviorTree.h" -#include "Misc/EngineVersionComparison.h" -#include "BTD_TimeLimitRandom.generated.h" - - -struct FBTimeLimitMemoryRandom -{ -}; - -/** - * In UE5.4 changed completely now we can't nest from "TimeLimit" and forced to copy-paste same functionality - */ -UCLASS(Category = "UnrealHelperLibrary", hidecategories="Decorator") -class UHLAI_API UBTD_TimeLimitRandom : public UBTDecorator -{ - GENERATED_BODY() - -public: - UBTD_TimeLimitRandom(const FObjectInitializer& ObjectInitializer); - - /** TimeLimit */ - UPROPERTY(EditAnywhere, Category="TimeLimitRandom", meta=(ClampMin="0")) - FFloatInterval TimeLimitRange = FFloatInterval(3.0f, 5.0f); - UPROPERTY(EditAnywhere, Category="TimeLimitRandom") - bool bUseIntegers = true; - - virtual FString GetStaticDescription() const override; - -#if UE_VERSION_NEWER_THAN(5, 4, 0) - virtual void DescribeRuntimeValues(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTDescriptionVerbosity::Type Verbosity, TArray& Values) const override; -#if WITH_EDITOR - virtual FName GetNodeIconName() const override; -#endif // WITH_EDITOR -#endif - -protected: - virtual void OnNodeActivation(FBehaviorTreeSearchData& SearchData) override; - -#if UE_VERSION_NEWER_THAN(5, 4, 0) - // 5.4.0 and up only code - virtual uint16 GetInstanceMemorySize() const override; - virtual void InitializeMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryInit::Type InitType) const override; - virtual void CleanupMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryClear::Type CleanupType) const override; - - virtual void OnBecomeRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override; - virtual void OnCeaseRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override; - virtual bool CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const override; - virtual void TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) override; -#endif - -private: - /** max allowed time for execution of underlying node */ - UPROPERTY(EditAnywhere, Category="Decorator") - float TimeLimit; -}; diff --git a/Source/UHLAI/Public/Services/BTS_GameplayFocus.h b/Source/UHLAI/Public/Services/BTS_GameplayFocus.h deleted file mode 100644 index cf28bcf5..00000000 --- a/Source/UHLAI/Public/Services/BTS_GameplayFocus.h +++ /dev/null @@ -1,33 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Misc/EngineVersionComparison.h" -#include "BehaviorTree/BehaviorTreeTypes.h" -#include "BehaviorTree/Services/BTService_DefaultFocus.h" -#include "BTS_GameplayFocus.generated.h" - -class UBehaviorTreeComponent; - -/** - * Prevents rotation jittering while moving to enemy - * Requires to turned on "UseControllerDesiredRotation" - * Requires to turn off "UseControllerRotationYaw"/"UseControllerRotationPitch"/"UseControllerRotationRoll" - * Troubleshooting: - * - Check that nothing "ClearFocus" when thinks that it don't work - * - Check that MoveTo uses "AllowStafe"(low chances to get work, in tests it don't block from strafing) - */ -UCLASS(Category = "UnrealHelperLibrary") -class UHLAI_API UBTS_GameplayFocus : public UBTService_DefaultFocus -{ - GENERATED_BODY() - -public: - UBTS_GameplayFocus(const FObjectInitializer& ObjectInitializer); - -#if UE_VERSION_NEWER_THAN(5, 4, 0) - virtual void InitializeMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryInit::Type InitType) const override; - virtual void CleanupMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryClear::Type CleanupType) const override; -#endif -}; diff --git a/Source/UHLAI/Public/Tasks/BTT_ClearFocus.h b/Source/UHLAI/Public/Tasks/BTT_ClearFocus.h deleted file mode 100644 index 1192cdda..00000000 --- a/Source/UHLAI/Public/Tasks/BTT_ClearFocus.h +++ /dev/null @@ -1,26 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "BehaviorTree/BTTaskNode.h" -#include "BTT_ClearFocus.generated.h" - -/** - * - */ -UCLASS(Category = "UnrealHelperLibrary") -class UHLAI_API UBTT_ClearFocus : public UBTTaskNode -{ - GENERATED_BODY() - -public: - UBTT_ClearFocus(const FObjectInitializer& ObjectInitializer); - - // not possible to expose "EAIFocusPriority::Type" - // by default clears Gameplay level priority - // UPROPERTY(Category="Decorator", EditAnywhere) - // EAIFocusPriority::Type Priority = (uint8)EAIFocusPriority::Gameplay; - - virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override; -}; diff --git a/Source/UHLAI/Public/Tasks/BTT_DebugPrintBBValue.h b/Source/UHLAI/Public/Tasks/BTT_DebugPrintBBValue.h deleted file mode 100644 index c0da3e46..00000000 --- a/Source/UHLAI/Public/Tasks/BTT_DebugPrintBBValue.h +++ /dev/null @@ -1,35 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "BehaviorTree/BTTaskNode.h" -#include "BTT_DebugPrintBBValue.generated.h" - -/** - * - */ -UCLASS(Category = "UnrealHelperLibrary") -class UHLAI_API UBTT_DebugPrintBBValue : public UBTTaskNode -{ - GENERATED_BODY() - -public: - UBTT_DebugPrintBBValue(const FObjectInitializer& ObjectInitializer); - - UPROPERTY(Category="Decorator", EditAnywhere) - FBlackboardKeySelector BlackboardKey; - - UPROPERTY(Category="Decorator", EditAnywhere) - float Duration = 3.5f; - - UPROPERTY(Category="Decorator", EditAnywhere) - FLinearColor Color = FLinearColor(0, 0.66, 1);; - - UPROPERTY(Category="Decorator", EditAnywhere) - FName Key = NAME_None; - - virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override; - FString GetBBKeyDescription(UBehaviorTreeComponent& OwnerComp); - virtual FString GetStaticDescription() const override; -}; diff --git a/Source/UHLAI/Public/Tasks/BTT_DebugPrintString.h b/Source/UHLAI/Public/Tasks/BTT_DebugPrintString.h deleted file mode 100644 index d0db3b84..00000000 --- a/Source/UHLAI/Public/Tasks/BTT_DebugPrintString.h +++ /dev/null @@ -1,42 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "BehaviorTree/BTTaskNode.h" -#include "BehaviorTree/ValueOrBBKey.h" -#include "BTT_DebugPrintString.generated.h" - -/** - * - */ -UCLASS(Category = "UnrealHelperLibrary") -class UHLAI_API UBTT_DebugPrintString : public UBTTaskNode -{ - GENERATED_BODY() - -public: - UBTT_DebugPrintString(const FObjectInitializer& ObjectInitializer); - - UPROPERTY(Category="Decorator", EditAnywhere, meta=(EditFixedSize, MultiLine, FullyExpand=true)) - TArray PrintStrings = { - FValueOrBBKey_String(""), - FValueOrBBKey_String(""), - FValueOrBBKey_String("") - }; - - UPROPERTY(Category="Decorator", EditAnywhere) - FValueOrBBKey_Float Duration = 3.5f; - - UPROPERTY(Category="Decorator", EditAnywhere) - FLinearColor Color = FLinearColor(0, 0.66, 1); - - UPROPERTY(Category="Decorator", EditAnywhere) - FValueOrBBKey_Name Key = FValueOrBBKey_Name(); - - virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override; - virtual FString GetStaticDescription() const override; - -private: - FString GetFinalString() const; -}; diff --git a/Source/UHLAI/Public/Tasks/BTT_FireGameplayEvent.h b/Source/UHLAI/Public/Tasks/BTT_FireGameplayEvent.h deleted file mode 100644 index e729c5f0..00000000 --- a/Source/UHLAI/Public/Tasks/BTT_FireGameplayEvent.h +++ /dev/null @@ -1,52 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "BehaviorTree/BTTaskNode.h" -#include "BTT_FireGameplayEvent.generated.h" - -struct FBlackboardKeySelector; - -/** - * - */ -UCLASS(Category = "UnrealHelperLibrary") -class UHLAI_API UBTT_FireGameplayEvent : public UBTTaskNode -{ - GENERATED_BODY() - - -public: - UBTT_FireGameplayEvent(const FObjectInitializer& ObjectInitializer); - - UPROPERTY(EditAnywhere, Category="Blackboard") - FGameplayTag EventTag = FGameplayTag::EmptyTag; - - UPROPERTY(EditAnywhere, Category="Blackboard") - FBlackboardKeySelector Target; - - UPROPERTY(EditAnywhere, Category="Blackboard") - FBlackboardKeySelector Instigator; - - UPROPERTY(EditAnywhere, Category="Blackboard") - FBlackboardKeySelector OptionalObject; - - UPROPERTY(EditAnywhere, Category="Blackboard") - FBlackboardKeySelector OptionalObject2; - - // tags that required on instigator to fire event ?? - UPROPERTY(EditAnywhere, Category="Blackboard") - FGameplayTagContainer InstigatorTags = {}; - - // tags that required on target to fire event ?? - UPROPERTY(EditAnywhere, Category="Blackboard") - FGameplayTagContainer TargetTags = {}; - - UPROPERTY(EditAnywhere, Category="Blackboard") - float EventMagnitude = 0.0f; - - virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override; - - virtual FString GetStaticDescription() const override; -}; diff --git a/Source/UHLAI/Public/Tasks/BTT_InvokeGameplayAbility.h b/Source/UHLAI/Public/Tasks/BTT_InvokeGameplayAbility.h deleted file mode 100644 index 6e87bd9b..00000000 --- a/Source/UHLAI/Public/Tasks/BTT_InvokeGameplayAbility.h +++ /dev/null @@ -1,64 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "UHLValueOrBBKey_GameplayTag.h" -#include "Abilities/GameplayAbilityTypes.h" -#include "BehaviorTree/BTTaskNode.h" -#include "BTT_InvokeGameplayAbility.generated.h" - -class IAbilitySystemInterface; - -struct FInvokeGameplayAbilityMemory -{ - FDelegateHandle AbilityEndHandle; -}; - -/** - * TODO Invoke by Class option? - * 1) tbh its bad practice to have hard refs on classes, - * no need in this options, better to force good practices - dont hard ref abilities - * 2) it brokes good architechture/behaviorTrees reusability if we hard ref ability - * it means that nested abilities can't be activated, with activation by tag - * all enemies can have different abilities implementation using same tag - */ -UCLASS(Category = "UnrealHelperLibrary") -class UHLAI_API UBTT_InvokeGameplayAbility : public UBTTaskNode -{ - GENERATED_BODY() - -public: - UBTT_InvokeGameplayAbility(const FObjectInitializer& ObjectInitializer); - - UPROPERTY(Category="Blackboard", EditAnywhere) - FUHLValueOrBBKey_GameplayTag GameplayTag; - - UPROPERTY(Category="Blackboard", EditAnywhere, DisplayName = "Activate") - FValueOrBBKey_Bool bActivate = true; - - UPROPERTY(Category="Blackboard", EditAnywhere, DisplayName = "WaitForFinishing") - FValueOrBBKey_Bool bWaitForFinishing = true; - - UPROPERTY(Category="Blackboard", EditAnywhere, DisplayName = "DebugMessages") - FValueOrBBKey_Bool bDebugMessages = false; - - /** Cancelled ability should be handled as success. */ - UPROPERTY(EditAnywhere, Category = "Gameplay Ability Activation", DisplayName = "TreatCancelledAbilityAsSuccess") - FValueOrBBKey_Bool bTreatCancelledAbilityAsSuccess = false; - - virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override; - virtual EBTNodeResult::Type AbortTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override; - virtual void OnTaskFinished(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTNodeResult::Type TaskResult) override; - - virtual void InitializeMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryInit::Type InitType) const override; - virtual uint16 GetInstanceMemorySize() const override { return sizeof(FInvokeGameplayAbilityMemory); }; - - virtual FString GetStaticDescription() const override; - -private: - bool bIsAborting = false; - - UFUNCTION() - void OnAbilityEnded(const FAbilityEndedData& AbilityEndedData, UBehaviorTreeComponent* OwnerComp); -}; diff --git a/Source/UHLAI/Public/Tasks/BTT_PlayAnimMontage.h b/Source/UHLAI/Public/Tasks/BTT_PlayAnimMontage.h deleted file mode 100644 index 96607779..00000000 --- a/Source/UHLAI/Public/Tasks/BTT_PlayAnimMontage.h +++ /dev/null @@ -1,96 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "PlayMontageCallbackProxy.h" -#include "BehaviorTree/BTTaskNode.h" -#include "BTT_PlayAnimMontage.generated.h" - -DECLARE_LOG_CATEGORY_EXTERN(LogBTT_PlayAnimMontage, Log, All); - -/** - * Deciding when to end the node - */ -UENUM() -enum ETaskNodeEndPolicy -{ - /** - * after the node ends, still need to perform montage node, using this policy can make the anime more coherent - */ - OnMontageBlendingOut, - - /** - * end when the montage is completely finished, applicable to situations where only one montage is executed - */ - OnMontageEnded -}; - -/** - * playMontage and wait finish. - * If the montage is already playing, it will be forcefully overwritten and played directly. - */ -UCLASS(Category = "UnrealHelperLibrary") -class UHLAI_API UBTT_PlayAnimMontage : public UBTTaskNode -{ - GENERATED_BODY() - -public: - UBTT_PlayAnimMontage(const FObjectInitializer& ObjectInitializer); - - UPROPERTY(Category="Blackboard", EditAnywhere) - UAnimMontage* AnimMontage = nullptr; - UPROPERTY(Category="Blackboard", EditAnywhere) - float PlayRate = 1.0f; - UPROPERTY(Category="Blackboard", EditAnywhere) - float StartingPosition = 0.0f; - UPROPERTY(Category="Blackboard", EditAnywhere) - FName StartSectionName = NAME_None; - UPROPERTY(Category="Blackboard", EditAnywhere) - bool StopMontageOnAbort = true; - UPROPERTY(Category="Blackboard", EditAnywhere) - TEnumAsByte TaskNodeEndPolicy = ETaskNodeEndPolicy::OnMontageBlendingOut; - - virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override; - virtual EBTNodeResult::Type AbortTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override; - virtual void OnTaskFinished(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, - EBTNodeResult::Type TaskResult) override; - - virtual FString GetStaticDescription() const override; - -private: - /** - * AIOwner Cache - */ - UPROPERTY() - TWeakObjectPtr AIOwner; - -protected: - /** - * PlayMontage and bind callback - */ - bool PlayMontage(USkeletalMeshComponent* InSkeletalMeshComponent, - UAnimMontage* MontageToPlay, - float InPlayRate, - float InStartingPosition, - FName InStartingSection); - - /** - * All callbacks at the end of montage need to be filtered - */ - UFUNCTION() - void OnMontageEnded(UAnimMontage* InAnimMontage, bool bInterrupted); - - /** - * All callbacks at the BlendingOut of montage need to be filtered - */ - UFUNCTION() - void OnMontageBlendingOut(UAnimMontage* InAnimMontage, bool bInterrupted); - - void ClearMontageDelegate(); - - /** - * finish AIOwner task node, if AIOwner still is Valid - */ - void FinishTaskNode(); -}; diff --git a/Source/UHLAI/Public/Tasks/BTT_SetBBValue.h b/Source/UHLAI/Public/Tasks/BTT_SetBBValue.h deleted file mode 100644 index 887c9b28..00000000 --- a/Source/UHLAI/Public/Tasks/BTT_SetBBValue.h +++ /dev/null @@ -1,97 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "BehaviorTree/BTTaskNode.h" -#include "BehaviorTree/BehaviorTreeTypes.h" -#include "Core/UHLBlackboardValueType.h" -#include "Core/UHLMathOperations.h" -#include "BTT_SetBBValue.generated.h" - -/** - * Use with caution, setting BB values in BehaviorTrees directly is "anti-pattern" - * mostly you want to write BTTasks where its possible, use it for test purposes - * - * TODO arithmetic operations like A + B, A * B ... - * TODO vector calculations - add relative to owner, e.g. set Value as GetActorLocation + Value(offset) - */ -UCLASS(Category = "UnrealHelperLibrary") -class UHLAI_API UBTT_SetBBValue : public UBTTaskNode -{ - GENERATED_BODY() - -public: - UBTT_SetBBValue(const FObjectInitializer& ObjectInitializer); - - /** blackboard key selector */ - UPROPERTY(EditAnywhere, Category="Blackboard") - struct FBlackboardKeySelector BlackboardKey; - - UPROPERTY( - EditAnywhere, Category="Blackboard", - meta=(EditCondition="CurrentBBKeyValueType==EBlackboardValueType::Int || CurrentBBKeyValueType==EBlackboardValueType::Float || CurrentBBKeyValueType==EBlackboardValueType::Vector || CurrentBBKeyValueType==EBlackboardValueType::Rotator", - EditConditionHides, ShowOnlyInnerProperties)) - FOperationOnBBValue OperationOnBBValue; - - /** Values */ - UPROPERTY(Category="Blackboard", EditAnywhere, meta=(DisplayName="Value", EditCondition="CurrentBBKeyValueType==EBlackboardValueType::Bool", EditConditionHides)) - bool BoolValue; - UPROPERTY(Category="Blackboard", EditAnywhere, meta=(DisplayName="Value", EditCondition="CurrentBBKeyValueType==EBlackboardValueType::String", EditConditionHides, MultiLine)) - FString StringValue; - UPROPERTY(Category="Blackboard", EditAnywhere, meta=(DisplayName="Value", EditCondition="CurrentBBKeyValueType==EBlackboardValueType::Name", EditConditionHides, MultiLine)) - FName NameValue; - UPROPERTY(Category="Blackboard", EditAnywhere, meta=(DisplayName="Value", EditCondition="CurrentBBKeyValueType==EBlackboardValueType::Enum || CurrentBBKeyValueType==EBlackboardValueType::NativeEnum", EditConditionHides, GetOptions="GetEnumOptions")) - FString EnumStringValue; - UPROPERTY(Category="Blackboard", EditAnywhere, meta=(DisplayName="Value", EditCondition="CurrentBBKeyValueType==EBlackboardValueType::Object", EditConditionHides)) - FBlackboardKeySelector ObjectValue; - UPROPERTY(Category="Blackboard", EditAnywhere, meta=(DisplayName="Value", EditCondition="CurrentBBKeyValueType==EBlackboardValueType::Class", EditConditionHides)) - UClass* ClassValue; - /** ~Values */ - - virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override; - - virtual FString GetStaticDescription() const override; - - virtual void InitializeFromAsset(UBehaviorTree& Asset) override; - - virtual void PostLoad() override; - -#if WITH_EDITORONLY_DATA - - // UPROPERTY(Category=Blackboard, EditAnywhere, meta=(DisplayName="Key Query")) - // TEnumAsByte BasicOperation; - // UPROPERTY(Category=Blackboard, EditAnywhere, meta=(DisplayName="Key Query")) - // TEnumAsByte ArithmeticOperation; - // UPROPERTY(Category=Blackboard, EditAnywhere, meta=(DisplayName="Key Query")) - // TEnumAsByte TextOperation; - -#endif - -#if WITH_EDITOR - virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override; -#endif - -private: - UPROPERTY() - UEnum* CurrentEnum; - UPROPERTY() - EBlackboardValueType CurrentBBKeyValueType = EBlackboardValueType::None; - - UFUNCTION() - TArray GetEnumOptions(); - - UPROPERTY(meta=(DeprecatedProperty, DeprecationMessage="Use \"MathOperationNew\" instead")) - EUHL_MathOperations MathOperation = EUHL_MathOperations::None; - UPROPERTY(meta=(DeprecatedProperty, DeprecationMessage="Use \"OperationOnBBValue.IntValue\" instead")) - int32 IntValue; - UPROPERTY(meta=(DeprecatedProperty, DeprecationMessage="Use \"OperationOnBBValue.FloatValue\" instead")) - float FloatValue; - UPROPERTY(meta=(DeprecatedProperty, DeprecationMessage="Use \"OperationOnBBValue.VectorValue\" instead")) - FVector VectorValue; - UPROPERTY(meta=(DeprecatedProperty, DeprecationMessage="Use \"OperationOnBBValue.RotatorValue\" instead")) - FRotator RotatorValue; - - UPROPERTY() - bool bMigratedToMathOperation = false; -}; diff --git a/Source/UHLAI/Public/Tasks/BTT_TurnTo.h b/Source/UHLAI/Public/Tasks/BTT_TurnTo.h deleted file mode 100644 index 76cbea7d..00000000 --- a/Source/UHLAI/Public/Tasks/BTT_TurnTo.h +++ /dev/null @@ -1,143 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Data/TurnSettings.h" -#include "BehaviorTree/BTTaskNode.h" -#include "BehaviorTree/Services/BTService_DefaultFocus.h" -#include "BehaviorTree/Tasks/BTTask_BlackboardBase.h" -#include "UnrealHelperLibraryTypes.h" -#include "GameFramework/Character.h" -#include "BTT_TurnTo.generated.h" - -class AAIController; -class ACharacter; - -namespace TurnToStatics -{ - static bool IsTurnWithAnimationRequired(ACharacter* Character) - { - if (!Character) return false; - if (Character->IsPlayingRootMotion()) return false; - return true; - } - - static FTurnRange GetTurnRange(float DeltaAngle, bool& bCurrentTurnRangeSet, FTurnSettings TurnSettings_In) - { - FTurnRange Result; - bCurrentTurnRangeSet = false; - for (TTuple TurnToRange : TurnSettings_In.TurnRangesGroups) - { - for (FTurnRange Range : TurnToRange.Value.TurnRanges) - { - if (Range.Range.Contains(DeltaAngle)) - { - Result = Range; - bCurrentTurnRangeSet = true; - break; - } - } - if (bCurrentTurnRangeSet) - { - break; - } - } - return Result; - } - - FORCEINLINE_DEBUGGABLE FVector::FReal CalculateAngleDifferenceDot(const FVector& VectorA, const FVector& VectorB) - { - return (VectorA.IsNearlyZero() || VectorB.IsNearlyZero()) - ? 1.f - : VectorA.CosineAngle2D(VectorB); - } -} - -struct FBTTurnToMemory : FBTFocusMemory -{ - FTurnRange CurrentTurnRange; - bool bCurrentTurnRangeSet = false; - FTurnSettings TurnSettings; - bool bCurrentTurnSettingsSet = false; - - void Reset() - { - FocusActorSet = nullptr; - FocusLocationSet = FAISystem::InvalidLocation; - bActorSet = false; - bCurrentTurnRangeSet = false; - bCurrentTurnSettingsSet = false; - } -}; - -/** - * Mostly copy-pasted from RotateToFaceBBEntry but can use animations to rotate - * TODO bForceRotateNotOnlyWithAnims - overrides DataAsset setting, in rare cases we need to rotate in place - */ -UCLASS(config = Game, Category = "UnrealHelperLibrary") -class UHLAI_API UBTT_TurnTo : public UBTTask_BlackboardBase -{ - GENERATED_BODY() - -protected: - // TODO IMO can't be 0.0f, enemy wont turn such precisely clamp to 0.1f at least? - /** Success condition precision in degrees */ - UPROPERTY(config, Category="TurnTo", EditAnywhere, meta = (ClampMin = "0.0", Units="Degrees")) - float Precision = 1.0f; - - UPROPERTY(EditAnywhere, Category="TurnTo") - bool bUseTurnAnimations = true; - UPROPERTY(EditAnywhere, Category="TurnTo", meta=(EditCondition="bUseTurnAnimations", EditConditionHides)) - EUHLSettingsSource SettingsSource = EUHLSettingsSource::Actor; - - UPROPERTY(EditAnywhere, Category="TurnTo", meta=(EditCondition="bUseTurnAnimations && SettingsSource==EUHLSettingsSource::Node", EditConditionHides)) - FTurnSettings TurnSettings; - UPROPERTY(EditAnywhere, Category="TurnTo", meta=(EditCondition="bUseTurnAnimations && SettingsSource==EUHLSettingsSource::DataAsset", EditConditionHides)) - UTurnSettingsDataAsset* RotateToAnimationsDataAsset; - - UPROPERTY(EditAnywhere, Category="TurnTo") - bool bDebug = false; - - // Prefers to rotate 180deg if relative angle >115deg, suits for all medium mobs(human size) - UFUNCTION(BlueprintCallable, Category="Setup", CallInEditor, meta=(EditCondition="bUseTurnAnimations && SettingsSource==EUHLSettingsSource::Node", EditConditionHides, DisplayPriority=1)) - void SetupPreset_Default_90_180(); - // All ranges have same proportion - UFUNCTION(BlueprintCallable, Category="Setup", CallInEditor, meta=(EditCondition="bUseTurnAnimations && SettingsSource==EUHLSettingsSource::Node", EditConditionHides, DisplayPriority=1)) - void SetupPreset_BigEnemy_90_180(); - UFUNCTION(BlueprintCallable, Category="Setup", CallInEditor, meta=(EditCondition="bUseTurnAnimations && SettingsSource==EUHLSettingsSource::Node", EditConditionHides, DisplayPriority=2)) - void SetupPreset_45_90_180(); - UFUNCTION(BlueprintCallable, Category="Setup", CallInEditor, meta=(EditCondition="bUseTurnAnimations && SettingsSource==EUHLSettingsSource::Node", EditConditionHides, DisplayPriority=3)) - void SetupPreset_15_45_90_180(); - UFUNCTION(BlueprintCallable, Category="Setup", CallInEditor, meta=(EditCondition="bUseTurnAnimations && SettingsSource==EUHLSettingsSource::Node", EditConditionHides, DisplayPriority=4)) - void SetupPreset_15_30_45_90_180(); - UFUNCTION(BlueprintCallable, Category="Setup", CallInEditor, meta=(EditCondition="bUseTurnAnimations && SettingsSource==EUHLSettingsSource::Node", EditConditionHides, DisplayPriority=5)) - void Cleanup(); - -private: - /** cached Precision tangent value */ - float PrecisionDot; - -public: - UBTT_TurnTo(const FObjectInitializer& ObjectInitializer); - - virtual void PostInitProperties() override; - virtual void PostLoad() override; - - virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override; - virtual void TickTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) override; - virtual EBTNodeResult::Type AbortTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override; - virtual void DescribeRuntimeValues(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTDescriptionVerbosity::Type Verbosity, TArray& Values) const override; - virtual FString GetStaticDescription() const override; - - virtual uint16 GetInstanceMemorySize() const override { return sizeof(FBTTurnToMemory); } - virtual void InitializeMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryInit::Type InitType) const override; - virtual void CleanupMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryClear::Type CleanupType) const override; - -protected: - float GetPrecisionDot() const { return PrecisionDot; } - void CleanUp(AAIController& AIController, uint8* NodeMemory); - -private: - FTurnSettings GetTurnSettings(AActor* Actor, bool& bCurrentTurnSettingsSet); -}; diff --git a/Source/UHLAI/Public/UHLAI.h b/Source/UHLAI/Public/UHLAI.h deleted file mode 100644 index b677a153..00000000 --- a/Source/UHLAI/Public/UHLAI.h +++ /dev/null @@ -1,14 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "Modules/ModuleManager.h" - - -class FUHLAIModule : public IModuleInterface -{ -public: - /** IModuleInterface implementation */ - virtual void StartupModule() override; - virtual void ShutdownModule() override; -}; diff --git a/Source/UHLAI/Public/UHLValueOrBBKey_GameplayTag.h b/Source/UHLAI/Public/UHLValueOrBBKey_GameplayTag.h deleted file mode 100644 index e5496078..00000000 --- a/Source/UHLAI/Public/UHLValueOrBBKey_GameplayTag.h +++ /dev/null @@ -1,47 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "BehaviorTree/ValueOrBBKey.h" -#include "UHLValueOrBBKey_GameplayTag.generated.h" - -// TODO: Looks like there is same thing(not sure) in -// Experimental/GameplayBehaviors/Source/GameplayBehaviorsModule/Public/AI/ValueOrBBKey_GameplayTag.h - -USTRUCT(BlueprintType, Category = "UnrealHelperLibrary") -struct UHLAI_API FUHLValueOrBBKey_GameplayTag : public FValueOrBlackboardKeyBase -{ - GENERATED_BODY() - - FUHLValueOrBBKey_GameplayTag(FGameplayTag Default = FGameplayTag::EmptyTag) - : DefaultValue(Default) {} - FGameplayTag GetValue(const UBehaviorTreeComponent& BehaviorComp) const; - FGameplayTag GetValue(const UBehaviorTreeComponent* BehaviorComp) const; - FGameplayTag GetValue(const UBlackboardComponent& Blackboard) const; - FGameplayTag GetValue(const UBlackboardComponent* Blackboard) const; - - bool SerializeFromMismatchedTag(const FPropertyTag& Tag, FStructuredArchive::FSlot Slot); - -#if WITH_EDITOR - virtual bool IsCompatibleType(const UBlackboardKeyType* KeyType) const override; -#endif // WITH_EDITOR - - FString ToString() const; - - UE_DEPRECATED_FORGAME(5.5, "Implicit conversion will be removed next version. Call GetValue instead") - operator FName() const { return DefaultValue.GetTagName(); } - -protected: - UPROPERTY(EditAnywhere, Category = "Value") - FGameplayTag DefaultValue = FGameplayTag::EmptyTag; -}; - -template <> -struct TStructOpsTypeTraits : public TStructOpsTypeTraitsBase2 -{ - enum - { - WithStructuredSerializeFromMismatchedTag = true, - }; -}; diff --git a/Source/UHLAI/UHLAI.Build.cs b/Source/UHLAI/UHLAI.Build.cs deleted file mode 100644 index 7df75dea..00000000 --- a/Source/UHLAI/UHLAI.Build.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -using UnrealBuildTool; - -public class UHLAI : ModuleRules -{ - public UHLAI(ReadOnlyTargetRules Target) : base(Target) - { - PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; - - PublicIncludePaths.AddRange( - new string[] { - // ... add public include paths required here ... - } - ); - - - PrivateIncludePaths.AddRange( - new string[] { - // ... add other private include paths required here ... - } - ); - - - PublicDependencyModuleNames.AddRange( - new string[] - { - "Core", - "CoreUObject", - - "GameplayAbilities", - "GameplayTags", - "GameplayTasks", - - "AIModule", - - // ... add other public dependencies that you statically link with here ... - } - ); - - - PrivateDependencyModuleNames.AddRange( - new string[] - { - "Engine", - - // TODO: probably should be removed - "UnrealHelperLibrary", - - "AnimGraphRuntime", - } - ); - - - DynamicallyLoadedModuleNames.AddRange( - new string[] - { - // ... add any modules that your module loads dynamically here ... - } - ); - } -} diff --git a/Source/UHLAIEditor/Private/UHLAIEditor.cpp b/Source/UHLAIEditor/Private/UHLAIEditor.cpp deleted file mode 100644 index 719de2a7..00000000 --- a/Source/UHLAIEditor/Private/UHLAIEditor.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UHLAIEditor.h" -#include "Misc/MessageDialog.h" -#include "ToolMenus.h" -#include "UHLAIEditorValueOrBBKeyDetails.h" - -static const FName UHLAIEditorTabName("UHLAIEditor"); - -#define LOCTEXT_NAMESPACE "FUHLAIEditorModule" - -void FUHLAIEditorModule::StartupModule() -{ - // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module - - // Register the details customizer - FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked("PropertyEditor"); - // PropertyModule.RegisterCustomPropertyTypeLayout("ValueOrBBKey_GameplayTag", FOnGetPropertyTypeCustomizationInstance::CreateStatic(&FValueOrBBKeyDetails_GameplayTag::MakeInstance)); - // PropertyModule.RegisterCustomPropertyTypeLayout("ValueOrBBKey_GameplayTag", FOnGetPropertyTypeCustomizationInstance::CreateStatic(&FValueOrBBKeyDetails_GameplayTag::MakeInstance)); - // PropertyModule.RegisterCustomClassLayout("BlackboardKeyType_Class", FOnGetDetailCustomizationInstance::CreateStatic(&FBlackboardKeyDetails_Class::MakeInstance)); - // PropertyModule.RegisterCustomPropertyTypeLayout("ValueOrBBKey_GameplayTag", FOnGetPropertyTypeCustomizationInstance::CreateStatic(&FValueOrBBKeyDetails_Struct::MakeInstance)); - PropertyModule.RegisterCustomPropertyTypeLayout("ValueOrBBKey_GameplayTag", FOnGetPropertyTypeCustomizationInstance::CreateStatic(&FValueOrBBKeyDetails_GameplayTag::MakeInstance)); - PropertyModule.NotifyCustomizationModuleChanged(); -} - -void FUHLAIEditorModule::ShutdownModule() -{ - // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, - // we call this function before unloading the module. - - // Unregister the details customization - if (FModuleManager::Get().IsModuleLoaded("PropertyEditor")) - { - FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked("PropertyEditor"); - PropertyModule.UnregisterCustomPropertyTypeLayout("ValueOrBBKey_GameplayTag"); - PropertyModule.NotifyCustomizationModuleChanged(); - } -} - - -#undef LOCTEXT_NAMESPACE - -IMPLEMENT_MODULE(FUHLAIEditorModule, UHLAIEditor) diff --git a/Source/UHLAIEditor/Private/UHLAIEditorValueOrBBKeyDetails.cpp b/Source/UHLAIEditor/Private/UHLAIEditorValueOrBBKeyDetails.cpp deleted file mode 100644 index 7fb079fe..00000000 --- a/Source/UHLAIEditor/Private/UHLAIEditorValueOrBBKeyDetails.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UHLAIEditorValueOrBBKeyDetails.h" - -#include "GameplayTagContainer.h" -#include "IDetailChildrenBuilder.h" -#include "SGameplayTagCombo.h" - -TSharedRef FValueOrBBKeyDetails_GameplayTag::MakeInstance() -{ - return MakeShareable(new FValueOrBBKeyDetails_GameplayTag); -} - -void FValueOrBBKeyDetails_GameplayTag::CustomizeChildren(TSharedRef StructPropertyHandle, class IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils) -{ - if (GameplayTagProperty && GameplayTagProperty->IsEditable()) - { - StructBuilder.AddProperty(GameplayTagProperty.ToSharedRef()); - } -} - -TSharedRef FValueOrBBKeyDetails_GameplayTag::CreateDefaultValueWidget() -{ - return SNew(SGameplayTagCombo) - // .Visibility(this, &SGraphPin::GetDefaultValueVisibility) - // .Filter(FilterString) - .Tag(this, &FValueOrBBKeyDetails_GameplayTag::GetGameplayTag) - .OnTagChanged(this, &FValueOrBBKeyDetails_GameplayTag::OnGameplayTagChanged); -} - -void FValueOrBBKeyDetails_GameplayTag::OnGameplayTagChanged(const FGameplayTag NewTag) -{ - if (DefaultValueProperty.IsValid()) - { - FGameplayTag TagToSet = NewTag; - FString TagAsString = TagToSet.ToString(); - const FPropertyAccess::Result Result = DefaultValueProperty->SetValueFromFormattedString(TagAsString); - if (Result != FPropertyAccess::Success) - { - UE_LOG(LogTemp, Warning, TEXT("Failed to set GameplayTag value on property handle.")); - } - } -} - -FGameplayTag FValueOrBBKeyDetails_GameplayTag::GetGameplayTag() const -{ - FGameplayTag* GameplayTag = nullptr; - void* StructData = nullptr; - if (DefaultValueProperty->GetValueData(StructData) == FPropertyAccess::Success) - { - GameplayTag = reinterpret_cast(StructData); - } - return *GameplayTag; -} diff --git a/Source/UHLAIEditor/Public/UHLAIEditor.h b/Source/UHLAIEditor/Public/UHLAIEditor.h deleted file mode 100644 index 38abb6c6..00000000 --- a/Source/UHLAIEditor/Public/UHLAIEditor.h +++ /dev/null @@ -1,18 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Modules/ModuleManager.h" - -class FToolBarBuilder; -class FMenuBuilder; - -class FUHLAIEditorModule : public IModuleInterface -{ -public: - /** IModuleInterface implementation */ - virtual void StartupModule() override; - virtual void ShutdownModule() override; - -}; diff --git a/Source/UHLAIEditor/Public/UHLAIEditorValueOrBBKeyDetails.h b/Source/UHLAIEditor/Public/UHLAIEditorValueOrBBKeyDetails.h deleted file mode 100644 index c96d79b4..00000000 --- a/Source/UHLAIEditor/Public/UHLAIEditorValueOrBBKeyDetails.h +++ /dev/null @@ -1,23 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "GameplayTagContainer.h" -#include "ValueOrBBKeyDetails.h" - -class FValueOrBBKeyDetails_GameplayTag : public FValueOrBBKeyDetails -{ -public: - /** Makes a new instance of this detail layout class for a specific detail view requesting it */ - static TSharedRef MakeInstance(); - - virtual void CustomizeChildren(TSharedRef StructPropertyHandle, class IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override; - -protected: - TSharedPtr GameplayTagProperty; - - virtual TSharedRef CreateDefaultValueWidget() override; - - void OnGameplayTagChanged(const FGameplayTag NewTag); - FGameplayTag GetGameplayTag() const; -}; diff --git a/Source/UHLAIEditor/UHLAIEditor.Build.cs b/Source/UHLAIEditor/UHLAIEditor.Build.cs deleted file mode 100644 index be0d14d4..00000000 --- a/Source/UHLAIEditor/UHLAIEditor.Build.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -using UnrealBuildTool; - -public class UHLAIEditor : ModuleRules -{ - public UHLAIEditor(ReadOnlyTargetRules Target) : base(Target) - { - PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; - - PublicIncludePaths.AddRange( - new string[] { - // ... add public include paths required here ... - } - ); - - - PrivateIncludePaths.AddRange( - new string[] { - // ... add other private include paths required here ... - } - ); - - - PublicDependencyModuleNames.AddRange( - new string[] - { - "Core", - "CoreUObject", - "Engine", - "PropertyEditor", - "Blutility", - "UMG", - "BehaviorTreeEditor", - // ... add other public dependencies that you statically link with here ... - } - ); - - - PrivateDependencyModuleNames.AddRange( - new string[] - { - "Projects", - "InputCore", - "EditorFramework", - "UnrealEd", - "ToolMenus", - "Slate", - "SlateCore", - "UnrealEd", - "DeveloperSettings", - - "UHLAI", - - "EditorWidgets", - - "GameplayTags", - "GameplayTagsEditor", - // ... add private dependencies that you statically link with here ... - } - ); - - - DynamicallyLoadedModuleNames.AddRange( - new string[] - { - // ... add any modules that your module loads dynamically here ... - } - ); - } -} diff --git a/Source/UHLCharacter/Private/AttributeSets/UHLBaseCharacterAttributeSet.cpp b/Source/UHLCharacter/Private/AttributeSets/UHLBaseCharacterAttributeSet.cpp deleted file mode 100644 index 14a93083..00000000 --- a/Source/UHLCharacter/Private/AttributeSets/UHLBaseCharacterAttributeSet.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "AttributeSets/UHLBaseCharacterAttributeSet.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLBaseCharacterAttributeSet) - -void UUHLBaseCharacterAttributeSet::PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue) -{ - Super::PreAttributeChange(Attribute, NewValue); - - // If a Max value changes, adjust current to keep Current % of Current to Max - if (Attribute == GetMaxHealthAttribute()) // GetMaxHealthAttribute comes from the Macros defined at the top of the header - { - AdjustAttributeForMaxChange(Health, MaxHealth, NewValue, GetHealthAttribute()); - } - - ClampAttribute(Attribute, NewValue); -} - -void UUHLBaseCharacterAttributeSet::PreAttributeBaseChange(const FGameplayAttribute& Attribute, float& NewValue) const -{ - Super::PreAttributeBaseChange(Attribute, NewValue); - - ClampAttribute(Attribute, NewValue); -} - -void UUHLBaseCharacterAttributeSet::AdjustAttributeForMaxChange(FGameplayAttributeData & AffectedAttribute, const FGameplayAttributeData & MaxAttribute, float NewMaxValue, const FGameplayAttribute & AffectedAttributeProperty) -{ - TObjectPtr AbilityComp = GetOwningAbilitySystemComponent(); - const float CurrentMaxValue = MaxAttribute.GetCurrentValue(); - if (!FMath::IsNearlyEqual(CurrentMaxValue, NewMaxValue) && AbilityComp) - { - // Change current value to maintain the current Val / Max percent - const float CurrentValue = AffectedAttribute.GetCurrentValue(); - float NewDelta = (CurrentMaxValue > 0.f) ? (CurrentValue * NewMaxValue / CurrentMaxValue) - CurrentValue : NewMaxValue; - - AbilityComp->ApplyModToAttributeUnsafe(AffectedAttributeProperty, EGameplayModOp::Additive, NewDelta); - } -} - -void UUHLBaseCharacterAttributeSet::ClampAttribute(const FGameplayAttribute& Attribute, float& NewValue) const -{ - // Values clamp should be always here, dont move to "PostGameplayEffectExecute" - // it leads to value jittering every frame e.g for stamina like "150, 151, 150, 151, 150, 151, ..." - if (Attribute == GetHealthAttribute()) - { - NewValue = FMath::Clamp(NewValue, 0.0f, MaxHealth.GetCurrentValue()); - } -} - diff --git a/Source/UHLCharacter/Private/Characters/UHLBaseCharacter.cpp b/Source/UHLCharacter/Private/Characters/UHLBaseCharacter.cpp deleted file mode 100644 index a8841282..00000000 --- a/Source/UHLCharacter/Private/Characters/UHLBaseCharacter.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Characters/UHLBaseCharacter.h" - -#include "GameFramework/CharacterMovementComponent.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLBaseCharacter) - -// Sets default values -AUHLBaseCharacter::AUHLBaseCharacter(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - // smooth AI rotation - bUseControllerRotationYaw = false; - GetCharacterMovement()->bOrientRotationToMovement = 0; - GetCharacterMovement()->bUseControllerDesiredRotation = true; -} - -FTurnSettings AUHLBaseCharacter::GetTurnSettings_Implementation() const -{ - return TurnSettingsDataAsset->TurnSettings; -} - diff --git a/Source/UHLCharacter/Private/Characters/UHLBaseCharacterWithASC.cpp b/Source/UHLCharacter/Private/Characters/UHLBaseCharacterWithASC.cpp deleted file mode 100644 index 52325e1d..00000000 --- a/Source/UHLCharacter/Private/Characters/UHLBaseCharacterWithASC.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Characters/UHLBaseCharacterWithASC.h" - -#include "GameFramework/Controller.h" -#include "UHLAbilitySystemComponent.h" -#include "AttributeSets/UHLBaseCharacterAttributeSet.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLBaseCharacterWithASC) - -AUHLBaseCharacterWithASC::AUHLBaseCharacterWithASC(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - AbilitySystemComponent = CreateDefaultSubobject(TEXT("UHLAbilitySystem")); - - // some attribute sets can be added here, but its not only option - // you can use UHL Settings to set defaults for every AbilitySystemComponent and add default AttributeSet - // AbilitySystemComponent->AttributeSets = { UUHLBaseCharacterAttributeSet::StaticClass() }; -} - -void AUHLBaseCharacterWithASC::PossessedBy(AController* NewController) -{ - Super::PossessedBy(NewController); - - if (bInitUHLAbilitySystemOnPosses) - { - if (bDontInitOnSameControllerTwice) - { - if (NewController != PreviousController.Get()) - { - AbilitySystemComponent->InitAbilitySystem(NewController, this); - PreviousController = NewController; - } - } - else - { - AbilitySystemComponent->InitAbilitySystem(NewController, this); - } - - // Advanced setup if you want to make something after attributes set, but before abilities activated - // AbilitySystemComponent->InitAbilitySystem(NewController, this, false); - // AbilitySystemComponent->ActivateInitialAbilities(); - } -} diff --git a/Source/UHLCharacter/Private/Components/UHLCharacterMovementComponent.cpp b/Source/UHLCharacter/Private/Components/UHLCharacterMovementComponent.cpp deleted file mode 100644 index de47b7c5..00000000 --- a/Source/UHLCharacter/Private/Components/UHLCharacterMovementComponent.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2024 NextGenium - - -#include "Components/UHLCharacterMovementComponent.h" - -UUHLCharacterMovementComponent::UUHLCharacterMovementComponent() -{ - bUseControllerDesiredRotation = true; - bOrientRotationToMovement = false; -} - -void UUHLCharacterMovementComponent::SetRotationRate(FRotator RotationRate_In) -{ - RotationRate = RotationRate_In; -} diff --git a/Source/UHLCharacter/Private/Controllers/UHLPlayerController.cpp b/Source/UHLCharacter/Private/Controllers/UHLPlayerController.cpp deleted file mode 100644 index c8375ff1..00000000 --- a/Source/UHLCharacter/Private/Controllers/UHLPlayerController.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Controllers/UHLPlayerController.h" - -#include "Kismet/GameplayStatics.h" -#include "Engine/World.h" -#include "Engine/GameInstance.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLPlayerController) - -void AUHLPlayerController::BeginPlay() -{ - Super::BeginPlay(); -} diff --git a/Source/UHLCharacter/Private/UHLCharacter.cpp b/Source/UHLCharacter/Private/UHLCharacter.cpp deleted file mode 100644 index f4760b6c..00000000 --- a/Source/UHLCharacter/Private/UHLCharacter.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UHLCharacter.h" - -#include "Misc/Paths.h" -#include "GameplayTagsManager.h" - -#define LOCTEXT_NAMESPACE "FUHLCharacterModule" - - -void FUHLCharacterModule::StartupModule() -{ - UGameplayTagsManager& TagsManager = UGameplayTagsManager::Get(); - // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module - TagsManager.AddTagIniSearchPath(FPaths::ProjectPluginsDir() / TEXT("UnrealHelperLibrary/Config/Tags")); -} - -void FUHLCharacterModule::ShutdownModule() -{ - // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, - // we call this function before unloading the module. -} - -#undef LOCTEXT_NAMESPACE - -IMPLEMENT_MODULE(FUHLCharacterModule, UHLCharacter) diff --git a/Source/UHLCharacter/Public/AttributeSets/UHLBaseCharacterAttributeSet.h b/Source/UHLCharacter/Public/AttributeSets/UHLBaseCharacterAttributeSet.h deleted file mode 100644 index cfd7dab9..00000000 --- a/Source/UHLCharacter/Public/AttributeSets/UHLBaseCharacterAttributeSet.h +++ /dev/null @@ -1,37 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "AbilitySystemComponent.h" -#include "AttributeSet.h" -#include "AttributeSets/UHLAttributeSet.h" -#include "UHLBaseCharacterAttributeSet.generated.h" - -/** - * - */ -UCLASS(Category = "UnrealHelperLibrary") -class UHLCHARACTER_API UUHLBaseCharacterAttributeSet : public UUHLAttributeSet -{ - GENERATED_BODY() - -public: - ATTRIBUTE_ACCESSORS(UUHLBaseCharacterAttributeSet, Health); - ATTRIBUTE_ACCESSORS(UUHLBaseCharacterAttributeSet, MaxHealth); - -protected: - virtual void PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue) override; - virtual void PreAttributeBaseChange(const FGameplayAttribute& Attribute, float& NewValue) const override; - - // Helper function to proportionally adjust the value of an attribute when it's associated max attribute changes. - // (i.e. When MaxHealth increases, Health increases by an amount that maintains the same percentage as before) - void AdjustAttributeForMaxChange(FGameplayAttributeData& AffectedAttribute, const FGameplayAttributeData& MaxAttribute, float NewMaxValue, const FGameplayAttribute& AffectedAttributeProperty); - virtual void ClampAttribute(const FGameplayAttribute& Attribute, float& NewValue) const; - -private: - UPROPERTY(BlueprintReadOnly, Category = "Attributes | Health", Meta=(AllowPrivateAccess=true)) - FGameplayAttributeData Health; - UPROPERTY(BlueprintReadOnly, Category = "Attributes | Health", Meta=(AllowPrivateAccess=true)) - FGameplayAttributeData MaxHealth; -}; diff --git a/Source/UHLCharacter/Public/Characters/UHLBaseCharacter.h b/Source/UHLCharacter/Public/Characters/UHLBaseCharacter.h deleted file mode 100644 index 82136900..00000000 --- a/Source/UHLCharacter/Public/Characters/UHLBaseCharacter.h +++ /dev/null @@ -1,31 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Core/UHLAIActorSettings.h" -#include "GameFramework/Character.h" -#include "UHLBaseCharacter.generated.h" - -/** - * Character with base interfaces and features implemented, - * except AbilitySystem implementation cause its may vary on project setup - * ASC can be inited on PlayerState/Character - */ -UCLASS() -class UHLCHARACTER_API AUHLBaseCharacter : public ACharacter, - public IUHLAIActorSettings -{ - GENERATED_BODY() - -public: - // Sets default values for this character's properties - AUHLBaseCharacter(const FObjectInitializer& ObjectInitializer); - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="TurnSettings") - UTurnSettingsDataAsset* TurnSettingsDataAsset; - -/** IUHLActorSettings */ - virtual FTurnSettings GetTurnSettings_Implementation() const override; -/** ~IUHLActorSettings */ -}; diff --git a/Source/UHLCharacter/Public/Characters/UHLBaseCharacterWithASC.h b/Source/UHLCharacter/Public/Characters/UHLBaseCharacterWithASC.h deleted file mode 100644 index e020e47d..00000000 --- a/Source/UHLCharacter/Public/Characters/UHLBaseCharacterWithASC.h +++ /dev/null @@ -1,53 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "AbilitySystemInterface.h" -#include "UHLAbilitySystemComponent.h" -#include "Characters/UHLBaseCharacter.h" -#include "Core/UHLAbilitySystemInterface.h" -#include "UHLBaseCharacterWithASC.generated.h" - -class UAbilitySystemComponent; - -/** - * Extended version of UHLBaseCharacter but with AbilitySystem and ASC init on "PossessedBy" - */ -UCLASS() -class UHLCHARACTER_API AUHLBaseCharacterWithASC : public AUHLBaseCharacter, - public IAbilitySystemInterface, - public IUHLAbilitySystemInterface -{ - GENERATED_BODY() - -public: - AUHLBaseCharacterWithASC(const FObjectInitializer& ObjectInitializer); - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="UHL BaseCharacter with ASC") - bool bInitUHLAbilitySystemOnPosses = true; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="UHL BaseCharacter with ASC") - bool bDontInitOnSameControllerTwice = true; - - /** IAbilitySystemInterface **/ - virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override { return AbilitySystemComponent; }; - /** ~IAbilitySystemInterface **/ - - /** IUHLAbilitySystemInterface */ - virtual UUHLAbilitySystemComponent* GetUHLAbilitySystemComponent_Implementation() const override - { - return AbilitySystemComponent; - }; - /** ~IUHLAbilitySystemInterface */ - -protected: - /** GameplayAbilities */ - UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category="UHL BaseCharacter with ASC") - UUHLAbilitySystemComponent* AbilitySystemComponent; - /** ~GameplayAbilities */ - - virtual void PossessedBy(AController* NewController) override; - -private: - TWeakObjectPtr PreviousController; -}; diff --git a/Source/UHLCharacter/Public/Components/UHLCharacterMovementComponent.h b/Source/UHLCharacter/Public/Components/UHLCharacterMovementComponent.h deleted file mode 100644 index c40fbc5c..00000000 --- a/Source/UHLCharacter/Public/Components/UHLCharacterMovementComponent.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2024 NextGenium - -#pragma once - -#include "CoreMinimal.h" -#include "GameFramework/CharacterMovementComponent.h" -#include "UHLCharacterMovementComponent.generated.h" - -/** - * - */ -UCLASS(Blueprintable, BlueprintType) -class UHLCHARACTER_API UUHLCharacterMovementComponent : public UCharacterMovementComponent -{ - GENERATED_BODY() - -public: - UUHLCharacterMovementComponent(); - - // not required? - void SetRotationRate(FRotator RotationRate_In); -}; diff --git a/Source/UHLCharacter/Public/Controllers/UHLPlayerController.h b/Source/UHLCharacter/Public/Controllers/UHLPlayerController.h deleted file mode 100644 index 99114819..00000000 --- a/Source/UHLCharacter/Public/Controllers/UHLPlayerController.h +++ /dev/null @@ -1,19 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "GameFramework/PlayerController.h" -#include "UHLPlayerController.generated.h" - -/** - * - */ -UCLASS() -class UHLCHARACTER_API AUHLPlayerController : public APlayerController -{ - GENERATED_BODY() - -public: - virtual void BeginPlay() override; -}; diff --git a/Source/UHLCharacter/Public/UHLCharacter.h b/Source/UHLCharacter/Public/UHLCharacter.h deleted file mode 100644 index fd1f15a9..00000000 --- a/Source/UHLCharacter/Public/UHLCharacter.h +++ /dev/null @@ -1,14 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "Modules/ModuleManager.h" - - -class FUHLCharacterModule : public IModuleInterface -{ -public: - /** IModuleInterface implementation */ - virtual void StartupModule() override; - virtual void ShutdownModule() override; -}; diff --git a/Source/UHLCharacter/UHLCharacter.Build.cs b/Source/UHLCharacter/UHLCharacter.Build.cs deleted file mode 100644 index 512b86c4..00000000 --- a/Source/UHLCharacter/UHLCharacter.Build.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -using UnrealBuildTool; - -public class UHLCharacter : ModuleRules -{ - public UHLCharacter(ReadOnlyTargetRules Target) : base(Target) - { - PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; - - PublicIncludePaths.AddRange( - new string[] { - // ... add public include paths required here ... - } - ); - - - PrivateIncludePaths.AddRange( - new string[] { - // ... add other private include paths required here ... - } - ); - - - PublicDependencyModuleNames.AddRange( - new string[] - { - "Core", - // ... add other public dependencies that you statically link with here ... - "GameplayAbilities", - "GameplayTags", - "GameplayTasks", - "EnhancedInput", - - "UnrealHelperLibrary", - "UHLDebugSystem", - "UHLAI", - "UHLGAS", - } - ); - - - PrivateDependencyModuleNames.AddRange( - new string[] - { - "CoreUObject", - "Engine", - } - ); - - - DynamicallyLoadedModuleNames.AddRange( - new string[] - { - // ... add any modules that your module loads dynamically here ... - } - ); - } -} diff --git a/Source/UHLDebug/Private/UHLDebug.cpp b/Source/UHLDebug/Private/UHLDebug.cpp deleted file mode 100644 index b9586a21..00000000 --- a/Source/UHLDebug/Private/UHLDebug.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UHLDebug.h" - -#include "Misc/Paths.h" -#include "GameplayTagsManager.h" - -#define LOCTEXT_NAMESPACE "FUHLDebugModule" - - -void FUHLDebugModule::StartupModule() -{ - UGameplayTagsManager& TagsManager = UGameplayTagsManager::Get(); - // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module - TagsManager.AddTagIniSearchPath(FPaths::ProjectPluginsDir() / TEXT("UnrealHelperLibrary/Config/Tags")); -} - -void FUHLDebugModule::ShutdownModule() -{ - // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, - // we call this function before unloading the module. -} - -#undef LOCTEXT_NAMESPACE - -IMPLEMENT_MODULE(FUHLDebugModule, UHLDebug) diff --git a/Source/UHLDebug/Private/UHLDebugModuleSubsystem.cpp b/Source/UHLDebug/Private/UHLDebugModuleSubsystem.cpp deleted file mode 100644 index e7ad06ad..00000000 --- a/Source/UHLDebug/Private/UHLDebugModuleSubsystem.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "UHLDebugModuleSubsystem.h" - -#include "GameFramework/Pawn.h" -#include "AbilitySystemInterface.h" -#include "UHLGASBlueprintLibrary.h" -#include "Blueprint/UserWidget.h" -#include "Core/UHLGameplayTags.h" -#include "Kismet/GameplayStatics.h" -#include "UI/UHLDebugWidget.h" -#include "AA_WaitDebugCategoryChange.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLDebugModuleSubsystem) - -UUHLDebugModuleSubsystem::UUHLDebugModuleSubsystem() -{ - UHLDebugWidgetClass = FSoftObjectPath(TEXT("/UnrealHelperLibrary/UI/UI_UHL_DebugWidget.UI_UHL_DebugWidget_C")); -} - -void UUHLDebugModuleSubsystem::Initialize(FSubsystemCollectionBase& Collection) -{ - Super::Initialize(Collection); - - UAA_WaitDebugCategoryChange* WaitEncounterDebugCategoryChangeTask = - UAA_WaitDebugCategoryChange::WaitDebugCategoryChange( - GetWorld(), - UHLGameplayTags::TAG_UHL_DebugCategory_InputSystem_AbilityInputCache - ); - WaitEncounterDebugCategoryChangeTask->OnChange.AddUniqueDynamic( - this, - &UUHLDebugModuleSubsystem::OnAbilityInputDebugCategoryChanged); - WaitEncounterDebugCategoryChangeTask->Activate(); -} - -void UUHLDebugModuleSubsystem::Deinitialize() -{ - Super::Deinitialize(); -} - -void UUHLDebugModuleSubsystem::OnAbilityInputDebugCategoryChanged(bool bEnabled) -{ - if (bEnabled) - { - UUHLAbilitySystemComponent* UHLASC = GetPlayerAbilitySystemComponent(); - - UUHLDebugWidget* DebugWidget = GetOrCreateUHLDebugWidget(); - if (!DebugWidget) return; - DebugWidget->ToggleAbilityInputCache(UHLASC); - } - else - { - if (DebugWidgetInstance) - { - DebugWidgetInstance->ToggleAbilityInputCache(nullptr); - }; - } -} - -UUHLDebugWidget* UUHLDebugModuleSubsystem::GetOrCreateUHLDebugWidget() -{ - if (DebugWidgetInstance) return DebugWidgetInstance; - - APlayerController* PlayerController = GetPlayerController(); - if (!PlayerController) return nullptr; - - UClass* WidgetClass = UHLDebugWidgetClass.LoadSynchronous(); - DebugWidgetInstance = CreateWidget(PlayerController, WidgetClass); - DebugWidgetInstance->AddToViewport(99999999); - - return DebugWidgetInstance; -} - -APlayerController* UUHLDebugModuleSubsystem::GetPlayerController() const -{ - return UGameplayStatics::GetPlayerController(GetWorld(), 0); -} - -UUHLAbilitySystemComponent* UUHLDebugModuleSubsystem::GetPlayerAbilitySystemComponent() const -{ - APlayerController* PlayerController = GetPlayerController(); - if (!PlayerController) return nullptr; - - APawn* Pawn = PlayerController->GetPawn(); - if (!Pawn) return nullptr; - - IAbilitySystemInterface* AbilitySystemInterface = Cast(Pawn); - if (!AbilitySystemInterface) return nullptr; - - UAbilitySystemComponent* ASC = AbilitySystemInterface->GetAbilitySystemComponent(); - if (!ASC) return nullptr; - - UUHLAbilitySystemComponent* UHLASC = Cast(ASC); - if (!UHLASC) return nullptr; - - return UHLASC; -} diff --git a/Source/UHLDebug/Private/UI/UHLDebugWidget.cpp b/Source/UHLDebug/Private/UI/UHLDebugWidget.cpp deleted file mode 100644 index 5203b477..00000000 --- a/Source/UHLDebug/Private/UI/UHLDebugWidget.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "UI/UHLDebugWidget.h" - -#include "UHLAbilitySystemComponent.h" -#include "Blueprint/WidgetTree.h" -#include "Components/TextBlock.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLDebugWidget) - -void UUHLDebugWidget::ToggleAbilityInputCache(UUHLAbilitySystemComponent* ASC_In) -{ - ASC = ASC_In; - if (ASC.Get()) - { - bShowAbilityInputCacheList = true; - } - else - { - bShowAbilityInputCacheList = false; - } -} - -void UUHLDebugWidget::NativeTick(const FGeometry& MyGeometry, float InDeltaTime) -{ - Super::NativeTick(MyGeometry, InDeltaTime); - - if (bShowAbilityInputCacheList) - { - FString NewText = ""; - TArray AbilityInputCache = ASC->GetAbilityInputCache()->GetAbilityInputCache(); - - for (int32 i = AbilityInputCache.Num() - 1; i >= 0; i--) - { - NewText.Append(AbilityInputCache[i].ToString() + FString("\n")); - } - - AbilityInputCacheTextBlock->SetText(FText::FromString(NewText)); - } -} diff --git a/Source/UHLDebug/Public/UHLDebug.h b/Source/UHLDebug/Public/UHLDebug.h deleted file mode 100644 index a9ec7c0a..00000000 --- a/Source/UHLDebug/Public/UHLDebug.h +++ /dev/null @@ -1,14 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "Modules/ModuleManager.h" - - -class FUHLDebugModule : public IModuleInterface -{ -public: - /** IModuleInterface implementation */ - virtual void StartupModule() override; - virtual void ShutdownModule() override; -}; diff --git a/Source/UHLDebug/Public/UHLDebugModuleSubsystem.h b/Source/UHLDebug/Public/UHLDebugModuleSubsystem.h deleted file mode 100644 index 55885c2e..00000000 --- a/Source/UHLDebug/Public/UHLDebugModuleSubsystem.h +++ /dev/null @@ -1,36 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Subsystems/GameInstanceSubsystem.h" -#include "UI/UHLDebugWidget.h" -#include "UHLDebugModuleSubsystem.generated.h" - -// TODO use ULocalPlayer -UCLASS() -class UHLDEBUG_API UUHLDebugModuleSubsystem : public ULocalPlayerSubsystem -{ - GENERATED_BODY() - -public: - UUHLDebugModuleSubsystem(); - -protected: - virtual void Initialize(FSubsystemCollectionBase& Collection) override; - virtual void Deinitialize() override; - -private: - UPROPERTY() - TSoftClassPtr UHLDebugWidgetClass; - UPROPERTY() - UUHLDebugWidget* DebugWidgetInstance = nullptr; - - // TODO use ULocalPlayer - APlayerController* GetPlayerController() const; - UUHLAbilitySystemComponent* GetPlayerAbilitySystemComponent() const; - UUHLDebugWidget* GetOrCreateUHLDebugWidget(); - - UFUNCTION() - void OnAbilityInputDebugCategoryChanged(bool bEnabled); -}; diff --git a/Source/UHLDebug/Public/UI/UHLDebugWidget.h b/Source/UHLDebug/Public/UI/UHLDebugWidget.h deleted file mode 100644 index 43a5b93e..00000000 --- a/Source/UHLDebug/Public/UI/UHLDebugWidget.h +++ /dev/null @@ -1,34 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "UHLAbilitySystemComponent.h" -#include "Blueprint/UserWidget.h" -#include "Components/VerticalBox.h" -#include "UHLDebugWidget.generated.h" - - -class UTextBlock; - -/** - * - */ -UCLASS() -class UHLDEBUG_API UUHLDebugWidget : public UUserWidget -{ - GENERATED_BODY() - -public: - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UHLDebugWidget", meta = (BindWidget)) - UTextBlock* AbilityInputCacheTextBlock; - - virtual void NativeTick(const FGeometry& MyGeometry, float InDeltaTime) override; - - UFUNCTION(BlueprintCallable, Category="UHLDebugWidget") - void ToggleAbilityInputCache(UUHLAbilitySystemComponent* ASC_In); - -private: - bool bShowAbilityInputCacheList = false; - TWeakObjectPtr ASC; -}; diff --git a/Source/UHLDebug/UHLDebug.Build.cs b/Source/UHLDebug/UHLDebug.Build.cs deleted file mode 100644 index 4a8c61d4..00000000 --- a/Source/UHLDebug/UHLDebug.Build.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -using UnrealBuildTool; - -// Module that helps debugging UnrealHelperLibrary and can depend on all other modules -// Don't mess with UHLDebugSystem - that completely independent system from UHL -// and probably should be other plugin -public class UHLDebug : ModuleRules -{ - public UHLDebug(ReadOnlyTargetRules Target) : base(Target) - { - PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; - - PublicIncludePaths.AddRange( - new string[] { - // ... add public include paths required here ... - } - ); - - - PrivateIncludePaths.AddRange( - new string[] { - // ... add other private include paths required here ... - } - ); - - - PublicDependencyModuleNames.AddRange( - new string[] - { - "Core", - // ... add other public dependencies that you statically link with here ... - "GameplayAbilities", - "GameplayTags", - "GameplayTasks", - "EnhancedInput", - } - ); - - - PrivateDependencyModuleNames.AddRange( - new string[] - { - "CoreUObject", - "Engine", - - "Slate", - "SlateCore", - "UMG", - "DeveloperSettings", - - "UnrealHelperLibrary", - "UHLDebugSystem", - "UHLGAS", - } - ); - - - DynamicallyLoadedModuleNames.AddRange( - new string[] - { - // ... add any modules that your module loads dynamically here ... - } - ); - } -} diff --git a/Source/UHLDebugSystem/Private/AA_WaitDebugCategoryChange.cpp b/Source/UHLDebugSystem/Private/AA_WaitDebugCategoryChange.cpp deleted file mode 100644 index fb0aeb00..00000000 --- a/Source/UHLDebugSystem/Private/AA_WaitDebugCategoryChange.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "AA_WaitDebugCategoryChange.h" - -#include "UnrealEngine.h" -#include "Engine/Engine.h" -#include "Engine/World.h" -#include "Engine/GameInstance.h" -#include "Kismet/GameplayStatics.h" -#include "UHLDebugSystemSubsystem.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(AA_WaitDebugCategoryChange) - -UAA_WaitDebugCategoryChange* UAA_WaitDebugCategoryChange::WaitDebugCategoryChange(const UObject* WorldContext, FGameplayTag DebugCategoryTag, bool bCheckOnStart) -{ - // We must have a valid contextual world for this action, so we don't even make it - // unless we can resolve the UWorld from WorldContext. - UWorld* ContextWorld = GEngine->GetWorldFromContextObject(WorldContext, EGetWorldErrorMode::ReturnNull); - if(!IsValid(ContextWorld) || !ensureAlwaysMsgf(IsValid(WorldContext), TEXT("World Context was not valid."))) - { - return nullptr; - } - - UAA_WaitDebugCategoryChange* NewAction = NewObject(); - NewAction->ContextWorld = ContextWorld; - NewAction->DebugCategoryTagInternal = DebugCategoryTag; - NewAction->bCheckOnStart = bCheckOnStart; - NewAction->RegisterWithGameInstance(ContextWorld->GetGameInstance()); - return NewAction; -} - -void UAA_WaitDebugCategoryChange::Activate() -{ - UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(GetWorld()); - if (IsValid(GameInstance)) - { - UUHLDebugSystemSubsystem* UHLDebugSubsystem = GameInstance->GetSubsystem(); - UHLDebugSubsystem->OnDebugCategoryChanged.AddUniqueDynamic(this, &UAA_WaitDebugCategoryChange::OnDebugCategoryChange); - if (bCheckOnStart) - { - OnDebugCategoryChange(DebugCategoryTagInternal, UHLDebugSubsystem->IsCategoryEnabled(DebugCategoryTagInternal)); - } - } -} - -void UAA_WaitDebugCategoryChange::OnDebugCategoryChange(FGameplayTag DebugCategoryTag, bool bEnabled) -{ - if (DebugCategoryTag != DebugCategoryTagInternal) return; - - if (OnChange.IsBound()) - { - OnChange.Broadcast(bEnabled); - } - - if (bEnabled) - { - if (OnEnabled.IsBound()) - { - OnEnabled.Broadcast(bEnabled); - } - } - else - { - if (OnDisabled.IsBound()) - { - OnDisabled.Broadcast(bEnabled); - } - } -} diff --git a/Source/UHLDebugSystem/Private/DebugCategories/DCC_AbilitySystem_Abilities.cpp b/Source/UHLDebugSystem/Private/DebugCategories/DCC_AbilitySystem_Abilities.cpp deleted file mode 100644 index 427fec56..00000000 --- a/Source/UHLDebugSystem/Private/DebugCategories/DCC_AbilitySystem_Abilities.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "DebugCategories/DCC_AbilitySystem_Abilities.h" - -#include "Engine/World.h" -#include "Kismet/KismetSystemLibrary.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(DCC_AbilitySystem_Abilities) - -void UDCC_AbilitySystem_Abilities::Activate_Implementation(UObject* ContextObject) -{ - UKismetSystemLibrary::ExecuteConsoleCommand(ContextObject->GetWorld(), FString("showdebug abilitysystem")); - UKismetSystemLibrary::ExecuteConsoleCommand(ContextObject->GetWorld(), FString("AbilitySystem.Debug.SetCategory Ability")); - return Super::Activate_Implementation(ContextObject); -} - -void UDCC_AbilitySystem_Abilities::Deactivate_Implementation(UObject* ContextObject) -{ - UKismetSystemLibrary::ExecuteConsoleCommand(ContextObject->GetWorld(), FString("showdebug reset")); - Super::Deactivate_Implementation(ContextObject); -} diff --git a/Source/UHLDebugSystem/Private/DebugCategories/DCC_AbilitySystem_Attributes.cpp b/Source/UHLDebugSystem/Private/DebugCategories/DCC_AbilitySystem_Attributes.cpp deleted file mode 100644 index ac73ee2a..00000000 --- a/Source/UHLDebugSystem/Private/DebugCategories/DCC_AbilitySystem_Attributes.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "DebugCategories/DCC_AbilitySystem_Attributes.h" - -#include "Engine/World.h" -#include "Kismet/KismetSystemLibrary.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(DCC_AbilitySystem_Attributes) - -void UDCC_AbilitySystem_Attributes::Activate_Implementation(UObject* ContextObject) -{ - UKismetSystemLibrary::ExecuteConsoleCommand(ContextObject->GetWorld(), FString("showdebug abilitysystem")); - UKismetSystemLibrary::ExecuteConsoleCommand(ContextObject->GetWorld(), FString("AbilitySystem.Debug.SetCategory Attributes")); - return Super::Activate_Implementation(ContextObject); -} - -void UDCC_AbilitySystem_Attributes::Deactivate_Implementation(UObject* ContextObject) -{ - UKismetSystemLibrary::ExecuteConsoleCommand(ContextObject->GetWorld(), FString("showdebug reset")); - Super::Deactivate_Implementation(ContextObject); -} diff --git a/Source/UHLDebugSystem/Private/DebugCategories/DCC_AbilitySystem_Effects.cpp b/Source/UHLDebugSystem/Private/DebugCategories/DCC_AbilitySystem_Effects.cpp deleted file mode 100644 index eef36977..00000000 --- a/Source/UHLDebugSystem/Private/DebugCategories/DCC_AbilitySystem_Effects.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "DebugCategories/DCC_AbilitySystem_Effects.h" - -#include "Engine/World.h" -#include "Kismet/KismetSystemLibrary.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(DCC_AbilitySystem_Effects) - -void UDCC_AbilitySystem_Effects::Activate_Implementation(UObject* ContextObject) -{ - UKismetSystemLibrary::ExecuteConsoleCommand(ContextObject->GetWorld(), FString("showdebug abilitysystem")); - UKismetSystemLibrary::ExecuteConsoleCommand(ContextObject->GetWorld(), FString("AbilitySystem.Debug.SetCategory GameplayEffects")); - return Super::Activate_Implementation(ContextObject); -} - -void UDCC_AbilitySystem_Effects::Deactivate_Implementation(UObject* ContextObject) -{ - UKismetSystemLibrary::ExecuteConsoleCommand(ContextObject->GetWorld(), FString("showdebug reset")); - Super::Deactivate_Implementation(ContextObject); -} diff --git a/Source/UHLDebugSystem/Private/DebugCategories/DCC_Collisions.cpp b/Source/UHLDebugSystem/Private/DebugCategories/DCC_Collisions.cpp deleted file mode 100644 index badf1450..00000000 --- a/Source/UHLDebugSystem/Private/DebugCategories/DCC_Collisions.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "DebugCategories/DCC_Collisions.h" - -#include "Engine/World.h" -#include "Kismet/KismetSystemLibrary.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(DCC_Collisions) - -void UDCC_Collisions::Activate_Implementation(UObject* ContextObject) -{ - UKismetSystemLibrary::ExecuteConsoleCommand(ContextObject->GetWorld(), FString("ShowFlag.Collision 1")); - Super::Activate_Implementation(ContextObject); -} - -void UDCC_Collisions::Deactivate_Implementation(UObject* ContextObject) -{ - UKismetSystemLibrary::ExecuteConsoleCommand(ContextObject->GetWorld(), FString("ShowFlag.Collision 0")); - Super::Deactivate_Implementation(ContextObject); -} diff --git a/Source/UHLDebugSystem/Private/DebugCategories/DCC_InputSystem_EnhancedInput.cpp b/Source/UHLDebugSystem/Private/DebugCategories/DCC_InputSystem_EnhancedInput.cpp deleted file mode 100644 index beb4a512..00000000 --- a/Source/UHLDebugSystem/Private/DebugCategories/DCC_InputSystem_EnhancedInput.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "DebugCategories/DCC_InputSystem_EnhancedInput.h" - -#include "Engine/World.h" -#include "Kismet/KismetSystemLibrary.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(DCC_InputSystem_EnhancedInput) - -void UDCC_InputSystem_EnhancedInput::Activate_Implementation(UObject* ContextObject) -{ - UKismetSystemLibrary::ExecuteConsoleCommand(ContextObject->GetWorld(), FString("showdebug enhancedinput")); - Super::Activate_Implementation(ContextObject); -} - -void UDCC_InputSystem_EnhancedInput::Deactivate_Implementation(UObject* ContextObject) -{ - UKismetSystemLibrary::ExecuteConsoleCommand(ContextObject->GetWorld(), FString("showdebug reset")); - Super::Deactivate_Implementation(ContextObject); -} diff --git a/Source/UHLDebugSystem/Private/DebugCategoryButtonWidget.cpp b/Source/UHLDebugSystem/Private/DebugCategoryButtonWidget.cpp deleted file mode 100644 index 53197f95..00000000 --- a/Source/UHLDebugSystem/Private/DebugCategoryButtonWidget.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "DebugCategoryButtonWidget.h" - -#include "Engine/GameInstance.h" -#include "Blueprint/WidgetTree.h" -#include "Components/Button.h" -#include "Components/ButtonSlot.h" -#include "Components/CheckBox.h" -#include "Components/HorizontalBox.h" -#include "Components/HorizontalBoxSlot.h" -#include "Components/TextBlock.h" -#include "Kismet/GameplayStatics.h" -#include "UHLDebugCategory.h" -#include "UHLDebugSystemSubsystem.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(DebugCategoryButtonWidget) - -void UDebugCategoryButtonWidget::SetUp(const FUHLDebugCategory& UHLDebugCategory_In) -{ - UHLDebugCategory = UHLDebugCategory_In; - TextBlock->SetText(FText::FromString(UHLDebugCategory_In.Name)); - UpdateCheckboxState(UHLDebugCategory_In.GetIsEnabled()); - Button->SetBackgroundColor(UHLDebugCategory.Color); - Button->OnClicked.AddUniqueDynamic(this, &UDebugCategoryButtonWidget::OnButtonClicked); - UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(GetWorld()); - if (GameInstance) - { - UUHLDebugSystemSubsystem* UHLDebugSubsystem = GameInstance->GetSubsystem(); - UHLDebugSubsystem->OnDebugCategoryChanged.AddUniqueDynamic(this, &UDebugCategoryButtonWidget::OnDebugCategoryChanged); - } -} - -void UDebugCategoryButtonWidget::UpdateCheckboxState(bool bEnabled_In) -{ - CheckBox->SetCheckedState(bEnabled_In ? ECheckBoxState::Checked : ECheckBoxState::Unchecked); -} - -bool UDebugCategoryButtonWidget::Initialize() -{ - bool bIsWidgetInitialized = Super::Initialize(); - - // more correct way to avoid error. than in original post. - if(!HasAnyFlags(RF_ClassDefaultObject)) - { - // root have to be initialized in Initialize function, otherwise it will not work, donno exactly why. - Button = WidgetTree->ConstructWidget(); - WidgetTree->RootWidget = Button; - } - return bIsWidgetInitialized; -} - -void UDebugCategoryButtonWidget::NativePreConstruct() -{ - Super::NativeConstruct(); - - if (!WidgetTree) return; - - HorizontalBox = WidgetTree->ConstructWidget(); - CheckBox = WidgetTree->ConstructWidget(); - TextBlock = WidgetTree->ConstructWidget(); - if (!HorizontalBox || !CheckBox || !TextBlock) return; - - TextBlock->SetShadowOffset(FVector2D(1.0f, 1.0f)); - TextBlock->SetShadowColorAndOpacity(FColor::FromHex("#000000FF")); - TextBlock->SetVisibility(ESlateVisibility::HitTestInvisible); - CheckBox->SetVisibility(ESlateVisibility::HitTestInvisible); - CheckBox->SetIsEnabled(false); - FCheckBoxStyle CheckBoxStyle = CheckBox->GetWidgetStyle(); - CheckBoxStyle.CheckedImage.TintColor = FColor::Black; - CheckBoxStyle.ForegroundColor = FColor::White; - CheckBoxStyle.CheckedForeground = FColor::White; - CheckBoxStyle.HoveredForeground = FColor::White; - CheckBoxStyle.PressedForeground = FColor::White; - CheckBoxStyle.UndeterminedForeground = FColor::White; - CheckBoxStyle.CheckedHoveredForeground = FColor::White; - CheckBoxStyle.CheckedPressedForeground = FColor::White; - CheckBox->SetWidgetStyle(CheckBoxStyle); - HorizontalBox->SetVisibility(ESlateVisibility::HitTestInvisible); - - UButtonSlot* HorizontalBoxButtonSlot = Cast(Button->AddChild(HorizontalBox)); - UHorizontalBoxSlot* CheckboxHorizontalBoxSlot = Cast(HorizontalBox->AddChild(CheckBox)); - UHorizontalBoxSlot* TextBlockHorizontalBoxSlot = Cast(HorizontalBox->AddChild(TextBlock)); - if (!HorizontalBoxButtonSlot || !CheckboxHorizontalBoxSlot || !TextBlockHorizontalBoxSlot) return; - - HorizontalBoxButtonSlot->SetHorizontalAlignment(HAlign_Left); - CheckboxHorizontalBoxSlot->SetPadding(FMargin(0, 0, 10, 0)); - TextBlockHorizontalBoxSlot->SetHorizontalAlignment(HAlign_Left); - TextBlockHorizontalBoxSlot->SetVerticalAlignment(VAlign_Top); -} - -void UDebugCategoryButtonWidget::OnButtonClicked() -{ - if (OnMadeClick.IsBound()) - { - OnMadeClick.Broadcast(this, UHLDebugCategory.Tags.First()); - } -} - -void UDebugCategoryButtonWidget::OnDebugCategoryChanged(FGameplayTag DebugCategoryTag_In, bool bEnabled_In) -{ - if (UHLDebugCategory.Tags.First() == DebugCategoryTag_In) - { - UpdateCheckboxState(bEnabled_In); - } -} diff --git a/Source/UHLDebugSystem/Private/Development/UHLDebugSystemSettings.cpp b/Source/UHLDebugSystem/Private/Development/UHLDebugSystemSettings.cpp deleted file mode 100644 index 8ef656b7..00000000 --- a/Source/UHLDebugSystem/Private/Development/UHLDebugSystemSettings.cpp +++ /dev/null @@ -1,254 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Development/UHLDebugSystemSettings.h" - -#include "Core/UHLGameplayTags.h" -#include "UHLDebugCategory.h" -#include "UHLDebugSystemSubsystem.h" -#include "DebugCategories/DCC_AbilitySystem_Abilities.h" -#include "DebugCategories/DCC_AbilitySystem_Attributes.h" -#include "DebugCategories/DCC_AbilitySystem_Effects.h" -#include "DebugCategories/DCC_Collisions.h" -#include "DebugCategories/DCC_InputSystem_EnhancedInput.h" -#include "Utils/UnrealHelperLibraryBPL.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLDebugSystemSettings) - -void UUHLDebugSystemSettings::OnEnabledDebugCategoryEntryChanged( - FGameplayTag ChangedDebugCategoryTag, bool bEnabled) -{ - if (ChangedDebugCategoryTag != FGameplayTag::EmptyTag) - { - FUHLDebugCategory* UHLDebugCategory = DebugCategories.FindByPredicate([=](const FUHLDebugCategory& DebugCategory) - { - return DebugCategory.Tags.HasAnyExact(FGameplayTagContainer(ChangedDebugCategoryTag)); - }); - if (UHLDebugCategory != nullptr) - { - - for (FGameplayTag BlockedTag : UHLDebugCategory->Blocks.GetGameplayTagArray()) - { - for (TTuple& EnabledDebugCategory : EnabledDebugCategories) - { - if (!EnabledDebugCategory.Key.MatchesTag(ChangedDebugCategoryTag) - && EnabledDebugCategory.Key.MatchesTag(BlockedTag)) - { - EnabledDebugCategory.Value = false; - } - } - } - - for (FGameplayTag RequiredDebugCategoryTag : UHLDebugCategory->RequiredDebugCategories.GetGameplayTagArray()) - { - for (TTuple& EnabledDebugCategory : EnabledDebugCategories) - { - if (!EnabledDebugCategory.Key.MatchesTag(ChangedDebugCategoryTag) - && EnabledDebugCategory.Key.MatchesTag(RequiredDebugCategoryTag)) - { - EnabledDebugCategory.Value = true; - } - } - } - - // UpdateEnabledDebugCategoriesList(); - } - } - - EnabledDebugCategories[ChangedDebugCategoryTag] = bEnabled; -} - -TArray UUHLDebugSystemSettings::GET_DEFAULT_UHL_DEBUG_CATEGORIES() -{ - TArray DEFAULT_UHL_DEBUG_CATEGORIES = {}; - - FUHLDebugCategory AbilitySystemAttributesDebugCategory = {}; - AbilitySystemAttributesDebugCategory.Name = "AbilitySystem Attributes"; - AbilitySystemAttributesDebugCategory.Tags = FGameplayTagContainer{ UHLGameplayTags::TAG_UHL_DebugCategory_AbilitySystem_Attributes }; - AbilitySystemAttributesDebugCategory.Blocks.AddTag(UHLGameplayTags::TAG_UHL_DebugCategory_AbilitySystem); - AbilitySystemAttributesDebugCategory.Blocks.AddTag(UHLGameplayTags::TAG_UHL_DebugCategory_InputSystem_EnhancedInputSystem); - AbilitySystemAttributesDebugCategory.Components = { UDCC_AbilitySystem_Attributes::StaticClass() }; - AbilitySystemAttributesDebugCategory.bIsDefaultUHLDebugCategory = true; - DEFAULT_UHL_DEBUG_CATEGORIES.Add(AbilitySystemAttributesDebugCategory); - - FUHLDebugCategory AbilitySystemEffectsDebugCategory = {}; - AbilitySystemEffectsDebugCategory.Name = "AbilitySystem Effects"; - AbilitySystemEffectsDebugCategory.Tags = FGameplayTagContainer{ UHLGameplayTags::TAG_UHL_DebugCategory_AbilitySystem_Effects }; - AbilitySystemEffectsDebugCategory.Blocks.AddTag(UHLGameplayTags::TAG_UHL_DebugCategory_AbilitySystem); - AbilitySystemEffectsDebugCategory.Blocks.AddTag(UHLGameplayTags::TAG_UHL_DebugCategory_InputSystem_EnhancedInputSystem); - AbilitySystemEffectsDebugCategory.Components = { UDCC_AbilitySystem_Effects::StaticClass() }; - AbilitySystemEffectsDebugCategory.bIsDefaultUHLDebugCategory = true; - DEFAULT_UHL_DEBUG_CATEGORIES.Add(AbilitySystemEffectsDebugCategory); - - FUHLDebugCategory AbilitySystemAbilitiesDebugCategory = {}; - AbilitySystemAbilitiesDebugCategory.Name = "AbilitySystem Abilities"; - AbilitySystemAbilitiesDebugCategory.Tags = FGameplayTagContainer{ UHLGameplayTags::TAG_UHL_DebugCategory_AbilitySystem_Abilities }; - AbilitySystemAbilitiesDebugCategory.Blocks.AddTag(UHLGameplayTags::TAG_UHL_DebugCategory_AbilitySystem); - AbilitySystemAbilitiesDebugCategory.Blocks.AddTag(UHLGameplayTags::TAG_UHL_DebugCategory_InputSystem_EnhancedInputSystem); - AbilitySystemAbilitiesDebugCategory.Components = { UDCC_AbilitySystem_Abilities::StaticClass() }; - AbilitySystemAbilitiesDebugCategory.bIsDefaultUHLDebugCategory = true; - DEFAULT_UHL_DEBUG_CATEGORIES.Add(AbilitySystemAbilitiesDebugCategory); - - FUHLDebugCategory EnhancedInputSystemDebugCategory = {}; - EnhancedInputSystemDebugCategory.Name = "EnhancedInputSystem"; - EnhancedInputSystemDebugCategory.Tags = FGameplayTagContainer{ UHLGameplayTags::TAG_UHL_DebugCategory_InputSystem_EnhancedInputSystem }; - EnhancedInputSystemDebugCategory.Blocks.AddTag(UHLGameplayTags::TAG_UHL_DebugCategory_AbilitySystem); - EnhancedInputSystemDebugCategory.Components = { UDCC_InputSystem_EnhancedInput::StaticClass() }; - EnhancedInputSystemDebugCategory.bIsDefaultUHLDebugCategory = true; - DEFAULT_UHL_DEBUG_CATEGORIES.Add(EnhancedInputSystemDebugCategory); - - FUHLDebugCategory AbilityInputCacheDebugCategory = {}; - AbilityInputCacheDebugCategory.Name = "AbilityInputCache"; - AbilityInputCacheDebugCategory.Tags = FGameplayTagContainer{ UHLGameplayTags::TAG_UHL_DebugCategory_InputSystem_AbilityInputCache }; - AbilityInputCacheDebugCategory.bIsDefaultUHLDebugCategory = true; - DEFAULT_UHL_DEBUG_CATEGORIES.Add(AbilityInputCacheDebugCategory); - - FUHLDebugCategory CollisionsDebugCategory = {}; - CollisionsDebugCategory.Name = "Collisions"; - CollisionsDebugCategory.Tags = FGameplayTagContainer{ UHLGameplayTags::TAG_UHL_DebugCategory_Collisions }; - EnhancedInputSystemDebugCategory.Components = { UDCC_Collisions::StaticClass() }; - CollisionsDebugCategory.bIsDefaultUHLDebugCategory = true; - DEFAULT_UHL_DEBUG_CATEGORIES.Add(CollisionsDebugCategory); - - return DEFAULT_UHL_DEBUG_CATEGORIES; -} - -#if WITH_EDITOR -void UUHLDebugSystemSettings::PostInitProperties() -{ - Super::PostInitProperties(); - - UpdateDefaultUHLDebugCategories(); - - for (const FUHLDebugCategory& DebugCategory : DebugCategories) - { - if (DebugCategory.ByDefaultEnabledInBuildTypes.Contains(UUnrealHelperLibraryBPL::GetBuildType())) - { - EnabledDebugCategories.Emplace(DebugCategory.Tags.First(), true); - } - } - - RecreateEnabledDebugCategoriesList(); -} - -void UUHLDebugSystemSettings::PreEditChange(FProperty* PropertyAboutToChange) -{ - if (PropertyAboutToChange->GetName() == GET_MEMBER_NAME_CHECKED(UUHLDebugSystemSettings, EnabledDebugCategories)) - { - LastEnabledDebugCategories = TMap(EnabledDebugCategories); - } - - Super::PreEditChange(PropertyAboutToChange); -} - -void UUHLDebugSystemSettings::PostEditChangeChainProperty(struct FPropertyChangedChainEvent& PropertyChangedEvent) -{ - FName PropertyName = PropertyChangedEvent.GetPropertyName(); - - bool bEditingEnabledCategoriesKey = PropertyName == "EnabledDebugCategories_Key"; - if (bEditingEnabledCategoriesKey || (EnabledDebugCategories.IsEmpty() && !DebugCategories.IsEmpty())) - { - RecreateEnabledDebugCategoriesList(); - return; - } - - Super::PostEditChangeChainProperty(PropertyChangedEvent); - - bool bEditingEnabledDebugCategories = - PropertyName == GET_MEMBER_NAME_CHECKED(UUHLDebugSystemSettings, EnabledDebugCategories) - && !LastEnabledDebugCategories.IsEmpty() - && !EnabledDebugCategories.IsEmpty() - && LastEnabledDebugCategories.Num() == EnabledDebugCategories.Num(); - - // disable other DebugCategories by "Blocks" tags - if (bEditingEnabledDebugCategories) - { - bool NewValue = false; - FGameplayTag ChangedDebugCategoryTag = FGameplayTag::EmptyTag; - for (const TTuple& EnabledDebugCategory : EnabledDebugCategories) - { - if (LastEnabledDebugCategories[EnabledDebugCategory.Key] != EnabledDebugCategory.Value) - { - NewValue = EnabledDebugCategory.Value; - ChangedDebugCategoryTag = EnabledDebugCategory.Key; - } - } - - OnEnabledDebugCategoryEntryChanged(ChangedDebugCategoryTag, NewValue); - } - - if (PropertyName == GET_MEMBER_NAME_CHECKED(UUHLDebugSystemSettings, bExcludeDefaultUHLDebugCategories)) - { - UpdateDefaultUHLDebugCategories(); - RecreateEnabledDebugCategoriesList(); - } - - if (PropertyName == GET_MEMBER_NAME_CHECKED(UUHLDebugSystemSettings, DebugCategories) - || PropertyChangedEvent.PropertyChain.GetActiveMemberNode()->GetValue()->GetName() == GET_MEMBER_NAME_CHECKED(UUHLDebugSystemSettings, DebugCategories)) - { - RecreateEnabledDebugCategoriesList(); - } -} -#endif - -void UUHLDebugSystemSettings::RecreateEnabledDebugCategoriesList() -{ - TMap CopyOfEnabledDebugCategories = TMap(EnabledDebugCategories); - - EnabledDebugCategories.Empty(); - for (const FUHLDebugCategory& DebugCategory : DebugCategories) - { - for (FGameplayTag GameplayTag : DebugCategory.Tags.GetGameplayTagArray()) - { - bool* KeyVal = CopyOfEnabledDebugCategories.Find(GameplayTag); - EnabledDebugCategories.Add(GameplayTag, KeyVal ? *KeyVal : false); - } - } -} - -void UUHLDebugSystemSettings::UpdateEnabledDebugCategoriesList() -{ - for (const FUHLDebugCategory& DebugCategory : DebugCategories) - { - TArray Keys; - EnabledDebugCategories.GetKeys(Keys); - - FGameplayTagContainer KeysContainer = FGameplayTagContainer::CreateFromArray(Keys); - if (!KeysContainer.HasAll(DebugCategory.Tags)) - { - for (FGameplayTag GameplayTag : DebugCategory.Tags.GetGameplayTagArray()) - { - if (GameplayTag.MatchesAny(KeysContainer)) - { - continue; - } - EnabledDebugCategories.Add(GameplayTag, false); - } - } - } -} - -void UUHLDebugSystemSettings::UpdateDefaultUHLDebugCategories() -{ - if (bExcludeDefaultUHLDebugCategories) - { - DebugCategories.RemoveAll([=](const FUHLDebugCategory& DebugCategory) - { - return DebugCategory.bIsDefaultUHLDebugCategory; - }); - } - else - { - for (const FUHLDebugCategory& DefaultUHLDebugCategory : GET_DEFAULT_UHL_DEBUG_CATEGORIES()) - { - FUHLDebugCategory* FoundDebugCategory = DebugCategories.FindByPredicate([=](const FUHLDebugCategory& Category) - { - return Category.Tags == DefaultUHLDebugCategory.Tags; - }); - if (!FoundDebugCategory) - { - DebugCategories.Add(DefaultUHLDebugCategory); - } - } - } -} diff --git a/Source/UHLDebugSystem/Private/UHLDebugBlueprintLibrary.cpp b/Source/UHLDebugSystem/Private/UHLDebugBlueprintLibrary.cpp deleted file mode 100644 index ffbafc44..00000000 --- a/Source/UHLDebugSystem/Private/UHLDebugBlueprintLibrary.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UHLDebugBlueprintLibrary.h" - -#include "GameplayTagsManager.h" -#include "Misc/ConfigCacheIni.h" -#include "Animation/AnimMontage.h" -#include "DrawDebugHelpers.h" -#include "UHLDebugSystemSubsystem.h" -#include "Engine/World.h" -#include "Engine/GameInstance.h" -#include "Kismet/GameplayStatics.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLDebugBlueprintLibrary) - -bool UUHLDebugBlueprintLibrary::IsUHLDebugCategoryEnabled(UObject* WorldContextObject, FGameplayTag DebugCategoryGameplayTag) -{ - UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(WorldContextObject); - if (!IsValid(GameInstance)) - { - return false; - } - - UUHLDebugSystemSubsystem* UHLDebugSubsystem = GameInstance->GetSubsystem(); - if (!IsValid(UHLDebugSubsystem)) - { - return false; - } - - return UHLDebugSubsystem->IsCategoryEnabled(DebugCategoryGameplayTag); -} diff --git a/Source/UHLDebugSystem/Private/UHLDebugCategory.cpp b/Source/UHLDebugSystem/Private/UHLDebugCategory.cpp deleted file mode 100644 index 493d255c..00000000 --- a/Source/UHLDebugSystem/Private/UHLDebugCategory.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UHLDebugCategory.h" - -#include "Templates/SubclassOf.h" -#include "UHLDebugCategoryComponent.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLDebugCategory) - -bool FUHLDebugCategory::TryEnable(UObject* ContextObj) -{ - bool bResult = false; - - int32 ComponentsActivated = 0; - int32 ComponentsRequiredToActivate = Components.Num(); - for (TSubclassOf ComponentClass : Components) - { - if (!ComponentClass) - { - ComponentsRequiredToActivate--; - continue; - }; - - UUHLDebugCategoryComponent* Component = GetOrCreateDebugCategoryComponent(ComponentClass, ContextObj); - if (Component->CanActivate(ContextObj)) - { - Component->Activate(ContextObj); - ComponentsActivated++; - } - } - if (ComponentsActivated == ComponentsRequiredToActivate) - { - bResult = true; - } - - bIsEnabled = true; - return bResult; -} - -void FUHLDebugCategory::TryDisable(UObject* ContextObj) -{ - for (UUHLDebugCategoryComponent* InstancedComponent : InstancedComponents) - { - if (InstancedComponent) - { - InstancedComponent->Deactivate(ContextObj); - } - } - bIsEnabled = false; -} - -UUHLDebugCategoryComponent* FUHLDebugCategory::GetOrCreateDebugCategoryComponent(TSubclassOf ComponentClass, UObject* ContextObj) -{ - UUHLDebugCategoryComponent* Component = nullptr; - UUHLDebugCategoryComponent** FoundComponent = GetDebugCategoryComponent(ComponentClass, ContextObj); - if (!FoundComponent) - { - Component = NewObject(ContextObj, ComponentClass); - InstancedComponents.Add(Component); - } - else - { - Component = *FoundComponent; - } - - return Component; -} - -UUHLDebugCategoryComponent** FUHLDebugCategory::GetDebugCategoryComponent(TSubclassOf ComponentClass, UObject* ContextObj) -{ - return InstancedComponents.FindByPredicate([=](UUHLDebugCategoryComponent* DebugCategoryComponent) - { - return DebugCategoryComponent->GetClass() == ComponentClass; - }); -} diff --git a/Source/UHLDebugSystem/Private/UHLDebugCategoryComponent.cpp b/Source/UHLDebugSystem/Private/UHLDebugCategoryComponent.cpp deleted file mode 100644 index 6dde961b..00000000 --- a/Source/UHLDebugSystem/Private/UHLDebugCategoryComponent.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "UHLDebugCategoryComponent.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLDebugCategoryComponent) - -bool UUHLDebugCategoryComponent::CanActivate_Implementation(UObject* ContextObject) const -{ - return true; -} - -void UUHLDebugCategoryComponent::Activate_Implementation(UObject* ContextObject) -{ -} - -void UUHLDebugCategoryComponent::Deactivate_Implementation(UObject* ContextObject) -{ -} diff --git a/Source/UHLDebugSystem/Private/UHLDebugSystem.cpp b/Source/UHLDebugSystem/Private/UHLDebugSystem.cpp deleted file mode 100644 index d484f6db..00000000 --- a/Source/UHLDebugSystem/Private/UHLDebugSystem.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UHLDebugSystem.h" - -#include "Misc/Paths.h" -#include "GameplayTagsManager.h" -#include "UHLConfigMigrationUtils.h" -#include "Development/UHLDebugSystemSettings.h" - -#define LOCTEXT_NAMESPACE "FUHLDebugSystemModule" - -void FUHLDebugSystemModule::StartupModule() -{ - UGameplayTagsManager& TagsManager = UGameplayTagsManager::Get(); - // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module - TagsManager.AddTagIniSearchPath(FPaths::ProjectPluginsDir() / TEXT("UnrealHelperLibrary/Config/Tags")); - - MigrateOldSettingsFromMainModule(); -} - -void FUHLDebugSystemModule::ShutdownModule() -{ - // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, - // we call this function before unloading the module. -} - -void FUHLDebugSystemModule::MigrateOldSettingsFromMainModule() -{ - UHLConfigMigrationUtils::MigrateConfigSectionIfNeeded( - TEXT("/Script/UnrealHelperLibrary.UHLDebugSubsystemSettings"), - TEXT("/Script/UHLDebugSystem.UHLDebugSystemSettings"), - TEXT("bMigrationFromOldSettingsDone"), - GGameIni, - GGameIni - ); - - UUHLDebugSystemSettings* Settings = GetMutableDefault(); - if (Settings) - { - Settings->ReloadConfig(); - // Settings->SaveConfig(); - } -} - -#undef LOCTEXT_NAMESPACE - -IMPLEMENT_MODULE(FUHLDebugSystemModule, UHLDebugSystem) diff --git a/Source/UHLDebugSystem/Private/UHLDebugSystemSubsystem.cpp b/Source/UHLDebugSystem/Private/UHLDebugSystemSubsystem.cpp deleted file mode 100644 index df82852b..00000000 --- a/Source/UHLDebugSystem/Private/UHLDebugSystemSubsystem.cpp +++ /dev/null @@ -1,284 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "UHLDebugSystemSubsystem.h" - -#include "UnrealHelperLibrary.h" -#include "GameFramework/Pawn.h" -#include "GameFramework/Controller.h" -#include "GameFramework/PlayerController.h" -#include "Development/UHLDebugSystemSettings.h" -#include "UnrealHelperLibraryTypes.h" -#include "Utils/UnrealHelperLibraryBPL.h" -#if WITH_EDITOR -#include "Framework/Notifications/NotificationManager.h" -#include "Widgets/Notifications/SNotificationList.h" -#endif - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLDebugSystemSubsystem) - -UUHLDebugSystemSubsystem::UUHLDebugSystemSubsystem() -{ -} - -void UUHLDebugSystemSubsystem::Initialize(FSubsystemCollectionBase& Collection) -{ - Super::Initialize(Collection); - - if (bSetupped) return; - bSetupped = true; - UE_LOG(LogUnrealHelperLibrary, Warning, TEXT("[UUHLDebugSubsystem::Initialize] Start")); - - const UUHLDebugSystemSettings* DeveloperSettings = GetDefault(); - DebugCategories = DeveloperSettings->DebugCategories; - - for (const TTuple& EnabledDebugCategory : DeveloperSettings->EnabledDebugCategories) - { - const FUHLDebugCategory* UHLDebugCategory = DebugCategories.FindByPredicate([=](const FUHLDebugCategory& DebugCategory) - { - return DebugCategory.Tags.HasAnyExact(FGameplayTagContainer(EnabledDebugCategory.Key)); - }); - if (EnabledDebugCategory.Value == true && UHLDebugCategory != nullptr && !UHLDebugCategory->bRequiresPlayerControllerToEnable) - { - EnableDebugCategory(EnabledDebugCategory.Key, EnabledDebugCategory.Value); - } - }; - - EUHLBuildType BuildType = UUnrealHelperLibraryBPL::GetBuildType(); - if (BuildType != EUHLBuildType::Editor) - { - UE_LOG(LogUnrealHelperLibrary, Warning, TEXT("[UUHLDebugSubsystem::Initialize] BuildType not editor so check DebugCategories that should be enabled")); - for (const FUHLDebugCategory& DebugCategory : DebugCategories) - { - UE_LOG(LogUnrealHelperLibrary, Warning, TEXT("[UUHLDebugSubsystem::Initialize] EnableDebugCategory %s"), *DebugCategory.Tags.First().ToString()); - if (DebugCategory.ByDefaultEnabledInBuildTypes.Contains(BuildType)) - { - EnableDebugCategory(DebugCategory.Tags.First(), true); - } - } - } - UE_LOG(LogUnrealHelperLibrary, Warning, TEXT("[UUHLDebugSubsystem::SetUp] Finish")); - - FWorldDelegates::OnPostWorldInitialization.AddUObject(this, &ThisClass::OnPostWorldInit); - FWorldDelegates::OnWorldBeginTearDown.AddUObject(this, &ThisClass::OnWorldBeginTearDown); -} - -void UUHLDebugSystemSubsystem::Deinitialize() -{ - FWorldDelegates::OnPostWorldInitialization.RemoveAll(this); - - if (UWorld* World = GetWorld()) - { - if (ActorSpawnedDelegateHandle.IsValid()) - { - World->RemoveOnActorSpawnedHandler(ActorSpawnedDelegateHandle); - } - } - - for (FUHLDebugCategory& DebugCategory : DebugCategories) - { - // if (DebugCategory.bForceComponentsDeactivateOnEnd) - if (DebugCategory.GetIsEnabled()) - { - DebugCategory.TryDisable(this); - } - } - - Super::Deinitialize(); -} - -void UUHLDebugSystemSubsystem::OnActorSpawned(AActor* SpawnedActor) -{ - if (AController* Controller = Cast(SpawnedActor)) - { - // Pawn spawned, check if it’s controlled by a player - if (APlayerController* PC = Cast(Controller)) - { - UE_LOG(LogTemp, Log, TEXT("Pawn %s began play, controlled by PlayerController %s"), *Controller->GetName(), *PC->GetName()); - // Handle the player/pawn here (e.g., subscribe to further events, spawn effects, etc.) - - // unsubscribe as fast as possible - if (UWorld* World = GetWorld()) - { - if (ActorSpawnedDelegateHandle.IsValid()) - { - World->RemoveOnActorSpawnedHandler(ActorSpawnedDelegateHandle); - } - } - SetUpCategoriesThatRequiresPlayerController(); - } - } -} - -void UUHLDebugSystemSubsystem::SetUpCategoriesThatRequiresPlayerController() -{ - if (bSetUpCategoriesThatRequiresPlayerController) return; - UE_LOG(LogUnrealHelperLibrary, Warning, TEXT("[UUHLDebugSubsystem::SetUpCategoriesThatRequiresPlayerController] Start")); - bSetUpCategoriesThatRequiresPlayerController = true; - - const UUHLDebugSystemSettings* DeveloperSettings = GetDefault(); - - for (const TTuple& EnabledDebugCategory : DeveloperSettings->EnabledDebugCategories) - { - const FUHLDebugCategory* UHLDebugCategory = DebugCategories.FindByPredicate([=](const FUHLDebugCategory& DebugCategory) - { - return DebugCategory.Tags.HasAnyExact(FGameplayTagContainer(EnabledDebugCategory.Key)); - }); - if (EnabledDebugCategory.Value == true && UHLDebugCategory != nullptr && UHLDebugCategory->bRequiresPlayerControllerToEnable) - { - EnableDebugCategory(EnabledDebugCategory.Key, EnabledDebugCategory.Value); - } - }; - - // activate debug categories that "bSetUpCategoriesThatRequiresPlayerController" and should be enabled in BuildType - EUHLBuildType BuildType = UUnrealHelperLibraryBPL::GetBuildType(); - if (BuildType != EUHLBuildType::Editor) - { - UE_LOG(LogUnrealHelperLibrary, Warning, TEXT("[UUHLDebugSubsystem::SetUpCategoriesThatRequiresPlayerController] BuildType not editor so check DebugCategories that should be enabled")); - for (const FUHLDebugCategory& DebugCategory : DebugCategories) - { - if (DebugCategory.ByDefaultEnabledInBuildTypes.Contains(BuildType)) - { - UE_LOG(LogUnrealHelperLibrary, Warning, TEXT("[UUHLDebugSubsystem::SetUpCategoriesThatRequiresPlayerController] EnableDebugCategory %s"), *DebugCategory.Tags.First().ToString()); - EnableDebugCategory(DebugCategory.Tags.First(), true); - } - } - } - - bIsSetuping = false; - UE_LOG(LogUnrealHelperLibrary, Warning, TEXT("[UUHLDebugSubsystem::SetUpCategoriesThatRequiresPlayerController] Finish")); -} - -bool UUHLDebugSystemSubsystem::IsCategoryEnabled(const FGameplayTag DebugCategoryTag) const -{ - const FUHLDebugCategory* UHLDebugCategory = DebugCategories.FindByPredicate([=](const FUHLDebugCategory& DebugCategory) - { - return DebugCategory.Tags.HasAnyExact(FGameplayTagContainer(DebugCategoryTag)); - }); - if (UHLDebugCategory != nullptr) - { - return UHLDebugCategory->GetIsEnabled(); - } - return false; -} - -void UUHLDebugSystemSubsystem::EnableDebugCategory(const FGameplayTag DebugCategoryTag, bool bEnable) -{ - bool bEnabled = bEnable; - - FUHLDebugCategory* UHLDebugCategory = DebugCategories.FindByPredicate([=](const FUHLDebugCategory& DebugCategory) - { - return DebugCategory.Tags.HasAnyExact(FGameplayTagContainer(DebugCategoryTag)); - }); - if (UHLDebugCategory == nullptr) return; - if (UHLDebugCategory->bRequiresPlayerControllerToEnable && !bSetUpCategoriesThatRequiresPlayerController) return; - if (UHLDebugCategory->GetIsEnabled() && bEnable) return; - if (!UHLDebugCategory->GetIsEnabled() && !bEnable) return; - - if (bEnable) - { - // Disable blocked DebugCategories - for (const FUHLDebugCategory& DebugCategory : DebugCategories) - { - if (DebugCategory != *UHLDebugCategory - && !UHLDebugCategory->Blocks.IsEmpty() - && DebugCategory.Tags.HasAny(UHLDebugCategory->Blocks)) - { - EnableDebugCategory(DebugCategory.Tags.First(), false); - } - } - - // Enable required DebugCategories - for (const FUHLDebugCategory& DebugCategory : DebugCategories) - { - if (DebugCategory != *UHLDebugCategory - && !UHLDebugCategory->RequiredDebugCategories.IsEmpty() - && DebugCategory.Tags.HasAny(UHLDebugCategory->RequiredDebugCategories)) - { - EnableDebugCategory(DebugCategory.Tags.First(), true); - } - } - - bEnabled = UHLDebugCategory->TryEnable(this); - } - else - { - if (!bIsSetuping) - // TODO remove - // || (bIsSetuping && UHLDebugCategory->bForceComponentsDeactivateOnEnd)) - { - // Check that its not required by some other DebugCategory - bool bHasDependantDebugCategory = false; - FUHLDebugCategory DependantDebugCategory; - for (const FUHLDebugCategory& DebugCategory : DebugCategories) - { - if (DebugCategory != *UHLDebugCategory - && !DebugCategory.RequiredDebugCategories.IsEmpty() - && DebugCategory.RequiredDebugCategories.HasAny(UHLDebugCategory->Tags)) - { - bHasDependantDebugCategory = true; - DependantDebugCategory = DebugCategory; - // EnableDebugCategory(DebugCategory.Tags.First(), true); - } - } - if (bHasDependantDebugCategory) - { - DependantDebugCategory.TryDisable(this); - - #if WITH_EDITOR - // Create the notification info - FText ToastText = FText::Format(FTextFormat::FromString(TEXT("UHLDebugSystem: Dependant DebugCategory {0} also disabled")), FText::FromString(DependantDebugCategory.Name)); - FNotificationInfo Info(ToastText); - Info.bFireAndForget = true; // auto‑expire - Info.FadeOutDuration = 0.5f; // smooth fade - Info.ExpireDuration = 5.0f; // seconds on‑screen - Info.bUseThrobber = false; // no spinning icon - Info.bUseLargeFont = false; - Info.bUseSuccessFailIcons = false; // we’ll show a warning icon manually - - // Optionally give it a warning icon on the left: - static const FName WarningIconName = TEXT("Icons.Warning"); - Info.Image = FCoreStyle::Get().GetBrush(WarningIconName); - - // Fire it off - FSlateNotificationManager::Get().AddNotification(Info); - #endif - } - - UHLDebugCategory->TryDisable(this); - } - } - - for (FGameplayTag GameplayTag : UHLDebugCategory->Tags.GetGameplayTagArray()) - { - OnDebugCategoryChanged.Broadcast(GameplayTag, bEnabled); - } -} - -void UUHLDebugSystemSubsystem::ToggleDebugCategory(const FGameplayTag DebugCategoryTag) -{ - EnableDebugCategory(DebugCategoryTag, !IsCategoryEnabled(DebugCategoryTag)); -} - -const FUHLDebugCategory& UUHLDebugSystemSubsystem::GetDebugCategoryByTag(const FGameplayTag DebugCategoryTag) const -{ - const FUHLDebugCategory* UHLDebugCategory = DebugCategories.FindByPredicate([=](const FUHLDebugCategory& DebugCategory) - { - return DebugCategory.Tags.HasAnyExact(FGameplayTagContainer(DebugCategoryTag)); - }); - return *UHLDebugCategory; -} - -void UUHLDebugSystemSubsystem::OnPostWorldInit(UWorld* InWorld, const UWorld::InitializationValues IVS) -{ - if (InWorld->IsGameWorld()) - { - FOnActorSpawned::FDelegate ActorSpawnedDelegate = FOnActorSpawned::FDelegate::CreateUObject(this, &UUHLDebugSystemSubsystem::OnActorSpawned); - ActorSpawnedDelegateHandle = InWorld->AddOnActorSpawnedHandler(ActorSpawnedDelegate); - } -} - -void UUHLDebugSystemSubsystem::OnWorldBeginTearDown(UWorld* World) -{ - World->RemoveOnActorSpawnedHandler(ActorSpawnedDelegateHandle); -} \ No newline at end of file diff --git a/Source/UHLDebugSystem/Private/UI/UHLDebugCategoriesListWidget.cpp b/Source/UHLDebugSystem/Private/UI/UHLDebugCategoriesListWidget.cpp deleted file mode 100644 index f7e4df26..00000000 --- a/Source/UHLDebugSystem/Private/UI/UHLDebugCategoriesListWidget.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "UI/UHLDebugCategoriesListWidget.h" - -#include "Engine/GameInstance.h" -#include "Blueprint/WidgetTree.h" -#include "Components/ButtonSlot.h" -#include "Components/ScrollBoxSlot.h" -#include "Development/UHLDebugSystemSettings.h" -#include "Kismet/GameplayStatics.h" -#include "DebugCategoryButtonWidget.h" -#include "UHLDebugSystemSubsystem.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLDebugCategoriesListWidget) - -bool UUHLDebugCategoriesListWidget::Initialize() -{ - bool bIsWidgetInitialized = Super::Initialize(); - - if(!HasAnyFlags(RF_ClassDefaultObject)) - { - // root have to be initialized in Initialize function, otherwise it will not work, donno exactly why. - ScrollBox = WidgetTree->ConstructWidget(); - ScrollBox->SetConsumeMouseWheel(EConsumeMouseWheel::Always); - ScrollBox->SetVisibility(ESlateVisibility::Visible); - WidgetTree->RootWidget = ScrollBox; - } - - return bIsWidgetInitialized; -} - -void UUHLDebugCategoriesListWidget::NativeConstruct() -{ - Super::NativeConstruct(); - - ScrollBox->ClearChildren(); - - UHLDebugSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem(); - - const TArray& UHLDebugCategories = UHLDebugSubsystem->GetDebugCategories(); - for (const FUHLDebugCategory& UHLDebugCategory : UHLDebugCategories) - { - UDebugCategoryButtonWidget* UHLDebugCategoryButton = WidgetTree->ConstructWidget(); - UScrollBoxSlot* ScrollBoxSlot = Cast(ScrollBox->AddChild(UHLDebugCategoryButton)); - UHLDebugCategoryButton->SetUp(UHLDebugCategory); - UHLDebugCategoryButton->OnMadeClick.AddUniqueDynamic(this, &UUHLDebugCategoriesListWidget::OnButtonClicked); - - ScrollBoxSlot->SetPadding(FMargin(0, 0, 0, 10)); - ScrollBoxSlot->SetHorizontalAlignment(EHorizontalAlignment::HAlign_Fill); - } -} - -void UUHLDebugCategoriesListWidget::NativePreConstruct() -{ - Super::NativePreConstruct(); - const UUHLDebugSystemSettings* DeveloperSettings = GetDefault(); - for (TTuple EnabledDebugCategory : DeveloperSettings->EnabledDebugCategories) - { - UDebugCategoryButtonWidget* UHLDebugCategoryButton = WidgetTree->ConstructWidget(); - UScrollBoxSlot* ScrollBoxSlot = Cast(ScrollBox->AddChild(UHLDebugCategoryButton)); - - const FUHLDebugCategory* UHLDebugCategory = DeveloperSettings->DebugCategories.FindByPredicate([=](const FUHLDebugCategory& DebugCategory) - { - return DebugCategory.Tags.HasAnyExact(FGameplayTagContainer(EnabledDebugCategory.Key)); - }); - if (UHLDebugCategory != nullptr) - { - UHLDebugCategoryButton->SetUp(*UHLDebugCategory); - ScrollBoxSlot->SetPadding(FMargin(0, 0, 0, 10)); - } - } -} - -void UUHLDebugCategoriesListWidget::OnButtonClicked(UDebugCategoryButtonWidget* Button, FGameplayTag DebugCategoryGameplayTag) -{ - if (!Button) return; - - UHLDebugSubsystem->ToggleDebugCategory(DebugCategoryGameplayTag); - Button->UpdateCheckboxState(UHLDebugSubsystem->IsCategoryEnabled(DebugCategoryGameplayTag)); -} diff --git a/Source/UHLDebugSystem/Public/AA_WaitDebugCategoryChange.h b/Source/UHLDebugSystem/Public/AA_WaitDebugCategoryChange.h deleted file mode 100644 index d39580d6..00000000 --- a/Source/UHLDebugSystem/Public/AA_WaitDebugCategoryChange.h +++ /dev/null @@ -1,48 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "GameplayTagContainer.h" -#include "Kismet/BlueprintAsyncActionBase.h" -#include "AA_WaitDebugCategoryChange.generated.h" - -DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FWaitDebugCategoryChanged, bool, bEnabled); - -UCLASS(BlueprintType, meta=(ExposedAsyncProxy = AsyncAction)) -class UHLDEBUGSYSTEM_API UAA_WaitDebugCategoryChange : public UBlueprintAsyncActionBase -{ - GENERATED_BODY() - -public: - // TODO add updating bool value from Blueprint by reference - // UFUNCTION(BlueprintCallable, DisplayName="WaitDebugCategoryChange", meta=(WorldContext="WorldContext", BlueprintInternalUseOnly="true", AutoCreateRefTerm="bIsDebugEnabledValueRef", AdvancedDisplay="bIsDebugEnabledValueRef")) - // static UAA_WaitDebugCategoryChange* WaitDebugCategoryChange(const UObject* WorldContext, FGameplayTag DebugCategoryTag, bool bCheckOnStart, const bool& bIsDebugEnabledValueRef); - - // WARNING for better experience tags are filtered add child to "UHL.DebugCategory" or "DebugCategory" - UFUNCTION(BlueprintCallable, Category="UnrealHelperLibrary", meta=(WorldContext="WorldContext", BlueprintInternalUseOnly="true", Keywords = "UnrealHelperLibrary debug UHL debugCategory debugging")) - static UAA_WaitDebugCategoryChange* WaitDebugCategoryChange(const UObject* WorldContext, UPARAM(meta=(Categories="UHL.DebugCategory,DebugCategory"))FGameplayTag DebugCategoryTag, bool bCheckOnStart = true); - - UPROPERTY(BlueprintAssignable, Category="WaitDebugCategoryChange") - FWaitDebugCategoryChanged OnChange; - UPROPERTY(BlueprintAssignable, Category="WaitDebugCategoryChange") - FWaitDebugCategoryChanged OnEnabled; - UPROPERTY(BlueprintAssignable, Category="WaitDebugCategoryChange") - FWaitDebugCategoryChanged OnDisabled; - - virtual void Activate() override; - - virtual UWorld* GetWorld() const override - { - return ContextWorld.IsValid() ? ContextWorld.Get() : nullptr; - } - -private: - TWeakObjectPtr ContextWorld = nullptr; - - FGameplayTag DebugCategoryTagInternal = FGameplayTag::EmptyTag; - bool bCheckOnStart = true; - - UFUNCTION() - void OnDebugCategoryChange(FGameplayTag DebugCategoryTag, bool bEnabled); -}; diff --git a/Source/UHLDebugSystem/Public/DebugCategories/DCC_AbilitySystem_Abilities.h b/Source/UHLDebugSystem/Public/DebugCategories/DCC_AbilitySystem_Abilities.h deleted file mode 100644 index 0115994d..00000000 --- a/Source/UHLDebugSystem/Public/DebugCategories/DCC_AbilitySystem_Abilities.h +++ /dev/null @@ -1,20 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "UHLDebugCategoryComponent.h" -#include "DCC_AbilitySystem_Abilities.generated.h" - -/** - * - */ -UCLASS() -class UHLDEBUGSYSTEM_API UDCC_AbilitySystem_Abilities : public UUHLDebugCategoryComponent -{ - GENERATED_BODY() - -public: - virtual void Activate_Implementation(UObject* ContextObject) override; - virtual void Deactivate_Implementation(UObject* ContextObject) override; -}; diff --git a/Source/UHLDebugSystem/Public/DebugCategories/DCC_AbilitySystem_Attributes.h b/Source/UHLDebugSystem/Public/DebugCategories/DCC_AbilitySystem_Attributes.h deleted file mode 100644 index 97c6fc37..00000000 --- a/Source/UHLDebugSystem/Public/DebugCategories/DCC_AbilitySystem_Attributes.h +++ /dev/null @@ -1,20 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "UHLDebugCategoryComponent.h" -#include "DCC_AbilitySystem_Attributes.generated.h" - -/** - * - */ -UCLASS() -class UHLDEBUGSYSTEM_API UDCC_AbilitySystem_Attributes : public UUHLDebugCategoryComponent -{ - GENERATED_BODY() - -public: - virtual void Activate_Implementation(UObject* ContextObject) override; - virtual void Deactivate_Implementation(UObject* ContextObject) override; -}; diff --git a/Source/UHLDebugSystem/Public/DebugCategories/DCC_AbilitySystem_Effects.h b/Source/UHLDebugSystem/Public/DebugCategories/DCC_AbilitySystem_Effects.h deleted file mode 100644 index ef385da2..00000000 --- a/Source/UHLDebugSystem/Public/DebugCategories/DCC_AbilitySystem_Effects.h +++ /dev/null @@ -1,20 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "UHLDebugCategoryComponent.h" -#include "DCC_AbilitySystem_Effects.generated.h" - -/** - * - */ -UCLASS() -class UHLDEBUGSYSTEM_API UDCC_AbilitySystem_Effects : public UUHLDebugCategoryComponent -{ - GENERATED_BODY() - -public: - virtual void Activate_Implementation(UObject* ContextObject) override; - virtual void Deactivate_Implementation(UObject* ContextObject) override; -}; diff --git a/Source/UHLDebugSystem/Public/DebugCategories/DCC_Collisions.h b/Source/UHLDebugSystem/Public/DebugCategories/DCC_Collisions.h deleted file mode 100644 index 322c36c5..00000000 --- a/Source/UHLDebugSystem/Public/DebugCategories/DCC_Collisions.h +++ /dev/null @@ -1,20 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "UHLDebugCategoryComponent.h" -#include "DCC_Collisions.generated.h" - -/** - * - */ -UCLASS() -class UHLDEBUGSYSTEM_API UDCC_Collisions : public UUHLDebugCategoryComponent -{ - GENERATED_BODY() - -public: - virtual void Activate_Implementation(UObject* ContextObject) override; - virtual void Deactivate_Implementation(UObject* ContextObject) override; -}; diff --git a/Source/UHLDebugSystem/Public/DebugCategories/DCC_InputSystem_EnhancedInput.h b/Source/UHLDebugSystem/Public/DebugCategories/DCC_InputSystem_EnhancedInput.h deleted file mode 100644 index a3b3f155..00000000 --- a/Source/UHLDebugSystem/Public/DebugCategories/DCC_InputSystem_EnhancedInput.h +++ /dev/null @@ -1,20 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "UHLDebugCategoryComponent.h" -#include "DCC_InputSystem_EnhancedInput.generated.h" - -/** - * - */ -UCLASS() -class UHLDEBUGSYSTEM_API UDCC_InputSystem_EnhancedInput : public UUHLDebugCategoryComponent -{ - GENERATED_BODY() - -public: - virtual void Activate_Implementation(UObject* ContextObject) override; - virtual void Deactivate_Implementation(UObject* ContextObject) override; -}; diff --git a/Source/UHLDebugSystem/Public/DebugCategoryButtonWidget.h b/Source/UHLDebugSystem/Public/DebugCategoryButtonWidget.h deleted file mode 100644 index cd36b7af..00000000 --- a/Source/UHLDebugSystem/Public/DebugCategoryButtonWidget.h +++ /dev/null @@ -1,53 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "GameplayTagContainer.h" -#include "UHLDebugCategory.h" -#include "Blueprint/UserWidget.h" -#include "DebugCategoryButtonWidget.generated.h" - -DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FDebugCategoryButtonClick, UDebugCategoryButtonWidget*, Button, FGameplayTag, DebugCategoryTag); - -class UUHLDebugSystemSubsystem; -struct FUHLDebugCategory; -class UTextBlock; -class UCheckBox; -class UHorizontalBox; -class UButton; -/** - * - */ -UCLASS() -class UHLDEBUGSYSTEM_API UDebugCategoryButtonWidget : public UUserWidget -{ - GENERATED_BODY() - -public: - void SetUp(const FUHLDebugCategory& UHLDebugCategory_In); - void UpdateCheckboxState(bool bEnabled_In); - - FDebugCategoryButtonClick OnMadeClick; - -protected: - virtual bool Initialize() override; - virtual void NativePreConstruct() override; - -private: - UPROPERTY() - UButton* Button; - UPROPERTY() - UHorizontalBox* HorizontalBox; - UPROPERTY() - UCheckBox* CheckBox; - UPROPERTY() - UTextBlock* TextBlock; - UPROPERTY() - FUHLDebugCategory UHLDebugCategory; - - UFUNCTION() - void OnButtonClicked(); - UFUNCTION() - void OnDebugCategoryChanged(FGameplayTag DebugCategoryTag_In, bool bEnabled_In); -}; diff --git a/Source/UHLDebugSystem/Public/Development/UHLDebugSystemSettings.h b/Source/UHLDebugSystem/Public/Development/UHLDebugSystemSettings.h deleted file mode 100644 index f09a79c8..00000000 --- a/Source/UHLDebugSystem/Public/Development/UHLDebugSystemSettings.h +++ /dev/null @@ -1,59 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "GameplayTagContainer.h" -#include "Misc/App.h" -#include "UHLDebugSystemSubsystem.h" -#include "UHLDebugSystemSettings.generated.h" - -/** - * - */ -UCLASS(config="Game", defaultconfig, PrioritizeCategories="DebugCategories", DisplayName="UHL Debug System") -class UHLDEBUGSYSTEM_API UUHLDebugSystemSettings : public UDeveloperSettings -{ - GENERATED_BODY() - -public: - UPROPERTY(EditAnywhere, Category="DebugCategories", NoClear, meta=(FullyExpand=true, ForceInlineRow /**, ReadOnlyKeys **/)) - TMap EnabledDebugCategories = {}; - - // don't use/show default UHLDebugCategories - UPROPERTY(config, EditAnywhere, Category="DebugCategoriesSettings") - bool bExcludeDefaultUHLDebugCategories = false; - - UPROPERTY(config, EditAnywhere, Category="DebugCategoriesSettings", meta=(TitleProperty="Name", NoElementDuplicate)) - TArray DebugCategories = {}; - - UPROPERTY(config) - bool bMigrationFromOldSettingsDone = false; - - // TODO: choosing debug subsystem class??? user can extend debug subsystem with own things? - // TSubclassOf UHLDebugSubsystemClass; - - void OnEnabledDebugCategoryEntryChanged(FGameplayTag ChangedDebugCategoryTag, bool bEnabled); - - static TArray GET_DEFAULT_UHL_DEBUG_CATEGORIES(); - -protected: -//~UDeveloperSettings interface - virtual FName GetCategoryName() const override { return FApp::GetProjectName(); }; -//~End of UDeveloperSettings interface - -#if WITH_EDITOR - virtual void PostInitProperties() override; - virtual void PreEditChange(FProperty* PropertyAboutToChange) override; - virtual void PostEditChangeChainProperty(struct FPropertyChangedChainEvent& PropertyChangedEvent) override; -#endif - -private: - TMap LastEnabledDebugCategories; - - void RecreateEnabledDebugCategoriesList(); - void UpdateEnabledDebugCategoriesList(); - void UpdateDefaultUHLDebugCategories(); - - -}; diff --git a/Source/UHLDebugSystem/Public/UHLDebugBlueprintLibrary.h b/Source/UHLDebugSystem/Public/UHLDebugBlueprintLibrary.h deleted file mode 100644 index 2180a7b9..00000000 --- a/Source/UHLDebugSystem/Public/UHLDebugBlueprintLibrary.h +++ /dev/null @@ -1,21 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "GameplayEffect.h" -#include "AssetRegistry/AssetData.h" -#include "Kismet/BlueprintFunctionLibrary.h" -#include "UHLDebugBlueprintLibrary.generated.h" - -UCLASS() -class UHLDEBUGSYSTEM_API UUHLDebugBlueprintLibrary : public UBlueprintFunctionLibrary -{ - GENERATED_BODY() - -public: - /** DebugSubsystem **/ - UFUNCTION( - BlueprintPure, Category = "UnrealHelperLibrary|Debug", meta = (Categories = "UHL.DebugCategory,DebugCategory", WorldContext = "WorldContextObject", Keywords = "UnrealHelperLibrary debug")) - static bool IsUHLDebugCategoryEnabled(UObject* WorldContextObject, FGameplayTag DebugCategoryGameplayTag); - /** ~DebugSubsystem **/ -}; diff --git a/Source/UHLDebugSystem/Public/UHLDebugCategory.h b/Source/UHLDebugSystem/Public/UHLDebugCategory.h deleted file mode 100644 index c66e2836..00000000 --- a/Source/UHLDebugSystem/Public/UHLDebugCategory.h +++ /dev/null @@ -1,88 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "UHLDebugCategoryComponent.h" -#include "GameplayTagContainer.h" -#include "UnrealHelperLibraryTypes.h" -#include "UHLDebugCategory.generated.h" - - -USTRUCT(BlueprintType) -struct FUHLDebugCategory -{ - GENERATED_BODY() - - // TODO: - // UPROPERTY(EditAnywhere, BlueprintReadWrite) - // bool bActive = true; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UHLDebugCategory") - FString Name = ""; - - // if DebugCategory requires PlayerController it can't be enabled before "SetUpCategoriesThatRequiresPlayerController" being called - // Mostly you want to add "SetUpCategoriesThatRequiresPlayerController" in your "PlayerController.BeginPlay" - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UHLDebugCategory") - bool bRequiresPlayerControllerToEnable = true; - - // Tags associated with this debug category, like GameplayAbilities category can be activated/deactivated by tag - // WARNING - for better experience tags are filtered add child to "UHL.DebugCategory" or "DebugCategory" - // WARNING 2 - NATIVE tags are not supported due to "plugin/module" restrictions, use FGameplayTag::RequestGameplayTag - // and gameplay tags ini files - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UHLDebugCategory", meta=(Categories = "UHL.DebugCategory,DebugCategory")) - FGameplayTagContainer Tags = {}; - - // What DebugCategories required to be enabled for this DebugCategory. On enabling this DebugCategory it will try to enable required DebgugCategories disable other debug categories that match "Required" tags - // WARNING for better experience tags are filtered add child to "UHL.DebugCategory" or "DebugCategory" - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UHLDebugCategory", meta=(Categories = "UHL.DebugCategory,DebugCategory")) - FGameplayTagContainer RequiredDebugCategories = {}; - - // What DebugCategories this DebugCategory blocks. On enabling this DebugCategory it will disable other debug categories that match "Blocks" tags - // WARNING for better experience tags are filtered add child to "UHL.DebugCategory" or "DebugCategory" - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UHLDebugCategory", meta=(Categories = "UHL.DebugCategory,DebugCategory")) - FGameplayTagContainer Blocks = {}; // blocks other debug categories activation with specified tags - // TODO BlockedBy - what categories blocks it - // UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(Categories = "UHL.DebugCategory")) - FGameplayTagContainer BlockedBy = {}; - - /** defines what to do when DebugCategory enabling, works a bit similar to GameplayAbilities and GameplayEffects components. - Example - I want component that enables AbilitySystem debug, I write DebugCategoryComponent(C++/BP) and add it here, - so when DebugCategory enables that simple component "activates", when DebugCategory - disabled component "deactivates", such simple **/ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UHLDebugCategory", meta=(ForceShowPluginContent)) - TArray> Components = {}; - // for UI, background color and so on - // ~"FColor::MakeRandomColor()" will lead to non-critical error - // ~unreal don't support random colors from native code. - // ~They should be deterministic but there is no option - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UHLDebugCategory", AdvancedDisplay, meta = (IgnoreForMemberInitializationTest)) - FLinearColor Color = FColor::MakeRandomColor(); - UPROPERTY() - bool bIsDefaultUHLDebugCategory = false; - - // "Editor" will mean that its will be enabled in "EnabledDebugCategories" by default for all devs on EditorStartup - // Others means that DebugCategory will be enabled on start - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UHLDebugCategory", AdvancedDisplay) - TArray ByDefaultEnabledInBuildTypes = {}; - - bool TryEnable(UObject* ContextObj); - void TryDisable(UObject* ContextObj); - bool GetIsEnabled() const { return bIsEnabled; }; - - bool operator==(const FUHLDebugCategory& Other) const - { - return Name == Other.Name; - // not sure checking tags that might change is good idea - // return ShortName == Other.ShortName && Tags == Other.Tags; - } - -private: - bool bIsEnabled = false; - - UPROPERTY() - TArray InstancedComponents = {}; - - UUHLDebugCategoryComponent* GetOrCreateDebugCategoryComponent(TSubclassOf ComponentClass, UObject* ContextObj); - UUHLDebugCategoryComponent** GetDebugCategoryComponent(TSubclassOf ComponentClass, UObject* ContextObj); -}; diff --git a/Source/UHLDebugSystem/Public/UHLDebugCategoryComponent.h b/Source/UHLDebugSystem/Public/UHLDebugCategoryComponent.h deleted file mode 100644 index 6400e515..00000000 --- a/Source/UHLDebugSystem/Public/UHLDebugCategoryComponent.h +++ /dev/null @@ -1,21 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "UHLDebugCategoryComponent.generated.h" - -// TODO force activation with "MMB" click -UCLASS(Abstract, Blueprintable) -class UHLDEBUGSYSTEM_API UUHLDebugCategoryComponent : public UObject -{ - GENERATED_BODY() - -public: - UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "UHLDebugSubsystem") - void Activate(UObject* ContextObject); - UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "UHLDebugSubsystem") - void Deactivate(UObject* ContextObject); - UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "UHLDebugSubsystem") - bool CanActivate(UObject* ContextObject) const; -}; diff --git a/Source/UHLDebugSystem/Public/UHLDebugSystem.h b/Source/UHLDebugSystem/Public/UHLDebugSystem.h deleted file mode 100644 index 4daeeb97..00000000 --- a/Source/UHLDebugSystem/Public/UHLDebugSystem.h +++ /dev/null @@ -1,17 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "Modules/ModuleManager.h" - - -class FUHLDebugSystemModule final : public IModuleInterface -{ -public: - /** IModuleInterface implementation */ - virtual void StartupModule() override; - virtual void ShutdownModule() override; - -private: - void MigrateOldSettingsFromMainModule(); -}; diff --git a/Source/UHLDebugSystem/Public/UHLDebugSystemSubsystem.h b/Source/UHLDebugSystem/Public/UHLDebugSystemSubsystem.h deleted file mode 100644 index 4ddf1350..00000000 --- a/Source/UHLDebugSystem/Public/UHLDebugSystemSubsystem.h +++ /dev/null @@ -1,72 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" - -#include "CoreGlobals.h" -#include "Engine/Engine.h" -#include "Engine/World.h" -#include "EngineUtils.h" -#include "GameplayTagContainer.h" -#include "UHLDebugCategory.h" -#include "Subsystems/GameInstanceSubsystem.h" -#include "UHLDebugSystemSubsystem.generated.h" - - -DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnUHLDebugCategoryChanged, FGameplayTag, DebugCategoryTag, bool, bEnabled); - -UCLASS() -class UHLDEBUGSYSTEM_API UUHLDebugSystemSubsystem : public UGameInstanceSubsystem -{ - GENERATED_BODY() - -public: - UUHLDebugSystemSubsystem(); - - FOnUHLDebugCategoryChanged OnDebugCategoryChanged; - - // TODO filter gameplayTags, allow using only values from DebugCategories `meta=(Categories="")` - // probably "Godreaper.DebugCategories." required, or "ProjectName.DebugCategories"... - UFUNCTION(Exec, BlueprintCallable, Category="UHLDebugSubsystem", meta=(Categories = "UHL.DebugCategory,DebugCategory")) - bool IsCategoryEnabled(const FGameplayTag DebugCategoryTag) const; - - UFUNCTION(Exec, BlueprintCallable, Category="UHLDebugSubsystem", meta=(Categories = "UHL.DebugCategory,DebugCategory")) - void EnableDebugCategory(const FGameplayTag DebugCategoryTag, bool bEnable); - - UFUNCTION(Exec, BlueprintCallable, Category="UHLDebugSubsystem", meta=(Categories = "UHL.DebugCategory,DebugCategory")) - void ToggleDebugCategory(const FGameplayTag DebugCategoryTag); - - UFUNCTION(BlueprintCallable, Category="UHLDebugSubsystem", meta=(Categories = "UHL.DebugCategory,DebugCategory")) - const FUHLDebugCategory& GetDebugCategoryByTag(const FGameplayTag DebugCategoryTag) const; - - const TArray& GetDebugCategories() const { return DebugCategories; } - -protected: - virtual void Initialize(FSubsystemCollectionBase& Collection) override; - virtual void Deinitialize() override; - -private: - bool bSetupped = false; - bool bSetUpCategoriesThatRequiresPlayerController = false; - bool bIsSetuping = true; - - UPROPERTY() - TArray DebugCategories = {}; - - FDelegateHandle ActorSpawnedDelegateHandle; - - // waiting for world initialize to wait PlayerController spawned for InitDebugCategories - void OnPostWorldInit(UWorld* InWorld, const UWorld::InitializationValues IVS); - - // waiting for world teardown to not waiting for PlayerController spawn until next world inited - UFUNCTION() - void OnWorldBeginTearDown(UWorld* World); - - // waiting for PlayerController spawned to InitDebugCategories that requires PlayerController - UFUNCTION() - void OnActorSpawned(AActor* SpawnedActor); - - // should be called when player controller available, e.g. in PlayerController.BeginPlay - void SetUpCategoriesThatRequiresPlayerController(); -}; diff --git a/Source/UHLDebugSystem/Public/UI/UHLDebugCategoriesListWidget.h b/Source/UHLDebugSystem/Public/UI/UHLDebugCategoriesListWidget.h deleted file mode 100644 index cf5de541..00000000 --- a/Source/UHLDebugSystem/Public/UI/UHLDebugCategoriesListWidget.h +++ /dev/null @@ -1,32 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "GameplayTagContainer.h" -#include "Components/ScrollBox.h" -#include "UHLDebugCategoriesListWidget.generated.h" - -class UUHLDebugSystemSubsystem; -class UDebugCategoryButtonWidget; -class UCanvasPanel; -/** - * - */ -UCLASS() -class UHLDEBUGSYSTEM_API UUHLDebugCategoriesListWidget : public UUserWidget -{ - GENERATED_BODY() - -protected: - virtual bool Initialize() override; - virtual void NativeConstruct() override; - virtual void NativePreConstruct() override; - -private: - UPROPERTY() - UScrollBox* ScrollBox; - TWeakObjectPtr UHLDebugSubsystem; - UFUNCTION() - void OnButtonClicked(UDebugCategoryButtonWidget* Button, FGameplayTag DebugCategoryGameplayTag); -}; diff --git a/Source/UHLDebugSystem/UHLDebugSystem.Build.cs b/Source/UHLDebugSystem/UHLDebugSystem.Build.cs deleted file mode 100644 index 97dfa81c..00000000 --- a/Source/UHLDebugSystem/UHLDebugSystem.Build.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -using UnrealBuildTool; - -// DebugSystem based on GameplayTags that completely separate from other UHL modules -// should be completely independent of UHL and probably will be other plugin -public class UHLDebugSystem : ModuleRules -{ - public UHLDebugSystem(ReadOnlyTargetRules Target) : base(Target) - { - PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; - - PublicIncludePaths.AddRange( - new string[] { - // ... add public include paths required here ... - } - ); - - - PrivateIncludePaths.AddRange( - new string[] { - // ... add other private include paths required here ... - } - ); - - - PublicDependencyModuleNames.AddRange( - new string[] - { - "Core", - "CoreUObject", - "Engine", - - // ... add other public dependencies that you statically link with here ... - "GameplayAbilities", - "GameplayTags", - "GameplayTasks", - "EnhancedInput", - - // TODO remove if possible used only for DebugPrints and EUHLBuildType - "UnrealHelperLibrary", - } - ); - - - PrivateDependencyModuleNames.AddRange( - new string[] - { - "Slate", - "SlateCore", - "UMG", - "AnimGraphRuntime", - "DeveloperSettings", - - // Should not use any other UHL modules - - "UHLModulesHelper", - // ... add private dependencies that you statically link with here ... - } - ); - - - DynamicallyLoadedModuleNames.AddRange( - new string[] - { - // ... add any modules that your module loads dynamically here ... - } - ); - } -} diff --git a/Source/UHLDebugSystemEditor/Private/UHLDebugSystemEditor.cpp b/Source/UHLDebugSystemEditor/Private/UHLDebugSystemEditor.cpp deleted file mode 100644 index 999ed66a..00000000 --- a/Source/UHLDebugSystemEditor/Private/UHLDebugSystemEditor.cpp +++ /dev/null @@ -1,139 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UHLDebugSystemEditor.h" - -#include "FileHelpers.h" -#include "Development/UHLDebugSystemSettings.h" -#include "ToolMenus.h" -#include "Kismet/GameplayStatics.h" - -static const FName UHLDebugSystemEditorTabName("UHLDebugSystemEditor"); - -#define LOCTEXT_NAMESPACE "FUHLDebugSystemEditorModule" - -namespace UHLDebugSystemEditorFunctionLibrary -{ - static bool HasPlayWorld() { return GEditor->PlayWorld != nullptr; } - - static bool HasNoPlayWorld() { return !HasPlayWorld(); } - - static bool IsOptionEnabled(const FGameplayTag DebugCategoryTag) - { - if (HasPlayWorld()) - { - UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(GEditor->PlayWorld); - if (!GameInstance) return false; - - UUHLDebugSystemSubsystem* DebugSubsystem = GameInstance->GetSubsystem(); - if (!DebugSubsystem) return false; - - return DebugSubsystem->IsCategoryEnabled(DebugCategoryTag); - } - else - { - const UUHLDebugSystemSettings* Settings = GetDefault(); - bool bEnabled = Settings->EnabledDebugCategories[DebugCategoryTag]; - return bEnabled; - } - } - - static void ToggleDebugCategory_Clicked(const FGameplayTag DebugCategoryTag) - { - if (HasPlayWorld()) - { - UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(GEditor->PlayWorld); - if (GameInstance) - { - UUHLDebugSystemSubsystem* DebugSubsystem = GameInstance->GetSubsystem(); - if (DebugSubsystem) - { - DebugSubsystem->ToggleDebugCategory(DebugCategoryTag); - } - } - } - - UUHLDebugSystemSettings* Settings = GetMutableDefault(); - bool bEnabled = Settings->EnabledDebugCategories[DebugCategoryTag]; - Settings->EnabledDebugCategories.Emplace(DebugCategoryTag, !bEnabled); - Settings->OnEnabledDebugCategoryEntryChanged(DebugCategoryTag, !bEnabled); - - // if this controls editor UI, you may need to force a menu refresh: - // FSlateApplication::Get().DismissAllMenus(); - // ExtendToolbar(); // or however you re-populate your menu - } - - static TSharedRef GetDebugCategoriesStateDropdown() - { - FMenuBuilder MenuBuilder(true, nullptr); - - MenuBuilder.BeginSection(NAME_None, FText::FromString("DebugCategories")); - for (const FUHLDebugCategory& DebugCategory : GetDefault()->DebugCategories) - { - const FText DisplayName = FText::FromString(DebugCategory.Tags.First().ToString()); - MenuBuilder.AddMenuEntry( - DisplayName, - FText::Format(LOCTEXT("DebugCategoryDescription", "{0}"), FText::FromString(DebugCategory.Name)), - FSlateIcon(), - FUIAction( - FExecuteAction::CreateStatic(&UHLDebugSystemEditorFunctionLibrary::ToggleDebugCategory_Clicked, DebugCategory.Tags.First()), - FCanExecuteAction(), - // FCanExecuteAction::CreateStatic(&UHLDebugSystemEditorFunctionLibrary::HasNoPlayWorld), - FIsActionChecked::CreateStatic(&UHLDebugSystemEditorFunctionLibrary::IsOptionEnabled, DebugCategory.Tags.First()), - FIsActionButtonVisible() - // FIsActionButtonVisible::CreateStatic(&UHLDebugSystemEditorFunctionLibrary::HasNoPlayWorld) - ), - NAME_None, - EUserInterfaceActionType::ToggleButton - ); - } - MenuBuilder.EndSection(); - - return MenuBuilder.MakeWidget(); - } - - static bool CanShowDebugCategories() - { - return !GetDefault()->EnabledDebugCategories.IsEmpty(); - } - - static void RegisterGameEditorMenus() - { - UToolMenu* Menu = UToolMenus::Get()->ExtendMenu("LevelEditor.LevelEditorToolBar.PlayToolBar"); - FToolMenuSection& Section = Menu->AddSection("PlayGameExtensions", TAttribute(), - FToolMenuInsert("Play", EToolMenuInsertType::Default)); - - FToolMenuEntry ToolMenuEntry = FToolMenuEntry::InitComboButton( - "DebugCategoriesState", - FUIAction( - FExecuteAction(), - // FCanExecuteAction::CreateStatic(&UHLDebugSystemEditorFunctionLibrary::HasNoPlayWorld), - FCanExecuteAction(), - FIsActionChecked(), - FIsActionButtonVisible::CreateStatic(&UHLDebugSystemEditorFunctionLibrary::CanShowDebugCategories)), - FOnGetContent::CreateStatic(&UHLDebugSystemEditorFunctionLibrary::GetDebugCategoriesStateDropdown), - LOCTEXT("UHLDebugSystemEditor_Label", "Debug Categories"), - LOCTEXT("UHLDebugSystemEditor_ToolTip", "Enabling/Disabling debug categories fast"), - FSlateIcon(FAppStyle::GetAppStyleSetName(), "Icons.Tools") - ); - ToolMenuEntry.StyleNameOverride = "CalloutToolbar"; - Section.AddEntry(ToolMenuEntry); - } -} - -void FUHLDebugSystemEditorModule::StartupModule() -{ - if (FSlateApplication::IsInitialized()) - { - UToolMenus::RegisterStartupCallback( - FSimpleMulticastDelegate::FDelegate::CreateStatic(&UHLDebugSystemEditorFunctionLibrary::RegisterGameEditorMenus)); - } -} - -void FUHLDebugSystemEditorModule::ShutdownModule() -{ - UToolMenus::UnRegisterStartupCallback(this); -} - -#undef LOCTEXT_NAMESPACE - -IMPLEMENT_MODULE(FUHLDebugSystemEditorModule, UHLDebugSystemEditor) diff --git a/Source/UHLDebugSystemEditor/Public/UHLDebugSystemEditor.h b/Source/UHLDebugSystemEditor/Public/UHLDebugSystemEditor.h deleted file mode 100644 index 6223f7cd..00000000 --- a/Source/UHLDebugSystemEditor/Public/UHLDebugSystemEditor.h +++ /dev/null @@ -1,17 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" - -class FToolBarBuilder; -class FMenuBuilder; - -class FUHLDebugSystemEditorModule : public IModuleInterface -{ -public: - - /** IModuleInterface implementation */ - virtual void StartupModule() override; - virtual void ShutdownModule() override; -}; diff --git a/Source/UHLDebugSystemEditor/UHLDebugSystemEditor.Build.cs b/Source/UHLDebugSystemEditor/UHLDebugSystemEditor.Build.cs deleted file mode 100644 index 37e97807..00000000 --- a/Source/UHLDebugSystemEditor/UHLDebugSystemEditor.Build.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -using UnrealBuildTool; - -public class UHLDebugSystemEditor : ModuleRules -{ - public UHLDebugSystemEditor(ReadOnlyTargetRules Target) : base(Target) - { - PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; - - PublicIncludePaths.AddRange( - new string[] { - // ... add public include paths required here ... - } - ); - - - PrivateIncludePaths.AddRange( - new string[] { - // ... add other private include paths required here ... - } - ); - - - PublicDependencyModuleNames.AddRange( - new string[] - { - "Core", - "CoreUObject", - "Engine", - "PropertyEditor", - "Blutility", - "UMG", - // ... add other public dependencies that you statically link with here ... - } - ); - - - PrivateDependencyModuleNames.AddRange( - new string[] - { - "Projects", - "InputCore", - "EditorFramework", - "UnrealEd", - "ToolMenus", - "Slate", - "SlateCore", - "UnrealEd", - "DeveloperSettings", - - "EditorWidgets", - - "GameplayTags", - "GameplayTagsEditor", - - "UHLDebugSystem", - // ... add private dependencies that you statically link with here ... - } - ); - - - DynamicallyLoadedModuleNames.AddRange( - new string[] - { - // ... add any modules that your module loads dynamically here ... - } - ); - } -} diff --git a/Source/UHLEditor/Private/Development/UHLEditorSettings.cpp b/Source/UHLEditor/Private/Development/UHLEditorSettings.cpp deleted file mode 100644 index efedb204..00000000 --- a/Source/UHLEditor/Private/Development/UHLEditorSettings.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Development/UHLEditorSettings.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLEditorSettings) \ No newline at end of file diff --git a/Source/UHLEditor/Private/UHLEditor.cpp b/Source/UHLEditor/Private/UHLEditor.cpp deleted file mode 100644 index 01dac294..00000000 --- a/Source/UHLEditor/Private/UHLEditor.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UHLEditor.h" -#include "UHLEditorStyle.h" -#include "UHLEditorCommands.h" -#include "Misc/MessageDialog.h" -#include "ToolMenus.h" -#include "UHLEditorBlueprintThumbnailRenderer.h" -#include "ThumbnailRendering/ThumbnailManager.h" - -static const FName UHLDebugSystemEditorTabName("UHLEditor"); - -#define LOCTEXT_NAMESPACE "FUHLEditorModule" - -void FUHLEditorModule::StartupModule() -{ - // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module - - FUHLEditorStyle::Initialize(); - FUHLEditorStyle::ReloadTextures(); - - FUHLEditorCommands::Register(); - - PluginCommands = MakeShareable(new FUICommandList); - - PluginCommands->MapAction( - FUHLEditorCommands::Get().PluginAction, - FExecuteAction::CreateRaw(this, &FUHLEditorModule::PluginButtonClicked), - FCanExecuteAction()); - - UToolMenus::RegisterStartupCallback(FSimpleMulticastDelegate::FDelegate::CreateRaw(this, &FUHLEditorModule::RegisterMenus)); - - UThumbnailManager::Get().UnregisterCustomRenderer(UBlueprint::StaticClass()); - UThumbnailManager::Get().RegisterCustomRenderer(UBlueprint::StaticClass(), UUHLEditorBlueprintThumbnailRenderer::StaticClass()); -} - -void FUHLEditorModule::ShutdownModule() -{ - // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, - // we call this function before unloading the module. - - UToolMenus::UnRegisterStartupCallback(this); - - UToolMenus::UnregisterOwner(this); - - FUHLEditorStyle::Shutdown(); - - FUHLEditorCommands::Unregister(); -} - -void FUHLEditorModule::PluginButtonClicked() -{ - // Put your "OnButtonClicked" stuff here - FText DialogText = FText::Format( - LOCTEXT("PluginButtonDialogText", "Add code to {0} in {1} to override this button's actions"), - FText::FromString(TEXT("FUHLEditorModule::PluginButtonClicked()")), - FText::FromString(TEXT("UHLEditor.cpp")) - ); - FMessageDialog::Open(EAppMsgType::Ok, DialogText); -} - -void FUHLEditorModule::RegisterMenus() -{ - // Owner will be used for cleanup in call to UToolMenus::UnregisterOwner - FToolMenuOwnerScoped OwnerScoped(this); - - { - UToolMenu* Menu = UToolMenus::Get()->ExtendMenu("LevelEditor.MainMenu.Window"); - { - FToolMenuSection& Section = Menu->FindOrAddSection("WindowLayout"); - Section.AddMenuEntryWithCommandList(FUHLEditorCommands::Get().PluginAction, PluginCommands); - } - } - - { - UToolMenu* ToolbarMenu = UToolMenus::Get()->ExtendMenu("LevelEditor.LevelEditorToolBar.PlayToolBar"); - { - FToolMenuSection& Section = ToolbarMenu->FindOrAddSection("PluginTools"); - { - FToolMenuEntry& Entry = Section.AddEntry(FToolMenuEntry::InitToolBarButton(FUHLEditorCommands::Get().PluginAction)); - Entry.SetCommandList(PluginCommands); - } - } - } -} - -#undef LOCTEXT_NAMESPACE - -IMPLEMENT_MODULE(FUHLEditorModule, UHLEditor) diff --git a/Source/UHLEditor/Private/UHLEditorBlueprintThumbnailRenderer.cpp b/Source/UHLEditor/Private/UHLEditorBlueprintThumbnailRenderer.cpp deleted file mode 100644 index d75dbfc5..00000000 --- a/Source/UHLEditor/Private/UHLEditorBlueprintThumbnailRenderer.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "UHLEditorBlueprintThumbnailRenderer.h" - -#include "CanvasItem.h" -#include "CanvasTypes.h" -#include "UHLEditorCustomThumbnail.h" -#include "ThumbnailRendering/ThumbnailManager.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLEditorBlueprintThumbnailRenderer) - -void UUHLEditorBlueprintThumbnailRenderer::GetThumbnailSize(UObject* Object, float Zoom, uint32& OutWidth, uint32& OutHeight) const -{ - UBlueprint* Blueprint = Cast(Object); - - if (Blueprint) - { - if (UTexture2D* Texture = GetTextureFromGeneratedClass(Blueprint->GeneratedClass)) - { - OutWidth = FMath::TruncToInt(Zoom * (float)Texture->GetSurfaceWidth()); - OutHeight = FMath::TruncToInt(Zoom * (float)Texture->GetSurfaceHeight()); - } - } - Super::GetThumbnailSize(Object, Zoom, OutWidth, OutHeight); -} - -void UUHLEditorBlueprintThumbnailRenderer::Draw(UObject* Object, int32 X, int32 Y, uint32 Width, uint32 Height, FRenderTarget* RenderTarget, FCanvas* Canvas, bool bAdditionalViewFamily) -{ - UBlueprint* Blueprint = Cast(Object); - if (Blueprint) - { - if (UTexture2D* Texture2D = GetTextureFromGeneratedClass(Blueprint->GeneratedClass)) - { - const bool bUseTranslucentBlend = Texture2D && Texture2D->HasAlphaChannel() && ((Texture2D->LODGroup == TEXTUREGROUP_UI) || (Texture2D->LODGroup == TEXTUREGROUP_Pixels2D)); - TRefCountPtr BatchedElementParameters; - if (bUseTranslucentBlend) - { - // If using alpha, draw a checkerboard underneath first. - const int32 CheckerDensity = 8; - TObjectPtr Checker = UThumbnailManager::Get().CheckerboardTexture; - Canvas->DrawTile( - 0.0f, 0.0f, Width, Height, // Dimensions - 0.0f, 0.0f, CheckerDensity, CheckerDensity, // UVs - FLinearColor::White, Checker->GetResource()); // Tint & Texture - } - // Use A canvas tile item to draw - FCanvasTileItem CanvasTile(FVector2D(X, Y), Texture2D->GetResource(), FVector2D(Width, Height), FLinearColor::White); - CanvasTile.BlendMode = bUseTranslucentBlend ? SE_BLEND_Translucent : SE_BLEND_Opaque; - CanvasTile.BatchedElementParameters = BatchedElementParameters; - CanvasTile.Draw(Canvas); - if (Texture2D && Texture2D->IsCurrentlyVirtualTextured()) - { - auto VTChars = TEXT("VT"); - int32 VTWidth = 0; - int32 VTHeight = 0; - StringSize(GEngine->GetLargeFont(), VTWidth, VTHeight, VTChars); - float PaddingX = Width / 128.0f; - float PaddingY = Height / 128.0f; - float ScaleX = Width / 64.0f; //Text is 1/64'th of the size of the thumbnails - float ScaleY = Height / 64.0f; - // VT overlay - FCanvasTextItem TextItem(FVector2D(Width - PaddingX - VTWidth * ScaleX, Height - PaddingY - VTHeight * ScaleY), FText::FromString(VTChars), GEngine->GetLargeFont(), - FLinearColor::White); - TextItem.EnableShadow(FLinearColor::Black); - TextItem.Scale = FVector2D(ScaleX, ScaleY); - TextItem.Draw(Canvas); - } - return; - } - } - Super::Draw(Object, X, Y, Width, Height, RenderTarget, Canvas, bAdditionalViewFamily); -} - -bool UUHLEditorBlueprintThumbnailRenderer::CanVisualizeAsset(UObject* Object) -{ - UBlueprint* Blueprint = Cast(Object); - - if (Blueprint && GetTextureFromGeneratedClass(Blueprint->GeneratedClass) != nullptr) - { - return true; - } - return Super::CanVisualizeAsset(Object); -} - -UTexture2D* UUHLEditorBlueprintThumbnailRenderer::GetTextureFromGeneratedClass(UClass* Class) const -{ - if (Class) - { - if (Class->ImplementsInterface(UUHLEditorCustomThumbnail::StaticClass())) - { - if (UObject* CDO = Class->GetDefaultObject()) - { - IUHLEditorCustomThumbnail* CustomThumbnailInterface = Cast(CDO); - if (CustomThumbnailInterface) - { - return CustomThumbnailInterface->Execute_GetCustomThumbnailIcon(CDO); - } - } - } - // else if (Class->IsChildOf(UBuff::StaticClass())) - // { - // if (UBuff* CDO = Class->GetDefaultObject()) - // { - // return CDO->GetIcon(); - // } - // } - } - return nullptr; -} diff --git a/Source/UHLEditor/Private/UHLEditorCommands.cpp b/Source/UHLEditor/Private/UHLEditorCommands.cpp deleted file mode 100644 index d21cb5d1..00000000 --- a/Source/UHLEditor/Private/UHLEditorCommands.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UHLEditorCommands.h" - -#define LOCTEXT_NAMESPACE "FUHLEditorModule" - -void FUHLEditorCommands::RegisterCommands() -{ - UI_COMMAND(PluginAction, "UHLEditorCommands", "Execute UHLEditorCommands action", EUserInterfaceActionType::Button, FInputChord()); -} - -#undef LOCTEXT_NAMESPACE diff --git a/Source/UHLEditor/Private/UHLEditorCustomThumbnail.cpp b/Source/UHLEditor/Private/UHLEditorCustomThumbnail.cpp deleted file mode 100644 index 03be988b..00000000 --- a/Source/UHLEditor/Private/UHLEditorCustomThumbnail.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "UHLEditorCustomThumbnail.h" - -// Add default functionality here for any IUHLEditorCustomThumbnail functions that are not pure virtual. - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLEditorCustomThumbnail) - -UTexture2D* IUHLEditorCustomThumbnail::GetCustomThumbnailIcon_Implementation() const -{ - return nullptr; -} \ No newline at end of file diff --git a/Source/UHLEditor/Private/UHLEditorStyle.cpp b/Source/UHLEditor/Private/UHLEditorStyle.cpp deleted file mode 100644 index d892fdad..00000000 --- a/Source/UHLEditor/Private/UHLEditorStyle.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UHLEditorStyle.h" -#include "UHLEditor.h" -#include "AssetRegistry/AssetRegistryModule.h" -#include "Development/UHLEditorSettings.h" -#include "Framework/Application/SlateApplication.h" -#include "Styling/SlateStyleRegistry.h" -#include "Slate/SlateGameResources.h" -#include "Interfaces/IPluginManager.h" -#include "Styling/SlateStyleMacros.h" - -#define RootToContentDir Style->RootToContentDir - -TSharedPtr FUHLEditorStyle::StyleInstance = nullptr; - -void FUHLEditorStyle::Initialize() -{ - if (!StyleInstance.IsValid()) - { - StyleInstance = Create(); - FSlateStyleRegistry::RegisterSlateStyle(*StyleInstance); - } -} - -void FUHLEditorStyle::Shutdown() -{ - FSlateStyleRegistry::UnRegisterSlateStyle(*StyleInstance); - ensure(StyleInstance.IsUnique()); - StyleInstance.Reset(); -} - -FName FUHLEditorStyle::GetStyleSetName() -{ - static FName StyleSetName(TEXT("UHLEditorStyle")); - return StyleSetName; -} - - -const FVector2D Icon16x16(16.0f, 16.0f); -const FVector2D Icon20x20(20.0f, 20.0f); - -TSharedRef< FSlateStyleSet > FUHLEditorStyle::Create() -{ - TSharedRef< FSlateStyleSet > Style = MakeShareable(new FSlateStyleSet("UHLEditorStyle")); - Style->SetContentRoot(IPluginManager::Get().FindPlugin("UnrealHelperLibrary")->GetBaseDir() / TEXT("Resources")); - // Style->SetContentRoot(FPaths::ProjectContentDir()); - - const UUHLEditorSettings* DeveloperSettings = GetDefault(); - for (FUHLEditorCustomClassIconDescription CustomClassIcon : DeveloperSettings->CustomClassIcons) - { - // FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked("AssetRegistry"); - FString Path = CustomClassIcon.Texture2D.GetLongPackageName(); - UObject* IconImageObject = LoadObject(nullptr, *Path); - - if (IsValid(IconImageObject)) - { - UTexture2D* IconImage = Cast(IconImageObject); - // FSlateDynamicImageBrush* DynamicImageBrush = new FSlateDynamicImageBrush(IconImage, Icon20x20, FName("CapsuleHitRegistrator")); - FSlateImageBrush* ImageBrush = new FSlateImageBrush(IconImage, Icon20x20); - - TArray> AllClasses = CustomClassIcon.Classes; - // support deprecated value - if (IsValid(CustomClassIcon.Class)) - { - AllClasses.Add(CustomClassIcon.Class); - } - for (const TSubclassOf Class : AllClasses) - { - if (!Class) continue; - FString ClassName = Class->GetName(); - // Modify the class icons to use our new awesome icons - FString IconStyleName = FString::Printf(TEXT("ClassIcon.%s"), *ClassName); - Style->Set(FName(IconStyleName), ImageBrush); - } - } - } - - Style->Set("UHLEditor.PluginAction", new IMAGE_BRUSH_SVG(TEXT("PlaceholderButtonIcon"), Icon20x20)); - return Style; -} - -void FUHLEditorStyle::ReloadTextures() -{ - if (FSlateApplication::IsInitialized()) - { - FSlateApplication::Get().GetRenderer()->ReloadTextureResources(); - } -} - -const ISlateStyle& FUHLEditorStyle::Get() -{ - return *StyleInstance; -} diff --git a/Source/UHLEditor/Private/UI/EditorUtility/EUW_UHL_Utils.cpp b/Source/UHLEditor/Private/UI/EditorUtility/EUW_UHL_Utils.cpp deleted file mode 100644 index cf472ff6..00000000 --- a/Source/UHLEditor/Private/UI/EditorUtility/EUW_UHL_Utils.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "UI/EditorUtility/EUW_UHL_Utils.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(EUW_UHL_Utils) \ No newline at end of file diff --git a/Source/UHLEditor/Public/Development/UHLEditorSettings.h b/Source/UHLEditor/Public/Development/UHLEditorSettings.h deleted file mode 100644 index bef8665c..00000000 --- a/Source/UHLEditor/Public/Development/UHLEditorSettings.h +++ /dev/null @@ -1,35 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "UHLEditorSettings.generated.h" - -USTRUCT(BlueprintType) -struct FUHLEditorCustomClassIconDescription -{ - GENERATED_BODY() - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="CustomClassIconDescription") - TSoftObjectPtr Texture2D; - - // deprecated, TODO: remove - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="CustomClassIconDescription", meta=(DeprecatedProperty, DeprecationMessage="Deprecated use Classes")) - TSubclassOf Class; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="CustomClassIconDescription") - TArray> Classes; -}; - -/** - * - */ -UCLASS(Config="Editor", DefaultConfig, meta = (DisplayName="UHL Editor")) -class UHLEDITOR_API UUHLEditorSettings : public UDeveloperSettings -{ - GENERATED_BODY() - -public: - UPROPERTY(config, EditAnywhere, Category="Custom Class Icons", meta=(FullyExpand)) - TArray CustomClassIcons; -}; diff --git a/Source/UHLEditor/Public/UHLEditor.h b/Source/UHLEditor/Public/UHLEditor.h deleted file mode 100644 index fe63c6f0..00000000 --- a/Source/UHLEditor/Public/UHLEditor.h +++ /dev/null @@ -1,29 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Modules/ModuleManager.h" - -class FToolBarBuilder; -class FMenuBuilder; - -class FUHLEditorModule : public IModuleInterface -{ -public: - - /** IModuleInterface implementation */ - virtual void StartupModule() override; - virtual void ShutdownModule() override; - - /** This function will be bound to Command. */ - void PluginButtonClicked(); - -private: - - void RegisterMenus(); - - -private: - TSharedPtr PluginCommands; -}; diff --git a/Source/UHLEditor/Public/UHLEditorBlueprintThumbnailRenderer.h b/Source/UHLEditor/Public/UHLEditorBlueprintThumbnailRenderer.h deleted file mode 100644 index 04182941..00000000 --- a/Source/UHLEditor/Public/UHLEditorBlueprintThumbnailRenderer.h +++ /dev/null @@ -1,29 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "ThumbnailRendering/BlueprintThumbnailRenderer.h" -#include "UHLEditorBlueprintThumbnailRenderer.generated.h" - -/** - * - */ -UCLASS() -class UHLEDITOR_API UUHLEditorBlueprintThumbnailRenderer : public UBlueprintThumbnailRenderer -{ - GENERATED_BODY() -protected: - - UUHLEditorBlueprintThumbnailRenderer(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) - {} - - // UThumbnailRenderer implementation - virtual void GetThumbnailSize(UObject* Object, float Zoom, uint32& OutWidth, uint32& OutHeight) const override; - virtual void Draw(UObject* Object, int32 X, int32 Y, uint32 Width, uint32 Height, FRenderTarget*, FCanvas* Canvas, bool bAdditionalViewFamily) override; - virtual bool CanVisualizeAsset(UObject* Object) override; -protected: - - UTexture2D* GetTextureFromGeneratedClass(UClass* Class) const; -}; diff --git a/Source/UHLEditor/Public/UHLEditorCommands.h b/Source/UHLEditor/Public/UHLEditorCommands.h deleted file mode 100644 index e5edb779..00000000 --- a/Source/UHLEditor/Public/UHLEditorCommands.h +++ /dev/null @@ -1,23 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Framework/Commands/Commands.h" -#include "UHLEditorStyle.h" - -class FUHLEditorCommands : public TCommands -{ -public: - - FUHLEditorCommands() - : TCommands(TEXT("UHLEditor"), NSLOCTEXT("Contexts", "UHLEditor", "UHLEditor Plugin"), NAME_None, FUHLEditorStyle::GetStyleSetName()) - { - } - - // TCommands<> interface - virtual void RegisterCommands() override; - -public: - TSharedPtr< FUICommandInfo > PluginAction; -}; diff --git a/Source/UHLEditor/Public/UHLEditorCustomThumbnail.h b/Source/UHLEditor/Public/UHLEditorCustomThumbnail.h deleted file mode 100644 index 05fe2b89..00000000 --- a/Source/UHLEditor/Public/UHLEditorCustomThumbnail.h +++ /dev/null @@ -1,31 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "UObject/Interface.h" -#include "UHLEditorCustomThumbnail.generated.h" - -// This class does not need to be modified. -UINTERFACE(MinimalAPI, meta = (Blueprintable)) -class UUHLEditorCustomThumbnail : public UInterface -{ - GENERATED_BODY() -}; - -/** - * - */ -class UHLEDITOR_API IUHLEditorCustomThumbnail -{ - GENERATED_BODY() - - // Add interface functions to this class. This is the class that will be inherited to implement this interface. -public: - -/** IUHLEditorCustomThumbnail **/ - UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="Custom Thumbnail") - UTexture2D* GetCustomThumbnailIcon() const; - virtual UTexture2D* GetCustomThumbnailIcon_Implementation() const; -/** ~IUHLEditorCustomThumbnail **/ -}; diff --git a/Source/UHLEditor/Public/UHLEditorStyle.h b/Source/UHLEditor/Public/UHLEditorStyle.h deleted file mode 100644 index 78c3096e..00000000 --- a/Source/UHLEditor/Public/UHLEditorStyle.h +++ /dev/null @@ -1,31 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Styling/SlateStyle.h" - -class FUHLEditorStyle -{ -public: - - static void Initialize(); - - static void Shutdown(); - - /** reloads textures used by slate renderer */ - static void ReloadTextures(); - - /** @return The Slate style set for the Shooter game */ - static const ISlateStyle& Get(); - - static FName GetStyleSetName(); - -private: - - static TSharedRef< class FSlateStyleSet > Create(); - -private: - - static TSharedPtr< class FSlateStyleSet > StyleInstance; -}; \ No newline at end of file diff --git a/Source/UHLEditor/Public/UI/EditorUtility/EUW_UHL_Utils.h b/Source/UHLEditor/Public/UI/EditorUtility/EUW_UHL_Utils.h deleted file mode 100644 index 6d3ed0ce..00000000 --- a/Source/UHLEditor/Public/UI/EditorUtility/EUW_UHL_Utils.h +++ /dev/null @@ -1,17 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "EditorUtilityWidget.h" -#include "EUW_UHL_Utils.generated.h" - -/** - * - */ -UCLASS(Blueprintable) -class UHLEDITOR_API UEUW_UHL_Utils : public UEditorUtilityWidget -{ - GENERATED_BODY() - -}; diff --git a/Source/UHLEditor/UHLEditor.Build.cs b/Source/UHLEditor/UHLEditor.Build.cs deleted file mode 100644 index f9a476ae..00000000 --- a/Source/UHLEditor/UHLEditor.Build.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -using UnrealBuildTool; - -public class UHLEditor : ModuleRules -{ - public UHLEditor(ReadOnlyTargetRules Target) : base(Target) - { - PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; - - PublicIncludePaths.AddRange( - new string[] { - // ... add public include paths required here ... - } - ); - - - PrivateIncludePaths.AddRange( - new string[] { - // ... add other private include paths required here ... - } - ); - - - PublicDependencyModuleNames.AddRange( - new string[] - { - "Core", - "CoreUObject", - "Engine", - "PropertyEditor", - "Blutility", - "UMG", - "BehaviorTreeEditor", - // ... add other public dependencies that you statically link with here ... - } - ); - - - PrivateDependencyModuleNames.AddRange( - new string[] - { - "Projects", - "InputCore", - "EditorFramework", - "UnrealEd", - "ToolMenus", - "Slate", - "SlateCore", - "UnrealEd", - "DeveloperSettings", - - "UnrealHelperLibrary", - "UHLModulesHelper", - - "EditorWidgets", - - "GameplayTags", - "GameplayTagsEditor", - // ... add private dependencies that you statically link with here ... - } - ); - - - DynamicallyLoadedModuleNames.AddRange( - new string[] - { - // ... add any modules that your module loads dynamically here ... - } - ); - } -} diff --git a/Source/UHLGAS/Private/Abilities/UHLGameplayAbility.cpp b/Source/UHLGAS/Private/Abilities/UHLGameplayAbility.cpp deleted file mode 100644 index d7d58c71..00000000 --- a/Source/UHLGAS/Private/Abilities/UHLGameplayAbility.cpp +++ /dev/null @@ -1,276 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Abilities/UHLGameplayAbility.h" - -#include "AbilitySystemComponent.h" -#include "AbilitySystemGlobals.h" -#include "UHLAbilitySystemComponent.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLGameplayAbility) - -UUHLGameplayAbility::UUHLGameplayAbility(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - ReplicationPolicy = EGameplayAbilityReplicationPolicy::ReplicateNo; - InstancingPolicy = EGameplayAbilityInstancingPolicy::InstancedPerActor; - NetExecutionPolicy = EGameplayAbilityNetExecutionPolicy::LocalPredicted; - NetSecurityPolicy = EGameplayAbilityNetSecurityPolicy::ClientOrServer; -} - -UUHLAbilitySystemComponent* UUHLGameplayAbility::GetUHLAbilitySystemComponentFromActorInfo() const -{ - if (!ensure(CurrentActorInfo)) - { - return nullptr; - } - checkf(CastChecked(CurrentActorInfo->AbilitySystemComponent.Get()), TEXT("UUHLGameplayAbility::GetUHLAbilitySystemComponentFromActorInfo can be used only on characters with UHLAbilitySystemComponent")); - return StaticCast(CurrentActorInfo->AbilitySystemComponent.Get()); -} - -bool UUHLGameplayAbility::K2_CommitAbilityDuration(bool BroadcastCommitEvent) -{ - ensure(CurrentActorInfo); - if (BroadcastCommitEvent) - { - if (UAbilitySystemComponent* AbilitySystemComponent = - GetAbilitySystemComponentFromActorInfo_Ensured()) - { - AbilitySystemComponent->NotifyAbilityCommit(this); - } - } - return CommitAbilityDuration(CurrentSpecHandle, CurrentActorInfo, CurrentActivationInfo); -} - -void UUHLGameplayAbility::TryActivateAbilityOnSpawn(const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilitySpec& Spec) const -{ - // Try to activate if activation policy is on spawn. - if (ActorInfo && !Spec.IsActive() && (ActivationPolicy == EUHLAbilityActivationPolicy::OnSpawn)) - { - UAbilitySystemComponent* ASC = ActorInfo->AbilitySystemComponent.Get(); - const AActor* AvatarActor = ActorInfo->AvatarActor.Get(); - - // If avatar actor is torn off or about to die, don't try to activate until we get the new one. - if (ASC && AvatarActor && !AvatarActor->GetTearOff() && (AvatarActor->GetLifeSpan() <= 0.0f)) - { - const bool bIsLocalExecution = (NetExecutionPolicy == EGameplayAbilityNetExecutionPolicy::LocalPredicted) || (NetExecutionPolicy == EGameplayAbilityNetExecutionPolicy::LocalOnly); - const bool bIsServerExecution = (NetExecutionPolicy == EGameplayAbilityNetExecutionPolicy::ServerOnly) || (NetExecutionPolicy == EGameplayAbilityNetExecutionPolicy::ServerInitiated); - - const bool bClientShouldActivate = ActorInfo->IsLocallyControlled() && bIsLocalExecution; - const bool bServerShouldActivate = ActorInfo->IsNetAuthority() && bIsServerExecution; - - if (bClientShouldActivate || bServerShouldActivate) - { - ASC->TryActivateAbility(Spec.Handle); - } - } - } -} - -void UUHLGameplayAbility::CommitExecute( - const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, - const FGameplayAbilityActivationInfo ActivationInfo) -{ - Super::CommitExecute(Handle, ActorInfo, ActivationInfo); - CommitAbilityDuration(Handle, ActorInfo, ActivationInfo); -} - -bool UUHLGameplayAbility::CommitAbilityDuration( - const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, - const FGameplayAbilityActivationInfo ActivationInfo, - FGameplayTagContainer* OptionalRelevantTags) -{ - if (!CheckAbilityDuration(Handle, ActorInfo, OptionalRelevantTags)) - { - return false; - } - ApplyDuration(Handle, ActorInfo, ActivationInfo); - return true; -} - -void UUHLGameplayAbility::ApplyDuration( - const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, - const FGameplayAbilityActivationInfo ActivationInfo) -{ - UGameplayEffect* AbilityDurationGE = GetAbilityDurationGameplayEffect(); - UAbilitySystemComponent* ASC = GetAbilitySystemComponentFromActorInfo(); - if (AbilityDurationGE && ASC) - { - FActiveGameplayEffectHandle EffectHandle = ApplyGameplayEffectToOwner( - Handle, - ActorInfo, - ActivationInfo, - AbilityDurationGE, - GetAbilityLevel(Handle, ActorInfo)); - - ASC->OnGameplayEffectRemoved_InfoDelegate(EffectHandle)->AddUObject( - this, - &UUHLGameplayAbility::OnDurationEnd); - } -} - -bool UUHLGameplayAbility::CheckAbilityDuration( - const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, - OUT FGameplayTagContainer* OptionalRelevantTags) const -{ - if (!ensure(ActorInfo)) - { - return true; - } - - const FGameplayTagContainer* AbilityDurationTag = GetAbilityDurationTags(); - if (AbilityDurationTag && !AbilityDurationTag->IsEmpty()) - { - if (UAbilitySystemComponent* AbilitySystemComponent = ActorInfo->AbilitySystemComponent. - Get()) - { - if (AbilitySystemComponent->HasAnyMatchingGameplayTags(*AbilityDurationTag)) - { - if (OptionalRelevantTags) - { - // const FGameplayTag& FailAbilityDurationTag = UAbilitySystemGlobals::Get(). - // ActivateFailCooldownTag; - // if (FailAbilityDurationTag.IsValid()) - // { - // OptionalRelevantTags->AddTag(FailAbilityDurationTag); - // } - - // Let the caller know which tags were blocking - OptionalRelevantTags->AppendMatchingTags( - AbilitySystemComponent->GetOwnedGameplayTags(), - *AbilityDurationTag); - } - - return false; - } - } - } - return true; -} - -void UUHLGameplayAbility::OnDurationEnd_Implementation( - const FGameplayEffectRemovalInfo& GameplayEffectRemovalInfo) -{ - if (bEndAbilityOnDurationExpired) - { - K2_EndAbility(); - } -} - -const FGameplayTagContainer* UUHLGameplayAbility::GetAbilityDurationTags() const -{ - UGameplayEffect* CDGE = GetAbilityDurationGameplayEffect(); - return CDGE ? &CDGE->GetGrantedTags() : nullptr; -} - -UGameplayEffect* UUHLGameplayAbility::GetAbilityDurationGameplayEffect() const -{ - if (AbilityDurationGameplayEffectClass) - { - return AbilityDurationGameplayEffectClass->GetDefaultObject(); - } - return nullptr; -} - -bool UUHLGameplayAbility::CommitCheck( - const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, - const FGameplayAbilityActivationInfo ActivationInfo, - FGameplayTagContainer* OptionalRelevantTags) -{ - if (!CheckAbilityDuration(Handle, ActorInfo, OptionalRelevantTags)) - { - return false; - } - return Super::CommitCheck(Handle, ActorInfo, ActivationInfo, OptionalRelevantTags); -} - -void UUHLGameplayAbility::CancelAbility( - const FGameplayAbilitySpecHandle Handle, - const FGameplayAbilityActorInfo* ActorInfo, - const FGameplayAbilityActivationInfo ActivationInfo, - bool bReplicateCancelAbility) -{ - if (!bCancelManually) - { - Super::CancelAbility(Handle, ActorInfo, ActivationInfo, bReplicateCancelAbility); - return; - } - - // Intercept and mark cancel requested - bCancelRequested = true; - - // Blueprint hook for custom cancel handling - ReceiveCancelRequested(); - -#if WITH_EDITOR - // Schedule an editor-only reminder if ReleaseCancellation() isn't called within 60 seconds - if (UWorld* World = GetWorld()) - { - World->GetTimerManager().SetTimer( - EditorWarningHandle, - this, - &ThisClass::CheckCancelReminder, - 60.0f, - false - ); - } -#endif -} - -#if WITH_EDITOR -void UUHLGameplayAbility::CheckCancelReminder() -{ - if (bCancelRequested && IsActive()) - { - if (GEngine) - { - GEngine->AddOnScreenDebugMessage( - -1, - 5.0f, - FColor::Yellow, - TEXT("Warning: ReleaseCancellation() was not called for this ability within 60 seconds.") - ); - } - } -} -#endif - -void UUHLGameplayAbility::ReleaseCancellation() -{ - if (bCancelManually && bCancelRequested && IsActive()) - { -#if WITH_EDITOR - // Clear any pending editor warning - if (UWorld* World = GetWorld()) - { - World->GetTimerManager().ClearTimer(EditorWarningHandle); - } -#endif - // Perform actual cancel - Super::CancelAbility(CurrentSpecHandle, CurrentActorInfo, CurrentActivationInfo, true); - bCancelRequested = false; - - // Blueprint hook after cancel completed - ReceiveCancelCompleted(); - } -} - -void UUHLGameplayAbility::OnGiveAbility(const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilitySpec& Spec) -{ - Super::OnGiveAbility(ActorInfo, Spec); - - K2_OnAbilityAdded(); - - TryActivateAbilityOnSpawn(ActorInfo, Spec); -} - -void UUHLGameplayAbility::OnRemoveAbility(const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilitySpec& Spec) -{ - K2_OnAbilityRemoved(); - Super::OnRemoveAbility(ActorInfo, Spec); -} - -void UUHLGameplayAbility::OnPawnAvatarSet() -{ - K2_OnPawnAvatarSet(); -} diff --git a/Source/UHLGAS/Private/Animations/Notifies/ANS_ActivateAbility.cpp b/Source/UHLGAS/Private/Animations/Notifies/ANS_ActivateAbility.cpp deleted file mode 100644 index 555e35a7..00000000 --- a/Source/UHLGAS/Private/Animations/Notifies/ANS_ActivateAbility.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Animations/Notifies/ANS_ActivateAbility.h" - -#include "Engine/World.h" -#include "Animation/AnimMontage.h" -#include "AbilitySystemComponent.h" -#include "AbilitySystemInterface.h" -#include "Components/SkeletalMeshComponent.h" -#include "Utils/UnrealHelperLibraryBPL.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(ANS_ActivateAbility) - -FString UANS_ActivateAbility::GetNotifyName_Implementation() const -{ - return FString("ActivateAbility ") + GameplayAbilityTag.ToString(); -} - -void UANS_ActivateAbility::NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyBegin(MeshComp, Animation, TotalDuration, EventReference); - - if (!GameplayAbilityTag.IsValid()) - { - UUnrealHelperLibraryBPL::DebugPrintString(MeshComp->GetWorld(), FString::Printf(TEXT("%s GameplayAbilityTag not set"), *this->GetName())); - return; - } - - ActorWithASC = Cast(MeshComp->GetOwner()); - if (ActorWithASC.IsValid()) - { - ActorWithASC->GetAbilitySystemComponent()->TryActivateAbilitiesByTag(FGameplayTagContainer(GameplayAbilityTag), bAllowRemoteActivation); - } -} - -void UANS_ActivateAbility::NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyEnd(MeshComp, Animation, EventReference); - - if (!GameplayAbilityTag.IsValid()) - { - UUnrealHelperLibraryBPL::DebugPrintString(MeshComp->GetWorld(), FString::Printf(TEXT("%s GameplayAbilityTag not set"), *this->GetName())); - return; - } - - CancelAbility(); -} - -void UANS_ActivateAbility::OnMontageBlendingOut(UAnimMontage* Montage, bool bInterrupted) -{ - if (!bDeactivateOnMontageBlendingOut || !Montage) - { - return; - } - - if (ActorWithASC.IsValid()) - { - CancelAbility(); - } -} - -void UANS_ActivateAbility::CancelAbility() -{ - if (ActorWithASC.IsValid()) - { - const FGameplayTagContainer Tags = FGameplayTagContainer(GameplayAbilityTag); - ActorWithASC->GetAbilitySystemComponent()->CancelAbilities(&Tags); - } -} diff --git a/Source/UHLGAS/Private/Animations/Notifies/ANS_CatchToAbilityInputCache.cpp b/Source/UHLGAS/Private/Animations/Notifies/ANS_CatchToAbilityInputCache.cpp deleted file mode 100644 index f25f810b..00000000 --- a/Source/UHLGAS/Private/Animations/Notifies/ANS_CatchToAbilityInputCache.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Animations/Notifies/ANS_CatchToAbilityInputCache.h" - -#include "AbilitySystemInterface.h" -#include "UHLAbilitySystemComponent.h" -#include "Components/SkeletalMeshComponent.h" -#include "Core/UHLGameplayTags.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(ANS_CatchToAbilityInputCache) - -void UANS_CatchToAbilityInputCache::NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyBegin(MeshComp, Animation, TotalDuration, EventReference); - - AActor* Actor = MeshComp->GetOwner(); - if (!IsValid(Actor)) return; - - checkf(Actor->Implements(), TEXT("ANS_CatchToAbilityInputCache can be used only on characters nested from UHL AbilitySystem")); - - IAbilitySystemInterface* AbilitySystemInterface = Cast(Actor); - if (AbilitySystemInterface == nullptr) return; - - ASC = Cast(AbilitySystemInterface->GetAbilitySystemComponent()); - checkf(ASC, TEXT("ANS_CatchToAbilityInputCache can be used only on characters nested from UHL AbilitySystem")); - - ASC->AddLooseGameplayTag(UHLGameplayTags::TAG_UHL_AbilityInputCache_Catching); -} - -void UANS_CatchToAbilityInputCache::NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyEnd(MeshComp, Animation, EventReference); - - if (!IsValid(ASC)) return; - - ASC->RemoveLooseGameplayTagCompletly(UHLGameplayTags::TAG_UHL_AbilityInputCache_Catching); -} diff --git a/Source/UHLGAS/Private/Animations/Notifies/ANS_CheckAbilityInputCache.cpp b/Source/UHLGAS/Private/Animations/Notifies/ANS_CheckAbilityInputCache.cpp deleted file mode 100644 index cbfd4422..00000000 --- a/Source/UHLGAS/Private/Animations/Notifies/ANS_CheckAbilityInputCache.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Animations/Notifies/ANS_CheckAbilityInputCache.h" - -#include "AbilitySystemInterface.h" -#include "UHLAbilitySystemComponent.h" -#include "Components/SkeletalMeshComponent.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(ANS_CheckAbilityInputCache) - -void UANS_CheckAbilityInputCache::NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyBegin(MeshComp, Animation, TotalDuration, EventReference); - - AActor* Actor = MeshComp->GetOwner(); - if (!IsValid(Actor)) return; - - checkf(Actor->Implements(), TEXT("ANS_CheckAbilityInputCache can be used only on characters nested from UHL AbilitySystem")); - - IAbilitySystemInterface* AbilitySystemInterface = Cast(Actor); - if (AbilitySystemInterface == nullptr) return; - - ASC = Cast(AbilitySystemInterface->GetAbilitySystemComponent()); - checkf(ASC, TEXT("ANS_CheckAbilityInputCache can be used only on characters nested from UHL AbilitySystem")); - - SavedTargetTags = TargetTags; -} - -void UANS_CheckAbilityInputCache::NotifyTick(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float FrameDeltaTime, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyTick(MeshComp, Animation, FrameDeltaTime, EventReference); - - if (!IsValid(ASC)) - { - return; - } - - // if (bUseCheckCacheOnlyWithThisTags) - // { - // if (SavedTargetTags.IsEmpty()) - // { - // NotifyEnd(MeshComp, Animation, EventReference); - // return; - // } - // - // TArray RemovedTags {}; - // for (const FGameplayTag& Tag : SavedTargetTags) - // { - // if (!ASC->GetAbilityInputCache()->GetAbilityInputCache().Contains(Tag)) continue; - // ASC->GetAbilityInputCache()->CheckCache(); - // if (bCacheOnce) - // { - // RemovedTags.Add(Tag); - // } - // } - // - // for (const FGameplayTag& Tag : RemovedTags) - // { - // SavedTargetTags.RemoveTag(Tag); - // } - // } - // else - // { - ASC->GetAbilityInputCache()->CheckCache(); - // } -} - -void UANS_CheckAbilityInputCache::NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyEnd(MeshComp, Animation, EventReference); - - if (bClearCacheOnEnd && IsValid(ASC)) - { - ASC->GetAbilityInputCache()->ClearCache(); - } -} diff --git a/Source/UHLGAS/Private/Animations/Notifies/ANS_UHLGAS_GlobalTimeDilation.cpp b/Source/UHLGAS/Private/Animations/Notifies/ANS_UHLGAS_GlobalTimeDilation.cpp deleted file mode 100644 index ac06e50d..00000000 --- a/Source/UHLGAS/Private/Animations/Notifies/ANS_UHLGAS_GlobalTimeDilation.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Animations/Notifies/ANS_UHLGAS_GlobalTimeDilation.h" - -#include "Animation/AnimMontage.h" -#include "Components/SkeletalMeshComponent.h" -#include "Kismet/GameplayStatics.h" - - -void UANS_UHLGAS_GlobalTimeDilation::NotifyTick(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float FrameDeltaTime, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyTick(MeshComp, Animation, FrameDeltaTime, EventReference); - - float GlobalTimeDilationCurveValue = 1.0f; - MeshComp->GetAnimInstance()->GetCurveValueWithDefault("GlobalTimeDilation", 1.0f, GlobalTimeDilationCurveValue); - - UGameplayStatics::SetGlobalTimeDilation(MeshComp->GetOwner(), GlobalTimeDilationCurveValue); -} - -void UANS_UHLGAS_GlobalTimeDilation::OnMontageBlendingOut(UAnimMontage* Montage, bool bInterrupted) -{ - Super::OnMontageBlendingOut(Montage, bInterrupted); - - UObject* Outer = Montage->GetOuter(); - UGameplayStatics::SetGlobalTimeDilation(Outer, 1.0f); -} - diff --git a/Source/UHLGAS/Private/Animations/Notifies/ANS_UHLGAS_TimedNiagaraEffect.cpp b/Source/UHLGAS/Private/Animations/Notifies/ANS_UHLGAS_TimedNiagaraEffect.cpp deleted file mode 100644 index 2d35d9df..00000000 --- a/Source/UHLGAS/Private/Animations/Notifies/ANS_UHLGAS_TimedNiagaraEffect.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Animations/Notifies/ANS_UHLGAS_TimedNiagaraEffect.h" - -#include "AbilitySystemComponent.h" -#include "AbilitySystemGlobals.h" - -void UANS_UHLGAS_TimedNiagaraEffect::NotifyBegin( - USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, - const FAnimNotifyEventReference& EventReference) -{ - AActor* Owner = MeshComp->GetOwner(); - if (!Owner) return; - - if (CanActivateNiagara(Owner)) - { - Super::NotifyBegin(MeshComp, Animation, TotalDuration, EventReference); - } -} - -bool UANS_UHLGAS_TimedNiagaraEffect::GetAbilitySystemChecksRequired() const -{ - return ActivationRequiredTags.Num() > 0 - || ActivationBlockedTags.Num() > 0; -} - -bool UANS_UHLGAS_TimedNiagaraEffect::CanActivateNiagara(AActor* Owner) const -{ - if (bIgnoreTagRequirementsInPreview && Owner->GetWorld()->IsPreviewWorld()) return true; - if (!GetAbilitySystemChecksRequired()) return true; - - UAbilitySystemComponent* ASC = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Owner); - if (!ASC) return false; - - const FGameplayTagContainer OwnedTags = ASC->GetOwnedGameplayTags(); - if (OwnedTags.HasAll(ActivationRequiredTags) && !OwnedTags.HasAny(ActivationBlockedTags)) - { - return true; - } - - return false; -} \ No newline at end of file diff --git a/Source/UHLGAS/Private/Animations/Notifies/AN_FireGameplayEvent.cpp b/Source/UHLGAS/Private/Animations/Notifies/AN_FireGameplayEvent.cpp deleted file mode 100644 index 7a27db5e..00000000 --- a/Source/UHLGAS/Private/Animations/Notifies/AN_FireGameplayEvent.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Animations/Notifies/AN_FireGameplayEvent.h" - -#include "AbilitySystemComponent.h" -#include "AbilitySystemGlobals.h" -#include "Components/SkeletalMeshComponent.h" -#include "Abilities/GameplayAbilityTypes.h" - -#if WITH_EDITOR -void UAN_FireGameplayEvent::PostEditChangeProperty( - struct FPropertyChangedEvent& PropertyChangedEvent) -{ - Super::PostEditChangeProperty(PropertyChangedEvent); - - if (PropertyChangedEvent.Property != nullptr && - PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(UAN_FireGameplayEvent, EventTag)) - { - if (UAnimSequenceBase* AnimSeq = Cast(GetOuter())) - { - AnimSeq->Modify(); - } - } -} -#endif - -FString UAN_FireGameplayEvent::GetNotifyName_Implementation() const -{ - return FString("FireGameplayEvent->") + EventTag.ToString(); -} - -void UAN_FireGameplayEvent::Notify( - USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, - const FAnimNotifyEventReference& EventReference) -{ - Super::Notify(MeshComp, Animation, EventReference); - - if (!MeshComp) return; - - AActor* TargetActor = MeshComp->GetOwner(); - if (!TargetActor) return; - - UAbilitySystemComponent* TargetASC = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(TargetActor); - - FGameplayEventData EventData; - EventData.Target = TargetActor; - EventData.Instigator = TargetActor; - EventData.EventMagnitude = EventMagnitude; - EventData.OptionalObject = OptionalObject; - EventData.OptionalObject2 = OptionalObject2; - EventData.TargetTags = TargetTags; - EventData.InstigatorTags = InstigatorTags; - TargetASC->HandleGameplayEvent(EventTag, &EventData); -} \ No newline at end of file diff --git a/Source/UHLGAS/Private/AttributeSets/UHLAttributeSet.cpp b/Source/UHLGAS/Private/AttributeSets/UHLAttributeSet.cpp deleted file mode 100644 index 5f506ef1..00000000 --- a/Source/UHLGAS/Private/AttributeSets/UHLAttributeSet.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "AttributeSets/UHLAttributeSet.h" - -#include "UHLAbilitySystemComponent.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLAttributeSet) - -UUHLAttributeSet::UUHLAttributeSet() -{ -} - -UWorld* UUHLAttributeSet::GetWorld() const -{ - const UObject* Outer = GetOuter(); - check(Outer); - - return Outer->GetWorld(); -} - -UUHLAbilitySystemComponent* UUHLAttributeSet::GetUHLAbilitySystemComponent() const -{ - return Cast(GetOwningAbilitySystemComponent()); -} diff --git a/Source/UHLGAS/Private/Core/UHLAbilitySystemInterface.cpp b/Source/UHLGAS/Private/Core/UHLAbilitySystemInterface.cpp deleted file mode 100644 index bebb796c..00000000 --- a/Source/UHLGAS/Private/Core/UHLAbilitySystemInterface.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Core/UHLAbilitySystemInterface.h" - diff --git a/Source/UHLGAS/Private/Data/PayloadWithInstancedStructs.cpp b/Source/UHLGAS/Private/Data/PayloadWithInstancedStructs.cpp deleted file mode 100644 index 3a532afd..00000000 --- a/Source/UHLGAS/Private/Data/PayloadWithInstancedStructs.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "Data/PayloadWithInstancedStructs.h" - -UPayloadWithInstancedStructs::UPayloadWithInstancedStructs( - TArray InstancedStructs_In) -{ - InstancedStructs = InstancedStructs_In; -} \ No newline at end of file diff --git a/Source/UHLGAS/Private/Development/UHLGASSettings.cpp b/Source/UHLGAS/Private/Development/UHLGASSettings.cpp deleted file mode 100644 index ea5ace8c..00000000 --- a/Source/UHLGAS/Private/Development/UHLGASSettings.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Development/UHLGASSettings.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLGASSettings) \ No newline at end of file diff --git a/Source/UHLGAS/Private/Input/AbilityInputCache.cpp b/Source/UHLGAS/Private/Input/AbilityInputCache.cpp deleted file mode 100644 index 1caf78e9..00000000 --- a/Source/UHLGAS/Private/Input/AbilityInputCache.cpp +++ /dev/null @@ -1,140 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "Input/AbilityInputCache.h" - -#include "UHLAbilitySystemComponent.h" -#include "UHLGASBlueprintLibrary.h" -#include "Abilities/UHLGameplayAbility.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(AbilityInputCache) - -DEFINE_LOG_CATEGORY(Log_UHL_AbilityInputCache); - -void UAbilityInputCache::SetUp(UUHLAbilitySystemComponent* ASC_In) -{ - if (!ASC_In) return; - - ASC = ASC_In; -} - -bool UAbilityInputCache::AddTagToCache(FGameplayTag AbilityTag_In) -{ - // not required to be unique - AbilityInputCache.Add(AbilityTag_In); - UE_LOG(Log_UHL_AbilityInputCache, Log, TEXT("Add ability to InputCache - %s"), *AbilityTag_In.ToString()); - return true; -} - -bool UAbilityInputCache::AddTagsToCache(TArray AbilityTags_In, bool bReverse) -{ - if (AbilityTags_In.IsEmpty()) return false; - - if (bReverse) - { - for (int32 i = AbilityTags_In.Num() - 1; i >= 0; i--) - { - AddTagToCache(AbilityTags_In[i]); - } - } - else - { - for (int32 i = 0; i < AbilityTags_In.Num(); i++) - { - AddTagToCache(AbilityTags_In[i]); - } - } - - return true; -} - -// should cancel all abilities that also cached but not fired -void UAbilityInputCache::CheckCache() -{ - UE_LOG(Log_UHL_AbilityInputCache, Log, TEXT("Check AbilityInputCache")); - - if (AbilityInputCache.IsEmpty()) - { - UE_LOG(Log_UHL_AbilityInputCache, Log, TEXT("AbilityInputCache is empty")); - return; - }; - - if (ASC.IsValid()) - { - bool bActivatedAtLeastOneTag = false; - for (int32 i = AbilityInputCache.Num() - 1; i >= 0; i--) - { - FGameplayTag AbilityTagToActivate = AbilityInputCache[i]; - if (AbilityTagToActivate.IsValid()) - { - // 1) активировать некст абилку и уповать на то что rollattack не активируется потому что условия не подходят - - // 2) [средне хуйевый] сделать добавление в разные типы кэшей, тогда будет кэш Default/Normal/RollCache, - // - Default - кэш содержащий все действия, если нет приоритезации cache'а, то из Default берется действие - // - Normal - обычные атаки и действия(кувырок, прыжок) - // - RollCache - roll атаки и действия(кувырок, прыжок) - // в check cache - // говорю приоритезируй RollCache, он берет и достает кувырочную атаку либо сам roll, либо чет еще что в RollCache'е есть - // т.е. у каждой абилки есть несколько кешей в которые она заносится - Default/Normal/RollCache/JumpCache - // мб тогда наоборот добавлять действие во все cache'ы, а указывать в абилке только те кэши - // в которые ее добавлять не надо, ExcludeFromCaches TArray и список кэшей в которые абилку - // включать не стоит, минусы - контр-интуитивно, плюсы - "типо меньше работы" - - // [хуйня варик] 3) prioritize abilities matching tag и тогда в кувырке я смогу сказать приоритезируй - // атаку кувырочную, а не обычную удобненько, а как эта приоритезация должна работать, вот есть такой стэк - // - Roll - // - MeleeAttack.RightHand - // - MeleeAttack.Roll - // если говорю приоритезируй атаку MeleeAttack.Roll, то возьмет не Roll, а MeleeAttack.Roll - хуйня варик - - // 4) [вроде оч гибкий] CacheInputActivationRequiredTags/CacheInputBlockedTags - запретить если чел не в кувырке добавлять некоторые абилки в cache - // пример есть Roll атака, если мы не в Roll'е тогда зачем ее добавлять в Cache воообще, нужно не только - // bCacheInput чекать, но и вот эти теги присутствуют/отсутствуют. - // Единственная проблема вот я кувырок и ЛКМ почти одновременно нажал че произойдет? - // успеет ли tag кувырка наложится прежде чем я - - // TODO should we get another Ability from cache to activate - // if failed to activation of last ability failed ??? mb it should be an option - UE_LOG(Log_UHL_AbilityInputCache, Log, TEXT("InputCache checked found ability to activate - %s!"), *AbilityTagToActivate.ToString()); - - // FGameplayAbilitySpec AbilitySpec; - // UUHLGASBlueprintLibrary::FindAbilitySpecByTagUsingASC(ASC.Get(), AbilityTagToActivate, AbilitySpec); - // if (AbilitySpec.IsActive()) - // { - // const UUHLGameplayAbility* AbilityCDO = Cast(AbilitySpec.Ability); - // if (AbilityCDO->bIgnoreActivatedState) - // { - // // ASC->CancelAbilityHandle(AbilitySpec.Handle); - // // bool bCanceledSuccessfully = ASC->TryCancelAbilityWithTag(AbilityTagToActivate); - // // bCanceledSuccessfully; - // } - // } - - bool bActivated = ASC->TryActivateAbilityWithTag(AbilityTagToActivate); - UE_LOG(Log_UHL_AbilityInputCache, Log, TEXT("Activation %s - %s!"), bActivated ? TEXT("successful") : TEXT("failed"), *AbilityTagToActivate.ToString()); - - if (bActivated) - { - bActivatedAtLeastOneTag = true; - break; - } - } - } - - // possibly is shit, ANS_CheckAbilityInputCache clears cache on end (forgot how its related) - if (bActivatedAtLeastOneTag) - { - ClearCache(); - UE_LOG(Log_UHL_AbilityInputCache, Log, TEXT("AbilityInputCache activated at least on tag from cache - clean")); - } - } -} - -void UAbilityInputCache::ClearCache() -{ - AbilityInputCache.Empty(); -} - -// void UAbilityInputCache::RemoveTagFromCache(FGameplayTag AbilityTag_In) -// { -// AbilityInputCache.Remove(AbilityTag_In); -// } diff --git a/Source/UHLGAS/Private/Input/UHLInputComponent.cpp b/Source/UHLGAS/Private/Input/UHLInputComponent.cpp deleted file mode 100644 index e94de885..00000000 --- a/Source/UHLGAS/Private/Input/UHLInputComponent.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Input/UHLInputComponent.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLInputComponent) - -UUHLInputComponent::UUHLInputComponent(const FObjectInitializer& ObjectInitializer) -{ -} diff --git a/Source/UHLGAS/Private/Input/UHLInputConfig.cpp b/Source/UHLGAS/Private/Input/UHLInputConfig.cpp deleted file mode 100644 index 2a71bf76..00000000 --- a/Source/UHLGAS/Private/Input/UHLInputConfig.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "Input/UHLInputConfig.h" -// #include "LyraLogChannels.h" -// #include "InputMappingContext.h" -// #include "Settings/LyraSettingsLocal.h" -// #include "Player/LyraLocalPlayer.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLInputConfig) - -UUHLInputConfig::UUHLInputConfig(const FObjectInitializer& ObjectInitializer) {} - -// const UInputAction* UGCInputConfig::FindNativeInputActionForTag(const FGameplayTag& InputTag, bool bLogNotFound) const -// { -// for (const FGCInputAction& Action : NativeInputActions) -// { -// if (Action.InputAction && (Action.InputTag == InputTag)) -// { -// return Action.InputAction; -// } -// } -// -// if (bLogNotFound) -// { -// UE_LOG(LogTemp, Error, TEXT("Can't find NativeInputAction for InputTag [%s] on InputConfig [%s]."), *InputTag.ToString(), *GetNameSafe(this)); -// } -// -// return nullptr; -// } - -// const UInputAction* UGCInputConfig::FindAbilityInputActionForTag(const FGameplayTag& InputTag, bool bLogNotFound) const -// { -// for (const FGCInputActionAbilities& Action : AbilityInputActions) -// { -// if (Action.InputAction && (Action.AbilityTag == InputTag)) -// { -// return Action.InputAction; -// } -// } -// -// if (bLogNotFound) -// { -// UE_LOG(LogTemp, Error, TEXT("Can't find AbilityInputAction for InputTag [%s] on InputConfig [%s]."), *InputTag.ToString(), *GetNameSafe(this)); -// } -// -// return nullptr; -// } diff --git a/Source/UHLGAS/Private/Tasks/AA_TryActivateAbilityAndWait.cpp b/Source/UHLGAS/Private/Tasks/AA_TryActivateAbilityAndWait.cpp deleted file mode 100644 index 1faa8978..00000000 --- a/Source/UHLGAS/Private/Tasks/AA_TryActivateAbilityAndWait.cpp +++ /dev/null @@ -1,139 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Tasks/AA_TryActivateAbilityAndWait.h" - -#include "AbilitySystemBlueprintLibrary.h" -#include "AbilitySystemComponent.h" -#include "UHLGASBlueprintLibrary.h" -#include "Abilities/GameplayAbility.h" -#include "Data/PayloadWithInstancedStructs.h" -#include "Utils/UnrealHelperLibraryBPL.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(AA_TryActivateAbilityAndWait) - -void UAA_TryActivateAbilityAndWait::OnAbilityActivate(UGameplayAbility* ActivatedAbility) -{ - if (!IncludeTriggeredAbilities && ActivatedAbility->IsTriggered()) - { - return; - } - - const FGameplayTagContainer& AbilityTags = ActivatedAbility->GetAssetTags(); - if (WithTag.IsValid() && !AbilityTags.HasTag(WithTag)) - { - // Failed tag check - return; - } - - if (ShouldBroadcastDelegates()) - { - OnActivate.Broadcast(ActivatedAbility); - } - - // if (TriggerOnce) - // { - // EndAction(); - // } -} - -void UAA_TryActivateAbilityAndWait::OnAbilityDeactivate(UGameplayAbility* ActivatedAbility) -{ - const FGameplayTagContainer& AbilityTags = ActivatedAbility->GetAssetTags(); - if (WithTag.IsValid() && !AbilityTags.HasTag(WithTag)) - { - // Failed tag check - return; - } - - if (ShouldBroadcastDelegates()) - { - OnEndAbility.Broadcast(ActivatedAbility); - } - - if (TriggerOnce) - { - EndAction(); - } -} - -UAA_TryActivateAbilityAndWait* UAA_TryActivateAbilityAndWait::TryActivateAbilityAndWait(AActor* TargetActor, - FGameplayTag InWithTag, bool bUsingEvent_In, const TArray& PayloadInfo, bool InIncludeTriggeredAbilities, bool bAllowRemoteActivation, bool InTriggerOnce) -{ - UAA_TryActivateAbilityAndWait* MyObj = NewObject(); - MyObj->SetAbilityActor(TargetActor); - MyObj->WithTag = InWithTag; - MyObj->bUsingEvent = bUsingEvent_In; - MyObj->IncludeTriggeredAbilities = InIncludeTriggeredAbilities; - MyObj->TriggerOnce = InTriggerOnce; - MyObj->bAllowRemoteActivation = bAllowRemoteActivation; - MyObj->PayloadInfo = PayloadInfo; - return MyObj; -} - -// UAA_TryActivateAbilityAndWait* UAA_TryActivateAbilityAndWait::WaitForAbilityDeactivateWithTagRequirements( -// AActor* TargetActor, FGameplayTagRequirements TagRequirements, bool InIncludeTriggeredAbilities, -// bool InTriggerOnce) -// { -// UAA_TryActivateAbilityAndWait* MyObj = NewObject(); -// MyObj->SetAbilityActor(TargetActor); -// MyObj->TagRequirements = TagRequirements; -// MyObj->IncludeTriggeredAbilities = InIncludeTriggeredAbilities; -// MyObj->TriggerOnce = InTriggerOnce; -// return MyObj; -// } -// -// UAA_TryActivateAbilityAndWait* UAA_TryActivateAbilityAndWait::WaitForAbilityDeactivate_Query( -// AActor* TargetActor, FGameplayTagQuery Query, bool InIncludeTriggeredAbilities, bool InTriggerOnce) -// { -// UAA_TryActivateAbilityAndWait* MyObj = NewObject(); -// MyObj->SetAbilityActor(TargetActor); -// MyObj->Query = Query; -// MyObj->IncludeTriggeredAbilities = InIncludeTriggeredAbilities; -// MyObj->TriggerOnce = InTriggerOnce; -// return MyObj; -// } - -void UAA_TryActivateAbilityAndWait::Activate() -{ - Super::Activate(); - - if (UAbilitySystemComponent* ASC = GetAbilitySystemComponent()) - { - OnAbilityActivateDelegateHandle = ASC->AbilityActivatedCallbacks.AddUObject(this, &UAA_TryActivateAbilityAndWait::OnAbilityActivate); - OnAbilityActivateDelegateHandle = ASC->AbilityEndedCallbacks.AddUObject(this, &UAA_TryActivateAbilityAndWait::OnAbilityDeactivate); - - bool bActivated = false; - if (bUsingEvent) - { - UPayloadWithInstancedStructs* Payload = NewObject(); - Payload->InstancedStructs = PayloadInfo; - FGameplayEventData EventData; - EventData.OptionalObject = Payload; - int32 ActivatedAbilitiesCount = ASC->HandleGameplayEvent(WithTag, &EventData); - bActivated = (ActivatedAbilitiesCount > 0); - } - else - { - bActivated = UUHLGASBlueprintLibrary::TryActivateAbilityWithTag(ASC, WithTag, bAllowRemoteActivation); - } - if (!bActivated) - { - EndAction(); - } - } - else - { - EndAction(); - } -} - -void UAA_TryActivateAbilityAndWait::EndAction() -{ - if (UAbilitySystemComponent* ASC = GetAbilitySystemComponent()) - { - ASC->AbilityActivatedCallbacks.Remove(OnAbilityActivateDelegateHandle); - } - Super::EndAction(); -} - diff --git a/Source/UHLGAS/Private/Tasks/AA_UHLGAS_WaitAbilityActivate.cpp b/Source/UHLGAS/Private/Tasks/AA_UHLGAS_WaitAbilityActivate.cpp deleted file mode 100644 index 71366fbd..00000000 --- a/Source/UHLGAS/Private/Tasks/AA_UHLGAS_WaitAbilityActivate.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Tasks/AA_UHLGAS_WaitAbilityActivate.h" -#include "AbilitySystemGlobals.h" -#include "AbilitySystemComponent.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(AA_UHLGAS_WaitAbilityActivate) - -void UAA_UHLGAS_WaitAbilityActivate::OnAbilityActivate(UGameplayAbility* ActivatedAbility) -{ - if (!IncludeTriggeredAbilities && ActivatedAbility->IsTriggered()) - { - return; - } - - const FGameplayTagContainer& AbilityTags = ActivatedAbility->GetAssetTags(); - - if (TagRequirements.IsEmpty()) - { - if ((WithTag.IsValid() && !AbilityTags.HasTag(WithTag)) || - (WithoutTag.IsValid() && AbilityTags.HasTag(WithoutTag))) - { - // Failed tag check - return; - } - } - else - { - if (!TagRequirements.RequirementsMet(AbilityTags)) - { - // Failed tag check - return; - } - } - - if (Query.IsEmpty() == false) - { - if (Query.Matches(AbilityTags) == false) - { - // Failed query - return; - } - } - - if (ShouldBroadcastDelegates()) - { - OnActivate.Broadcast(ActivatedAbility); - } - - if (TriggerOnce) - { - EndAction(); - } -} - -UAA_UHLGAS_WaitAbilityActivate* UAA_UHLGAS_WaitAbilityActivate::WaitForAbilityActivate(AActor* TargetActor, - FGameplayTag InWithTag, FGameplayTag InWithoutTag, bool InIncludeTriggeredAbilities, bool InTriggerOnce) -{ - UAA_UHLGAS_WaitAbilityActivate* MyObj = NewObject(); - MyObj->SetAbilityActor(TargetActor); - MyObj->WithTag = InWithTag; - MyObj->WithoutTag = InWithoutTag; - MyObj->IncludeTriggeredAbilities = InIncludeTriggeredAbilities; - MyObj->TriggerOnce = InTriggerOnce; - return MyObj; -} - -UAA_UHLGAS_WaitAbilityActivate* UAA_UHLGAS_WaitAbilityActivate::WaitForAbilityActivateWithTagRequirements( - AActor* TargetActor, FGameplayTagRequirements TagRequirements, bool InIncludeTriggeredAbilities, - bool InTriggerOnce) -{ - UAA_UHLGAS_WaitAbilityActivate* MyObj = NewObject(); - MyObj->SetAbilityActor(TargetActor); - MyObj->TagRequirements = TagRequirements; - MyObj->IncludeTriggeredAbilities = InIncludeTriggeredAbilities; - MyObj->TriggerOnce = InTriggerOnce; - return MyObj; -} - -UAA_UHLGAS_WaitAbilityActivate* UAA_UHLGAS_WaitAbilityActivate::WaitForAbilityActivate_Query( - AActor* TargetActor, FGameplayTagQuery Query, bool InIncludeTriggeredAbilities, bool InTriggerOnce) -{ - UAA_UHLGAS_WaitAbilityActivate* MyObj = NewObject(); - MyObj->SetAbilityActor(TargetActor); - MyObj->Query = Query; - MyObj->IncludeTriggeredAbilities = InIncludeTriggeredAbilities; - MyObj->TriggerOnce = InTriggerOnce; - return MyObj; -} - -void UAA_UHLGAS_WaitAbilityActivate::Activate() -{ - Super::Activate(); - - if (UAbilitySystemComponent* ASC = GetAbilitySystemComponent()) - { - OnAbilityActivateDelegateHandle = ASC->AbilityActivatedCallbacks.AddUObject(this, &UAA_UHLGAS_WaitAbilityActivate::OnAbilityActivate); - } - else - { - EndAction(); - } -} - -void UAA_UHLGAS_WaitAbilityActivate::EndAction() -{ - if (UAbilitySystemComponent* ASC = GetAbilitySystemComponent()) - { - ASC->AbilityActivatedCallbacks.Remove(OnAbilityActivateDelegateHandle); - } - Super::EndAction(); -} - diff --git a/Source/UHLGAS/Private/Tasks/AA_WaitAbilityDeactivate.cpp b/Source/UHLGAS/Private/Tasks/AA_WaitAbilityDeactivate.cpp deleted file mode 100644 index 1fbb026c..00000000 --- a/Source/UHLGAS/Private/Tasks/AA_WaitAbilityDeactivate.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Tasks/AA_WaitAbilityDeactivate.h" -#include "AbilitySystemGlobals.h" -#include "AbilitySystemComponent.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(AA_WaitAbilityDeactivate) - -void UAA_WaitAbilityDeactivate::OnAbilityDeactivate(UGameplayAbility* DeactivatedAbility) -{ - const FGameplayTagContainer& AbilityTags = DeactivatedAbility->GetAssetTags(); - - if (TagRequirements.IsEmpty()) - { - if ((WithTag.IsValid() && !AbilityTags.HasTag(WithTag)) || - (WithoutTag.IsValid() && AbilityTags.HasTag(WithoutTag))) - { - // Failed tag check - return; - } - } - else - { - if (!TagRequirements.RequirementsMet(AbilityTags)) - { - // Failed tag check - return; - } - } - - if (Query.IsEmpty() == false) - { - if (Query.Matches(AbilityTags) == false) - { - // Failed query - return; - } - } - - if (ShouldBroadcastDelegates()) - { - OnDeactivate.Broadcast(DeactivatedAbility); - } - - if (TriggerOnce) - { - EndAction(); - } -} - -UAA_WaitAbilityDeactivate* UAA_WaitAbilityDeactivate::WaitForAbilityDeactivate(AActor* TargetActor, - FGameplayTag InWithTag, FGameplayTag InWithoutTag, bool InTriggerOnce) -{ - UAA_WaitAbilityDeactivate* MyObj = NewObject(); - MyObj->SetAbilityActor(TargetActor); - MyObj->WithTag = InWithTag; - MyObj->WithoutTag = InWithoutTag; - MyObj->TriggerOnce = InTriggerOnce; - return MyObj; -} - -UAA_WaitAbilityDeactivate* UAA_WaitAbilityDeactivate::WaitForAbilityDeactivateWithTagRequirements( - AActor* TargetActor, FGameplayTagRequirements TagRequirements, bool InTriggerOnce) -{ - UAA_WaitAbilityDeactivate* MyObj = NewObject(); - MyObj->SetAbilityActor(TargetActor); - MyObj->TagRequirements = TagRequirements; - MyObj->TriggerOnce = InTriggerOnce; - return MyObj; -} - -UAA_WaitAbilityDeactivate* UAA_WaitAbilityDeactivate::WaitForAbilityDeactivate_Query( - AActor* TargetActor, FGameplayTagQuery Query, bool InTriggerOnce) -{ - UAA_WaitAbilityDeactivate* MyObj = NewObject(); - MyObj->SetAbilityActor(TargetActor); - MyObj->Query = Query; - MyObj->TriggerOnce = InTriggerOnce; - return MyObj; -} - -void UAA_WaitAbilityDeactivate::Activate() -{ - Super::Activate(); - - if (UAbilitySystemComponent* ASC = GetAbilitySystemComponent()) - { - OnAbilityDeactivateDelegateHandle = ASC->AbilityEndedCallbacks.AddUObject(this, &UAA_WaitAbilityDeactivate::OnAbilityDeactivate); - } - else - { - EndAction(); - } -} - -void UAA_WaitAbilityDeactivate::EndAction() -{ - if (UAbilitySystemComponent* ASC = GetAbilitySystemComponent()) - { - ASC->AbilityEndedCallbacks.Remove(OnAbilityDeactivateDelegateHandle); - } - Super::EndAction(); -} - diff --git a/Source/UHLGAS/Private/Tasks/AA_WaitAttributeChangeRatioThreshold.cpp b/Source/UHLGAS/Private/Tasks/AA_WaitAttributeChangeRatioThreshold.cpp deleted file mode 100644 index a198b207..00000000 --- a/Source/UHLGAS/Private/Tasks/AA_WaitAttributeChangeRatioThreshold.cpp +++ /dev/null @@ -1,148 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Tasks/AA_WaitAttributeChangeRatioThreshold.h" - -#include "AbilitySystemComponent.h" -#include "AbilitySystemGlobals.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(AA_WaitAttributeChangeRatioThreshold) - -UAA_WaitAttributeChangeRatioThreshold::UAA_WaitAttributeChangeRatioThreshold(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - bTriggerOnce = false; - bMatchedComparisonLastAttributeChange = false; - LastAttributeNumeratorValue = 1.f; - LastAttributeDenominatorValue = 1.f; -} - -UAA_WaitAttributeChangeRatioThreshold* UAA_WaitAttributeChangeRatioThreshold::WaitForAttributeChangeRatioThreshold(AActor* TargetActor, FGameplayAttribute AttributeNumerator, FGameplayAttribute AttributeDenominator, TEnumAsByte ComparisonType, float ComparisonValue, bool bTriggerOnce, AActor* OptionalExternalOwner) -{ - UAA_WaitAttributeChangeRatioThreshold* MyTask = NewObject(); - MyTask->SetAbilityActor(TargetActor); - MyTask->AttributeNumerator = AttributeNumerator; - MyTask->AttributeDenominator = AttributeDenominator; - MyTask->ComparisonType = ComparisonType; - MyTask->ComparisonValue = ComparisonValue; - MyTask->bTriggerOnce = bTriggerOnce; - MyTask->ExternalOwner = OptionalExternalOwner ? UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(OptionalExternalOwner) : nullptr; - - return MyTask; -} - -void UAA_WaitAttributeChangeRatioThreshold::Activate() -{ - if (UAbilitySystemComponent* ASC = GetFocusedASC()) - { - LastAttributeNumeratorValue = ASC->GetNumericAttribute(AttributeNumerator); - LastAttributeDenominatorValue = ASC->GetNumericAttribute(AttributeDenominator); - bMatchedComparisonLastAttributeChange = DoesValuePassComparison(LastAttributeNumeratorValue, LastAttributeDenominatorValue); - - // Broadcast OnChange immediately with current value - if (ShouldBroadcastDelegates()) - { - OnChange.Broadcast(bMatchedComparisonLastAttributeChange, LastAttributeDenominatorValue != 0.f ? LastAttributeNumeratorValue/LastAttributeDenominatorValue : 0.f); - } - - OnNumeratorAttributeChangeDelegateHandle = ASC->GetGameplayAttributeValueChangeDelegate(AttributeNumerator).AddUObject(this, &UAA_WaitAttributeChangeRatioThreshold::OnNumeratorAttributeChange); - OnDenominatorAttributeChangeDelegateHandle = ASC->GetGameplayAttributeValueChangeDelegate(AttributeDenominator).AddUObject(this, &UAA_WaitAttributeChangeRatioThreshold::OnDenominatorAttributeChange); - } - else - { - EndAction(); - } -} - -void UAA_WaitAttributeChangeRatioThreshold::EndAction() -{ - if (UAbilitySystemComponent* ASC = GetFocusedASC()) - { - ASC->GetGameplayAttributeValueChangeDelegate(AttributeNumerator).Remove(OnNumeratorAttributeChangeDelegateHandle); - ASC->GetGameplayAttributeValueChangeDelegate(AttributeDenominator).Remove(OnDenominatorAttributeChangeDelegateHandle); - } - - Super::EndAction(); -} - -UAbilitySystemComponent* UAA_WaitAttributeChangeRatioThreshold::GetFocusedASC() const -{ - return ExternalOwner ? ToRawPtr(ExternalOwner) : GetAbilitySystemComponent(); -} - -void UAA_WaitAttributeChangeRatioThreshold::OnAttributeChange() -{ - UWorld* World = GetAbilitySystemComponent()->GetWorld(); - if (World && !CheckAttributeTimer.IsValid()) - { - // Trigger OnRatioChange check at the end of this frame/next so that any individual attribute change - // has time for the other attribute to update (in case they're linked) - World->GetTimerManager().SetTimer(CheckAttributeTimer, this, &UAA_WaitAttributeChangeRatioThreshold::OnRatioChange, 0.001f, false); - } -} - -void UAA_WaitAttributeChangeRatioThreshold::OnRatioChange() -{ - CheckAttributeTimer.Invalidate(); - - bool bPassedComparison = DoesValuePassComparison(LastAttributeNumeratorValue, LastAttributeDenominatorValue); - if (bPassedComparison != bMatchedComparisonLastAttributeChange) - { - bMatchedComparisonLastAttributeChange = bPassedComparison; - if (ShouldBroadcastDelegates()) - { - OnChange.Broadcast(bMatchedComparisonLastAttributeChange, LastAttributeDenominatorValue != 0.f ? LastAttributeNumeratorValue/LastAttributeDenominatorValue : 0.f); - } - if (bTriggerOnce) - { - EndAction(); - } - } -} - -void UAA_WaitAttributeChangeRatioThreshold::OnNumeratorAttributeChange(const FOnAttributeChangeData& CallbackData) -{ - LastAttributeNumeratorValue = CallbackData.NewValue; - OnAttributeChange(); -} - -void UAA_WaitAttributeChangeRatioThreshold::OnDenominatorAttributeChange(const FOnAttributeChangeData& CallbackData) -{ - LastAttributeDenominatorValue = CallbackData.NewValue; - OnAttributeChange(); -} - -bool UAA_WaitAttributeChangeRatioThreshold::DoesValuePassComparison(float ValueNumerator, float ValueDenominator) const -{ - if (ValueDenominator == 0.f) - { - return bMatchedComparisonLastAttributeChange; - } - - const float CurrentRatio = ValueNumerator / ValueDenominator; - bool bPassedComparison = true; - switch (ComparisonType) - { - case EWaitAttributeChangeComparison::ExactlyEqualTo: - bPassedComparison = (CurrentRatio == ComparisonValue); - break; - case EWaitAttributeChangeComparison::GreaterThan: - bPassedComparison = (CurrentRatio > ComparisonValue); - break; - case EWaitAttributeChangeComparison::GreaterThanOrEqualTo: - bPassedComparison = (CurrentRatio >= ComparisonValue); - break; - case EWaitAttributeChangeComparison::LessThan: - bPassedComparison = (CurrentRatio < ComparisonValue); - break; - case EWaitAttributeChangeComparison::LessThanOrEqualTo: - bPassedComparison = (CurrentRatio <= ComparisonValue); - break; - case EWaitAttributeChangeComparison::NotEqualTo: - bPassedComparison = (CurrentRatio != ComparisonValue); - break; - default: - break; - } - return bPassedComparison; -} diff --git a/Source/UHLGAS/Private/Tasks/AT_InterpolateToPosition.cpp b/Source/UHLGAS/Private/Tasks/AT_InterpolateToPosition.cpp deleted file mode 100644 index 48e2b2fc..00000000 --- a/Source/UHLGAS/Private/Tasks/AT_InterpolateToPosition.cpp +++ /dev/null @@ -1,299 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Tasks/AT_InterpolateToPosition.h" - -#include "Components/CapsuleComponent.h" -#include "Curves/CurveVector.h" -#include "Curves/CurveFloat.h" -#include "Engine/World.h" -#include "GameFramework/Character.h" -#include "GameFramework/CharacterMovementComponent.h" -#include "Kismet/KismetSystemLibrary.h" -#include "Net/UnrealNetwork.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(AT_InterpolateToPosition) - -UAT_InterpolateToPosition::UAT_InterpolateToPosition(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - bTickingTask = true; - bSimulatedTask = true; - bIsFinished = false; -} - -UAT_InterpolateToPosition* UAT_InterpolateToPosition::InterpolateToPosition( - FHitResult& OutHit, - UGameplayAbility* OwningAbility, - const FName TaskInstanceName, - FVector Location, - const FRotator Rotation, - float Duration, - UCurveFloat* OptionalInterpolationCurve, - UCurveVector* OptionalVectorInterpolationCurve, - AActor* OptionalActorToInterpolate, - const bool bIsIgnoreHit, - const float DistanceOffset, - const bool bUseCapsuleTrace -) -{ - UAT_InterpolateToPosition* MyObj = NewAbilityTask(OwningAbility, TaskInstanceName); - - MyObj->ActorToInterpolate = OptionalActorToInterpolate != nullptr ? OptionalActorToInterpolate : MyObj->GetAvatarActor(); - if (MyObj->ActorToInterpolate != nullptr) - { - MyObj->StartLocation = MyObj->ActorToInterpolate->GetActorLocation(); - MyObj->StartRotation = MyObj->ActorToInterpolate->GetActorRotation(); - } - - if (!bIsIgnoreHit) - { - bool bBlockingHit = false; - if (bUseCapsuleTrace) - { - const ACharacter* Character = Cast(MyObj->ActorToInterpolate); - if (IsValid(Character)) - { - const float Radius = Character->GetCapsuleComponent()->GetUnscaledCapsuleRadius(); - const float HalfHeight = Character->GetCapsuleComponent()->GetUnscaledCapsuleHalfHeight(); - - bBlockingHit = CheckCapsuleHit( - MyObj->GetWorld(), - MyObj->ActorToInterpolate->GetActorLocation(), - Location, - Radius, - HalfHeight, - {MyObj->ActorToInterpolate}, - OutHit - ); - } - } - else - { - bBlockingHit = CheckHit( - MyObj->GetWorld(), - MyObj->ActorToInterpolate->GetActorLocation(), - Location, - {MyObj->ActorToInterpolate}, - OutHit - ); - } - - if (bBlockingHit) - { - const FVector Start = MyObj->ActorToInterpolate->GetActorLocation(); - const FVector CurrentEnd = GetCurrentEndLocation( - Start, - OutHit.Location, - DistanceOffset - ); - - Duration = GetCurrentDuration(Duration, Start, Location, CurrentEnd); - Location = CurrentEnd; - } - } - - MyObj->TargetLocation = Location; - MyObj->TargetRotation = Rotation; - MyObj->DurationOfMovement = FMath::Max(Duration, 0.001f); // Avoid negative or divide-by-zero cases - MyObj->TimeMoveStarted = MyObj->GetWorld()->GetTimeSeconds(); - MyObj->TimeMoveWillEnd = MyObj->TimeMoveStarted + MyObj->DurationOfMovement; - MyObj->LerpCurve = OptionalInterpolationCurve; - MyObj->LerpCurveVector = OptionalVectorInterpolationCurve; - - return MyObj; -} - -void UAT_InterpolateToPosition::InitSimulatedTask(UGameplayTasksComponent& InGameplayTasksComponent) -{ - Super::InitSimulatedTask(InGameplayTasksComponent); - - TimeMoveStarted = GetWorld()->GetTimeSeconds(); - TimeMoveWillEnd = TimeMoveStarted + DurationOfMovement; -} - -void UAT_InterpolateToPosition::Activate() -{ - Super::Activate(); -} - -void UAT_InterpolateToPosition::TickTask(float DeltaTime) -{ - if (bIsFinished) - { - return; - } - - Super::TickTask(DeltaTime); - AActor* MyActor = ActorToInterpolate; - if (MyActor) - { - const ACharacter* MyCharacter = Cast(MyActor); - if (MyCharacter) - { - UCharacterMovementComponent* CharMoveComp = Cast(MyCharacter->GetMovementComponent()); - if (CharMoveComp) - { - CharMoveComp->SetMovementMode(MOVE_Custom, 0); - } - } - - const float CurrentTime = GetWorld()->GetTimeSeconds(); - - if (CurrentTime >= TimeMoveWillEnd) - { - bIsFinished = true; - - // Teleport in attempt to find a valid collision spot - MyActor->TeleportTo(TargetLocation, MyActor->GetActorRotation()); - if (!bIsSimulating) - { - MyActor->ForceNetUpdate(); - if (ShouldBroadcastAbilityTaskDelegates()) - { - OnTargetLocationReached.Broadcast(); - } - EndTask(); - } - } - else - { - FVector NewLocation; - FRotator NewRotation; - - float MoveFraction = (CurrentTime - TimeMoveStarted) / DurationOfMovement; - if (LerpCurveVector) - { - const FVector ComponentInterpolationFraction = LerpCurveVector->GetVectorValue(MoveFraction); - NewLocation = FMath::Lerp(StartLocation, TargetLocation, ComponentInterpolationFraction); - NewRotation = FRotator::ZeroRotator; // TODO: make it work, here its initialized to remove warning - } - else - { - if (LerpCurve) - { - MoveFraction = LerpCurve->GetFloatValue(MoveFraction); - } - - NewLocation = FMath::Lerp(StartLocation, TargetLocation, MoveFraction); - NewRotation = FMath::Lerp(StartRotation, TargetRotation, MoveFraction); - } - - MyActor->SetActorLocation(NewLocation); - MyActor->SetActorRotation(NewRotation); - } - } - else - { - bIsFinished = true; - EndTask(); - } -} - -void UAT_InterpolateToPosition::PreDestroyFromReplication() -{ - bIsFinished = true; - EndTask(); -} - -void UAT_InterpolateToPosition::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const -{ - DOREPLIFETIME(UAT_InterpolateToPosition, StartLocation); - DOREPLIFETIME(UAT_InterpolateToPosition, StartRotation); - DOREPLIFETIME(UAT_InterpolateToPosition, TargetLocation); - DOREPLIFETIME(UAT_InterpolateToPosition, StartRotation); - DOREPLIFETIME(UAT_InterpolateToPosition, DurationOfMovement); - DOREPLIFETIME(UAT_InterpolateToPosition, LerpCurve); - DOREPLIFETIME(UAT_InterpolateToPosition, LerpCurveVector); -} - -void UAT_InterpolateToPosition::OnDestroy(bool bInOwnerFinished) -{ - AActor* MyActor = ActorToInterpolate; - if (MyActor) - { - ACharacter* MyCharacter = Cast(MyActor); - if (MyCharacter) - { - UCharacterMovementComponent* CharMoveComp = Cast(MyCharacter->GetMovementComponent()); - if (CharMoveComp && CharMoveComp->MovementMode == MOVE_Custom) - { - CharMoveComp->SetMovementMode(MOVE_Walking); - } - } - } - - Super::OnDestroy(bInOwnerFinished); -} - -bool UAT_InterpolateToPosition::CheckHit( - const UWorld* World, - const FVector& Start, - const FVector& End, - const TArray& ActorsToIgnore, - FHitResult& OutHit -) -{ - return UKismetSystemLibrary::LineTraceSingle( - World, - Start, - End, - ETraceTypeQuery::TraceTypeQuery1, - false, - ActorsToIgnore, - EDrawDebugTrace::None, - OutHit, - true - ); -} - -bool UAT_InterpolateToPosition::CheckCapsuleHit( - const UWorld* World, - const FVector& Start, - const FVector& End, - const float Radius, - const float HalfHeight, - const TArray& ActorsToIgnore, - FHitResult& OutHit -) -{ - return UKismetSystemLibrary::CapsuleTraceSingle( - World, - Start, - End, - Radius, - HalfHeight, - ETraceTypeQuery::TraceTypeQuery1, - false, - ActorsToIgnore, - EDrawDebugTrace::None, - OutHit, - true - ); -} - -FVector UAT_InterpolateToPosition::GetCurrentEndLocation( - const FVector& Start, - const FVector& End, - const float DistanceOffset -) -{ - FVector Result {}; - const FVector Direction = End - Start; - float Distance = FVector::Dist(Start, End); - - Distance = FMath::Max(Distance + DistanceOffset, 0.f); - Result = Start + Direction.GetSafeNormal() * Distance; - - return Result; -} - -float UAT_InterpolateToPosition::GetCurrentDuration(const float Duration, const FVector& Start, const FVector& End, const FVector& CurrentEnd) -{ - float Result = Duration; - const float OriginalDistance = (End - Start).Size(); - const float NewDistance = (CurrentEnd - Start).Size(); - Result = Duration * (NewDistance / OriginalDistance); - - return Result; -} diff --git a/Source/UHLGAS/Private/UHLAbilitySet.cpp b/Source/UHLGAS/Private/UHLAbilitySet.cpp deleted file mode 100644 index cd201fb5..00000000 --- a/Source/UHLGAS/Private/UHLAbilitySet.cpp +++ /dev/null @@ -1,181 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UHLAbilitySet.h" - -#include "AbilitySystemComponent.h" -#include "GameplayAbilitySpec.h" -#include "UHLGAS.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLAbilitySet) - -void FUHLAbilitySet_GrantedHandles::SetAbilitySetTags(const FGameplayTagContainer& AbilitySetTagContainer) { AbilitySetTags = AbilitySetTagContainer; } - -void FUHLAbilitySet_GrantedHandles::AddAbilitySpecHandle(const FGameplayAbilitySpecHandle& Handle) -{ - if (Handle.IsValid()) - { - AbilitySpecHandles.Add(Handle); - } -} - -void FUHLAbilitySet_GrantedHandles::AddGameplayEffectHandle(const FActiveGameplayEffectHandle& Handle) -{ - if (Handle.IsValid()) - { - GameplayEffectHandles.Add(Handle); - } -} - -void FUHLAbilitySet_GrantedHandles::AddAttributeSet(UAttributeSet* Set) { GrantedAttributeSets.Add(Set); } - -void FUHLAbilitySet_GrantedHandles::TakeFromAbilitySystem(UAbilitySystemComponent* ASC) -{ - check(ASC); - - if (!ASC->IsOwnerActorAuthoritative()) - { - // Must be authoritative to give or take ability sets. - return; - } - - for (const FGameplayAbilitySpecHandle& Handle : AbilitySpecHandles) - { - if (Handle.IsValid()) - { - ASC->ClearAbility(Handle); - } - } - - for (const FActiveGameplayEffectHandle& Handle : GameplayEffectHandles) - { - if (Handle.IsValid()) - { - ASC->RemoveActiveGameplayEffect(Handle); - } - } - - for (UAttributeSet* Set : GrantedAttributeSets) - { - ASC->RemoveSpawnedAttribute(Set); - } - - AbilitySetTags.Reset(); - AbilitySpecHandles.Reset(); - GameplayEffectHandles.Reset(); - GrantedAttributeSets.Reset(); -} - -UUHLAbilitySet::UUHLAbilitySet(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) {} - -void UUHLAbilitySet::GiveToAbilitySystem(UAbilitySystemComponent* ASC, FUHLAbilitySet_GrantedHandles* OutGrantedHandles, UObject* SourceObject) const -{ - check(ASC); - - if (!ASC->IsOwnerActorAuthoritative()) - { - // Must be authoritative to give or take ability sets. - return; - } - - // Save AbilitySetTags to handles - OutGrantedHandles->SetAbilitySetTags(AbilitySetTags); - - // Grant the simple gameplay abilities. - for (int32 AbilityIndex = 0; AbilityIndex < GrantedSimpleGameplayAbilities.Num(); ++AbilityIndex) - { - TSubclassOf AbilityToGrant = GrantedSimpleGameplayAbilities[AbilityIndex]; - - if (!IsValid(AbilityToGrant)) - { - UE_LOG(LogUHLAbilitySystem, Error, TEXT("GrantedSimpleGameplayAbilities[%d] on ability set [%s] is not valid."), AbilityIndex, *GetNameSafe(this)); - continue; - } - - UGameplayAbility* AbilityCDO = AbilityToGrant->GetDefaultObject(); - - FGameplayAbilitySpec AbilitySpec(AbilityCDO, 1); - AbilitySpec.SourceObject = SourceObject; - - const FGameplayAbilitySpecHandle AbilitySpecHandle = ASC->GiveAbility(AbilitySpec); - - if (OutGrantedHandles) - { - OutGrantedHandles->AddAbilitySpecHandle(AbilitySpecHandle); - } - } - - // Grant the gameplay abilities. - for (int32 AbilityIndex = 0; AbilityIndex < GrantedGameplayAbilities.Num(); ++AbilityIndex) - { - const FUHLAbilitySet_GameplayAbility& AbilityToGrant = GrantedGameplayAbilities[AbilityIndex]; - - if (!IsValid(AbilityToGrant.Ability)) - { - UE_LOG(LogUHLAbilitySystem, Error, TEXT("GrantedGameplayAbilities[%d] on ability set [%s] is not valid."), AbilityIndex, *GetNameSafe(this)); - continue; - } - - UGameplayAbility* AbilityCDO = AbilityToGrant.Ability->GetDefaultObject(); - - FGameplayAbilitySpec AbilitySpec(AbilityCDO, AbilityToGrant.AbilityLevel); - AbilitySpec.SourceObject = SourceObject; - AbilitySpec.GetDynamicSpecSourceTags().AddTag(AbilityToGrant.InputTag); - - const FGameplayAbilitySpecHandle AbilitySpecHandle = ASC->GiveAbility(AbilitySpec); - - if (OutGrantedHandles) - { - OutGrantedHandles->AddAbilitySpecHandle(AbilitySpecHandle); - } - } - - // Grant the gameplay effects. - for (int32 EffectIndex = 0; EffectIndex < GrantedGameplayEffects.Num(); ++EffectIndex) - { - const FUHLAbilitySet_GameplayEffect& EffectToGrant = GrantedGameplayEffects[EffectIndex]; - - if (!IsValid(EffectToGrant.GameplayEffect)) - { - UE_LOG(LogUHLAbilitySystem, Error, TEXT("GrantedGameplayEffects[%d] on ability set [%s] is not valid"), EffectIndex, *GetNameSafe(this)); - continue; - } - - const UGameplayEffect* GameplayEffect = EffectToGrant.GameplayEffect->GetDefaultObject(); - const FActiveGameplayEffectHandle GameplayEffectHandle = ASC->ApplyGameplayEffectToSelf(GameplayEffect, EffectToGrant.EffectLevel, ASC->MakeEffectContext()); - - if (OutGrantedHandles) - { - OutGrantedHandles->AddGameplayEffectHandle(GameplayEffectHandle); - } - } - - // Grant the attribute sets. - for (int32 SetIndex = 0; SetIndex < GrantedAttributes.Num(); ++SetIndex) - { - const FUHLAbilitySet_AttributeSet& SetToGrant = GrantedAttributes[SetIndex]; - - if (!IsValid(SetToGrant.AttributeSet)) - { - UE_LOG(LogUHLAbilitySystem, Error, TEXT("GrantedAttributes[%d] on ability set [%s] is not valid"), SetIndex, *GetNameSafe(this)); - continue; - } - - UAttributeSet* NewSet = NewObject(ASC->GetOwner(), SetToGrant.AttributeSet); - ASC->AddAttributeSetSubobject(NewSet); - - if (OutGrantedHandles) - { - OutGrantedHandles->AddAttributeSet(NewSet); - } - } -} - -TArray> UUHLAbilitySet::GetAllAbilitiesList() const -{ - TArray> Result = GrantedSimpleGameplayAbilities; - for (const FUHLAbilitySet_GameplayAbility& GrantedGameplayAbility : GrantedGameplayAbilities) - { - Result.Add(GrantedGameplayAbility.Ability); - } - return Result; -} diff --git a/Source/UHLGAS/Private/UHLAbilitySystemComponent.cpp b/Source/UHLGAS/Private/UHLAbilitySystemComponent.cpp deleted file mode 100644 index 4f931d4a..00000000 --- a/Source/UHLGAS/Private/UHLAbilitySystemComponent.cpp +++ /dev/null @@ -1,527 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "UHLAbilitySystemComponent.h" - -#include "UHLAbilitySet.h" -#include "UHLGASBlueprintLibrary.h" -#include "Abilities/UHLGameplayAbility.h" -#include "Core/UHLGameplayTags.h" -#include "Development/UHLGASSettings.h" -#include "Utils/UnrealHelperLibraryBPL.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLAbilitySystemComponent) - -void UUHLAbilitySystemComponent::BeginPlay() -{ - Super::BeginPlay(); - - AbilityInputCache = NewObject(this); - AbilityInputCache->SetUp(this); - - InputPressedSpecHandles.Reset(); - InputReleasedSpecHandles.Reset(); - InputHeldSpecHandles.Reset(); - - AbilitySetGrantedHandles.Reset(); - - // AbilityActivatedCallbacks.AddUObject(this, ) -} - -UUHLAbilitySystemComponent::UUHLAbilitySystemComponent() -{ - const UUHLGASSettings* UHLSettings = GetDefault(); - if (UHLSettings->bUseAbilitySystemConfigDefaultsInASC) - { - FillSettingsFromConfig(UHLSettings->AbilitySystemConfigDefaults); - } -} - -void UUHLAbilitySystemComponent::InitAbilitySystem(AActor* NewOwner, AActor* InAvatarActor, bool bActivateInitialAbilities) -{ - if (bUseAbilitySystemConfig && AbilitySystemConfig) - { - FillSettingsFromConfig(AbilitySystemConfig->Settings); - } - - InitAbilityActorInfo(NewOwner, InAvatarActor); - - if (bGiveAttributesSetsOnStart) - { - for (TSubclassOf AttributeSet : AttributeSets) - { - UAttributeSet* NewSet = NewObject(GetOwner(), AttributeSet); - AddAttributeSetSubobject(NewSet); - } - } - - InitAttributes(); - GiveInitialTags(); - - if (bGiveAbilitiesOnStart) - { - for (auto& Ability : Abilities) - { - GiveAbility(FGameplayAbilitySpec(Ability)); - } - } - - // TODO: - // What if I want to give AbilitySet that initialized with my attributes? - // Move attributes initialize to AbilitySet? Already can be done through GameplayEffect? - // Try to initialize only attributes from AttributeSet? and after abilities/gameplayeffects? - if (bGiveAbilitySetsOnStart) - { - for (const TObjectPtr& AbilitySet : AbilitySets) - { - GiveAbilitySet(AbilitySet); - } - } - - if (bActivateInitialAbilities) - { - ActivateInitialAbilities(); - } -} - -void UUHLAbilitySystemComponent::InitAttributes_Implementation() -{ - if (bInitializeGameplayAttributes) - { - SetAttributes(InitialAttributes); - } -} - -void UUHLAbilitySystemComponent::GiveInitialTags() -{ - if (bGiveInitialGameplayTags) - { - AddLooseGameplayTags(InitialGameplayTags, 1); - } -} - -void UUHLAbilitySystemComponent::SetAttributes(TMap Attributes_In) -{ - for (TTuple InitialAttributePair : Attributes_In) - { - if (!HasAttributeSetForAttribute(InitialAttributePair.Key)) continue; - - SetNumericAttributeBase(InitialAttributePair.Key, InitialAttributePair.Value); - } -} - -void UUHLAbilitySystemComponent::ActivateInitialAbilities() -{ - if (bActivateAbilitiesOnStart) - { - for (const auto AbilityTags : ActiveAbilitiesOnStart) - { - TryActivateAbilityWithTag(AbilityTags.First()); - } - } -} - -void UUHLAbilitySystemComponent::GiveAbilitySet(const UUHLAbilitySet* AbilitySet) -{ - FUHLAbilitySet_GrantedHandles OutGrantedHandles; - AbilitySet->GiveToAbilitySystem(this, &OutGrantedHandles, this); - AbilitySetGrantedHandles.Add(OutGrantedHandles); -} - -void UUHLAbilitySystemComponent::RemoveAbilitySetByTag(const FGameplayTag& GameplayTag) -{ - for (int32 i = 0; i < AbilitySetGrantedHandles.Num(); i++) - { - FUHLAbilitySet_GrantedHandles& AbilitySetGrantedHandle = AbilitySetGrantedHandles[i]; - if (AbilitySetGrantedHandle.GetAbilitySetTags().HasAny(FGameplayTagContainer(GameplayTag))) - { - AbilitySetGrantedHandle.TakeFromAbilitySystem(this); - AbilitySetGrantedHandles.RemoveAt(i, 1); - } - } -} - -void UUHLAbilitySystemComponent::OnUnregister() -{ - FGameplayTagContainer AllTags; - GetOwnedGameplayTags(AllTags); - RemoveLooseGameplayTags(AllTags); - - Super::OnUnregister(); -} - -#if WITH_EDITOR - -bool UUHLAbilitySystemComponent::CanEditChange(const FProperty* InProperty) const -{ - const bool ParentVal = Super::CanEditChange(InProperty); - - if (InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, bInitializeGameplayAttributes) - || InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, InitialAttributes) - || InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, bGiveAbilitiesOnStart) - || InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, Abilities) - || InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, bGiveAttributesSetsOnStart) - || InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, AttributeSets) - || InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, bActivateAbilitiesOnStart) - || InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, ActiveAbilitiesOnStart) - || InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, bGiveInitialGameplayTags) - || InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, InitialGameplayTags) - || InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, bGiveAbilitySetsOnStart) - || InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, AbilitySets) - || InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, bPreviewAllAbilities) - || InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, DebugPreviewAbilitiesFromAbilitySets) - - || InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, bUseInputConfig) - || InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, InputConfig) - || InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, bUseAbilityInputCache) - || InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, bUseInputCacheWindows) - ) - { - return !bUseAbilitySystemConfig; - } - - return ParentVal; -} - -void UUHLAbilitySystemComponent::PostInitProperties() -{ - Super::PostInitProperties(); - - UpdatePreviewAbilitiesMap(); -} - -void UUHLAbilitySystemComponent::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) -{ - Super::PostEditChangeProperty(PropertyChangedEvent); - - if (PropertyChangedEvent.GetPropertyName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, AbilitySets) - || PropertyChangedEvent.GetPropertyName() == GET_MEMBER_NAME_CHECKED(UUHLAbilitySystemComponent, DebugPreviewAbilitiesFromAbilitySets)) - { - UpdatePreviewAbilitiesMap(); - } -} - -void UUHLAbilitySystemComponent::UpdatePreviewAbilitiesMap() -{ - DebugPreviewAbilitiesFromAbilitySets.Reset(); - - if (!bPreviewAllAbilities) - { - return; - } - - for (const UUHLAbilitySet* AbilitySet : AbilitySets) - { - if (!AbilitySet) continue; - - TTuple TuplePreview; - TuplePreview.Key = AbilitySet->GetName(); - - for (const TSubclassOf& AbilityRef : AbilitySet->GetAllAbilitiesList()) - { - if (!AbilityRef.Get()) continue; - TuplePreview.Value += AbilityRef->GetName().Replace(TEXT("_C"), TEXT("")) + "\n"; - } - DebugPreviewAbilitiesFromAbilitySets.Add(TuplePreview); - } -} -#endif - -void UUHLAbilitySystemComponent::FillSettingsFromConfig(const FUHLAbilitySystemSettings& AbilitySystemConfig_In) -{ - bInitializeGameplayAttributes = AbilitySystemConfig_In.bInitializeGameplayAttributes; - InitialAttributes = AbilitySystemConfig_In.InitialAttributes; - - bGiveAbilitiesOnStart = AbilitySystemConfig_In.bGiveAbilitiesOnStart; - Abilities = AbilitySystemConfig_In.Abilities; - - bGiveAttributesSetsOnStart = AbilitySystemConfig_In.bGiveAttributesSetsOnStart; - AttributeSets = AbilitySystemConfig_In.AttributeSets; - - bActivateAbilitiesOnStart = AbilitySystemConfig_In.bActivateAbilitiesOnStart; - ActiveAbilitiesOnStart = AbilitySystemConfig_In.ActiveAbilitiesOnStart; - - bGiveInitialGameplayTags = AbilitySystemConfig_In.bGiveInitialGameplayTags; - InitialGameplayTags = AbilitySystemConfig_In.InitialGameplayTags; - - bGiveAbilitySetsOnStart = AbilitySystemConfig_In.bGiveAbilitySetsOnStart; - AbilitySets = AbilitySystemConfig_In.AbilitySets; - - // bPreviewAllAbilities = AbilitySystemConfig_In.bPreviewAllAbilities; - // DebugPreviewAbilitiesFromAbilitySets = AbilitySystemConfig_In.DebugPreviewAbilitiesFromAbilitySets; - - bUseInputConfig = AbilitySystemConfig_In.bUseInputConfig; - InputConfig = AbilitySystemConfig_In.InputConfig; - bUseAbilityInputCache = AbilitySystemConfig_In.bUseAbilityInputCache; - bUseInputCacheWindows = AbilitySystemConfig_In.bUseInputCacheWindows; -} - -bool UUHLAbilitySystemComponent::TryActivateAbilityWithTag(FGameplayTag GameplayTag, bool bAllowRemoteActivation) -{ - return UUHLGASBlueprintLibrary::TryActivateAbilityWithTag(this, GameplayTag, bAllowRemoteActivation); -} - -bool UUHLAbilitySystemComponent::TryCancelAbilityWithTag(FGameplayTag GameplayTag) -{ - return UUHLGASBlueprintLibrary::TryCancelAbilityWithTag(this, GameplayTag); -} - -TArray UUHLAbilitySystemComponent::TryCancelAbilitiesWithTags(TArray GameplayTags) -{ - return UUHLGASBlueprintLibrary::TryCancelAbilitiesWithTags(this, GameplayTags); -} - -int32 UUHLAbilitySystemComponent::FireGameplayEvent(FGameplayTag EventTag, const FGameplayEventData& Payload) -{ - return HandleGameplayEvent(EventTag, &Payload); -} - -bool UUHLAbilitySystemComponent::CanAddAbilityToCache(UUHLGameplayAbility* GameplayAbility_In) const -{ - bool bHasRequiredTags = HasAllMatchingGameplayTags(GameplayAbility_In->AddToCacheRequiredTags); - bool bDontHaveBlockedTags = !HasAnyMatchingGameplayTags(GameplayAbility_In->AddToCacheBlockedTags); - - return bHasRequiredTags && bDontHaveBlockedTags; -} - -bool UUHLAbilitySystemComponent::IsAbilityActive(FGameplayTag GameplayTag) const -{ - return UUHLGASBlueprintLibrary::IsAbilityActiveByTag(this, GameplayTag); -} - -void UUHLAbilitySystemComponent::RemoveLooseGameplayTagCompletly(const FGameplayTag& GameplayTag) -{ - RemoveLooseGameplayTag(GameplayTag, 999999); -} - -void UUHLAbilitySystemComponent::AbilitySpecInputPressed(FGameplayAbilitySpec& Spec) -{ - Super::AbilitySpecInputPressed(Spec); - - // We don't support UGameplayAbility::bReplicateInputDirectly. - // Use replicated events instead so that the WaitInputPress ability task works. - if (Spec.IsActive()) - { -PRAGMA_DISABLE_DEPRECATION_WARNINGS - const UGameplayAbility* Instance = Spec.GetPrimaryInstance(); - FPredictionKey OriginalPredictionKey = Instance ? Instance->GetCurrentActivationInfo().GetActivationPredictionKey() : Spec.ActivationInfo.GetActivationPredictionKey(); -PRAGMA_ENABLE_DEPRECATION_WARNINGS - - // Invoke the InputPressed event. This is not replicated here. If someone is listening, they may replicate the InputPressed event to the server. - InvokeReplicatedEvent(EAbilityGenericReplicatedEvent::InputPressed, Spec.Handle, OriginalPredictionKey); - } -} - -void UUHLAbilitySystemComponent::AbilitySpecInputReleased(FGameplayAbilitySpec& Spec) -{ - Super::AbilitySpecInputReleased(Spec); - - // We don't support UGameplayAbility::bReplicateInputDirectly. - // Use replicated events instead so that the WaitInputRelease ability task works. - if (Spec.IsActive()) - { -PRAGMA_DISABLE_DEPRECATION_WARNINGS - const UGameplayAbility* Instance = Spec.GetPrimaryInstance(); - FPredictionKey OriginalPredictionKey = Instance ? Instance->GetCurrentActivationInfo().GetActivationPredictionKey() : Spec.ActivationInfo.GetActivationPredictionKey(); -PRAGMA_ENABLE_DEPRECATION_WARNINGS - - // Invoke the InputReleased event. This is not replicated here. If someone is listening, they may replicate the InputReleased event to the server. - InvokeReplicatedEvent(EAbilityGenericReplicatedEvent::InputReleased, Spec.Handle, OriginalPredictionKey); - } -} - -void UUHLAbilitySystemComponent::AbilityInputTagPressed(const FGameplayTag InputTag) -{ - if (InputTag.IsValid()) - { - for (const FGameplayAbilitySpec& AbilitySpec : ActivatableAbilities.Items) - { - // Replaced AbilitySpec.DynamicAbilityTags on AbilitySpec.Ability->GetAssetTags() - if (AbilitySpec.Ability && (AbilitySpec.Ability->GetAssetTags().HasTagExact(InputTag))) - { - InputPressedSpecHandles.AddUnique(AbilitySpec.Handle); - InputHeldSpecHandles.AddUnique(AbilitySpec.Handle); - } - } - } -} - -void UUHLAbilitySystemComponent::AbilityInputTagReleased(const FGameplayTag InputTag) -{ - if (InputTag.IsValid()) - { - for (const FGameplayAbilitySpec& AbilitySpec : ActivatableAbilities.Items) - { - // Replaced AbilitySpec.DynamicAbilityTags on AbilitySpec.Ability->AbilityTags - if (AbilitySpec.Ability && (AbilitySpec.Ability->GetAssetTags().HasTagExact(InputTag))) - { - InputReleasedSpecHandles.AddUnique(AbilitySpec.Handle); - InputHeldSpecHandles.Remove(AbilitySpec.Handle); - } - } - } -} - -// copy paste from LyraAbilitySystemComponent -void UUHLAbilitySystemComponent::ProcessAbilityInput(float DeltaTime, bool bGamePaused) -{ - if (!bUseInputConfig) return; - - if (HasMatchingGameplayTag(UHLGameplayTags::TAG_Gameplay_AbilityInputBlocked)) - { - ClearAbilityInput(); - return; - } - - static TArray AbilitiesToActivate; - AbilitiesToActivate.Reset(); - - //@TODO: See if we can use FScopedServerAbilityRPCBatcher ScopedRPCBatcher in some of these loops - - // - // Process all abilities that activate when the input is held. - // - for (const FGameplayAbilitySpecHandle& SpecHandle : InputHeldSpecHandles) - { - if (const FGameplayAbilitySpec* AbilitySpec = FindAbilitySpecFromHandle(SpecHandle)) - { - if (AbilitySpec->Ability && !AbilitySpec->IsActive()) - { - const UUHLGameplayAbility* AbilityCDO = Cast(AbilitySpec->Ability); - if (AbilityCDO->GetActivationPolicy() == EUHLAbilityActivationPolicy::WhileInputActive) - { - AbilitiesToActivate.AddUnique(AbilitySpec->Handle); - } - } - } - } - - // - // Process all abilities that had their input pressed this frame. - // - for (const FGameplayAbilitySpecHandle& SpecHandle : InputPressedSpecHandles) - { - if (FGameplayAbilitySpec* AbilitySpec = FindAbilitySpecFromHandle(SpecHandle)) - { - if (AbilitySpec->Ability) - { - AbilitySpec->InputPressed = true; - - const UUHLGameplayAbility* AbilityCDO = Cast(AbilitySpec->Ability); - if (AbilitySpec->IsActive() - // TODO move this logic to "OnInputTriggeredForceReactivate" ?? - // If ability active, we should try to activate it again, instead of sending data - // so that's why if "OnInputTriggered" choosed - skip - && AbilityCDO - && AbilityCDO->GetActivationPolicy() != EUHLAbilityActivationPolicy::OnInputTriggered) - { - // Ability is active so pass along the input event. - AbilitySpecInputPressed(*AbilitySpec); - } - else - { - // const UUHLGameplayAbility* AbilityCDO = Cast(AbilitySpec->Ability); - if (AbilityCDO && AbilityCDO->GetActivationPolicy() == EUHLAbilityActivationPolicy::OnInputTriggered) - { - AbilitiesToActivate.AddUnique(AbilitySpec->Handle); - } - } - } - } - } - - // - // Try to activate all the abilities that are from presses and holds. - // We do it all at once so that held inputs don't activate the ability - // and then also send a input event to the ability because of the press. - // - // TODO AbiilityInputCache field of improvement - check not "bAtLeastOneCachedAbilityActivated" - // but how much abilities was activated from "FUHLInputActionAbilities" - // if at least one from "FUHLInputActionAbilities" activated skip adding others to cache - bool bAtLeastOneCachedAbilityActivated = false; - TArray AbilityTagsRequiredToBeCached = {}; - for (const FGameplayAbilitySpecHandle& AbilitySpecHandle : AbilitiesToActivate) - { - if (!AbilitySpecHandle.IsValid()) continue; - - bool bActivated = TryActivateAbility(AbilitySpecHandle); - - // check AbilityCache - if (bUseAbilityInputCache && AbilitySpecHandle.IsValid()) - { - // works if not using cache windows or use them and now in "CatchTo AbilityInputCache" window - if (!bUseInputCacheWindows || (bUseInputCacheWindows && HasMatchingGameplayTag(UHLGameplayTags::TAG_UHL_AbilityInputCache_Catching))) - { - FGameplayAbilitySpec* AbilitySpec = FindAbilitySpecFromHandle(AbilitySpecHandle); - if (AbilitySpec->Ability) - { - UUHLGameplayAbility* GameplayAbility = StaticCast(AbilitySpec->Ability.Get()); - if (GameplayAbility->bCacheInput && (!bActivated || GameplayAbility->bIgnoreActivatedState)) - { - if (CanAddAbilityToCache(GameplayAbility)) - { - AbilityTagsRequiredToBeCached.Add(GameplayAbility->GetAssetTags().First()); - } - } - - if (GameplayAbility->bCacheInput && bActivated) - { - bAtLeastOneCachedAbilityActivated = true; - UUnrealHelperLibraryBPL::DebugPrintStrings(FString::Printf(TEXT("At least one activated %s"), *GameplayAbility->GetAssetTags().First().ToString())); - } - } - } - } - } - - if (!bAtLeastOneCachedAbilityActivated) - { - AbilityInputCache->AddTagsToCache(AbilityTagsRequiredToBeCached); - } - - // - // Process all abilities that had their input released this frame. - // - for (const FGameplayAbilitySpecHandle& SpecHandle : InputReleasedSpecHandles) - { - if (FGameplayAbilitySpec* AbilitySpec = FindAbilitySpecFromHandle(SpecHandle)) - { - if (AbilitySpec->Ability) - { - AbilitySpec->InputPressed = false; - - if (AbilitySpec->IsActive()) - { - // Ability is active so pass along the input event. - AbilitySpecInputReleased(*AbilitySpec); - - // if "WhileInputActive" EndAbility automatically - // const UUHLGameplayAbility* AbilityCDO = Cast(AbilitySpec->Ability); - // if (AbilityCDO && AbilityCDO->GetActivationPolicy() == EUHLAbilityActivationPolicy::WhileInputActive) - // { - // const FUHLWhileInputActiveSettings& WhileInputActiveSettings = AbilityCDO->GetWhileInputActiveSettings(); - // if (WhileInputActiveSettings.bCancelAbilityAutomatically) - // { - // // "EndAbility" not accessible, so try to cancel if "bCancelAbilityAutomatically" - // AbilitySpec->Ability->CancelAbility(AbilitySpec->Handle, AbilityActorInfo.Get(), AbilitySpec->ActivationInfo, WhileInputActiveSettings.bReplicateEndAbility); - // // AbilitySpec->Ability->EndAbility(AbilitySpec->Handle, AbilityActorInfo.Get(), AbilitySpec->ActivationInfo, WhileInputActiveSettings.bReplicateEndAbility, WhileInputActiveSettings.bMarkAsCanceledOnEnd); - // } - // } - } - } - } - } - - // - // Clear the cached ability handles. - // - InputPressedSpecHandles.Reset(); - InputReleasedSpecHandles.Reset(); -} - -void UUHLAbilitySystemComponent::ClearAbilityInput() -{ - InputPressedSpecHandles.Reset(); - InputReleasedSpecHandles.Reset(); - InputHeldSpecHandles.Reset(); -} diff --git a/Source/UHLGAS/Private/UHLAbilitySystemConfig.cpp b/Source/UHLGAS/Private/UHLAbilitySystemConfig.cpp deleted file mode 100644 index e73e60aa..00000000 --- a/Source/UHLGAS/Private/UHLAbilitySystemConfig.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "UHLAbilitySystemConfig.h" - -#include "Development/UHLGASSettings.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLAbilitySystemConfig) - -UUHLAbilitySystemConfig::UUHLAbilitySystemConfig() -{ - const UUHLGASSettings* UHLSettings = GetDefault(); - Settings = UHLSettings->AbilitySystemConfigDefaults; -} \ No newline at end of file diff --git a/Source/UHLGAS/Private/UHLGAS.cpp b/Source/UHLGAS/Private/UHLGAS.cpp deleted file mode 100644 index 3ba06aa1..00000000 --- a/Source/UHLGAS/Private/UHLGAS.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UHLGAS.h" - -#include "Misc/Paths.h" -#include "GameplayTagsManager.h" - -#define LOCTEXT_NAMESPACE "FUHLGASModule" - -DEFINE_LOG_CATEGORY(LogUHLAbilitySystem); - -void FUHLGASModule::StartupModule() -{ - UGameplayTagsManager& TagsManager = UGameplayTagsManager::Get(); - // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module - TagsManager.AddTagIniSearchPath(FPaths::ProjectPluginsDir() / TEXT("UnrealHelperLibrary/Config/Tags")); -} - -void FUHLGASModule::ShutdownModule() -{ - // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, - // we call this function before unloading the module. -} - -#undef LOCTEXT_NAMESPACE - -IMPLEMENT_MODULE(FUHLGASModule, UHLGAS) diff --git a/Source/UHLGAS/Private/UHLGASBlueprintLibrary.cpp b/Source/UHLGAS/Private/UHLGASBlueprintLibrary.cpp deleted file mode 100644 index 8a759ad3..00000000 --- a/Source/UHLGAS/Private/UHLGASBlueprintLibrary.cpp +++ /dev/null @@ -1,256 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UHLGASBlueprintLibrary.h" - -#include "AbilitySystemComponent.h" -#include "GameplayTagsManager.h" -#include "Misc/ConfigCacheIni.h" -#include "Animation/AnimMontage.h" -#include "DrawDebugHelpers.h" -#include "Core/UHLAbilitySystemInterface.h" -#include "Engine/World.h" -#include "Engine/GameInstance.h" -#include "UI/UHLHUD.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLGASBlueprintLibrary) - -UUHLAbilitySystemComponent* UUHLGASBlueprintLibrary::GetUHLAbilitySystemComponent(AActor* Actor) -{ - if (Actor == nullptr) - { - return nullptr; - } - - const IUHLAbilitySystemInterface* ASI = Cast(Actor); - if (ASI) - { - return IUHLAbilitySystemInterface::Execute_GetUHLAbilitySystemComponent(Actor); - } - - return Actor->FindComponentByClass(); -} - -FGameplayEffectSpec UUHLGASBlueprintLibrary::CreateGenericGASGameplayEffectSpec( - TSubclassOf GameplayEffectClass, AActor* HitInstigator, AActor* InEffectCauser, const FHitResult& HitResult, const UObject* SourceObject) -{ - const UGameplayEffect* GameplayEffect = GameplayEffectClass->GetDefaultObject(); - FGameplayEffectContext* GameplayEffectContext = new FGameplayEffectContext(HitInstigator, InEffectCauser); - FGameplayEffectContextHandle GameplayEffectContextHandle(GameplayEffectContext); - GameplayEffectContextHandle.AddHitResult(HitResult); - GameplayEffectContextHandle.AddSourceObject(SourceObject); - FGameplayEffectSpec GameplayEffectSpec(GameplayEffect, GameplayEffectContextHandle); - return GameplayEffectSpec; -} - -void UUHLGASBlueprintLibrary::UpdateStateGameplayTags(UAbilitySystemComponent* ASC, bool bCondition, FGameplayTag PositiveConditionTag, FGameplayTag NegativeConditionTag, bool bShouldReplicate) -{ - if (!ASC) - { - return; - } - - if (bCondition) - { - if (!ASC->HasMatchingGameplayTag(PositiveConditionTag)) - { - if (bShouldReplicate) - { - ASC->AddReplicatedLooseGameplayTag(PositiveConditionTag); - } - else - { - ASC->AddLooseGameplayTag(PositiveConditionTag); - } - } - if (NegativeConditionTag != FGameplayTag::EmptyTag) - { - if (bShouldReplicate) - { - ASC->RemoveReplicatedLooseGameplayTag(PositiveConditionTag); - } - else - { - ASC->RemoveLooseGameplayTag(NegativeConditionTag, 999999); - } - } - } - else - { - if (NegativeConditionTag == FGameplayTag::EmptyTag) - { - if (bShouldReplicate) - { - ASC->RemoveReplicatedLooseGameplayTag(PositiveConditionTag); - } - else - { - ASC->RemoveLooseGameplayTag(PositiveConditionTag, 999999); - } - } - else - { - if (!ASC->HasMatchingGameplayTag(NegativeConditionTag)) - { - if (bShouldReplicate) - { - ASC->AddReplicatedLooseGameplayTag(NegativeConditionTag); - } - else - { - ASC->AddLooseGameplayTag(NegativeConditionTag); - } - } - if (bShouldReplicate) - { - ASC->RemoveReplicatedLooseGameplayTag(PositiveConditionTag); - } - else - { - ASC->RemoveLooseGameplayTag(PositiveConditionTag, 999999); - } - } - } -} - -bool UUHLGASBlueprintLibrary::IsAbilityActiveByTag(const UAbilitySystemComponent* ASC, FGameplayTag GameplayTag) -{ - if (!IsValid(ASC)) return false; - - bool bResult = false; - TArray AbilitiesToActivate; - ASC->GetActivatableGameplayAbilitySpecsByAllMatchingTags(FGameplayTagContainer(GameplayTag), AbilitiesToActivate, false); - - for (FGameplayAbilitySpec* AbilitySpec : AbilitiesToActivate) - { - TArray AbilityInstances = AbilitySpec->GetAbilityInstances(); - for (UGameplayAbility* Ability : AbilityInstances) - { - bResult |= Ability->IsActive(); - } - } - return bResult; -} - -bool UUHLGASBlueprintLibrary::TryActivateAbilityWithTag(UAbilitySystemComponent* ASC, FGameplayTag GameplayTag, bool bAllowRemoteActivation) -{ - if (!IsValid(ASC)) return false; - return ASC->TryActivateAbilitiesByTag(FGameplayTagContainer(GameplayTag), bAllowRemoteActivation); -} - -bool UUHLGASBlueprintLibrary::TryCancelAbilityWithTag(UAbilitySystemComponent* ASC, FGameplayTag GameplayTag) -{ - if (!IsValid(ASC)) - return false; - - bool bResult = false; - TArray AbilitiesToCancel; - ASC->GetActivatableGameplayAbilitySpecsByAllMatchingTags(FGameplayTagContainer(GameplayTag), AbilitiesToCancel, false); - - for (FGameplayAbilitySpec* AbilitySpec : AbilitiesToCancel) - { - TArray AbilityInstances = AbilitySpec->GetAbilityInstances(); - for (UGameplayAbility* Ability : AbilityInstances) - { - if (Ability->IsActive()) - { - Ability->K2_CancelAbility(); - bResult = true; - } - } - } - return bResult; -} - -bool UUHLGASBlueprintLibrary::ToggleAbilityWithTag(UAbilitySystemComponent* ASC, FGameplayTag GameplayTag, bool bAllowRemoteActivation) -{ - if (!IsValid(ASC)) return false; - - bool bResult = false; - - if (IsAbilityActiveByTag(ASC, GameplayTag)) - { - bResult = TryCancelAbilityWithTag(ASC, GameplayTag); - } - else - { - bResult = TryActivateAbilityWithTag(ASC, GameplayTag, bAllowRemoteActivation); - } - - return bResult; -} - -TArray UUHLGASBlueprintLibrary::TryCancelAbilitiesWithTags(UAbilitySystemComponent* ASC, TArray GameplayTags) -{ - if (!IsValid(ASC)) - return {}; - - TArray Result; - for (auto GameplayTag : GameplayTags) - { - Result.Add(TryCancelAbilityWithTag(ASC, GameplayTag)); - } - return Result; -} - -int32 UUHLGASBlueprintLibrary::FireGameplayEvent(UAbilitySystemComponent* ASC, FGameplayTag EventTag, const FGameplayEventData& Payload) { return ASC->HandleGameplayEvent(EventTag, &Payload); } - -FGameplayTag UUHLGASBlueprintLibrary::FindTagByString(const FString& TagString, bool bMatchPartialString) -{ - const UGameplayTagsManager& Manager = UGameplayTagsManager::Get(); - FGameplayTag Tag = Manager.RequestGameplayTag(FName(*TagString), false); - - if (!Tag.IsValid() && bMatchPartialString) - { - FGameplayTagContainer AllTags; - Manager.RequestAllGameplayTags(AllTags, true); - - for (const FGameplayTag& TestTag : AllTags) - { - if (TestTag.ToString().Contains(TagString)) - { - // UE_LOG(LogUnrealHelperLibrary, Display, TEXT("Could not find exact match for tag [%s] but found partial match on tag [%s]."), *TagString, *TestTag.ToString()); - Tag = TestTag; - break; - } - } - } - - return Tag; -} - -void UUHLGASBlueprintLibrary::FindAbilitySpecByTag( - const TArray& AbilitiesSpecsContainer, FGameplayTag TagToFind, FGameplayAbilitySpec& AbilitySpec_Out) -{ - // Iterate all specs provided - for (const FGameplayAbilitySpec& Spec : AbilitiesSpecsContainer) - { - // Check the static tags on the ability class - const UGameplayAbility* AbilityCDO = Spec.GetPrimaryInstance() - ? Spec.GetPrimaryInstance() - : Spec.Ability.Get(); - - if (AbilityCDO) - { - // combine ability‐level and dynamic tags - const FGameplayTagContainer& StaticTags = AbilityCDO->GetAssetTags(); - const FGameplayTagContainer& DynamicTags = Spec.GetDynamicSpecSourceTags(); - - // If either has our desired tag, return this spec - if (StaticTags.HasTag(TagToFind) || DynamicTags.HasTag(TagToFind)) - { - AbilitySpec_Out = Spec; - return; - } - } - } - - // Not found - return; -} - -void UUHLGASBlueprintLibrary::FindAbilitySpecByTagUsingASC( - UAbilitySystemComponent* ASC, - FGameplayTag TagToFind, FGameplayAbilitySpec& AbilitySpec_Out) -{ - FindAbilitySpecByTag(ASC->GetActivatableAbilities(), TagToFind, AbilitySpec_Out); -} diff --git a/Source/UHLGAS/Public/Abilities/UHLGameplayAbility.h b/Source/UHLGAS/Public/Abilities/UHLGameplayAbility.h deleted file mode 100644 index 9ba91806..00000000 --- a/Source/UHLGAS/Public/Abilities/UHLGameplayAbility.h +++ /dev/null @@ -1,197 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Abilities/GameplayAbility.h" -#include "UHLGameplayAbility.generated.h" - -class UUHLAbilitySystemComponent; - -/** - * EUHLAbilityActivationPolicy - * - * Defines how an ability is meant to activate. - */ -UENUM(BlueprintType) -enum class EUHLAbilityActivationPolicy : uint8 -{ - // Try to activate the ability when the input is triggered. - OnInputTriggered, - - // Continually try to activate the ability while the input is active. - // Subscribe on "WaitInputRelease" and "EndAbility" in blueprint, - // it's not possible to EndAbility from C++ - WhileInputActive, - - // Try to activate the ability when an avatar is assigned. - OnSpawn -}; - -// USTRUCT(BlueprintType) -// struct FUHLWhileInputActiveSettings -// { -// GENERATED_BODY() -// -// UPROPERTY(EditDefaultsOnly, BlueprintReadOnly) -// bool bCancelAbilityAutomatically = true; -// UPROPERTY(EditDefaultsOnly, BlueprintReadOnly) -// bool bReplicateEndAbility = true; -// // UPROPERTY(EditDefaultsOnly, BlueprintReadOnly) -// // bool bMarkAsCanceledOnEnd = false; -// }; - -/** - * - */ -UCLASS(Abstract, Category="UnrealHelperLibrary", Blueprintable, BlueprintType) -class UHLGAS_API UUHLGameplayAbility : public UGameplayAbility -{ - GENERATED_BODY() - -public: - UUHLGameplayAbility(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get()); - - UFUNCTION(BlueprintCallable, Category = "UHL GameplayAbility") - EUHLAbilityActivationPolicy GetActivationPolicy() const { return ActivationPolicy; } - - // UFUNCTION(BlueprintCallable) - // FUHLWhileInputActiveSettings GetWhileInputActiveSettings() const { return WhileInputActiveSettings; } - - // should cache input if ability can't be activated for now - // Requirements: - // - ASC should enable "bUseAbilityInputCache" - // - Ability should have at least one AbilityTag - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AbilityInputCache") - bool bCacheInput = false; - - // ignore fact that ability already activated while checking cache - // it means - // - ability should be added to InputCache even if its already activated - // - "bRetriggerInstancedAbility" setting should be disabled to work because during - // AbilityInputCache->CheckCache() we cancel previous ability and start it again - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AbilityInputCache") - bool bIgnoreActivatedState = false; - - // tags required on owner ASC to be cache ability - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AbilityInputCache", DisplayName="[Add to Cache] RequiredTags") - FGameplayTagContainer AddToCacheRequiredTags; - // tags blocked on owner ASC - if present ability won't be cached - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AbilityInputCache", DisplayName="[Add to Cache] BlockedTags") - FGameplayTagContainer AddToCacheBlockedTags; - - /** - * When true, external CancelAbility calls are intercepted and must be completed manually via ReleaseCancellation(). - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UHL GameplayAbility") - bool bCancelManually = false; - - UFUNCTION(BlueprintCallable, Category="UHL GameplayAbility") - bool GetIsCancelRequested() const { return bCancelRequested; }; - - UFUNCTION(BlueprintCallable, Category="UHL GameplayAbility") - UUHLAbilitySystemComponent* GetUHLAbilitySystemComponentFromActorInfo() const; - - UFUNCTION(BlueprintCallable, Category="Ability", DisplayName = "CommitAbilityDuration") - bool K2_CommitAbilityDuration(bool BroadcastCommitEvent); - - void TryActivateAbilityOnSpawn(const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilitySpec& Spec) const; - - // Commit Ability - virtual void CommitExecute( - const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, - const FGameplayAbilityActivationInfo ActivationInfo) override; - virtual bool CommitAbilityDuration( - const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, - const FGameplayAbilityActivationInfo ActivationInfo, - FGameplayTagContainer* OptionalRelevantTags = nullptr); - - void ApplyDuration( - const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, - const FGameplayAbilityActivationInfo ActivationInfo); - bool CheckAbilityDuration( - FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, - FGameplayTagContainer* OptionalRelevantTags) const; - - UFUNCTION(BlueprintNativeEvent, Category = "UHL GameplayAbility") - void OnDurationEnd(const FGameplayEffectRemovalInfo& GameplayEffectRemovalInfo); - - const FGameplayTagContainer* GetAbilityDurationTags() const; - virtual UGameplayEffect* GetAbilityDurationGameplayEffect() const; - - virtual bool CommitCheck(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, FGameplayTagContainer* OptionalRelevantTags = nullptr) override; - // ~Commit Ability - - /** - * Completes a pending cancel request immediately. Call this to actually end the ability when bCancelManually is true. - */ - UFUNCTION(BlueprintCallable, Category = "UHL GameplayAbility") - void ReleaseCancellation(); - -protected: - // Defines how this ability is meant to activate. - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UHL GameplayAbility") - EUHLAbilityActivationPolicy ActivationPolicy = EUHLAbilityActivationPolicy::OnInputTriggered; - - // UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, meta=(EditCondition="ActivationPolicy == EUHLAbilityActivationPolicy::WhileInputActive", EditConditionHides)) - // FUHLWhileInputActiveSettings WhileInputActiveSettings; - - - /** Tracks whether a cancel request has been received */ - bool bCancelRequested = false; - -#if WITH_EDITORONLY_DATA - /** Timer handle for editor warning if ReleaseCancellation isn't called in time */ - FTimerHandle EditorWarningHandle; -#endif - - /** - * Override external cancel: either intercept or pass through. - */ - virtual void CancelAbility( - const FGameplayAbilitySpecHandle Handle, - const FGameplayAbilityActorInfo* ActorInfo, - const FGameplayAbilityActivationInfo ActivationInfo, - bool bReplicateCancelAbility = true) override; - - /** - * Called when a manual cancel request is intercepted. - */ - UFUNCTION(BlueprintImplementableEvent, Category = "Cancellation", meta = (DisplayName = "OnCancelRequested")) - void ReceiveCancelRequested(); - - /** - * Called when cancellation is completed (after manual release). - */ - UFUNCTION(BlueprintImplementableEvent, Category = "Cancellation", meta = (DisplayName = "OnCancelCompleted")) - void ReceiveCancelCompleted(); - -#if WITH_EDITORONLY_DATA - /** - * Editor-only: checks if cancellation was never released and draws a warning. - */ - void CheckCancelReminder(); -#endif - - - virtual void OnGiveAbility(const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilitySpec& Spec) override; - virtual void OnRemoveAbility(const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilitySpec& Spec) override; - virtual void OnPawnAvatarSet(); - - /** Called when this ability is granted to the ability system component. */ - UFUNCTION(BlueprintImplementableEvent, Category="UHL GameplayAbility", DisplayName = "OnAbilityAdded") - void K2_OnAbilityAdded(); - /** Called when this ability is removed from the ability system component. */ - UFUNCTION(BlueprintImplementableEvent, Category="UHL GameplayAbility", DisplayName = "OnAbilityRemoved") - void K2_OnAbilityRemoved(); - /** Called when the ability system is initialized with a pawn avatar. */ - UFUNCTION(BlueprintImplementableEvent, Category="UHL GameplayAbility", DisplayName = "OnPawnAvatarSet") - void K2_OnPawnAvatarSet(); - -private: - UPROPERTY(EditDefaultsOnly, Category="Ability Duration") - TSubclassOf AbilityDurationGameplayEffectClass = nullptr; - - UPROPERTY(EditDefaultsOnly, Category="Ability Duration") - bool bEndAbilityOnDurationExpired = true; -}; diff --git a/Source/UHLGAS/Public/Animations/Notifies/ANS_ActivateAbility.h b/Source/UHLGAS/Public/Animations/Notifies/ANS_ActivateAbility.h deleted file mode 100644 index ac565b06..00000000 --- a/Source/UHLGAS/Public/Animations/Notifies/ANS_ActivateAbility.h +++ /dev/null @@ -1,50 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "UObject/WeakInterfacePtr.h" -#include "GameplayTagContainer.h" -#include "AbilitySystemInterface.h" -#include "Animation/Notifies/ANS_UHL_Base.h" -#include "ANS_ActivateAbility.generated.h" - -/** - * - */ -UCLASS(Blueprintable, Category="UnrealHelperLibrary") -class UHLGAS_API UANS_ActivateAbility : public UANS_UHL_Base -{ - GENERATED_BODY() - -public: - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="ActivateAbility") - FGameplayTag GameplayAbilityTag = FGameplayTag::EmptyTag; - // TODO check should work only if montage exists - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="ActivateAbility") - bool bDeactivateOnMontageBlendingOut = true; - // by default don't allow remote execution, cause its requires time - // abilities in ANS's mostly don't have that time - // and not impacts gameplay, only enhances input and game feel - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="ActivateAbility") - bool bAllowRemoteActivation = false; - -protected: -#if WITH_EDITOR - /** Override this to prevent firing this notify state type in animation editors */ - virtual bool ShouldFireInEditor() { return false; } -#endif - virtual FString GetNotifyName_Implementation() const override; - - virtual void NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) override; - virtual void NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override; - - virtual void OnMontageBlendingOut(UAnimMontage* Montage, bool bInterrupted) override; - -private: - // TODO check ANS's should be stateless!? - TWeakInterfacePtr ActorWithASC; - - UFUNCTION() - void CancelAbility(); -}; diff --git a/Source/UHLGAS/Public/Animations/Notifies/ANS_CatchToAbilityInputCache.h b/Source/UHLGAS/Public/Animations/Notifies/ANS_CatchToAbilityInputCache.h deleted file mode 100644 index a12cca27..00000000 --- a/Source/UHLGAS/Public/Animations/Notifies/ANS_CatchToAbilityInputCache.h +++ /dev/null @@ -1,34 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Animation/AnimNotifies/AnimNotifyState.h" -#include "ANS_CatchToAbilityInputCache.generated.h" - -class UUHLAbilitySystemComponent; - -/** - * Should end then anything that "BlockActions" end - */ -UCLASS() -class UHLGAS_API UANS_CatchToAbilityInputCache : public UAnimNotifyState -{ - GENERATED_BODY() - -public: -#if WITH_EDITOR - /** Override this to prevent firing this notify state type in animation editors */ - virtual bool ShouldFireInEditor() { return false; } -#endif - - virtual FLinearColor GetEditorColor() override { return FColor::FromHex("#FFB341"); }; - virtual FString GetNotifyName_Implementation() const override { return FString("[UHL] CatchTo AbilityInputCache"); }; - - virtual void NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) override; - virtual void NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override; - -private: - UPROPERTY() - TObjectPtr ASC; -}; diff --git a/Source/UHLGAS/Public/Animations/Notifies/ANS_CheckAbilityInputCache.h b/Source/UHLGAS/Public/Animations/Notifies/ANS_CheckAbilityInputCache.h deleted file mode 100644 index 40dc6a24..00000000 --- a/Source/UHLGAS/Public/Animations/Notifies/ANS_CheckAbilityInputCache.h +++ /dev/null @@ -1,49 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "UHLAbilitySystemComponent.h" -#include "Animation/AnimNotifies/AnimNotifyState.h" -#include "ANS_CheckAbilityInputCache.generated.h" - -/** - * Should start after anything that "BlockActions" end - * by default clears AbilityInputCache on end - */ -UCLASS(Category="UnrealHelperLibrary") -class UHLGAS_API UANS_CheckAbilityInputCache final : public UAnimNotifyState -{ - GENERATED_BODY() - - FGameplayTagContainer SavedTargetTags = {}; - -public: - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="CheckAbilityInputCache") - bool bClearCacheOnEnd = true; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="CheckAbilityInputCache") - bool bCacheOnce = false; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="CheckAbilityInputCache") - bool bUseCheckCacheOnlyWithThisTags = false; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="CheckAbilityInputCache", meta = (EditCondition = "bUseCheckCacheOnlyWithThisTags")) - FGameplayTagContainer TargetTags = {}; - -#if WITH_EDITOR - /** Override this to prevent firing this notify state type in animation editors */ - virtual bool ShouldFireInEditor() { return false; } -#endif - - virtual FLinearColor GetEditorColor() override { return FColor::FromHex("#FFA420"); }; - virtual FString GetNotifyName_Implementation() const override { return FString("[UHL] Check AbilityInputCache"); }; - - virtual void NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) override; - virtual void NotifyTick(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float FrameDeltaTime, const FAnimNotifyEventReference& EventReference) override; - virtual void NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override; - -private: - UPROPERTY() - TObjectPtr ASC; -}; diff --git a/Source/UHLGAS/Public/Animations/Notifies/ANS_UHLGAS_GlobalTimeDilation.h b/Source/UHLGAS/Public/Animations/Notifies/ANS_UHLGAS_GlobalTimeDilation.h deleted file mode 100644 index 919717d8..00000000 --- a/Source/UHLGAS/Public/Animations/Notifies/ANS_UHLGAS_GlobalTimeDilation.h +++ /dev/null @@ -1,23 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Animations/Notifies/ANS_ActivateAbility.h" -#include "ANS_UHLGAS_GlobalTimeDilation.generated.h" - -/** - * - */ -UCLASS(Blueprintable, meta=(ToolTip="Controls when GlobalTimeDilation can be changed by GlobalTimeDilation Curve")) -class UHLGAS_API UANS_UHLGAS_GlobalTimeDilation : public UANS_UHL_Base -{ - GENERATED_BODY() - -public: - virtual void NotifyTick(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float FrameDeltaTime, const FAnimNotifyEventReference& EventReference) override; - virtual void OnMontageBlendingOut(UAnimMontage* Montage, bool bInterrupted) override; - - virtual FLinearColor GetEditorColor() override { return FLinearColor(232/256.0f, 229/256.0f, 139/256.0f); }; - virtual FString GetNotifyName_Implementation() const override { return FString("GlobalTimeDilation"); }; -}; diff --git a/Source/UHLGAS/Public/Animations/Notifies/ANS_UHLGAS_TimedNiagaraEffect.h b/Source/UHLGAS/Public/Animations/Notifies/ANS_UHLGAS_TimedNiagaraEffect.h deleted file mode 100644 index ae2012f6..00000000 --- a/Source/UHLGAS/Public/Animations/Notifies/ANS_UHLGAS_TimedNiagaraEffect.h +++ /dev/null @@ -1,34 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "AnimNotifyState_TimedNiagaraEffect.h" -#include "GameplayTagContainer.h" -#include "ANS_UHLGAS_TimedNiagaraEffect.generated.h" - -/** - * Drop in replacement for "AnimNotifyState_TimedNiagaraEffect" but with GAS functions - * like checking that tags are present on Actor - */ -UCLASS() -class UHLGAS_API UANS_UHLGAS_TimedNiagaraEffect : public UAnimNotifyState_TimedNiagaraEffect -{ - GENERATED_BODY() - -public: - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="UHL GAS") - FGameplayTagContainer ActivationRequiredTags = {}; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="UHL GAS") - FGameplayTagContainer ActivationBlockedTags = {}; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="UHL GAS") - bool bIgnoreTagRequirementsInPreview = true; - - virtual void NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) override; - - bool GetAbilitySystemChecksRequired() const; - - bool CanActivateNiagara(AActor* Owner) const; -}; diff --git a/Source/UHLGAS/Public/Animations/Notifies/AN_FireGameplayEvent.h b/Source/UHLGAS/Public/Animations/Notifies/AN_FireGameplayEvent.h deleted file mode 100644 index 870050a2..00000000 --- a/Source/UHLGAS/Public/Animations/Notifies/AN_FireGameplayEvent.h +++ /dev/null @@ -1,51 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "GameplayTagContainer.h" -#include "Animation/Notifies/AN_UHL_Base.h" -#include "AN_FireGameplayEvent.generated.h" - -/** - * - */ -UCLASS(Blueprintable, Category="UnrealHelperLibrary") -class UHLGAS_API UAN_FireGameplayEvent : public UAN_UHL_Base -{ - GENERATED_BODY() - -public: - UPROPERTY(EditAnywhere, Category="FireGameplayEvent") - FGameplayTag EventTag = FGameplayTag::EmptyTag; - - // TODO use "UPayloadWithInstancedStructs" from "UAA_TryActivateAbilityAndWait" - UPROPERTY(EditAnywhere, Category="FireGameplayEvent", Instanced) - UObject* OptionalObject = nullptr; - - UPROPERTY(EditAnywhere, Category="FireGameplayEvent", Instanced) - UObject* OptionalObject2 = nullptr; - - // tags that required on instigator to fire event ?? - UPROPERTY(EditAnywhere, Category="FireGameplayEvent") - FGameplayTagContainer InstigatorTags = {}; - - // tags that required on target to fire event ?? - UPROPERTY(EditAnywhere, Category="FireGameplayEvent") - FGameplayTagContainer TargetTags = {}; - - UPROPERTY(EditAnywhere, Category="FireGameplayEvent") - float EventMagnitude = 0.0f; - -protected: -#if WITH_EDITOR - /** Override this to prevent firing this notify state type in animation editors */ - virtual bool ShouldFireInEditor() { return false; } - virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override; -#endif - - virtual FLinearColor GetEditorColor() override { return FColor::FromHex("#FF7DE7"); }; - virtual FString GetNotifyName_Implementation() const override; - - virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override; -}; diff --git a/Source/UHLGAS/Public/AttributeSets/UHLAttributeSet.h b/Source/UHLGAS/Public/AttributeSets/UHLAttributeSet.h deleted file mode 100644 index f5e6460c..00000000 --- a/Source/UHLGAS/Public/AttributeSets/UHLAttributeSet.h +++ /dev/null @@ -1,54 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "AttributeSet.h" -#include "GameplayEffect.h" -#include "UHLAttributeSet.generated.h" - -class UUHLAbilitySystemComponent; - -/** - * This macro defines a set of helper functions for accessing and initializing attributes. - * - * The following example of the macro: - * ATTRIBUTE_ACCESSORS(ULyraHealthSet, Health) - * will create the following functions: - * static FGameplayAttribute GetHealthAttribute(); - * float GetHealth() const; - * void SetHealth(float NewVal); - * void InitHealth(float NewVal); - */ -#define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \ - GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \ - GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \ - GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \ - GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName) - -/** - * Delegate used to broadcast attribute events, some of these parameters may be null on clients: - * @param EffectInstigator The original instigating actor for this event - * @param EffectCauser The physical actor that caused the change - * @param EffectSpec The full effect spec for this change - * @param EffectMagnitude The raw magnitude, this is before clamping - * @param OldValue The value of the attribute before it was changed - * @param NewValue The value after it was changed -*/ -DECLARE_MULTICAST_DELEGATE_SixParams(FUHLAttributeEvent, AActor* /*EffectInstigator*/, AActor* /*EffectCauser*/, const FGameplayEffectSpec* /*EffectSpec*/, float /*EffectMagnitude*/, float /*OldValue*/, float /*NewValue*/); - -/** - * Lyra based class for sharing common attribute set functions - */ -UCLASS() -class UHLGAS_API UUHLAttributeSet : public UAttributeSet -{ - GENERATED_BODY() - -public: - UUHLAttributeSet(); - - UWorld* GetWorld() const override; - - UUHLAbilitySystemComponent* GetUHLAbilitySystemComponent() const; -}; diff --git a/Source/UHLGAS/Public/Core/UHLAbilitySystemInterface.h b/Source/UHLGAS/Public/Core/UHLAbilitySystemInterface.h deleted file mode 100644 index 5408a7ce..00000000 --- a/Source/UHLGAS/Public/Core/UHLAbilitySystemInterface.h +++ /dev/null @@ -1,28 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "UHLAbilitySystemComponent.h" -#include "UObject/Interface.h" -#include "UHLAbilitySystemInterface.generated.h" - -// This class does not need to be modified. -UINTERFACE(Blueprintable, MinimalAPI) -class UUHLAbilitySystemInterface : public UInterface -{ - GENERATED_BODY() -}; - -/** - * - */ -class UHLGAS_API IUHLAbilitySystemInterface -{ - GENERATED_BODY() - -public: - /** Returns the ability system component to use for this actor. It may live on another actor, such as a Pawn using the PlayerState's component */ - UFUNCTION(Category="UHLAbilitySystemInterface", BlueprintNativeEvent, BlueprintCallable) - UUHLAbilitySystemComponent* GetUHLAbilitySystemComponent() const; -}; \ No newline at end of file diff --git a/Source/UHLGAS/Public/Data/PayloadWithInstancedStructs.h b/Source/UHLGAS/Public/Data/PayloadWithInstancedStructs.h deleted file mode 100644 index aa00c191..00000000 --- a/Source/UHLGAS/Public/Data/PayloadWithInstancedStructs.h +++ /dev/null @@ -1,20 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "StructUtils/InstancedStruct.h" -#include "PayloadWithInstancedStructs.generated.h" - -UCLASS(Blueprintable) -class UPayloadWithInstancedStructs : public UObject -{ - GENERATED_BODY() - -public: - UPayloadWithInstancedStructs() = default; - UPayloadWithInstancedStructs(TArray InstancedStructs_In); - - UPROPERTY(EditAnywhere, BlueprintReadWrite) - TArray InstancedStructs = {}; -}; diff --git a/Source/UHLGAS/Public/Development/UHLGASSettings.h b/Source/UHLGAS/Public/Development/UHLGASSettings.h deleted file mode 100644 index e1274926..00000000 --- a/Source/UHLGAS/Public/Development/UHLGASSettings.h +++ /dev/null @@ -1,30 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "UHLAbilitySystemConfig.h" -#include "Engine/DeveloperSettings.h" -#include "Misc/App.h" -#include "UHLGASSettings.generated.h" - -/** - * - */ -UCLASS(Config="Game", DefaultConfig, DisplayName="UHL GAS") -class UHLGAS_API UUHLGASSettings : public UDeveloperSettings -{ - GENERATED_BODY() - -public: - UPROPERTY(Config, EditAnywhere, Category="Ability System Defaults") - FUHLAbilitySystemSettings AbilitySystemConfigDefaults = {}; - - UPROPERTY(Config, EditAnywhere, Category="Ability System Defaults") - bool bUseAbilitySystemConfigDefaultsInASC = true; - -protected: -//~UDeveloperSettings interface - virtual FName GetCategoryName() const override { return FApp::GetProjectName(); }; -//~End of UDeveloperSettings interface -}; diff --git a/Source/UHLGAS/Public/Input/AbilityInputCache.h b/Source/UHLGAS/Public/Input/AbilityInputCache.h deleted file mode 100644 index d07deb9b..00000000 --- a/Source/UHLGAS/Public/Input/AbilityInputCache.h +++ /dev/null @@ -1,53 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "GameplayTagContainer.h" -#include "AbilityInputCache.generated.h" - -class UUHLAbilitySystemComponent; - -DECLARE_LOG_CATEGORY_EXTERN(Log_UHL_AbilityInputCache, Log, All); - -UCLASS(Blueprintable) -class UAbilityInputCachePayload : public UObject -{ - GENERATED_BODY() - -public: - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Payload") - FGameplayTag AbilityGameplayTagToCache; -}; - -/** - * TODO clear cache on successfully activated ability? is it option? - */ -UCLASS() -class UHLGAS_API UAbilityInputCache final : public UObject -{ - GENERATED_BODY() - -public: - UFUNCTION(Category = "AbilityInputCache") - void SetUp(UUHLAbilitySystemComponent* ASC_In); - - UFUNCTION(BlueprintCallable, Category = "AbilityInputCache") - bool AddTagToCache(FGameplayTag AbilityTag_In); - UFUNCTION(BlueprintCallable, Category = "AbilityInputCache") - bool AddTagsToCache(TArray AbilityTags_In, bool bReverse = false); - UFUNCTION(BlueprintCallable, Category = "AbilityInputCache") - void CheckCache(); - UFUNCTION(BlueprintCallable, Category = "AbilityInputCache") - void ClearCache(); - UFUNCTION(BlueprintCallable, Category = "AbilityInputCache") - const TArray& GetAbilityInputCache() const { return AbilityInputCache; }; - // TODO: remove tags from cache explicitly (probably bad practice, dont give option to do so?) - // UFUNCTION(BlueprintCallable) - // void RemoveTagFromCache(FGameplayTag AbilityTag_In); - -private: - UPROPERTY() - TArray AbilityInputCache = {}; - TWeakObjectPtr ASC; -}; diff --git a/Source/UHLGAS/Public/Input/UHLInputComponent.h b/Source/UHLGAS/Public/Input/UHLInputComponent.h deleted file mode 100644 index 1fe0cb6d..00000000 --- a/Source/UHLGAS/Public/Input/UHLInputComponent.h +++ /dev/null @@ -1,66 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "UHLInputConfig.h" -#include "GameplayTagContainer.h" -#include "EnhancedInputComponent.h" -#include "EnhancedInputSubsystems.h" -#include "UHLInputComponent.generated.h" - -/** - * WARNING: Copy-paste from "Lyra project" - /Source/Input/LyraInputConfig - */ - -/** - * UUHLInputComponent - * - * Component used to manage input mappings and bindings using an input config data asset. - */ -UCLASS(Config = Input) -class UHLGAS_API UUHLInputComponent : public UEnhancedInputComponent -{ - GENERATED_BODY() - -public: - UUHLInputComponent(const FObjectInitializer& ObjectInitializer); - - // void AddInputMappings(const UGCInputConfig* InputConfig, UEnhancedInputLocalPlayerSubsystem* InputSubsystem) const; - // void RemoveInputMappings(const UGCInputConfig* InputConfig, UEnhancedInputLocalPlayerSubsystem* InputSubsystem) const; - - template - void BindAbilityActions(const UUHLInputConfig* InputConfig, UserClass* Object, PressedFuncType PressedFunc, ReleasedFuncType ReleasedFunc, TArray& BindHandles); - - // void RemoveBinds(TArray& BindHandles); - - // TODO: вроде ненужно - // void AddInputConfig(const FLoadedMappableConfigPair& ConfigPair, UEnhancedInputLocalPlayerSubsystem* InputSubsystem); - // void RemoveInputConfig(const FLoadedMappableConfigPair& ConfigPair, UEnhancedInputLocalPlayerSubsystem* InputSubsystem); -}; - -template -void UUHLInputComponent::BindAbilityActions(const UUHLInputConfig* InputConfig, UserClass* Object, PressedFuncType PressedFunc, ReleasedFuncType ReleasedFunc, TArray& BindHandles) -{ - check(InputConfig); - - for (const FUHLInputActionAbilities& Action : InputConfig->AbilityInputActions) - { - if (Action.InputAction && Action.bEnabled && !Action.AbilitiesToActivate.IsEmpty()) - { - for (FGameplayTag AbilityTag : Action.AbilitiesToActivate) - { - if (PressedFunc) - { - BindHandles.Add(BindAction(Action.InputAction, ETriggerEvent::Triggered, Object, PressedFunc, AbilityTag).GetHandle()); - } - - if (ReleasedFunc) - { - BindHandles.Add(BindAction(Action.InputAction, ETriggerEvent::Completed, Object, ReleasedFunc, AbilityTag).GetHandle()); - BindHandles.Add(BindAction(Action.InputAction, ETriggerEvent::Canceled, Object, ReleasedFunc, AbilityTag).GetHandle()); - } - } - } - } -} diff --git a/Source/UHLGAS/Public/Input/UHLInputConfig.h b/Source/UHLGAS/Public/Input/UHLInputConfig.h deleted file mode 100644 index 90018324..00000000 --- a/Source/UHLGAS/Public/Input/UHLInputConfig.h +++ /dev/null @@ -1,86 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Engine/DataAsset.h" -#include "GameplayTagContainer.h" -#include "UHLInputConfig.generated.h" - -/** - * WARNING: Copy paste from "Lyra project" - /Source/Input/LyraInputConfig - */ - -class UInputAction; -class UInputMappingContext; -// class ULyraLocalPlayer; - -/** - * FGCInputAction - * - * Struct used to map a input action to a gameplay input tag. - */ -USTRUCT(BlueprintType) -struct FUHLInputAction -{ - GENERATED_BODY() - -public: - UPROPERTY(EditDefaultsOnly, Category = "InputAction") - const UInputAction* InputAction = nullptr; - UPROPERTY(EditDefaultsOnly, Category = "InputAction", Meta = (Categories = "InputTag")) - FGameplayTag InputTag; -}; - -/** - * FGCInputActionAbilities - * - * Struct used to map a input action to a gameplay abilities tags - */ -USTRUCT(BlueprintType) -struct FUHLInputActionAbilities -{ - GENERATED_BODY() - -public: - UPROPERTY(EditDefaultsOnly, Category = "InputActionAbilities") - bool bEnabled = true; - UPROPERTY(EditDefaultsOnly, Category = "InputActionAbilities") - const UInputAction* InputAction = nullptr; - UPROPERTY(EditDefaultsOnly, Category = "InputActionAbilities") - TArray AbilitiesToActivate; -}; - -/** - * ULyraInputConfig - * - * Non-mutable data asset that contains input configuration properties. - */ -UCLASS(BlueprintType, Const) -class UHLGAS_API UUHLInputConfig : public UDataAsset -{ - GENERATED_BODY() - -public: - UUHLInputConfig(const FObjectInitializer& ObjectInitializer); - - // const UInputAction* FindNativeInputActionForTag(const FGameplayTag& InputTag, bool bLogNotFound = true) const; - // const UInputAction* FindAbilityInputActionForTag(const FGameplayTag& InputTag, bool bLogNotFound = true) const; - -public: - // List of input actions used by the owner. These input actions are mapped to a gameplay tag and must be manually bound. - // UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Meta = (TitleProperty = "InputAction")) - // TArray NativeInputActions; - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Native Input Actions") - FUHLInputAction NativeInputAction_Move; - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Native Input Actions") - FUHLInputAction NativeInputAction_LookMouse; - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Native Input Actions") - FUHLInputAction NativeInputAction_LookStick; - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Native Input Actions") - FUHLInputAction NativeInputAction_Interact; - - // List of input actions used by the owner. These input actions are mapped to a gameplay tag and are automatically bound to abilities with matching input tags. - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AbilityInputActions", Meta = (TitleProperty = "InputAction")) - TArray AbilityInputActions; -}; diff --git a/Source/UHLGAS/Public/Tasks/AA_TryActivateAbilityAndWait.h b/Source/UHLGAS/Public/Tasks/AA_TryActivateAbilityAndWait.h deleted file mode 100644 index dc54d5c6..00000000 --- a/Source/UHLGAS/Public/Tasks/AA_TryActivateAbilityAndWait.h +++ /dev/null @@ -1,63 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Abilities/Async/AbilityAsync.h" -#include "StructUtils/InstancedStruct.h" -#include "AA_TryActivateAbilityAndWait.generated.h" - -/** - * - */ -UCLASS() -class UHLGAS_API UAA_TryActivateAbilityAndWait : public UAbilityAsync -{ - GENERATED_BODY() - -public: - UFUNCTION() - void OnAbilityActivate(UGameplayAbility *ActivatedAbility); - UFUNCTION() - void OnAbilityDeactivate(UGameplayAbility *ActivatedAbility); - - /** - * Wait until the specified gameplay attribute is changed on a target ability system component - * It will keep listening as long as OnlyTriggerOnce = false - * If used in an ability graph, this async action will wait even after activation ends. It's recommended to use WaitForAttributeChange instead. - * - * If InstancedStructs specified will "SendGameplayEventToActor" with "UPayloadWithInstancedStructs" in "OptionalObject1" - * you should fill "AbilityTriggers" in GameplayAbility to activate it with this Event, - * also to wait for activate/endability "WithTag" should be GameplayAbility "AbilityTags"(not strict tag check) - * TODO: "PayloadInfo" not great solution probably better to check AN_FireGameplayEvent with its OptionalObject1/2 - */ - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|Ability|Tasks", meta = (DefaultToSelf = "TargetActor", BlueprintInternalUseOnly = "TRUE")) - static UAA_TryActivateAbilityAndWait* TryActivateAbilityAndWait(AActor* TargetActor, FGameplayTag WithTag, - bool bUsingEvent, const TArray& PayloadInfo, bool IncludeTriggeredAbilities=false, bool bAllowRemoteActivation=true, bool TriggerOnce=true); - - DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FWaitAbilityActivateDelegate, UGameplayAbility*, ActivatedAbility); - UPROPERTY(BlueprintAssignable) - FWaitAbilityActivateDelegate OnActivate; - - DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FWaitAbilityDeactivateDelegate, UGameplayAbility*, ActivatedAbility); - UPROPERTY(BlueprintAssignable) - FWaitAbilityActivateDelegate OnEndAbility; - -protected: - virtual void Activate() override; - virtual void EndAction() override; - - FGameplayTag WithTag; - FGameplayTag WithoutTag; - TArray PayloadInfo; - bool bUsingEvent = false; - bool IncludeTriggeredAbilities = false; - bool TriggerOnce; - bool bAllowRemoteActivation = true; - FGameplayTagRequirements TagRequirements; - - FGameplayTagQuery Query; - -protected: - FDelegateHandle OnAbilityActivateDelegateHandle; -}; diff --git a/Source/UHLGAS/Public/Tasks/AA_UHLGAS_WaitAbilityActivate.h b/Source/UHLGAS/Public/Tasks/AA_UHLGAS_WaitAbilityActivate.h deleted file mode 100644 index 918e63fa..00000000 --- a/Source/UHLGAS/Public/Tasks/AA_UHLGAS_WaitAbilityActivate.h +++ /dev/null @@ -1,60 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Abilities/Async/AbilityAsync.h" -#include "AA_UHLGAS_WaitAbilityActivate.generated.h" - -/** - * - */ -UCLASS() -class UHLGAS_API UAA_UHLGAS_WaitAbilityActivate : public UAbilityAsync -{ - GENERATED_BODY() - -public: - - UFUNCTION() - void OnAbilityActivate(UGameplayAbility *ActivatedAbility); - - /** - * Wait until the specified gameplay attribute is changed on a target ability system component - * It will keep listening as long as OnlyTriggerOnce = false - * If used in an ability graph, this async action will wait even after activation ends. It's recommended to use WaitForAttributeChange instead. - */ - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|Ability|Tasks", meta = (DefaultToSelf = "TargetActor", BlueprintInternalUseOnly = "TRUE")) - static UAA_UHLGAS_WaitAbilityActivate* WaitForAbilityActivate(AActor* TargetActor, FGameplayTag WithTag, - FGameplayTag WithoutTag, bool IncludeTriggeredAbilities=false, bool TriggerOnce=true); - - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|Ability|Tasks", meta = (DefaultToSelf = "TargetActor", BlueprintInternalUseOnly = "TRUE")) - static UAA_UHLGAS_WaitAbilityActivate* WaitForAbilityActivateWithTagRequirements(AActor* TargetActor, - FGameplayTagRequirements TagRequirements, bool IncludeTriggeredAbilities = false, - bool TriggerOnce = true); - - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|Ability|Tasks", meta = (DefaultToSelf = "TargetActor", BlueprintInternalUseOnly = "TRUE")) - static UAA_UHLGAS_WaitAbilityActivate* WaitForAbilityActivate_Query(AActor* TargetActor, - FGameplayTagQuery Query, bool IncludeTriggeredAbilities = false, bool TriggerOnce = true); - - - DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FWaitAbilityActivateDelegate, UGameplayAbility*, ActivatedAbility); - UPROPERTY(BlueprintAssignable) - FWaitAbilityActivateDelegate OnActivate; - -protected: - virtual void Activate() override; - virtual void EndAction() override; - - FGameplayTag WithTag; - FGameplayTag WithoutTag; - bool IncludeTriggeredAbilities = false; - bool TriggerOnce; - FGameplayTagRequirements TagRequirements; - - FGameplayTagQuery Query; - -protected: - - FDelegateHandle OnAbilityActivateDelegateHandle; -}; diff --git a/Source/UHLGAS/Public/Tasks/AA_WaitAbilityDeactivate.h b/Source/UHLGAS/Public/Tasks/AA_WaitAbilityDeactivate.h deleted file mode 100644 index 1639358a..00000000 --- a/Source/UHLGAS/Public/Tasks/AA_WaitAbilityDeactivate.h +++ /dev/null @@ -1,57 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Abilities/Async/AbilityAsync.h" -#include "AA_WaitAbilityDeactivate.generated.h" - -/** - * - */ -UCLASS() -class UHLGAS_API UAA_WaitAbilityDeactivate : public UAbilityAsync -{ - GENERATED_BODY() - -public: - - UFUNCTION() - void OnAbilityDeactivate(UGameplayAbility *DeactivatedAbility); - - /** - * Wait until the specified gameplay attribute is changed on a target ability system component - * It will keep listening as long as OnlyTriggerOnce = false - * If used in an ability graph, this async action will wait even after activation ends. It's recommended to use WaitForAttributeChange instead. - */ - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|Ability|Tasks", meta = (DefaultToSelf = "TargetActor", BlueprintInternalUseOnly = "TRUE")) - static UAA_WaitAbilityDeactivate* WaitForAbilityDeactivate(AActor* TargetActor, FGameplayTag WithTag, - FGameplayTag WithoutTag, bool TriggerOnce=true); - - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|Ability|Tasks", meta = (DefaultToSelf = "TargetActor", BlueprintInternalUseOnly = "TRUE")) - static UAA_WaitAbilityDeactivate* WaitForAbilityDeactivateWithTagRequirements(AActor* TargetActor, - FGameplayTagRequirements TagRequirements, bool TriggerOnce = true); - - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|Ability|Tasks", meta = (DefaultToSelf = "TargetActor", BlueprintInternalUseOnly = "TRUE")) - static UAA_WaitAbilityDeactivate* WaitForAbilityDeactivate_Query(AActor* TargetActor, - FGameplayTagQuery Query, bool TriggerOnce = true); - - - DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FWaitAbilityDeactivateDelegate, UGameplayAbility*, ActivatedAbility); - UPROPERTY(BlueprintAssignable) - FWaitAbilityDeactivateDelegate OnDeactivate; - -protected: - virtual void Activate() override; - virtual void EndAction() override; - - FGameplayTag WithTag; - FGameplayTag WithoutTag; - bool TriggerOnce; - FGameplayTagRequirements TagRequirements; - - FGameplayTagQuery Query; - -protected: - FDelegateHandle OnAbilityDeactivateDelegateHandle; -}; diff --git a/Source/UHLGAS/Public/Tasks/AA_WaitAttributeChangeRatioThreshold.h b/Source/UHLGAS/Public/Tasks/AA_WaitAttributeChangeRatioThreshold.h deleted file mode 100644 index c996b354..00000000 --- a/Source/UHLGAS/Public/Tasks/AA_WaitAttributeChangeRatioThreshold.h +++ /dev/null @@ -1,62 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Abilities/Async/AbilityAsync.h" -#include "Abilities/Tasks/AbilityTask_WaitAttributeChangeRatioThreshold.h" -#include "AA_WaitAttributeChangeRatioThreshold.generated.h" - -struct FGameplayEffectModCallbackData; - -/** - * - */ -UCLASS() -class UHLGAS_API UAA_WaitAttributeChangeRatioThreshold : public UAbilityAsync -{ - GENERATED_BODY() - - UAA_WaitAttributeChangeRatioThreshold(const FObjectInitializer& ObjectInitializer); - - UPROPERTY(BlueprintAssignable) - FWaitAttributeChangeRatioThresholdDelegate OnChange; - - - void OnNumeratorAttributeChange(const FOnAttributeChangeData& CallbackData); - void OnDenominatorAttributeChange(const FOnAttributeChangeData& CallbackData); - - /** Wait on attribute ratio change meeting a comparison threshold. */ - UFUNCTION(BlueprintCallable, Category="Ability|Tasks", meta = (DefaultToSelf = "TargetActor", BlueprintInternalUseOnly = "TRUE")) - static UAA_WaitAttributeChangeRatioThreshold* WaitForAttributeChangeRatioThreshold(AActor* TargetActor, FGameplayAttribute AttributeNumerator, FGameplayAttribute AttributeDenominator, TEnumAsByte ComparisonType, float ComparisonValue, bool bTriggerOnce, AActor* OptionalExternalOwner = nullptr); - - FGameplayAttribute AttributeNumerator; - FGameplayAttribute AttributeDenominator; - TEnumAsByte ComparisonType = EWaitAttributeChangeComparison::LessThanOrEqualTo; - float ComparisonValue = 0.0f; - bool bTriggerOnce; - FDelegateHandle OnNumeratorAttributeChangeDelegateHandle; - FDelegateHandle OnDenominatorAttributeChangeDelegateHandle; - -protected: - virtual void Activate() override; - virtual void EndAction() override; - - float LastAttributeNumeratorValue; - float LastAttributeDenominatorValue; - bool bMatchedComparisonLastAttributeChange; - - /** Timer used when either numerator or denominator attribute is changed to delay checking of ratio to avoid false positives (MaxHealth changed before Health updates accordingly) */ - FTimerHandle CheckAttributeTimer; - - UPROPERTY() - TObjectPtr ExternalOwner; - - UAbilitySystemComponent* GetFocusedASC() const; - - void OnAttributeChange(); - void OnRatioChange(); - - bool DoesValuePassComparison(float ValueNumerator, float ValueDenominator) const; - -}; diff --git a/Source/UHLGAS/Public/Tasks/AT_InterpolateToPosition.h b/Source/UHLGAS/Public/Tasks/AT_InterpolateToPosition.h deleted file mode 100644 index 7cf91a1a..00000000 --- a/Source/UHLGAS/Public/Tasks/AT_InterpolateToPosition.h +++ /dev/null @@ -1,103 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Abilities/Tasks/AbilityTask.h" -#include "AT_InterpolateToPosition.generated.h" - -class UCurveVector; -DECLARE_DYNAMIC_MULTICAST_DELEGATE(FInterpolateToPositionSimpleDelegate); - -/** - * Based on "AbilityTask_MoveToLocation" - */ -UCLASS(Category = "UnrealHelperLibrary") -class UHLGAS_API UAT_InterpolateToPosition : public UAbilityTask -{ - GENERATED_BODY() - -public: - UAT_InterpolateToPosition(const FObjectInitializer& ObjectInitializer); - - /** Move to the specified location, using the vector curve (range 0 - 1) if specified, otherwise the float curve (range 0 - 1) or fallback to linear interpolation */ - UFUNCTION(BlueprintCallable, Category = "Ability|Tasks", meta = (HidePin = "OwningAbility", DefaultToSelf = "OwningAbility", BlueprintInternalUseOnly = "TRUE")) - static UAT_InterpolateToPosition* InterpolateToPosition( - FHitResult& OutHit, - UGameplayAbility* OwningAbility, - FName TaskInstanceName, - FVector Location, - FRotator Rotation, - float Duration, - UCurveFloat* OptionalInterpolationCurve, - UCurveVector* OptionalVectorInterpolationCurve, - AActor* OptionalActorToInterpolate, - const bool bIsIgnoreHits = true, - const float DistanceOffset = 0.f, - const bool bUseCapsuleTrace = false - ); - - UPROPERTY(BlueprintAssignable, Category="Ability|Tasks") - FInterpolateToPositionSimpleDelegate OnTargetLocationReached; - - virtual void InitSimulatedTask(UGameplayTasksComponent& InGameplayTasksComponent) override; - - virtual void Activate() override; - virtual void TickTask(float DeltaTime) override; - virtual void PreDestroyFromReplication() override; - virtual void OnDestroy(bool bInOwnerFinished) override; - -private: - bool bIsFinished; - - UPROPERTY(Replicated) - FRotator StartRotation; - UPROPERTY(Replicated) - FRotator TargetRotation; - - UPROPERTY(Replicated) - FVector StartLocation; - UPROPERTY(Replicated) - FVector TargetLocation; - - UPROPERTY(Replicated) - float DurationOfMovement = 0.0f; - - float TimeMoveStarted = 0.0f; - float TimeMoveWillEnd = 0.0f; - - UPROPERTY(Replicated) - TObjectPtr LerpCurve; - UPROPERTY(Replicated) - TObjectPtr LerpCurveVector; - UPROPERTY(Replicated) - TObjectPtr ActorToInterpolate = nullptr; - - static bool CheckHit( - const UWorld* World, - const FVector& Start, - const FVector& End, - const TArray& ActorsToIgnore, - FHitResult& OutHit - ); - static bool CheckCapsuleHit( - const UWorld* World, - const FVector& Start, - const FVector& End, - const float Radius, - const float HalfHeight, - const TArray& ActorsToIgnore, - FHitResult& OutHit - ); - static FVector GetCurrentEndLocation( - const FVector& Start, - const FVector& End, - const float DistanceOffset = 0.f - ); - static float GetCurrentDuration( - const float Duration, - const FVector& Start, - const FVector& End, - const FVector& CurrentEnd - ); -}; diff --git a/Source/UHLGAS/Public/UHLAbilitySet.h b/Source/UHLGAS/Public/UHLAbilitySet.h deleted file mode 100644 index e3ff7998..00000000 --- a/Source/UHLGAS/Public/UHLAbilitySet.h +++ /dev/null @@ -1,158 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "ActiveGameplayEffectHandle.h" -#include "Engine/DataAsset.h" -#include "AttributeSet.h" -#include "GameplayTagContainer.h" - -#include "GameplayAbilitySpecHandle.h" -#include "UHLAbilitySet.generated.h" - -class UGameplayAbility; -class UAttributeSet; -class UGameplayEffect; -class UUHLAbilitySystemComponent; -class UUHLGameplayAbility; -class UObject; - -/** - * FUHLAbilitySet_GameplayAbility - * - * Data used by the ability set to grant gameplay abilities. - */ -USTRUCT(BlueprintType) -struct FUHLAbilitySet_GameplayAbility -{ - GENERATED_BODY() - -public: - // Gameplay ability to grant. - UPROPERTY(EditDefaultsOnly, Category = "GameplayAbility") - TSubclassOf Ability = nullptr; - - // Level of ability to grant. - UPROPERTY(EditDefaultsOnly, Category = "GameplayAbility") - int32 AbilityLevel = 1; - - // Tag used to process input for the ability. - UPROPERTY(EditDefaultsOnly, Category = "GameplayAbility", Meta = (Categories = "InputTag")) - FGameplayTag InputTag; -}; - -/** - * FUHLAbilitySet_GameplayEffect - * - * Data used by the ability set to grant gameplay effects. - */ -USTRUCT(BlueprintType) -struct FUHLAbilitySet_GameplayEffect -{ - GENERATED_BODY() - -public: - // Gameplay effect to grant. - UPROPERTY(EditDefaultsOnly, Category = "GameplayEffect") - TSubclassOf GameplayEffect = nullptr; - - // Level of gameplay effect to grant. - UPROPERTY(EditDefaultsOnly, Category = "GameplayEffect") - float EffectLevel = 1.0f; -}; - -/** - * FUHLAbilitySet_AttributeSet - * - * Data used by the ability set to grant attribute sets. - */ -USTRUCT(BlueprintType) -struct FUHLAbilitySet_AttributeSet -{ - GENERATED_BODY() - -public: - // Gameplay effect to grant. - UPROPERTY(EditDefaultsOnly, Category = "AttributeSet") - TSubclassOf AttributeSet; -}; - -/** - * FUHLAbilitySet_GrantedHandles - * - * Data used to store handles to what has been granted by the ability set. - */ -USTRUCT(BlueprintType) -struct FUHLAbilitySet_GrantedHandles -{ - GENERATED_BODY() - -public: - FGameplayTagContainer GetAbilitySetTags() const { return AbilitySetTags; } - void SetAbilitySetTags(const FGameplayTagContainer& AbilitySetTagContainer); - - void AddAbilitySpecHandle(const FGameplayAbilitySpecHandle& Handle); - void AddGameplayEffectHandle(const FActiveGameplayEffectHandle& Handle); - void AddAttributeSet(UAttributeSet* Set); - - void TakeFromAbilitySystem(UAbilitySystemComponent* ASC); - -protected: - UPROPERTY() - FGameplayTagContainer AbilitySetTags; - - // Handles to the granted abilities. - UPROPERTY() - TArray AbilitySpecHandles; - - // Handles to the granted gameplay effects. - UPROPERTY() - TArray GameplayEffectHandles; - - // Pointers to the granted attribute sets - UPROPERTY() - TArray> GrantedAttributeSets; -}; - -/** - * UUHLAbilitySet - * - * Non-mutable data asset used to grant gameplay abilities and gameplay effects. - * - * Based on Lyra "AbilitySets" - */ -UCLASS(BlueprintType, Const) -class UUHLAbilitySet : public UPrimaryDataAsset -{ - GENERATED_BODY() - -public: - UUHLAbilitySet(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get()); - - // Grants the ability set to the specified ability system component. - // The returned handles can be used later to take away anything that was granted. - void GiveToAbilitySystem(UAbilitySystemComponent* ASC, FUHLAbilitySet_GrantedHandles* OutGrantedHandles, UObject* SourceObject = nullptr) const; - - TArray> GetAllAbilitiesList() const; - -protected: - // AbilitySetTag to associate with and can be removed "RemoveAbilitySetByTag" - UPROPERTY(EditDefaultsOnly, Category = "AbilitySet Tags", meta = (TitleProperty = Ability)) - FGameplayTagContainer AbilitySetTags; - - // Gameplay abilities to grant when this ability set is granted. - UPROPERTY(EditDefaultsOnly, Category = "Gameplay Abilities", meta = (TitleProperty = Ability)) - TArray> GrantedSimpleGameplayAbilities; - - // Gameplay abilities to grant when this ability set is granted. - UPROPERTY(EditDefaultsOnly, Category = "Gameplay Abilities", meta = (TitleProperty = Ability)) - TArray GrantedGameplayAbilities; - - // Gameplay effects to grant when this ability set is granted. - UPROPERTY(EditDefaultsOnly, Category = "Gameplay Effects", meta = (TitleProperty = GameplayEffect)) - TArray GrantedGameplayEffects; - - // Attribute sets to grant when this ability set is granted. - UPROPERTY(EditDefaultsOnly, Category = "Attribute Sets", meta = (TitleProperty = AttributeSet)) - TArray GrantedAttributes; -}; diff --git a/Source/UHLGAS/Public/UHLAbilitySystemComponent.h b/Source/UHLGAS/Public/UHLAbilitySystemComponent.h deleted file mode 100644 index efadf2fd..00000000 --- a/Source/UHLGAS/Public/UHLAbilitySystemComponent.h +++ /dev/null @@ -1,160 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "AbilitySystemComponent.h" -#include "UHLAbilitySet.h" -#include "UHLAbilitySystemConfig.h" -#include "Input/AbilityInputCache.h" -#include "UHLAbilitySystemComponent.generated.h" - -class UUHLAbilitySystemConfig; -class UUHLAbilitySet; -class UUHLInputConfig; -class UUHLGameplayAbility; - -/** - * - */ -UCLASS(Category = "UnrealHelperLibrary", Blueprintable, meta=(BlueprintSpawnableComponent)) -class UHLGAS_API UUHLAbilitySystemComponent : public UAbilitySystemComponent -{ - GENERATED_BODY() - -public: - UUHLAbilitySystemComponent(); - - // "PropertyRedirects" don't or can't redirect properties to struct like "Settings" - // checked many ways nothing worked. Don't want to create "migration" so just fill - // properties from "AbilitySystemConfig" - // UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="UHL AbilitySystemComponent", meta=(ShowOnlyInnerProperties)) - // FUHLAbilitySystemSettings Settings = {}; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="UHL AbilitySystemComponent", meta=(InlineEditConditionToggle)) - bool bInitializeGameplayAttributes = true; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="UHL AbilitySystemComponent", meta=(ForceInlineRow, EditCondition="bInitializeGameplayAttributes")) - TMap InitialAttributes = {}; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="UHL AbilitySystemComponent", meta=(InlineEditConditionToggle)) - bool bGiveAbilitiesOnStart = true; - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UHL AbilitySystemComponent", meta=(EditCondition="bGiveAbilitiesOnStart")) - TArray> Abilities = {}; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="UHL AbilitySystemComponent", meta=(InlineEditConditionToggle)) - bool bGiveAttributesSetsOnStart = true; - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UHL AbilitySystemComponent", meta=(EditCondition="bGiveAttributesSetsOnStart")) - TArray> AttributeSets = {}; - - // TODO replace by "EUHLAbilityActivationPolicy::OnSpawn" - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="UHL AbilitySystemComponent", meta=(InlineEditConditionToggle)) - bool bActivateAbilitiesOnStart = true; - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UHL AbilitySystemComponent", meta=(EditCondition="bActivateAbilitiesOnStart")) - TArray ActiveAbilitiesOnStart = {}; - - // TODO initial GameplayEffects? - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="UHL AbilitySystemComponent", meta=(InlineEditConditionToggle)) - bool bGiveInitialGameplayTags = true; - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UHL AbilitySystemComponent", meta=(EditCondition="bGiveInitialGameplayTags")) - FGameplayTagContainer InitialGameplayTags; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="UHL AbilitySystemComponent", meta=(InlineEditConditionToggle)) - bool bGiveAbilitySetsOnStart = true; - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UHL AbilitySystemComponent", meta=(EditCondition="bGiveAbilitySetsOnStart")) - TArray AbilitySets = {}; - - UPROPERTY(EditAnywhere, Transient, BlueprintReadWrite, Category="UHL AbilitySystemComponent", AdvancedDisplay, meta=(InlineEditConditionToggle)) - bool bPreviewAllAbilities = true; - UPROPERTY(VisibleDefaultsOnly, Transient, AdvancedDisplay, Category="UHL AbilitySystemComponent", meta=(EditCondition="bPreviewAllAbilities", MultiLine=true)) - TMap DebugPreviewAbilitiesFromAbilitySets = {}; - - // binding inputs to tags check Readme.MD on how to setup it - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="InputConfig", meta=(EditCondition="!bUseAbilitySystemConfig")) - bool bUseInputConfig = false; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="InputConfig", meta=(EditCondition="bUseInputConfig")) - UUHLInputConfig* InputConfig = nullptr; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="InputConfig", meta=(EditCondition="bUseInputConfig")) - bool bUseAbilityInputCache = false; - // if enabled - caching works only in predefined user windows - ANS_AbilityInputCache_CacheWindow - // if disabled - works always - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="InputConfig", meta=(EditCondition="bUseInputConfig && bUseAbilityInputCache")) - bool bUseInputCacheWindows = true; - - // manage settings in config - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AbilitySystem Config") - bool bUseAbilitySystemConfig = false; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AbilitySystem Config", meta=(EditCondition="bUseAbilitySystemConfig")) - UUHLAbilitySystemConfig* AbilitySystemConfig; - - UFUNCTION(BlueprintCallable, Category="UHL AbilitySystemComponent", meta=(DefaultToSelf="InAvatarActor")) - virtual void InitAbilitySystem(AActor* NewOwner, AActor* InAvatarActor, bool bActivateInitialAbilities = true); - UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="UHL AbilitySystemComponent") - void InitAttributes(); - virtual void InitAttributes_Implementation(); - UFUNCTION(BlueprintCallable, Category="UHL AbilitySystemComponent") - virtual void GiveInitialTags(); - UFUNCTION(BlueprintCallable, Category="UHL AbilitySystemComponent") - virtual void SetAttributes(TMap Attributes_In); - UFUNCTION(BlueprintCallable, Category="UHL AbilitySystemComponent") - virtual void ActivateInitialAbilities(); - - UFUNCTION(BlueprintCallable, Category="UHL AbilitySystemComponent") - virtual void GiveAbilitySet(const UUHLAbilitySet* AbilitySet); - UFUNCTION(BlueprintCallable, Category="UHL AbilitySystemComponent") - virtual void RemoveAbilitySetByTag(const FGameplayTag& GameplayTag); - -/** Input Config **/ - void ProcessAbilityInput(float DeltaTime, bool bGamePaused); - void ClearAbilityInput(); - - virtual void AbilitySpecInputPressed(FGameplayAbilitySpec& Spec) override; - virtual void AbilitySpecInputReleased(FGameplayAbilitySpec& Spec) override; - virtual void AbilityInputTagPressed(const FGameplayTag InputTag); - virtual void AbilityInputTagReleased(const FGameplayTag InputTag); -/** Input Config **/ - - UFUNCTION(BlueprintCallable, Category = "UHL AbilitySystemComponent|AbilityInputCache") - UAbilityInputCache* GetAbilityInputCache() const { return AbilityInputCache; }; - UFUNCTION(BlueprintCallable, Category = "UHL AbilitySystemComponent|AbilityInputCache") - bool CanAddAbilityToCache(UUHLGameplayAbility* GameplayAbility_In) const; - - UFUNCTION(BlueprintCallable, Category="UHL AbilitySystemComponent") - virtual bool TryActivateAbilityWithTag(FGameplayTag GameplayTag, bool bAllowRemoteActivation = true); - UFUNCTION(BlueprintCallable, Category="UHL AbilitySystemComponent") - virtual bool TryCancelAbilityWithTag(FGameplayTag GameplayTag); - UFUNCTION(BlueprintCallable, Category="UHL AbilitySystemComponent") - virtual TArray TryCancelAbilitiesWithTags(TArray GameplayTags); - UFUNCTION(BlueprintCallable, Category="UHL AbilitySystemComponent") - virtual void RemoveLooseGameplayTagCompletly(const FGameplayTag& GameplayTag); - UFUNCTION(BlueprintCallable, Category="UHL AbilitySystemComponent") - virtual bool IsAbilityActive(FGameplayTag GameplayTag) const; - - UFUNCTION(BlueprintCallable, Category="UHL AbilitySystemComponent") - virtual int32 FireGameplayEvent(FGameplayTag EventTag, const FGameplayEventData& Payload); - -protected: - virtual void BeginPlay() override; - virtual void OnUnregister() override; - -#if WITH_EDITOR - virtual bool CanEditChange(const FProperty* InProperty) const override; - virtual void PostInitProperties() override; - virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override; - void UpdatePreviewAbilitiesMap(); -#endif - -private: - UPROPERTY() - TObjectPtr AbilityInputCache; - - // Handles to abilities that had their input pressed this frame. - TArray InputPressedSpecHandles; - // Handles to abilities that had their input released this frame. - TArray InputReleasedSpecHandles; - // Handles to abilities that have their input held. - TArray InputHeldSpecHandles; - // AbilitySets given to ASC - TArray AbilitySetGrantedHandles; - - void FillSettingsFromConfig(const FUHLAbilitySystemSettings& AbilitySystemConfig_In); -}; diff --git a/Source/UHLGAS/Public/UHLAbilitySystemConfig.h b/Source/UHLGAS/Public/UHLAbilitySystemConfig.h deleted file mode 100644 index aaab97a4..00000000 --- a/Source/UHLGAS/Public/UHLAbilitySystemConfig.h +++ /dev/null @@ -1,85 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "AttributeSet.h" -#include "GameplayTagContainer.h" -#include "Engine/DataAsset.h" -#include "UHLAbilitySystemConfig.generated.h" - -class UGameplayAbility; -class UUHLAbilitySet; -class UUHLInputConfig; -class UAttributeSet; - -USTRUCT(BlueprintType) -struct FUHLAbilitySystemSettings -{ - GENERATED_BODY() - -public: - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AbilitySystemSettings", meta=(InlineEditConditionToggle)) - bool bInitializeGameplayAttributes = true; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AbilitySystemSettings", meta=(ForceInlineRow, EditCondition="bInitializeGameplayAttributes")) - TMap InitialAttributes = {}; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AbilitySystemSettings", meta=(InlineEditConditionToggle)) - bool bGiveAbilitiesOnStart = true; - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="AbilitySystemSettings", meta=(EditCondition="bGiveAbilitiesOnStart")) - TArray> Abilities = {}; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AbilitySystemSettings", meta=(InlineEditConditionToggle)) - bool bGiveAttributesSetsOnStart = true; - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="AbilitySystemSettings", meta=(EditCondition="bGiveAttributesSetsOnStart")) - TArray> AttributeSets = {}; - - // TODO replace by "EUHLAbilityActivationPolicy::OnSpawn" - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AbilitySystemSettings", meta=(InlineEditConditionToggle)) - bool bActivateAbilitiesOnStart = true; - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="AbilitySystemSettings", meta=(EditCondition="bActivateAbilitiesOnStart")) - TArray ActiveAbilitiesOnStart = {}; - - // TODO initial GameplayEffects? - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AbilitySystemSettings", meta=(InlineEditConditionToggle)) - bool bGiveInitialGameplayTags = true; - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="AbilitySystemSettings", meta=(EditCondition="bGiveInitialGameplayTags")) - FGameplayTagContainer InitialGameplayTags; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AbilitySystemSettings", AdvancedDisplay, meta=(InlineEditConditionToggle)) - bool bGiveAbilitySetsOnStart = true; - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="AbilitySystemSettings", AdvancedDisplay, meta=(EditCondition="bGiveAbilitySetsOnStart")) - TArray AbilitySets = {}; - - UPROPERTY(EditAnywhere, Transient, BlueprintReadWrite, Category="AbilitySystemSettings", AdvancedDisplay, meta=(InlineEditConditionToggle)) - bool bPreviewAllAbilities = true; - UPROPERTY(VisibleDefaultsOnly, Transient, Category="AbilitySystemSettings", AdvancedDisplay, meta=(EditCondition="bPreviewAllAbilities", MultiLine=true)) - TMap DebugPreviewAbilitiesFromAbilitySets = {}; - - // binding inputs to tags check Readme.MD on how to setup it - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="InputConfig") - bool bUseInputConfig = false; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="InputConfig", meta=(EditCondition="bUseInputConfig")) - UUHLInputConfig* InputConfig = nullptr; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="InputConfig", meta=(EditCondition="bUseInputConfig")) - bool bUseAbilityInputCache = false; - // if enabled - caching works only in predefined user windows - ANS_AbilityInputCache_CacheWindow - // if disabled - works always - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="InputConfig", meta=(EditCondition="bUseInputConfig && bUseAbilityInputCache")) - bool bUseInputCacheWindows = true; -}; - -/** - * if you want to set default values like "AttributeSets" or something just nest from this - */ -UCLASS(Blueprintable, BlueprintType) -class UHLGAS_API UUHLAbilitySystemConfig : public UPrimaryDataAsset -{ - GENERATED_BODY() - -public: - UUHLAbilitySystemConfig(); - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AbilitySystemConfig", meta=(ShowOnlyInnerProperties)) - FUHLAbilitySystemSettings Settings; -}; diff --git a/Source/UHLGAS/Public/UHLGAS.h b/Source/UHLGAS/Public/UHLGAS.h deleted file mode 100644 index 45241fe1..00000000 --- a/Source/UHLGAS/Public/UHLGAS.h +++ /dev/null @@ -1,15 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "Modules/ModuleManager.h" - -UHLGAS_API DECLARE_LOG_CATEGORY_EXTERN(LogUHLAbilitySystem, Log, All); - -class FUHLGASModule : public IModuleInterface -{ -public: - /** IModuleInterface implementation */ - virtual void StartupModule() override; - virtual void ShutdownModule() override; -}; diff --git a/Source/UHLGAS/Public/UHLGASBlueprintLibrary.h b/Source/UHLGAS/Public/UHLGASBlueprintLibrary.h deleted file mode 100644 index 4aed7ef6..00000000 --- a/Source/UHLGAS/Public/UHLGASBlueprintLibrary.h +++ /dev/null @@ -1,91 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "GameplayEffect.h" -#include "UHLAbilitySystemComponent.h" -#include "AssetRegistry/AssetData.h" -#include "Kismet/BlueprintFunctionLibrary.h" -#include "UHLGASBlueprintLibrary.generated.h" - -class UWidget; -struct FBlackboardKeySelector; - -// TODO improve -// - validations if Actor1/Actors2 is nullptr - DebugPrintString it -// - keywords for every method - -/* - * Function library class. - * Each function in it is expected to be static and represents blueprint node that can be called in any blueprint. - * - * When declaring function you can define metadata for the node. Key function specifiers will be BlueprintPure and BlueprintCallable. - * BlueprintPure - means the function does not affect the owning object in any way and thus creates a node without Exec pins. - * BlueprintCallable - makes a function which can be executed in Blueprints - Thus it has Exec pins. - * DisplayName - full name of the node, shown when you mouse over the node and in the blueprint drop down menu. - * Its lets you name the node using characters not allowed in C++ function names. - * CompactNodeTitle - the word(s) that appear on the node. - * Keywords - the list of keywords that helps you to find node when you search for it using Blueprint drop-down menu. - * Good example is "Print String" node which you can find also by using keyword "log". - * Category - the category your node will be under in the Blueprint drop-down menu. - * - * For more info on custom blueprint nodes visit documentation: - * https://wiki.unrealengine.com/Custom_Blueprint_Node_Creation - */ -UCLASS() -class UHLGAS_API UUHLGASBlueprintLibrary : public UBlueprintFunctionLibrary -{ - GENERATED_BODY() - -public: - /** Tries to find an ability system component on the actor, will use AbilitySystemInterface or fall back to a component search */ - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary", Meta=(DefaultToSelf = "Actor")) - static UUHLAbilitySystemComponent* GetUHLAbilitySystemComponent(AActor* Actor); - - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|GAS", meta = (Keywords = "UnrealHelperLibrary debug GAS Development")) - static FGameplayEffectSpec CreateGenericGASGameplayEffectSpec( - TSubclassOf GameplayEffectClass, AActor* HitInstigator, AActor* InEffectCauser, const FHitResult& HitResult, const UObject* SourceObject); - - /** - * UUnrealHelperLibraryBPL::UpdateStateGameplayTags(ASC, GetMovementComponent()->Velocity.Length() > 0, - UHLGameplayTags::TAG_Character_State_IsMoving, - UHLGameplayTags::TAG_Character_State_IsIdling); - bCondition = true ? TAG_Character_State_IsMoving : TAG_Character_State_IsIdling - - UUnrealHelperLibraryBPL::UpdateStateGameplayTags(ASC, CharacterMovementVector.Length() > 0.4f, - UHLGameplayTags::TAG_Character_State_HasMoveInput, - FGameplayTag::EmptyTag); - bCondition = true ? TAG_Character_State_HasMoveInput : NONE - */ - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|GAS", meta = (Keywords = "UnrealHelperLibrary ability")) - static void UpdateStateGameplayTags(UAbilitySystemComponent* ASC, bool bCondition, FGameplayTag PositiveConditionTag, FGameplayTag NegativeConditionTag, bool bShouldReplicate = false); - - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|GAS", meta = (Keywords = "UnrealHelperLibrary ability")) - static bool IsAbilityActiveByTag(const UAbilitySystemComponent* ASC, FGameplayTag GameplayTag); - - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|GAS", meta = (Keywords = "UnrealHelperLibrary ability")) - static bool TryActivateAbilityWithTag(UAbilitySystemComponent* ASC, FGameplayTag GameplayTag, bool bAllowRemoteActivation); - - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|GAS", meta = (Keywords = "UnrealHelperLibrary ability")) - static bool TryCancelAbilityWithTag(UAbilitySystemComponent* ASC, FGameplayTag GameplayTag); - - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|GAS", meta = (Keywords = "UnrealHelperLibrary ability")) - static bool ToggleAbilityWithTag(UAbilitySystemComponent* ASC, FGameplayTag GameplayTag, bool bAllowRemoteActivation); - - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|GAS", meta = (Keywords = "UnrealHelperLibrary ability")) - static TArray TryCancelAbilitiesWithTags(UAbilitySystemComponent* ASC, TArray GameplayTags); - - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|GAS", meta = (Keywords = "UnrealHelperLibrary ability event fire")) - static int32 FireGameplayEvent(UAbilitySystemComponent* ASC, FGameplayTag EventTag, const FGameplayEventData& Payload); - - // "FGameplayTag::RequestGameplayTag()" crashes build on start, use this to find tag - // function from Lyra - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|GAS", meta = (Keywords = "UnrealHelperLibrary gameplaytag tag")) - static FGameplayTag FindTagByString(const FString& TagString, bool bMatchPartialString = false); - - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|GAS", meta = (Keywords = "UnrealHelperLibrary gameplaytag tag")) - static void FindAbilitySpecByTag(const TArray& AbilitiesSpecsContainer, FGameplayTag TagToFind, FGameplayAbilitySpec& AbilitySpec_Out); - - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|GAS", meta = (Keywords = "UnrealHelperLibrary gameplaytag tag")) - static void FindAbilitySpecByTagUsingASC(UAbilitySystemComponent* ASC, FGameplayTag TagToFind, FGameplayAbilitySpec& AbilitySpec_Out); -}; diff --git a/Source/UHLGAS/UHLGAS.Build.cs b/Source/UHLGAS/UHLGAS.Build.cs deleted file mode 100644 index dfc512ec..00000000 --- a/Source/UHLGAS/UHLGAS.Build.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -using UnrealBuildTool; - -public class UHLGAS : ModuleRules -{ - public UHLGAS(ReadOnlyTargetRules Target) : base(Target) - { - PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; - - PublicIncludePaths.AddRange( - new string[] { - // ... add public include paths required here ... - } - ); - - - PrivateIncludePaths.AddRange( - new string[] { - // ... add other private include paths required here ... - } - ); - - - PublicDependencyModuleNames.AddRange( - new string[] - { - "Core", - // ... add other public dependencies that you statically link with here ... - "GameplayAbilities", - "GameplayTags", - "GameplayTasks", - "EnhancedInput", - - "NiagaraAnimNotifies", - } - ); - - - PrivateDependencyModuleNames.AddRange( - new string[] - { - "CoreUObject", - "Engine", - - "DeveloperSettings", - - "UnrealHelperLibrary", - "UHLDebugSystem", - "UHLAI", - } - ); - - - DynamicallyLoadedModuleNames.AddRange( - new string[] - { - // ... add any modules that your module loads dynamically here ... - } - ); - } -} diff --git a/Source/UHLModulesHelper/Private/UHLConfigMigrationUtils.cpp b/Source/UHLModulesHelper/Private/UHLConfigMigrationUtils.cpp deleted file mode 100644 index 6770131a..00000000 --- a/Source/UHLModulesHelper/Private/UHLConfigMigrationUtils.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#include "UHLConfigMigrationUtils.h" - -namespace UHLConfigMigrationUtils -{ - bool MigrateConfigSectionIfNeeded( - const FString& FromSection, const FString& ToSection, - const FString& MigrationKey, - const FString& FromConfigFile, const FString& ToConfigFile) - { - // Check if migration has already been done. - bool bMigrationDone = false; - GConfig->GetBool(*ToSection, *MigrationKey, bMigrationDone, ToConfigFile); - if (bMigrationDone) - { - UE_LOG(LogTemp, Log, TEXT("Migration already completed.")); - return false; - } - - // Retrieve all lines from the old section. - TArray SectionLines; - if (GConfig->GetSection(*FromSection, SectionLines, FromConfigFile)) - { - UE_LOG(LogTemp, Log, TEXT("Found %d lines in the old section."), SectionLines.Num()); - for (const FString& Line : SectionLines) - { - FString Key, Value; - // Split the line into Key and Value. - if (Line.Split(TEXT("="), &Key, &Value)) - { - Key = Key.TrimStartAndEnd(); - Value = Value.TrimStartAndEnd(); - UE_LOG(LogTemp, Log, TEXT("Migrating key: %s with value: %s"), *Key, *Value); - GConfig->AddToSection(*ToSection, *Key, *Value, ToConfigFile); - } - else - { - UE_LOG(LogTemp, Warning, TEXT("Failed to split line: %s"), *Line); - } - } - - // Mark the migration as done. - GConfig->SetBool(*ToSection, *MigrationKey, true, ToConfigFile); - // Flush all changes to disk. - GConfig->Flush(true, ToConfigFile); - } - else - { - UE_LOG(LogTemp, Warning, TEXT("Old settings section %s not found in %s"), *FromSection, *FromConfigFile); - } - - return true; - } -} diff --git a/Source/UHLModulesHelper/Private/UHLModulesHelper.cpp b/Source/UHLModulesHelper/Private/UHLModulesHelper.cpp deleted file mode 100644 index 773b5550..00000000 --- a/Source/UHLModulesHelper/Private/UHLModulesHelper.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UHLModulesHelper.h" - -#include "Misc/Paths.h" -#include "GameplayTagsManager.h" - -#define LOCTEXT_NAMESPACE "FUHLModulesHelperModule" - - -void FUHLModulesHelperModule::StartupModule() -{ -} - -void FUHLModulesHelperModule::ShutdownModule() -{ - // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, - // we call this function before unloading the module. -} - -#undef LOCTEXT_NAMESPACE - -IMPLEMENT_MODULE(FUHLModulesHelperModule, UHLModulesHelper) diff --git a/Source/UHLModulesHelper/Public/UHLConfigMigrationUtils.h b/Source/UHLModulesHelper/Public/UHLConfigMigrationUtils.h deleted file mode 100644 index 2db9e9ed..00000000 --- a/Source/UHLModulesHelper/Public/UHLConfigMigrationUtils.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -namespace UHLConfigMigrationUtils -{ - /** - * Utility to migrate all config keys from one section to another. - * WARNING migration will be done only when you change your settings - * - * @param FromSection config section from which your config will be migrated e.g. TEXT("/Script/UnrealHelperLibrary.UHLDebugSubsystemSettings") - * @param ToSection config section to which your config will be migrated e.g. TEXT("/Script/UHLDebug.UHLDebugSubsystemSettings") - * @param MigrationKey property in your class that will be used as marker that migration completed, required to create UPROPERTY(config) for this - * @param FromConfigFile config file that will be used to get config section - * @param ToConfigFile config file that will be used to set config section - * @return bool if successfully migrated - */ - UHLMODULESHELPER_API bool MigrateConfigSectionIfNeeded( - const FString& FromSection, - const FString& ToSection, - const FString& MigrationKey, - const FString& FromConfigFile, - const FString& ToConfigFile - ); -} diff --git a/Source/UHLModulesHelper/Public/UHLModulesHelper.h b/Source/UHLModulesHelper/Public/UHLModulesHelper.h deleted file mode 100644 index 793a490a..00000000 --- a/Source/UHLModulesHelper/Public/UHLModulesHelper.h +++ /dev/null @@ -1,14 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "Modules/ModuleManager.h" - - -class FUHLModulesHelperModule : public IModuleInterface -{ -public: - /** IModuleInterface implementation */ - virtual void StartupModule() override; - virtual void ShutdownModule() override; -}; diff --git a/Source/UHLModulesHelper/UHLModulesHelper.Build.cs b/Source/UHLModulesHelper/UHLModulesHelper.Build.cs deleted file mode 100644 index f97130c8..00000000 --- a/Source/UHLModulesHelper/UHLModulesHelper.Build.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -using UnrealBuildTool; - -public class UHLModulesHelper : ModuleRules -{ - public UHLModulesHelper(ReadOnlyTargetRules Target) : base(Target) - { - PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; - - PublicIncludePaths.AddRange( - new string[] { - // ... add public include paths required here ... - } - ); - - - PrivateIncludePaths.AddRange( - new string[] { - // ... add other private include paths required here ... - } - ); - - - PublicDependencyModuleNames.AddRange( - new string[] - { - "Core", - // ... add other public dependencies that you statically link with here ... - } - ); - - - PrivateDependencyModuleNames.AddRange( - new string[] - { - "CoreUObject", - "Engine", - } - ); - - - DynamicallyLoadedModuleNames.AddRange( - new string[] - { - // ... add any modules that your module loads dynamically here ... - } - ); - } -} diff --git a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_ChangeCapsuleBase.cpp b/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_ChangeCapsuleBase.cpp deleted file mode 100644 index ac553286..00000000 --- a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_ChangeCapsuleBase.cpp +++ /dev/null @@ -1,325 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "Animation/Notifies/ANS_ChangeCapsuleBase.h" - -#include "Components/CapsuleComponent.h" -#include "DrawDebugHelpers.h" - -void UANS_ChangeCapsuleBase::NotifyBegin( - USkeletalMeshComponent* MeshComp, - UAnimSequenceBase* Animation, - float TotalDuration, - const FAnimNotifyEventReference& EventReference -) -{ - Super::NotifyBegin(MeshComp, Animation, TotalDuration, EventReference); - - ElapsedTime = 0.0f; - NotifyTotalDuration = TotalDuration; - bHasValidOriginals = false; - CapsuleComp = nullptr; - - if (!MeshComp) - { - return; - } - - // Let the subclass find its capsule component - CapsuleComp = FindCapsuleComponent(MeshComp); - if (!CapsuleComp) - { - return; - } - - // Store “original” values immediately - OriginalRadius = CapsuleComp->GetUnscaledCapsuleRadius(); - OriginalHalfHeight = CapsuleComp->GetUnscaledCapsuleHalfHeight(); - OriginalScale = CapsuleComp->GetRelativeScale3D(); - OriginalShapeColor = CapsuleComp->ShapeColor.ReinterpretAsLinear(); - - // Compute and cache “target” values now - TargetRadius = bModifyRadius ? NewRadius : OriginalRadius; - TargetHalfHeight = bModifyHalfHeight ? NewHalfHeight : OriginalHalfHeight; - TargetScale = bModifyScale ? NewScale : OriginalScale; - TargetLineThickness = bModifyLineThickness ? NewLineThickness : OriginalLineThickness; - TargetShapeColor = bModifyShapeColor ? NewShapeColor : OriginalShapeColor; - - bHasValidOriginals = true; - - // --- Construct FAlphaBlend for blend-in using FAlphaBlendArgs --- - { - FAlphaBlendArgs InArgs; - InArgs.BlendTime = (BlendTimeIn > KINDA_SMALL_NUMBER) ? BlendTimeIn : 0.0f; - InArgs.BlendOption = BlendOptionIn; - BlendInAlpha = FAlphaBlend(InArgs); - } - - // --- Construct FAlphaBlend for blend-out using FAlphaBlendArgs --- - { - FAlphaBlendArgs OutArgs; - OutArgs.BlendTime = (BlendTimeOut > KINDA_SMALL_NUMBER) ? BlendTimeOut : 0.0f; - OutArgs.BlendOption = BlendOptionOut; - BlendOutAlpha = FAlphaBlend(OutArgs); - } - - // If instant blend-in, snap right away to the “target” values - if (BlendTimeIn <= KINDA_SMALL_NUMBER) - { - if (bModifyRadius) - { - CapsuleComp->SetCapsuleRadius(TargetRadius, /*bUpdateOverlaps=*/ false); - } - if (bModifyHalfHeight) - { - CapsuleComp->SetCapsuleHalfHeight(TargetHalfHeight, /*bUpdateOverlaps=*/ false); - } - if (bModifyScale) - { - CapsuleComp->SetRelativeScale3D(TargetScale); - } - if (bModifyLineThickness) - { - CapsuleComp->SetLineThickness(TargetLineThickness); - } - if (bModifyShapeColor) - { - CapsuleComp->ShapeColor = TargetShapeColor.ToFColor(/*bSRGB=*/ true); - } - } - // Otherwise, leave them at “original” until NotifyTick interpolates - - SaveOriginalCollisionSettings(); - ApplyCollisionSettings(); -} - -void UANS_ChangeCapsuleBase::NotifyTick( - USkeletalMeshComponent* MeshComp, - UAnimSequenceBase* Animation, - float FrameDeltaTime, - const FAnimNotifyEventReference& EventReference -) -{ - Super::NotifyTick(MeshComp, Animation, FrameDeltaTime, EventReference); - - if (!bHasValidOriginals || !CapsuleComp) - { - return; - } - - ElapsedTime += FrameDeltaTime; - - // 1) Compute “raw alpha” in [0..1] based on blend-in / hold / blend-out - float RawAlpha = 1.0f; - - // a) Blend-in phase - if (BlendTimeIn > KINDA_SMALL_NUMBER && ElapsedTime < BlendTimeIn) - { - BlendInAlpha.Update(FrameDeltaTime); - RawAlpha = BlendInAlpha.GetBlendedValue(); - } - // b) Hold at target (after blend-in, before blend-out) - else if (ElapsedTime >= BlendTimeIn && ElapsedTime <= (NotifyTotalDuration - BlendTimeOut)) - { - RawAlpha = 1.0f; - } - // c) Blend-out phase - else if (BlendTimeOut > KINDA_SMALL_NUMBER && ElapsedTime > (NotifyTotalDuration - BlendTimeOut)) - { - float OutElapsed = ElapsedTime - (NotifyTotalDuration - BlendTimeOut); - BlendOutAlpha.Update(FrameDeltaTime); - RawAlpha = 1.0f - BlendOutAlpha.GetBlendedValue(); - } - // d) Otherwise (zero‐blend cases), RawAlpha stays 1.0 - - RawAlpha = FMath::Clamp(RawAlpha, 0.0f, 1.0f); - - // 2) If user provided an EaseCurve, remap RawAlpha - if (EaseCurve.GetRichCurveConst() && EaseCurve.GetRichCurveConst()->GetNumKeys() > 0) - { - float Curved = EaseCurve.GetRichCurveConst()->Eval(RawAlpha); - RawAlpha = FMath::Clamp(Curved, 0.0f, 1.0f); - } - - // 3) Lerp each property from “original” → “target” using RawAlpha - float CurrentRadius = OriginalRadius; - float CurrentHalfHeight = OriginalHalfHeight; - FVector CurrentScale = OriginalScale; - float CurrentLineThickness = OriginalLineThickness; - FLinearColor CurrentShapeColor = OriginalShapeColor; - - if (bModifyRadius) - { - CurrentRadius = FMath::Lerp(OriginalRadius, TargetRadius, RawAlpha); - CapsuleComp->SetCapsuleRadius(CurrentRadius, /*bUpdateOverlaps=*/ false); - } - if (bModifyHalfHeight) - { - CurrentHalfHeight = FMath::Lerp(OriginalHalfHeight, TargetHalfHeight, RawAlpha); - CapsuleComp->SetCapsuleHalfHeight(CurrentHalfHeight, /*bUpdateOverlaps=*/ false); - } - if (bModifyScale) - { - CurrentScale = FMath::Lerp(OriginalScale, TargetScale, RawAlpha); - CapsuleComp->SetRelativeScale3D(CurrentScale); - } - if (bModifyLineThickness) - { - CurrentLineThickness = FMath::Lerp(OriginalLineThickness, TargetLineThickness, RawAlpha); - CapsuleComp->SetLineThickness(CurrentLineThickness); - } - if (bModifyShapeColor) - { - CurrentShapeColor = FMath::Lerp(OriginalShapeColor, TargetShapeColor, RawAlpha); - CapsuleComp->ShapeColor = CurrentShapeColor.ToFColor(/*bSRGB=*/ true); - } - - // 4) If bDebug is true, draw a wireframe debug capsule using the current interpolated values - if (bDebug && CapsuleComp) - { - FVector Location = CapsuleComp->GetComponentLocation(); - FRotator Rotation = CapsuleComp->GetComponentRotation(); - const FVector CompScale = CapsuleComp->GetComponentScale(); - float DrawRadius = CurrentRadius * FMath::Max(CompScale.X, CompScale.Y); - float DrawHalfHeight = CurrentHalfHeight * CompScale.Z; - FColor DebugColor = FColor::Yellow; - float LifeTime = 0.0f; // one frame - uint8 DepthPriority = 0; // Normal - float Thickness = 1.0f; - - DrawDebugCapsule( - CapsuleComp->GetWorld(), - Location, - DrawHalfHeight, - DrawRadius, - Rotation.Quaternion(), - DebugColor, - false, - LifeTime, - DepthPriority, - Thickness - ); - } -} - -void UANS_ChangeCapsuleBase::NotifyEnd( - USkeletalMeshComponent* MeshComp, - UAnimSequenceBase* Animation, - const FAnimNotifyEventReference& EventReference -) -{ - Super::NotifyEnd(MeshComp, Animation, EventReference); - - if (!bHasValidOriginals || !CapsuleComp) - { - return; - } - - // Always restore every modified property back to its original value - if (bModifyRadius) - { - CapsuleComp->SetCapsuleRadius(OriginalRadius, /*bUpdateOverlaps=*/ false); - } - if (bModifyHalfHeight) - { - CapsuleComp->SetCapsuleHalfHeight(OriginalHalfHeight, /*bUpdateOverlaps=*/ false); - } - if (bModifyScale) - { - CapsuleComp->SetRelativeScale3D(OriginalScale); - } - if (bModifyLineThickness) - { - CapsuleComp->SetLineThickness(OriginalLineThickness); - } - if (bModifyShapeColor) - { - CapsuleComp->ShapeColor = OriginalShapeColor.ToFColor(/*bSRGB=*/ true); - } - - // Clear internal pointers & flags - CapsuleComp = nullptr; - bHasValidOriginals = false; - ElapsedTime = 0.0f; - NotifyTotalDuration = 0.0f; - - RestoreOriginalCollisionSettings(); -} - -void UANS_ChangeCapsuleBase::SaveOriginalCollisionSettings() -{ - if (!CapsuleComp) return; - - // Collision Enabled - OriginalCapsuleSettings.CollisionEnabled = CapsuleComp->GetCollisionEnabled(); - OriginalCapsuleSettings.bForceQueryOnly = false; - OriginalCapsuleSettings.bOverrideCollisionEnabled = true; - - // Profile Name - OriginalCapsuleSettings.CollisionProfileName = CapsuleComp->GetCollisionProfileName(); - OriginalCapsuleSettings.bOverrideCollisionProfileName = true; - - // Overlap Events - OriginalCapsuleSettings.bGenerateOverlapEvents = CapsuleComp->GetGenerateOverlapEvents(); - OriginalCapsuleSettings.bOverrideGenerateOverlapEvents = true; - - // Custom Responses - OriginalCapsuleSettings.CustomResponses.Empty(); - for (int32 Chan = 0; Chan < ECollisionChannel::ECC_MAX; ++Chan) - { - OriginalCapsuleSettings.CustomResponses.Add( - static_cast(Chan), - CapsuleComp->GetCollisionResponseToChannel((ECollisionChannel)Chan) - ); - } - OriginalCapsuleSettings.bOverrideCustomResponses = true; -} - -void UANS_ChangeCapsuleBase::RestoreOriginalCollisionSettings() -{ - if (!CapsuleComp) return; - - // Restore enabled & profile - CapsuleComp->SetCollisionEnabled(OriginalCapsuleSettings.CollisionEnabled); - CapsuleComp->SetCollisionProfileName(OriginalCapsuleSettings.CollisionProfileName); - - // Restore overlap - CapsuleComp->SetGenerateOverlapEvents(OriginalCapsuleSettings.bGenerateOverlapEvents); - - // Restore responses - for (auto& Pair : OriginalCapsuleSettings.CustomResponses) - { - CapsuleComp->SetCollisionResponseToChannel(Pair.Key, Pair.Value); - } -} - -void UANS_ChangeCapsuleBase::ApplyCollisionSettings() -{ - if (!CapsuleComp) return; - - // Apply overrides - if (CapsuleCollisionSettings.bOverrideCollisionEnabled) - { - // Use if-else instead of ternary to prevent ambiguity - ECollisionEnabled::Type NewMode = CapsuleCollisionSettings.CollisionEnabled; - if (CapsuleCollisionSettings.bForceQueryOnly) - { - NewMode = ECollisionEnabled::QueryOnly; - } - CapsuleComp->SetCollisionEnabled(NewMode); - } - if (CapsuleCollisionSettings.bOverrideCollisionProfileName) - { - CapsuleComp->SetCollisionProfileName(CapsuleCollisionSettings.CollisionProfileName); - } - if (CapsuleCollisionSettings.bOverrideGenerateOverlapEvents) - { - CapsuleComp->SetGenerateOverlapEvents(CapsuleCollisionSettings.bGenerateOverlapEvents); - } - if (CapsuleCollisionSettings.bOverrideCustomResponses) - { - for (auto& Pair : CapsuleCollisionSettings.CustomResponses) - { - CapsuleComp->SetCollisionResponseToChannel(Pair.Key, Pair.Value); - } - } -} diff --git a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_ChangeCharacterCapsule.cpp b/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_ChangeCharacterCapsule.cpp deleted file mode 100644 index de1f814d..00000000 --- a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_ChangeCharacterCapsule.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "Animation/Notifies/ANS_ChangeCharacterCapsule.h" - -#include "GameFramework/Character.h" -#include "Components/CapsuleComponent.h" - -UCapsuleComponent* UANS_ChangeCharacterCapsule::FindCapsuleComponent(USkeletalMeshComponent* MeshComp) const -{ - if (!MeshComp) - { - return nullptr; - } - - AActor* OwningActor = MeshComp->GetOwner(); - if (!OwningActor) - { - return nullptr; - } - - if (ACharacter* CharOwner = Cast(OwningActor)) - { - return CharOwner->GetCapsuleComponent(); - } - - return nullptr; -} diff --git a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_ChangeNamedCapsule.cpp b/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_ChangeNamedCapsule.cpp deleted file mode 100644 index d9f51e72..00000000 --- a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_ChangeNamedCapsule.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "Animation/Notifies/ANS_ChangeNamedCapsule.h" - -#include "Components/CapsuleComponent.h" -#include "GameFramework/Actor.h" - -UCapsuleComponent* UANS_ChangeNamedCapsule::FindCapsuleComponent(USkeletalMeshComponent* MeshComp) const -{ - if (!MeshComp) - { - return nullptr; - } - - AActor* OwningActor = MeshComp->GetOwner(); - if (!OwningActor || CapsuleComponentName.IsNone()) - { - return nullptr; - } - - TArray FoundComps; - OwningActor->GetComponents(FoundComps); - - for (UCapsuleComponent* Cap : FoundComps) - { - if (Cap && Cap->GetFName() == CapsuleComponentName) - { - return Cap; - } - } - - return nullptr; -} diff --git a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_ChangeRotationRate.cpp b/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_ChangeRotationRate.cpp deleted file mode 100644 index d5584c45..00000000 --- a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_ChangeRotationRate.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Animation/Notifies/ANS_ChangeRotationRate.h" - -#include "GameFramework/Character.h" -#include "GameFramework/CharacterMovementComponent.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(ANS_ChangeRotationRate) - -FString UANS_ChangeRotationRate::GetNotifyName_Implementation() const -{ - return FString::Printf( - TEXT("Change RotationRate to Pitch=%.2f, Yaw=%.2f, Roll=%.2f"), - RotationRate.Pitch, - RotationRate.Yaw, - RotationRate.Roll - ); -} - -void UANS_ChangeRotationRate::NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyBegin(MeshComp, Animation, TotalDuration, EventReference); - - ACharacter* Character = Cast(MeshComp->GetOwner()); - if (!Character) return; - - CharacterMovementComponent = Character->GetCharacterMovement(); - if (!CharacterMovementComponent.IsValid()) return; - - // UUHLCharacterMovementComponent* UHLCMC = GetUHLCharacterMovementComponent(Character); - // if (!UHLCMC) return; - - // InitialRotationRate = UHLCMC->RotationRate; - // UHLCMC->SetRotationRate(RotationRate); - - InitialRotationRate = CharacterMovementComponent->RotationRate; - CharacterMovementComponent->RotationRate = RotationRate; -} - -void UANS_ChangeRotationRate::NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) -{ - ReturnInitialRotationRate(); - - Super::NotifyEnd(MeshComp, Animation, EventReference); -} - -void UANS_ChangeRotationRate::OnMontageBlendingOut(UAnimMontage* Montage, bool bInterrupted) -{ - if (CharacterMovementComponent.IsValid()) - { - ReturnInitialRotationRate(); - } -} - -void UANS_ChangeRotationRate::ReturnInitialRotationRate() -{ - if (CharacterMovementComponent.IsValid()) - { - CharacterMovementComponent->RotationRate = InitialRotationRate; - } -} - -// UUHLCharacterMovementComponent* UANS_ChangeRotationRate::GetUHLCharacterMovementComponent(ACharacter* Character) -// { -// UCharacterMovementComponent* CharacterMovementComponent = Character->GetCharacterMovement(); -// if (CharacterMovementComponent) -// { -// UUHLCharacterMovementComponent* UHLCharacterMovementComponent = Cast(CharacterMovementComponent); -// if (UHLCharacterMovementComponent) -// { -// return UHLCharacterMovementComponent; -// } -// } -// return nullptr; -// } diff --git a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_EnableRootMotionZAxisMovement.cpp b/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_EnableRootMotionZAxisMovement.cpp deleted file mode 100644 index d963994c..00000000 --- a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_EnableRootMotionZAxisMovement.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Animation/Notifies/ANS_EnableRootMotionZAxisMovement.h" - -#include "GameFramework/Character.h" -#include "GameFramework/CharacterMovementComponent.h" -#include "Animation/AnimInstance.h" -#include "Components/CapsuleComponent.h" -#include "Components/SkeletalMeshComponent.h" -#include "Utils/UHLTraceUtilsBPL.h" -#include "Utils/UnrealHelperLibraryBPL.h" -#include "DrawDebugHelpers.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(ANS_EnableRootMotionZAxisMovement) - -UANS_EnableRootMotionZAxisMovement::UANS_EnableRootMotionZAxisMovement(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - LandCheckBlendOutSettings = FMontageBlendSettings(); - LandCheckBlendOutSettings.Blend = 1.0f; - LandCheckBlendOutSettings.BlendMode = EMontageBlendMode::Inertialization; -} - -void UANS_EnableRootMotionZAxisMovement::NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyBegin(MeshComp, Animation, TotalDuration, EventReference); - - ACharacter* BaseCharacter = Cast(MeshComp->GetOwner()); - if (!BaseCharacter) return; - - UCharacterMovementComponent* MovementComponent = BaseCharacter->GetCharacterMovement(); - InitialMovementMode = MovementComponent->MovementMode; - MovementComponent->SetMovementMode(MOVE_Flying); -} - -void UANS_EnableRootMotionZAxisMovement::NotifyEndOrBlendOut(USkeletalMeshComponent* MeshComp) -{ - Super::NotifyEndOrBlendOut(MeshComp); - - if (!MeshComp) return; - - ACharacter* BaseCharacter = Cast(MeshComp->GetOwner()); - if (!BaseCharacter) return; - - UCharacterMovementComponent* MovementComponent = BaseCharacter->GetCharacterMovement(); - if (MovementComponent->MovementMode == MOVE_Flying) - { - MovementComponent->SetMovementMode(MOVE_Falling); - } - - // 1) land до окончания, когда например запрыгиваем куда-то - - // а OnLanded в этом случае вообще будет работать, кмк - нет. - // Значит нужно чекать самостоятельно "land" и на MOVE_Falling переключать? - // UPD вообще не нужно ничо чекать, ANS должен закончится до/вовремя Land'а - // а значит никаких проблем с этим нет - // 2) ANS кончился а мы при этом не приземлились на землю и до земли далеко - // нужно Stop'ить montage, а для этого сделать sweep test капсулы вниз - if (bStopMontageIfLandCheckFails) - { - FVector CurrentLocation = BaseCharacter->GetActorLocation(); - FVector EndLocation = CurrentLocation + FVector(0.0f, 0.0f, -LandCheckDistance); - - FCollisionQueryParams CollisionParams; - CollisionParams.AddIgnoredActor(BaseCharacter); - // ignore all attached actors - TArray CharacterAttachedActors; - BaseCharacter->GetAttachedActors(CharacterAttachedActors, false, true); - - FHitResult HitResult; - // TODO use Sphere instead of capsule - bool bHasHit = UUHLTraceUtilsBPL::SweepCapsuleSingleByChannel( - BaseCharacter->GetWorld(), - HitResult, - CurrentLocation, - EndLocation, - BaseCharacter->GetCapsuleComponent()->GetScaledCapsuleRadius(), - BaseCharacter->GetCapsuleComponent()->GetScaledCapsuleHalfHeight(), - BaseCharacter->GetActorRotation().Quaternion(), - CollisionChannel, - CollisionParams, - FCollisionResponseParams::DefaultResponseParam, - bDebug, - 5.0f, - FColor::Red, - FColor::Yellow, - 0.2f - ); - - if (!bHasHit) - { - // TODO try stop specific montage - // const UAnimMontage* AnimMontage = CurrentAnimMontage.Get(); - // BaseCharacter->StopAnimMontage(); - FAnimMontageInstance* AnimMontage = BaseCharacter->GetRootMotionAnimMontageInstance(); - if (AnimMontage && AnimMontage->IsValid()) - { - AnimMontage->PushDisableRootMotion(); - AnimMontage->Stop(LandCheckBlendOutSettings, false); - } - else - { - UUnrealHelperLibraryBPL::DebugPrintString( - BaseCharacter->GetWorld(), - FString::Printf(TEXT("UANS_EnableRootMotionZAxisMovement::NotifyEndOrBlendOut on %s error root motion AnimMontage not found"), *BaseCharacter->GetName()) - ); - } - } - else - { - if (HitResult.IsValidBlockingHit() && bDebug) - { - DrawDebugString( - BaseCharacter->GetWorld(), HitResult.Location, FString::Printf(TEXT("Land check: %s"), - *HitResult.GetActor()->GetName()), nullptr, - FColor::Green, 5.0f, true, 1.0f - ); - } - } - } -} diff --git a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_MagnetTo.cpp b/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_MagnetTo.cpp deleted file mode 100644 index 3198d700..00000000 --- a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_MagnetTo.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Animation/Notifies/ANS_MagnetTo.h" - -#include "GameFramework/Character.h" -#include "Kismet/KismetMathLibrary.h" -#include "Components/SkeletalMeshComponent.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(ANS_MagnetTo) - -void UANS_MagnetTo::NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyBegin(MeshComp, Animation, TotalDuration, EventReference); - - // Speed = Distance / TotalDuration / 60; - BaseCharacter = Cast(MeshComp->GetOwner()); - - // FTimerHandle TimerHandle; - // MeshComp->GetWorld()->GetTimerManager().SetTimer(TimerHandle, this, &UANS_MagnetTo::TimerTick, 0.0f, true, -1); - - // GetWorld()->GetTimerManager().SetTimer(TimerHandle, this, &ABaseDestructibleActor::FinalDestruct, TimeToDisappear); -} - -void UANS_MagnetTo::NotifyTick(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float FrameDeltaTime, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyTick(MeshComp, Animation, FrameDeltaTime, EventReference); - - Alpha = FMath::Clamp(Alpha + FrameDeltaTime, 0, 1); - FVector NewLocation = BaseCharacter->GetActorLocation(); - float Delta = UKismetMathLibrary::Ease(0, Distance / 1000, Alpha, EEasingFunc::Linear); - NewLocation += BaseCharacter->GetActorForwardVector() * Delta; - BaseCharacter->SetActorLocation(NewLocation, true); - // BaseCharacter.Get()->GetCharacterMovement()->AddForce(BaseCharacter-> GetActorForwardVector() * Distance); -} - -void UANS_MagnetTo::NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyEnd(MeshComp, Animation, EventReference); -} diff --git a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_SpawnAndSwitchPlayerCamera.cpp b/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_SpawnAndSwitchPlayerCamera.cpp deleted file mode 100644 index af8883f6..00000000 --- a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_SpawnAndSwitchPlayerCamera.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Animation/Notifies/ANS_SpawnAndSwitchPlayerCamera.h" - -#include "GameFramework/PlayerController.h" -#include "Kismet/GameplayStatics.h" -#include "Engine/World.h" - -void UANS_SpawnAndSwitchPlayerCamera::NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyBegin(MeshComp, Animation, TotalDuration, EventReference); - - if (!MeshComp || !CameraToSpawnClass) - { - return; - } - - // 1. Get the owning actor and its PlayerController - AActor* OwningActor = MeshComp->GetOwner(); - if (!OwningActor) - { - return; - } - - APlayerController* PC = Cast(OwningActor->GetInstigatorController()); - if (!PC) - { - // If the owning actor isn’t possessed by a PC, try another route - PC = UGameplayStatics::GetPlayerController(OwningActor->GetWorld(), PlayerControllerIndex); - } - if (!PC) - { - return; - } - - // 2. Store the previous view target (so we can return to it later) - PreviousViewTarget = PC->GetViewTarget(); - - // 3. Spawn the camera actor at the owner’s location (or at a specific socket) - FTransform SpawnTransform = OwningActor->GetActorTransform(); - if (AttachSocketName != NAME_None) - { - // If we want to attach to a socket/bone, get its world transform - if (MeshComp->DoesSocketExist(AttachSocketName)) - { - SpawnTransform = MeshComp->GetSocketTransform(AttachSocketName); - } - } - - FActorSpawnParameters SpawnParams; - SpawnParams.Owner = OwningActor; - SpawnParams.Instigator = Cast(OwningActor); - - SpawnedCameraInstance = Cast( - OwningActor->GetWorld()->SpawnActor( - CameraToSpawnClass, - SpawnTransform, - SpawnParams - ) - ); - - if (!SpawnedCameraInstance) - { - return; - } - - // Optionally, attach the spawned camera to the owner (so it follows) - if (AttachSocketName != NAME_None) - { - SpawnedCameraInstance->AttachToComponent( - MeshComp, - AttachRules.ToEngineRules(), - AttachSocketName - ); - } - - // 4. Blend to the spawned camera - PC->SetViewTargetWithBlend(SpawnedCameraInstance, BlendInTime, BlendInFunction); -} - -void UANS_SpawnAndSwitchPlayerCamera::NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyEnd(MeshComp, Animation, EventReference); - - if (!MeshComp) - { - return; - } - - // 1. Try to get the same PlayerController we used before - AActor* OwningActor = MeshComp->GetOwner(); - if (!OwningActor) - { - return; - } - - APlayerController* PC = Cast(OwningActor->GetInstigatorController()); - if (!PC) - { - PC = UGameplayStatics::GetPlayerController(OwningActor->GetWorld(), 0); - } - if (!PC) - { - return; - } - - // 2. Blend back to the original view target if it’s still valid - if (PreviousViewTarget) - { - PC->SetViewTargetWithBlend(PreviousViewTarget, BlendOutTime, BlendOutFunction); - } - - // 3. Destroy the spawned camera actor - if (SpawnedCameraInstance) - { - SpawnedCameraInstance->SetLifeSpan(3); - SpawnedCameraInstance = nullptr; - } - - // 4. Clear the stored pointer - PreviousViewTarget = nullptr; -} diff --git a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_UHL_AllowCharacterRotation.cpp b/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_UHL_AllowCharacterRotation.cpp deleted file mode 100644 index 543109b1..00000000 --- a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_UHL_AllowCharacterRotation.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "Animation/Notifies/ANS_UHL_AllowCharacterRotation.h" - -#include "GameFramework/Character.h" -#include "GameFramework/CharacterMovementComponent.h" - - -FString UANS_UHL_AllowCharacterRotation::GetNotifyName_Implementation() const -{ - // Base name - FString NotifyName = TEXT("AllowCharacterRotation"); - - // Optional rotation‐rate suffix - if (bChangeRotationRate) - { - NotifyName += FString::Printf( - TEXT(" + change RotationRate to Pitch=%.2f, Yaw=%.2f, Roll=%.2f"), - RotationRate.Pitch, - RotationRate.Yaw, - RotationRate.Roll - ); - } - - return NotifyName; -} - -void UANS_UHL_AllowCharacterRotation::NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyBegin(MeshComp, Animation, TotalDuration, EventReference); - - ACharacter* Character = Cast(MeshComp->GetOwner()); - if (!Character) return; - - CharacterMovementComponent = Character->GetCharacterMovement(); - if (!CharacterMovementComponent.IsValid()) return; - - CharacterMovementComponent->bAllowPhysicsRotationDuringAnimRootMotion = true; - - if (bChangeRotationRate) - { - InitialRotationRate = CharacterMovementComponent->RotationRate; - CharacterMovementComponent->RotationRate = RotationRate; - } -} - -void UANS_UHL_AllowCharacterRotation::NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) -{ - ReturnDefaults(); - - Super::NotifyEnd(MeshComp, Animation, EventReference); -} - -void UANS_UHL_AllowCharacterRotation::OnMontageBlendingOut(UAnimMontage* Montage, bool bInterrupted) -{ - ReturnDefaults(); -} - -void UANS_UHL_AllowCharacterRotation::ReturnDefaults() -{ - if (CharacterMovementComponent.IsValid()) - { - CharacterMovementComponent->bAllowPhysicsRotationDuringAnimRootMotion = false; - if (bChangeRotationRate) - { - CharacterMovementComponent->RotationRate = InitialRotationRate; - } - } -} diff --git a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_UHL_Base.cpp b/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_UHL_Base.cpp deleted file mode 100644 index 0ed49ea3..00000000 --- a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_UHL_Base.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Animation/Notifies/ANS_UHL_Base.h" -#include "Runtime/Engine/Classes/Animation/AnimMontage.h" -#include "Engine/World.h" -#include "Components/SkeletalMeshComponent.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(ANS_UHL_Base) - -void UANS_UHL_Base::NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyBegin(MeshComp, Animation, TotalDuration, EventReference); - - const UAnimMontage* CurrentAnimMontage = EventReference.GetNotify()->GetLinkedMontage(); - - if (CurrentAnimMontage) - { - if (bUseOnMontageBlendingOut) - { - MeshComp->AnimScriptInstance->OnMontageBlendingOut.AddUniqueDynamic(this, &UANS_UHL_Base::OnMontageBlendingOut); - } - } -} - -void UANS_UHL_Base::NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) -{ - Super::NotifyEnd(MeshComp, Animation, EventReference); - - if (ShouldUseExperimentalUHLFeatures()) - { - NotifyEndOrBlendOut(MeshComp); - } - - if (bUseOnMontageBlendingOut) - { - MeshComp->AnimScriptInstance->OnMontageBlendingOut.RemoveDynamic(this, &UANS_UHL_Base::OnMontageBlendingOut); - } -} - -/** Experimental **/ -void UANS_UHL_Base::NotifyEndOrBlendOut(USkeletalMeshComponent* MeshComp) -{ - if (!ShouldUseExperimentalUHLFeatures()) return; -} -/** ~Experimental **/ - -void UANS_UHL_Base::OnMontageBlendingOut(UAnimMontage* Montage, bool bInterrupted) -{ - if (!Montage) - { - return; - } - - if (ShouldUseExperimentalUHLFeatures()) - { - UObject* Outer = Montage->GetOuter(); - USkeletalMeshComponent* SkeletalMeshComponent = Cast(Outer); - if (SkeletalMeshComponent) - { - NotifyEndOrBlendOut(SkeletalMeshComponent); - } - } -} diff --git a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_UHL_DisableWalkOffLedges.cpp b/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_UHL_DisableWalkOffLedges.cpp deleted file mode 100644 index f8cf6f20..00000000 --- a/Source/UnrealHelperLibrary/Private/Animation/Notifies/ANS_UHL_DisableWalkOffLedges.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Animation/Notifies/ANS_UHL_DisableWalkOffLedges.h" - -#include "Components/CapsuleComponent.h" -#include "GameFramework/Character.h" -#include "GameFramework/CharacterMovementComponent.h" - -void UANS_UHL_DisableWalkOffLedges::NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) -{ - if (!MeshComp) return; - - ACharacter* OwnerChar = Cast(MeshComp->GetOwner()); - if (!OwnerChar) return; - - UCharacterMovementComponent* MoveComp = OwnerChar->GetCharacterMovement(); - if (!MoveComp) return; - - // Store original - bOriginalCanWalkOffLedges = MoveComp->bCanWalkOffLedges; - OriginalPerchRadius = MoveComp->PerchRadiusThreshold; - - // Apply new settings - MoveComp->bCanWalkOffLedges = false; - if (PerchRadiusThreshold >= 0.0f) - { - MoveComp->PerchRadiusThreshold = PerchRadiusThreshold; - } - else - { - MoveComp->PerchRadiusThreshold = OwnerChar->GetCapsuleComponent()->GetScaledCapsuleRadius(); - } -} - -void UANS_UHL_DisableWalkOffLedges::NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) -{ - if (!MeshComp) return; - - ACharacter* OwnerChar = Cast(MeshComp->GetOwner()); - if (!OwnerChar) return; - - UCharacterMovementComponent* MoveComp = OwnerChar->GetCharacterMovement(); - if (!MoveComp) return; - - // Restore original if we stored them - MoveComp->bCanWalkOffLedges = bOriginalCanWalkOffLedges; - MoveComp->PerchRadiusThreshold = OriginalPerchRadius; -} diff --git a/Source/UnrealHelperLibrary/Private/Animation/Notifies/AN_AttachActorWithUniqueId.cpp b/Source/UnrealHelperLibrary/Private/Animation/Notifies/AN_AttachActorWithUniqueId.cpp deleted file mode 100644 index 8a516520..00000000 --- a/Source/UnrealHelperLibrary/Private/Animation/Notifies/AN_AttachActorWithUniqueId.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Animation/Notifies/AN_AttachActorWithUniqueId.h" - -#include "Components/SkeletalMeshComponent.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(AN_AttachActorWithUniqueId) - -#if WITH_EDITOR -void UAN_AttachActorWithUniqueId::PostEditChangeProperty( - struct FPropertyChangedEvent& PropertyChangedEvent) -{ - Super::PostEditChangeProperty(PropertyChangedEvent); - - if (PropertyChangedEvent.Property != nullptr && - PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(UAN_AttachActorWithUniqueId, UniqueId)) - { - if (UAnimSequenceBase* AnimSeq = Cast(GetOuter())) - { - AnimSeq->Modify(); - } - } -} -#endif - -FString UAN_AttachActorWithUniqueId::GetNotifyName_Implementation() const -{ - return FString("Attach With UniqueId -> ") + UniqueId.ToString(); -} - -void UAN_AttachActorWithUniqueId::Notify( - USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, - const FAnimNotifyEventReference& EventReference) -{ - Super::Notify(MeshComp, Animation, EventReference); - - if (!MeshComp) return; - - AActor* OwnerActor = MeshComp->GetOwner(); - if (!OwnerActor) return; - - // 1) Load the class synchronously - UClass* ActorClass = ActorToAttach.LoadSynchronous(); - if (!ActorClass) - { - UE_LOG(LogTemp, Warning, TEXT("Failed to load ActorToSpawn!")); - return; - } - - FActorSpawnParameters ActorSpawnParameters; - ActorSpawnParameters.Owner = OwnerActor; - ActorSpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; - - AActor* SpawnedActor = MeshComp->GetWorld()->SpawnActor(ActorClass, - MeshComp->GetSocketTransform(SocketName), ActorSpawnParameters); - - if (!SpawnedActor) return; - - SpawnedActor->AttachToComponent(MeshComp, AttachmentRules.ToEngineRules(), SocketName); - SpawnedActor->Tags.Add(UniqueId); -} \ No newline at end of file diff --git a/Source/UnrealHelperLibrary/Private/Animation/Notifies/AN_DetachActorWithUniqueId.cpp b/Source/UnrealHelperLibrary/Private/Animation/Notifies/AN_DetachActorWithUniqueId.cpp deleted file mode 100644 index 7426bbf7..00000000 --- a/Source/UnrealHelperLibrary/Private/Animation/Notifies/AN_DetachActorWithUniqueId.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Animation/Notifies/AN_DetachActorWithUniqueId.h" - -#include "Components/SkeletalMeshComponent.h" -#include "Components/PrimitiveComponent.h" -#include "Components/ActorComponent.h" -#include "TimerManager.h" -#include "Utils/UnrealHelperLibraryBPL.h" - -#if WITH_EDITOR -void UAN_DetachActorWithUniqueId::PostEditChangeProperty( - struct FPropertyChangedEvent& PropertyChangedEvent) -{ - Super::PostEditChangeProperty(PropertyChangedEvent); - - if (PropertyChangedEvent.Property != nullptr && - PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(UAN_DetachActorWithUniqueId, UniqueId)) - { - if (UAnimSequenceBase* AnimSeq = Cast(GetOuter())) - { - AnimSeq->Modify(); - } - } -} -#endif - -FString UAN_DetachActorWithUniqueId::GetNotifyName_Implementation() const -{ - return FString("Detach With UniqueId->") + UniqueId.ToString(); -} - -void UAN_DetachActorWithUniqueId::Notify( - USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, - const FAnimNotifyEventReference& EventReference) -{ - Super::Notify(MeshComp, Animation, EventReference); - - if (!MeshComp) return; - - AActor* OwnerActor = MeshComp->GetOwner(); - if (!OwnerActor) return; - - AActor* AttachedActor = UUnrealHelperLibraryBPL::FindAttachedActorByTag(OwnerActor, UniqueId); - if (!AttachedActor) return; - - AttachedActor->DetachFromActor(DetachmentRules.ToEngineRules()); - - // checking that physics enabled before AutoDestroy and it worth to create timer - if (bEnablePhysicsOnDetach && EnablePhysicsDelay < AutoDestroyDelay) - { - FTimerDelegate Delegate; - Delegate.BindLambda([AttachedActor]() - { - // TODO: improve detachment logic - TArray Comps = AttachedActor->K2_GetComponentsByClass(UPrimitiveComponent::StaticClass()); - for (UActorComponent* Comp : Comps) - { - if (UPrimitiveComponent* Prim = Cast(Comp)) - { - Prim->SetCollisionProfileName(TEXT("PhysicsActor")); - Prim->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics); - Prim->SetSimulatePhysics(true); - // Prim->SetEnableGravity(true); - // // ensure it has a physics‐friendly collision profile - // Prim->SetCollisionProfileName(TEXT("PhysicsActor")); - // Prim->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics); - // - // // turn on physics and wake it up - // Prim->SetSimulatePhysics(true); - // Prim->WakeAllRigidBodies(); - - // 3) (Optional) give it a little kick - const FVector Impulse = AttachedActor->GetActorForwardVector() * 200.0f - + FVector::UpVector * 100.0f; - Prim->AddImpulse(Impulse, NAME_None, /*bVelChange=*/ true); - } - } - }); - MeshComp->GetWorld()->GetTimerManager().SetTimer(TimerHandle, Delegate, EnablePhysicsDelay, false); - } - - if (bAutoDestroy) - { - AttachedActor->SetLifeSpan(AutoDestroyDelay); - } -} \ No newline at end of file diff --git a/Source/UnrealHelperLibrary/Private/Animation/Notifies/AN_UHL_Base.cpp b/Source/UnrealHelperLibrary/Private/Animation/Notifies/AN_UHL_Base.cpp deleted file mode 100644 index cc5d6c25..00000000 --- a/Source/UnrealHelperLibrary/Private/Animation/Notifies/AN_UHL_Base.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Animation/Notifies/AN_UHL_Base.h" -#include "Components/SkeletalMeshComponent.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(AN_UHL_Base) - -void UAN_UHL_Base::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) -{ - OnNotified.Broadcast(MeshComp); - - Super::Notify(MeshComp, Animation, EventReference); -} diff --git a/Source/UnrealHelperLibrary/Private/Core/UHLGameplayTags.cpp b/Source/UnrealHelperLibrary/Private/Core/UHLGameplayTags.cpp deleted file mode 100644 index 1569b38b..00000000 --- a/Source/UnrealHelperLibrary/Private/Core/UHLGameplayTags.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Core/UHLGameplayTags.h" - -namespace UHLGameplayTags -{ - UE_DEFINE_GAMEPLAY_TAG(TAG_Gameplay_AbilityInputBlocked, "Gameplay.AbilityInputBlocked"); - UE_DEFINE_GAMEPLAY_TAG(TAG_UHL_Debug_CheckGASGameplayTagsOnActor, "UHL.Debug.CheckGASGameplayTagsOnActor"); - - // Abilities - UE_DEFINE_GAMEPLAY_TAG_COMMENT(TAG_UHL_Abilities_Character_GlobalTimeDilation, "UHL.Abilities.Character.GlobalTimeDilation", ""); - - // AbilityInputCache - UE_DEFINE_GAMEPLAY_TAG_COMMENT(TAG_UHL_AbilityInputCache_Catching, "UHL.AbilityInputCache.Catching", "Opened for catching actions to AbilityInputCache"); - - // Debug Categories - UE_DEFINE_GAMEPLAY_TAG_COMMENT(TAG_UHL_DebugCategory_AbilitySystem, "UHL.DebugCategory.AbilitySystem", ""); - UE_DEFINE_GAMEPLAY_TAG_COMMENT(TAG_UHL_DebugCategory_AbilitySystem_Attributes, "UHL.DebugCategory.AbilitySystem.Attributes", ""); - UE_DEFINE_GAMEPLAY_TAG_COMMENT(TAG_UHL_DebugCategory_AbilitySystem_Effects, "UHL.DebugCategory.AbilitySystem.Effects", ""); - UE_DEFINE_GAMEPLAY_TAG_COMMENT(TAG_UHL_DebugCategory_AbilitySystem_Abilities, "UHL.DebugCategory.AbilitySystem.Abilities", ""); - UE_DEFINE_GAMEPLAY_TAG_COMMENT(TAG_UHL_DebugCategory_AbilitySystem_DebugBasicHUD, "UHL.DebugCategory.AbilitySystem.DebugBasicHUD", ""); - UE_DEFINE_GAMEPLAY_TAG_COMMENT(TAG_UHL_DebugCategory_AbilitySystem_DebugAbilityTags, "UHL.DebugCategory.AbilitySystem.DebugAbilityTags", ""); - UE_DEFINE_GAMEPLAY_TAG_COMMENT(TAG_UHL_DebugCategory_InputSystem_EnhancedInputSystem, "UHL.DebugCategory.InputSystem.EnhancedInputSystem", ""); - UE_DEFINE_GAMEPLAY_TAG_COMMENT(TAG_UHL_DebugCategory_InputSystem_AbilityInputCache, "UHL.DebugCategory.InputSystem.AbilityInputCache", ""); - UE_DEFINE_GAMEPLAY_TAG_COMMENT(TAG_UHL_DebugCategory_Collisions, "UHL.DebugCategory.Collisions", ""); - - // Errors - UE_DEFINE_GAMEPLAY_TAG(TAG_Error, "Error"); -} - diff --git a/Source/UnrealHelperLibrary/Private/Development/UHLSettings.cpp b/Source/UnrealHelperLibrary/Private/Development/UHLSettings.cpp deleted file mode 100644 index b2df5850..00000000 --- a/Source/UnrealHelperLibrary/Private/Development/UHLSettings.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Development/UHLSettings.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLSettings) \ No newline at end of file diff --git a/Source/UnrealHelperLibrary/Private/Subsystems/EnemyTickManager/EnemyTickOptimizerSubsystem.cpp b/Source/UnrealHelperLibrary/Private/Subsystems/EnemyTickManager/EnemyTickOptimizerSubsystem.cpp deleted file mode 100644 index 4e028319..00000000 --- a/Source/UnrealHelperLibrary/Private/Subsystems/EnemyTickManager/EnemyTickOptimizerSubsystem.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Subsystems/EnemyTickManager/EnemyTickOptimizerSubsystem.h" - -#include "GameFramework/Character.h" -#include "Development/UHLSettings.h" -#include "Kismet/GameplayStatics.h" -#include "Engine/World.h" -#include "TimerManager.h" - -void UEnemyTickOptimizerSubsystem::Initialize(FSubsystemCollectionBase& Collection) -{ - Super::Initialize(Collection); - - const UUHLSettings* UHLSettings = GetDefault(); - Settings = UHLSettings->EnemyTickOptimizerSubsystemSettings; - - if (Settings.bEnable) - { - // Set up a timer to call UpdateTickIntervals every 0.5 seconds - GetWorld()->GetTimerManager().SetTimer( - TickOptimizerTimerHandle, - this, - &UEnemyTickOptimizerSubsystem::UpdateTickIntervals, - Settings.UpdateInterval, - true - ); - } -} - -void UEnemyTickOptimizerSubsystem::Deinitialize() -{ - // Clear the timer when the subsystem is shut down - GetWorld()->GetTimerManager().ClearTimer(TickOptimizerTimerHandle); - - Super::Deinitialize(); -} - -void UEnemyTickOptimizerSubsystem::RegisterEnemy(ACharacter* Enemy) -{ - if (Enemy && !RegisteredEnemies.Contains(Enemy)) - { - RegisteredEnemies.Add(Enemy); - } -} - -void UEnemyTickOptimizerSubsystem::UnregisterEnemy(ACharacter* Enemy) -{ - RegisteredEnemies.Remove(Enemy); -} - -void UEnemyTickOptimizerSubsystem::UpdateTickIntervals() -{ - // Get the player character - ACharacter* PlayerCharacter = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0); - if (!PlayerCharacter) - { - return; - } - - FVector PlayerLocation = PlayerCharacter->GetActorLocation(); - - // Iterate through all registered enemies and adjust their tick intervals - for (ACharacter* Enemy : RegisteredEnemies) - { - if (Enemy) - { - float Distance = FVector::Dist(PlayerLocation, Enemy->GetActorLocation()); - float TickInterval; - - if (Distance < Settings.CloseDistance) - { - TickInterval = Settings.CloseTickInterval; // e.g., 0.0f (every frame) - } - else if (Distance < Settings.MediumDistance) - { - TickInterval = Settings.MediumTickInterval; // e.g., 0.1f - } - else if (Distance < Settings.FarDistance) - { - TickInterval = Settings.FarTickInterval; // e.g., 0.5f - } - else - { - TickInterval = Settings.DefaultEnemyTickInterval; // e.g., 1.0f - } - - if (Settings.bDontTickIfNotRenderedRecently - && !Enemy->WasRecentlyRendered() - && Distance > Settings.MediumDistance) - { - TickInterval = Settings.RecentlyNotRenderedTickInterval; - } - - // Set tick interval for the enemy actor - Enemy->SetActorTickInterval(TickInterval); - // Enemy->GetMesh()->SetComponentTickInterval(TickInterval); - if (Settings.bSetTickOnActorComponentsAlso) - { - for (UActorComponent* Component : Enemy->GetComponents()) - { - if (Component->IsComponentTickEnabled()) - { - Component->SetComponentTickInterval(TickInterval); - } - } - } - - // Set tick interval for the enemy's controller, if it exists - if (AController* Controller = Enemy->GetController()) - { - Controller->PrimaryActorTick.TickInterval = TickInterval; - } - } - } -} \ No newline at end of file diff --git a/Source/UnrealHelperLibrary/Private/UI/UHLHUD.cpp b/Source/UnrealHelperLibrary/Private/UI/UHLHUD.cpp deleted file mode 100644 index c171b47d..00000000 --- a/Source/UnrealHelperLibrary/Private/UI/UHLHUD.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "UI/UHLHUD.h" - -#include "Engine/World.h" -#include "Blueprint/WidgetLayoutLibrary.h" - -void AUHLHUD::DrawHUD() -{ - Super::DrawHUD(); - - if (!bEnabledDrawDebug) return; - - FVector2D ViewportSize = UWidgetLayoutLibrary::GetViewportSize(GetWorld()); - FVector2D ViewportSizeOffset = ViewportSize / 2; - - // FVector2f Test; - // UUnrealHelperLibraryBPL::DrawDebugCrossHair(GetWorld(), 100.0f, 3.0f, 0.0f, Test, FLinearColor::Red); - - for (const FLineInfo& LineInfo : LineInfos) - { - FVector2D StartPos = LineInfo.Start; - FVector2D EndPos = LineInfo.End; - if (LineInfo.bRelativeToViewportCenter) - { - StartPos += ViewportSizeOffset; - EndPos += ViewportSizeOffset; - } - DrawLine( - StartPos.X, StartPos.Y, - EndPos.X, EndPos.Y, - LineInfo.Color, - LineInfo.LineThickness - ); - FVector2D TextPos = (EndPos - StartPos) + ViewportSizeOffset; - - DrawText(LineInfo.Text, FColor::Red, TextPos.X, TextPos.Y); - } - LineInfos.RemoveAll([=](const FLineInfo& LineInfo) - { - return !LineInfo.bPersistent; - }); -} - -void AUHLHUD::AddOrUpdateLineInfoToDrawNextTick(FLineInfo LineInfo_In) -{ - LineInfos.Add(LineInfo_In); -} \ No newline at end of file diff --git a/Source/UnrealHelperLibrary/Private/UnrealHelperLibrary.cpp b/Source/UnrealHelperLibrary/Private/UnrealHelperLibrary.cpp deleted file mode 100644 index 6e99bb9a..00000000 --- a/Source/UnrealHelperLibrary/Private/UnrealHelperLibrary.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "UnrealHelperLibrary.h" - -#include "Misc/Paths.h" -#include "GameplayTagsManager.h" - -#define LOCTEXT_NAMESPACE "FUnrealHelperLibraryModule" - -DEFINE_LOG_CATEGORY(LogUnrealHelperLibrary); - -void FUnrealHelperLibraryModule::StartupModule() -{ - UGameplayTagsManager& TagsManager = UGameplayTagsManager::Get(); - // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module - TagsManager.AddTagIniSearchPath(FPaths::ProjectPluginsDir() / TEXT("UnrealHelperLibrary/Config/Tags")); - - // TArray> OutTagArray; - // TArray OutPaths; - // TagsManager.GetTagSourceSearchPaths(OutPaths); - // TagsManager.GetAllTagsFromSource(FApp::GetProjectName(), OutTagArray); - // // GameplayTagsManager.FindTagsWithSource() - // - // // TODO find MainModule name - // FString Test1 = FApp::GetName(); - // FString Test2 = FApp::GetProjectName(); - // FString Test3 = FApp::GetInstanceName(); - // FString Test6 = FModuleManager::Get().GetGameBinariesDirectory(); - // - // // TArray OutModuleStatuses; - // // FModuleManager::Get().QueryModules(OutModuleStatuses); - // - // // FModuleStatus* MyGameModule = OutModuleStatuses.FindByPredicate([](const FModuleStatus& ModuleStatusStatus) { - // // return ModuleStatusStatus.bIsGameModule && ModuleStatusStatus.bIsLoaded; - // // }); - // - // // Ask the module manager for a list of currently-loaded gameplay modules - // UGameplayTagsManager::Get().OnLastChanceToAddNativeTags().AddLambda([this]() - // { - // UGameplayTagsManager& TagsManager2 = UGameplayTagsManager::Get(); - // - // // StaticImpl.RootTag = UGameplayTagsManager::Get().AddNativeGameplayTag(TagT::GetRootTagStr()); - // TArray GameModulesNames; - // TArray ModuleStatuses; - // FModuleManager::Get().QueryModules(ModuleStatuses); - // - // for (FModuleStatus& ModuleStatus : ModuleStatuses) - // { - // // We only care about game modules that are currently loaded - // if (ModuleStatus.bIsLoaded && ModuleStatus.bIsGameModule) - // { - // GameModulesNames.Add(MoveTemp(ModuleStatus.Name)); - // } - // } - // - // for (const FString& GameModulesName : GameModulesNames) - // { - // // GameplayTagsManager.FindTagsWithSource(FString("Bogatyr"), NativeTags); - // TArray NativeTags; - // TagsManager2.FindTagsWithSource(GameModulesName, NativeTags); - // - // for (FGameplayTag& NativeTag : NativeTags) - // { - // FName NativeTagNam = NativeTag.GetTagName(); - // // FNativeGameplayTag* Test = new FNativeGameplayTag(FName("UnrealHelperLibrary"), FName("UnrealHelperLibrary"), NativeTagNam, "", ENativeGameplayTagToken::PRIVATE_USE_MACRO_INSTEAD); - // // TagsManager2.AddNativeGameplayTag(Test); - // TagsManager2.AddNativeGameplayTag(NativeTagNam, ""); - // } - // } - // FName TestTag = "Test123.Test322.Test123"; - // TagsManager2.AddNativeGameplayTag(TestTag, ""); - // // UGameplayTagsManager::Get().DoneAddingNativeTags(); - // }); - // - // TagsManager.ConstructGameplayTagTree(); - // TagsManager.LoadGameplayTagTables(); - - // for (const FGameplayTag& Tag : NativeTags) - // { - // if (IsTagOnlyAvailableFromExcludedSources(Manager, Tag, ExcludedPlugins)) - // { - // FAssetIdentifier TagId = FAssetIdentifier(FGameplayTag::StaticStruct(), Tag.GetTagName()); - // AssetIdsInPlugin.Add(TagId); - // } - // } - // } -} - -void FUnrealHelperLibraryModule::ShutdownModule() -{ - // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, - // we call this function before unloading the module. -} - -#undef LOCTEXT_NAMESPACE - -IMPLEMENT_MODULE(FUnrealHelperLibraryModule, UnrealHelperLibrary) diff --git a/Source/UnrealHelperLibrary/Private/Utils/UHLLoadingUtilLibrary.cpp b/Source/UnrealHelperLibrary/Private/Utils/UHLLoadingUtilLibrary.cpp deleted file mode 100644 index 3efdc8be..00000000 --- a/Source/UnrealHelperLibrary/Private/Utils/UHLLoadingUtilLibrary.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Utils/UHLLoadingUtilLibrary.h" - -#include "Engine/CoreSettings.h" -#include "Engine/Engine.h" -#include "Engine/World.h" -#include "GameFramework/WorldSettings.h" -#include "Misc/AssertionMacros.h" -#include "UObject/Object.h" - -#include - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLLoadingUtilLibrary) - -bool UUHLLoadingUtilLibrary::HasCapturedDefaults = false; -float UUHLLoadingUtilLibrary::DefaultLevelStreamingComponentsRegistrationGranularity; -float UUHLLoadingUtilLibrary::DefaultLevelStreamingActorsUpdateTimeLimit; -float UUHLLoadingUtilLibrary::DefaultAsyncLoadingTimeLimit; - -void UUHLLoadingUtilLibrary::ApplyDefaultPriorityLoading(const UObject* WorldContextObject) -{ - // Call first, just in case defaults have not been captured yet - CaptureDefaultLoadingSettings(); - ApplyCustomPriorityLoading(WorldContextObject, false, DefaultAsyncLoadingTimeLimit, DefaultLevelStreamingActorsUpdateTimeLimit); -} - -void UUHLLoadingUtilLibrary::ApplyStreamingPriorityLoading(const UObject* WorldContextObject) -{ - ApplyCustomPriorityLoading(WorldContextObject, false, 10.0f, 10.0f); -} - -void UUHLLoadingUtilLibrary::ApplyHighestPriorityLoading(const UObject* WorldContextObject) -{ - ApplyCustomPriorityLoading(WorldContextObject, true, FLT_MAX, FLT_MAX); -} - -void UUHLLoadingUtilLibrary::ApplyCustomPriorityLoading(const UObject* WorldContextObject, bool UseHighPriorityLoading, float MaxAsyncLoadingMilliSeconds, float MaxActorUpdateMilliSeconds) -{ - CaptureDefaultLoadingSettings(); - - if (!ensure(WorldContextObject != nullptr)) - { - return; - } - - UWorld* World = WorldContextObject->GetWorld(); - - if (!ensure(World != nullptr)) - { - return; - } - - AWorldSettings* WorldSettings = World->GetWorldSettings(); - - if (!ensure(WorldSettings != nullptr)) - { - return; - } - - WorldSettings->bHighPriorityLoadingLocal = UseHighPriorityLoading; - GLevelStreamingActorsUpdateTimeLimit = MaxActorUpdateMilliSeconds; - GLevelStreamingComponentsRegistrationGranularity = DefaultLevelStreamingComponentsRegistrationGranularity; - GAsyncLoadingUseFullTimeLimit = UseHighPriorityLoading; - GAsyncLoadingTimeLimit = MaxAsyncLoadingMilliSeconds; -} - -void UUHLLoadingUtilLibrary::FlushLevelStreaming(const UObject* WorldContextObject) -{ - if (!ensure(WorldContextObject != nullptr)) - { - return; - } - - UWorld* World = WorldContextObject->GetWorld(); - - if (!ensure(World != nullptr)) - { - return; - } - - GEngine->BlockTillLevelStreamingCompleted(World); -} - -void UUHLLoadingUtilLibrary::ForceGarbageCollection() -{ -#if WITH_EDITOR - GEngine->ForceGarbageCollection(false); -#else - GEngine->ForceGarbageCollection(true); -#endif -} - -void UUHLLoadingUtilLibrary::CaptureDefaultLoadingSettings() -{ - if (!HasCapturedDefaults) - { - DefaultLevelStreamingComponentsRegistrationGranularity = GLevelStreamingComponentsRegistrationGranularity; - DefaultLevelStreamingActorsUpdateTimeLimit = GLevelStreamingActorsUpdateTimeLimit; - DefaultAsyncLoadingTimeLimit = GAsyncLoadingTimeLimit; - HasCapturedDefaults = true; - } -} diff --git a/Source/UnrealHelperLibrary/Private/Utils/UHLTraceUtilsBPL.cpp b/Source/UnrealHelperLibrary/Private/Utils/UHLTraceUtilsBPL.cpp deleted file mode 100644 index 310eef43..00000000 --- a/Source/UnrealHelperLibrary/Private/Utils/UHLTraceUtilsBPL.cpp +++ /dev/null @@ -1,178 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - - -#include "Utils/UHLTraceUtilsBPL.h" -#include "Engine/World.h" -#include "Engine/EngineTypes.h" -#include "Engine/HitResult.h" -#include "DrawDebugHelpers.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UHLTraceUtilsBPL) - -bool UUHLTraceUtilsBPL::SweepCapsuleSingleByChannel(const UWorld* World, FHitResult& OutHit, const FVector& Start, - const FVector& End, float Radius, float HalfHeight, - const FQuat& Rot, ECollisionChannel TraceChannel, - const FCollisionQueryParams& Params, - const FCollisionResponseParams& ResponseParam, bool bDrawDebug, - float DrawTime, - FColor TraceColor, FColor HitColor, float FailDrawTime) -{ - bool bResult = false; - - FailDrawTime = FailDrawTime == -1.0f ? DrawTime : FailDrawTime; - - FCollisionShape CollisionShape = FCollisionShape::MakeCapsule(Radius, HalfHeight); - bResult = World->SweepSingleByChannel(OutHit, Start, End, Rot, TraceChannel, CollisionShape, Params, ResponseParam); - -#if ENABLE_DRAW_DEBUG - if (bDrawDebug) - { - DrawDebugCapsule(World, Start, HalfHeight, Radius, Rot, TraceColor, false, bResult ? DrawTime : FailDrawTime); - DrawDebugCapsule(World, End, HalfHeight, Radius, Rot, TraceColor, false, bResult ? DrawTime : FailDrawTime); - DrawDebugLine(World, Start, End, TraceColor, false, bResult ? DrawTime : FailDrawTime); - - if (bResult) - { - float Thickness = FMath::Clamp(HalfHeight / 100, 1.25, 5); - // UUnrealHelperLibraryBPLibrary::DebugPrintStrings(FString::Printf(TEXT("%f"), Thickness)); - DrawDebugPoint(World, OutHit.ImpactPoint, 10.0f, HitColor, false, DrawTime, 0); - DrawDebugCapsule(World, OutHit.Location, HalfHeight, Radius, Rot, TraceColor, false, DrawTime, 0, Thickness); - } - } -#endif - - return bResult; -} - -bool UUHLTraceUtilsBPL::SweepCapsuleMultiByChannel(const UWorld* World, TArray& OutHits, const FVector& Start, const FVector& End, float Radius, float HalfHeight, const FQuat& Rot, - ECollisionChannel TraceChannel, const FCollisionQueryParams& Params, const FCollisionResponseParams& ResponseParam, bool bDrawDebug, float DrawTime, FColor TraceColor, FColor HitColor, float FailDrawTime) -{ - bool bResult = false; - - FailDrawTime = FailDrawTime == -1.0f ? DrawTime : FailDrawTime; - - FCollisionShape CollisionShape = FCollisionShape::MakeCapsule(Radius, HalfHeight); - bResult = World->SweepMultiByChannel(OutHits, Start, End, Rot, TraceChannel, CollisionShape, Params, ResponseParam); - -#if ENABLE_DRAW_DEBUG - if (bDrawDebug) - { - DrawDebugCapsule(World, Start, HalfHeight, Radius, Rot, TraceColor, false, bResult ? DrawTime : FailDrawTime); - DrawDebugCapsule(World, End, HalfHeight, Radius, Rot, TraceColor, false, bResult ? DrawTime : FailDrawTime); - DrawDebugLine(World, Start, End, TraceColor, false, bResult ? DrawTime : FailDrawTime); - - if (bResult) - { - float Thickness = FMath::Clamp(HalfHeight / 100, 1.25, 5); - for (const FHitResult& OutHit : OutHits) - { - // UUnrealHelperLibraryBPLibrary::DebugPrintStrings(FString::Printf(TEXT("%f"), Thickness)); - DrawDebugPoint(World, OutHit.ImpactPoint, 10.0f, HitColor, false, DrawTime, 0); - DrawDebugCapsule(World, OutHit.Location, HalfHeight, Radius, Rot, TraceColor, false, DrawTime, 0, Thickness); - } - } - } -#endif - - return bResult; -} - -bool UUHLTraceUtilsBPL::SweepCapsuleMultiByProfile(const UWorld* World, TArray& OutHits, const FVector& Start, - const FVector& End, float Radius, float HalfHeight, - const FQuat& Rot, FName ProfileName, - const FCollisionQueryParams& Params, - bool bDrawDebug, float DrawTime, - FColor TraceColor, FColor HitColor) -{ - bool bResult = false; - - FCollisionShape CollisionShape = FCollisionShape::MakeCapsule(Radius, HalfHeight); - bResult = World->SweepMultiByProfile(OutHits, Start, End, Rot, ProfileName, CollisionShape, Params); - -// TODO make debug, dont have time -// #if ENABLE_DRAW_DEBUG -// if (bDrawDebug) -// { -// DrawDebugCapsule(World, Start, HalfHeight, Radius, Rot, TraceColor, false, DrawTime); -// DrawDebugCapsule(World, End, HalfHeight, Radius, Rot, TraceColor, false, DrawTime); -// DrawDebugLine(World, Start, End, TraceColor, false, DrawTime); -// -// if (bResult) -// { -// DrawDebugCapsule(World, OutHit.Location, HalfHeight, Radius, Rot, HitColor, false, DrawTime); -// DrawDebugPoint(World, OutHit.ImpactPoint, 10.0f, HitColor, false, DrawTime); -// } -// } -// #endif - - return bResult; -} - -bool UUHLTraceUtilsBPL::SweepSphereSingleByChannel(const UWorld* World, FHitResult& OutHit, const FVector& Start, - const FVector& End, float Radius, ECollisionChannel TraceChannel, const FCollisionQueryParams& Params, - const FCollisionResponseParams& ResponseParam, bool bDrawDebug, float DrawTime, FColor TraceColor, FColor HitColor) -{ - bool bResult = false; - - FCollisionShape CollisionShape = FCollisionShape::MakeSphere(Radius); - bResult = World->SweepSingleByChannel(OutHit, Start, End, FQuat::Identity, TraceChannel, CollisionShape, Params, ResponseParam); - -#if ENABLE_DRAW_DEBUG - if (bDrawDebug) - { - FVector DebugCenter = (Start + End) * 0.5f; - FVector TraceVector = End - Start; - float DebugCapsuleHalfHeight = TraceVector.Size() * 0.5f; - - FQuat DebugCapsuleRotation = FRotationMatrix::MakeFromZ(TraceVector).ToQuat(); - - DrawDebugCapsule(World, DebugCenter, DebugCapsuleHalfHeight, Radius, DebugCapsuleRotation, TraceColor, false, DrawTime); - - if (bResult) - { - DrawDebugSphere(World, OutHit.Location, Radius, 16, HitColor, false, DrawTime); - DrawDebugPoint(World, OutHit.ImpactPoint, 10.0f, HitColor, false, DrawTime); - } - } -#endif - - return bResult; -} - -bool UUHLTraceUtilsBPL::OverlapCapsuleAnyByProfile(const UWorld* World, const FVector& Pos, float Radius, float HalfHeight, - FQuat Rot, FName ProfileName, const FCollisionQueryParams& QueryParams, bool bDrawDebug, float DrawTime, - FColor HitColor) -{ - bool bResult = false; - - FCollisionShape CollisionShape = FCollisionShape::MakeCapsule(Radius, HalfHeight); - bResult = World->OverlapAnyTestByProfile(Pos, Rot, ProfileName, CollisionShape, QueryParams); - -#if ENABLE_DRAW_DEBUG - if (bDrawDebug && bResult) - { - DrawDebugCapsule(World, Pos, HalfHeight, Radius, Rot, HitColor, false, DrawTime); - } -#endif - - return bResult; -} - -bool UUHLTraceUtilsBPL::OverlapBlockingTestByProfile(const UWorld* World, const FVector& Pos, float Radius, float HalfHeight, - FQuat Rot, FName ProfileName, const FCollisionQueryParams& QueryParams, bool bDrawDebug, float DrawTime, - FColor HitColor) -{ - bool bResult = false; - - FCollisionShape CollisionShape = FCollisionShape::MakeCapsule(Radius, HalfHeight); - bResult = World->OverlapBlockingTestByProfile(Pos, Rot, ProfileName, CollisionShape, QueryParams); - -#if ENABLE_DRAW_DEBUG - if (bDrawDebug && bResult) - { - DrawDebugCapsule(World, Pos, HalfHeight, Radius, Rot, HitColor, false, DrawTime); - } -#endif - - return bResult; -} diff --git a/Source/UnrealHelperLibrary/Private/Utils/UnrealHelperLibraryBPL.cpp b/Source/UnrealHelperLibrary/Private/Utils/UnrealHelperLibraryBPL.cpp deleted file mode 100644 index 0e6944bc..00000000 --- a/Source/UnrealHelperLibrary/Private/Utils/UnrealHelperLibraryBPL.cpp +++ /dev/null @@ -1,1241 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#include "Utils/UnrealHelperLibraryBPL.h" - -#include "KismetAnimationLibrary.h" -#include "Components/CapsuleComponent.h" -#include "Engine/SCS_Node.h" -#include "Engine/SimpleConstructionScript.h" -#include "GameFramework/Character.h" -#include "Kismet/GameplayStatics.h" -#include "Kismet/KismetMathLibrary.h" -#include "Kismet/KismetSystemLibrary.h" -#include "Misc/ConfigCacheIni.h" -#include "Animation/AnimMontage.h" -#include "DrawDebugHelpers.h" -#include "NavigationSystem.h" -#include "Blueprint/SlateBlueprintLibrary.h" -#include "Blueprint/WidgetLayoutLibrary.h" -#include "Components/Widget.h" -#include "Engine/World.h" -#include "Engine/GameInstance.h" -#include "UI/UHLHUD.h" - -#include UE_INLINE_GENERATED_CPP_BY_NAME(UnrealHelperLibraryBPL) - -static const int32 DEPTH_PRIORITY = -1; - -FString UUnrealHelperLibraryBPL::GetProjectVersion() -{ - FString ProjectVersion; - GConfig->GetString(TEXT("/Script/EngineSettings.GeneralProjectSettings"), TEXT("ProjectVersion"), ProjectVersion, GGameIni); - return ProjectVersion; -} - -void UUnrealHelperLibraryBPL::DebugPrintStrings(const FString& A, const FString& B, const FString& C, const FString& D, const FString& E, const FString& F, const FString& G, const FString& H, - const FString& I, const FString& J, float Duration, const FName Key, const bool bEnabled) -{ - FString StringResult; - StringResult.Empty(A.Len() + B.Len() + C.Len() + D.Len() + E.Len() + 1); // adding one for the string terminator - StringResult += A; - StringResult += B; - StringResult += C; - StringResult += D; - StringResult += E; - - if (!bEnabled) - return; - - UKismetSystemLibrary::PrintString(nullptr, StringResult, true, true, FLinearColor(0, 0.66, 1), Duration, Key); -} - -void UUnrealHelperLibraryBPL::DebugPrintString(const UObject* WorldContextObject, const FString& A, float Duration, const FName Key, const bool bEnabled) -{ - FString StringResult; - StringResult.Empty(A.Len() + 1); // adding one for the string terminator - - if (!bEnabled) - return; - - UKismetSystemLibrary::PrintString(WorldContextObject, StringResult, true, true, FLinearColor(0, 0.66, 1), Duration, Key); -} - -void UUnrealHelperLibraryBPL::DrawDebugBar() {} - -float UUnrealHelperLibraryBPL::GetAnimMontageSectionLengthByName(UAnimMontage* AnimMontage, FName SectionName) -{ - float Result = -1; - - if (!IsValid(AnimMontage)) - return Result; - int32 SectionIdx = SectionName.IsNone() ? 0 : AnimMontage->GetSectionIndex(SectionName); - - if (SectionIdx == INDEX_NONE) - return Result; - DebugPrintString(AnimMontage->GetWorld(), FString::Printf(TEXT("Section %s %i"), *SectionName.ToString(), SectionIdx), Result); - Result = AnimMontage->GetSectionLength(SectionIdx); - - return Result; -} - -EUHLDirection UUnrealHelperLibraryBPL::GetOppositeDirection(EUHLDirection Direction_In) -{ - switch (Direction_In) - { - case EUHLDirection::Left: - return EUHLDirection::Right; - case EUHLDirection::Right: - return EUHLDirection::Left; - case EUHLDirection::Front: - return EUHLDirection::Back; - case EUHLDirection::Back: - return EUHLDirection::Front; - default: - return EUHLDirection::None; - } -} - -TArray UUnrealHelperLibraryBPL::GetNamesOfComponentsOnObject(UObject* OwnerObject, UClass* Class) -{ - TArray Result = {}; - - UBlueprintGeneratedClass* BlueprintGeneratedClass = - OwnerObject->IsA() ? Cast(OwnerObject) : Cast(OwnerObject->GetClass()); - if (!BlueprintGeneratedClass) - return Result; - - TArray DefaultObjectSubobjects; - BlueprintGeneratedClass->GetDefaultObjectSubobjects(DefaultObjectSubobjects); - - // Search for ActorComponents created from C++ - for (UObject* DefaultSubObject : DefaultObjectSubobjects) - { - if (DefaultSubObject->IsA(Class)) - { - Result.Add(DefaultSubObject->GetName()); - } - } - - // Search for ActorComponents created in Blueprint - for (USCS_Node* Node : BlueprintGeneratedClass->SimpleConstructionScript->GetAllNodes()) - { - if (Node->ComponentClass->IsChildOf(Class)) - { - Result.Add(Node->GetVariableName().ToString()); - } - } - - return Result; -} - -float UUnrealHelperLibraryBPL::RelativeAngleToActor( - AActor* ActorRelativeToWhomAngleCalculated, AActor* TargetActor, bool bRelativeToActorBack, const bool bDebug, const float DebugLifetime, const FLinearColor DebugColor) -{ - if (!IsValid(ActorRelativeToWhomAngleCalculated) || !IsValid(TargetActor)) - return FLOAT_ERROR; - - float Multiplier = bRelativeToActorBack ? 1 : -1; - float Result = UKismetAnimationLibrary::CalculateDirection( - ActorRelativeToWhomAngleCalculated->GetActorLocation() - TargetActor->GetActorLocation(), (ActorRelativeToWhomAngleCalculated->GetActorForwardVector() * Multiplier).ToOrientationRotator()); - - if (bDebug) - { - UWorld* DebugWorld = ActorRelativeToWhomAngleCalculated->GetWorld(); - FColor DebugCol = DebugColor.ToFColor(true); - FVector LineStart = ActorRelativeToWhomAngleCalculated->GetActorLocation(); - FVector LineEnd = TargetActor->GetActorLocation(); - FVector TextLocation = GetCenterPointBetweenVectors(ActorRelativeToWhomAngleCalculated->GetWorld(), LineStart, LineEnd); - - DrawDebugString(DebugWorld, TextLocation, FString::Printf(TEXT("RelativeAngle: %.2f°"), Result), 0, DebugCol, DebugLifetime, true, 1.0f); - DrawDebugDirectionalArrow(DebugWorld, LineStart, LineEnd, RELATIVE_POINT_ARROW_SIZE, DebugCol, true, DebugLifetime, DEPTH_PRIORITY, 2); - } - - return Result; -} - -float UUnrealHelperLibraryBPL::RelativeAngleToVector(AActor* ActorRelativeToWhomAngleCalculated, FVector TargetVector) -{ - if (!IsValid(ActorRelativeToWhomAngleCalculated)) - return FLOAT_ERROR; - return UKismetAnimationLibrary::CalculateDirection( - ActorRelativeToWhomAngleCalculated->GetActorLocation() - TargetVector, (ActorRelativeToWhomAngleCalculated->GetActorForwardVector() * -1).ToOrientationRotator()); -} - -float UUnrealHelperLibraryBPL::RelativeAngleVectorToVector(FVector VectorRelativeToWhomAngleCalculated, FVector TargetVector) -{ - return UKismetAnimationLibrary::CalculateDirection(VectorRelativeToWhomAngleCalculated - TargetVector, (VectorRelativeToWhomAngleCalculated * -1).ToOrientationRotator()); -} - -EUHLDirection UUnrealHelperLibraryBPL::GetHitReactDirection(const FVector& SourceActorLocation, const AActor* TargetActor) -{ - const FVector& ActorLocation = TargetActor->GetActorLocation(); - // PointPlaneDist is super cheap - 1 vector subtraction, 1 dot product. - float DistanceToFrontBackPlane = FVector::PointPlaneDist(SourceActorLocation, ActorLocation, TargetActor->GetActorRightVector()); - float DistanceToRightLeftPlane = FVector::PointPlaneDist(SourceActorLocation, ActorLocation, TargetActor->GetActorForwardVector()); - - if (FMath::Abs(DistanceToFrontBackPlane) <= FMath::Abs(DistanceToRightLeftPlane)) - { - // Determine if Front or Back - - // Can see if it's left or right of Left/Right plane which would determine Front or Back - if (DistanceToRightLeftPlane >= 0) - { - return EUHLDirection::Front; - } - return EUHLDirection::Back; - } - // Determine if Right or Left - - if (DistanceToFrontBackPlane >= 0) - { - return EUHLDirection::Right; - } - return EUHLDirection::Left; -} - -FVector2D UUnrealHelperLibraryBPL::GetViewportSizeUnscaled(UObject* WorldContextObject) -{ - FVector2D ViewportSize = UWidgetLayoutLibrary::GetViewportSize(WorldContextObject); - float ViewportScale = UWidgetLayoutLibrary::GetViewportScale(WorldContextObject); - FVector2D ViewportSizeUnscaled = ViewportSize / ViewportScale; - return ViewportSizeUnscaled; -} - -FVector2D UUnrealHelperLibraryBPL::GetWidgetCenterPosition(UObject* WorldContextObject, UWidget* Widget) -{ - FVector2D Result; - - FGeometry WidgetGeometry = Widget->GetCachedGeometry(); - FVector2D WidgetCenterAbsolutePosition = WidgetGeometry.GetAbsolutePositionAtCoordinates(FVector2f(0.5, 0.5)); - - FVector2D PixelPos; - FVector2D ViewportPos; - USlateBlueprintLibrary::AbsoluteToViewport(WorldContextObject, WidgetCenterAbsolutePosition, PixelPos, ViewportPos); - - Result = PixelPos; - - return Result; -} - -float UUnrealHelperLibraryBPL::GetActorDistanceToCenterOfScreen(UObject* WorldContextObject, const AActor* Actor, APlayerController* PlayerController, bool bPlayerViewportRelative, const bool bDebug, const float DebugLifetime) -{ - float Result = 9999999.0f; - FVector2D ViewportSizeUnscaled = GetViewportSizeUnscaled(WorldContextObject); - - FVector2D CurrentActorScreenPosition; - UWidgetLayoutLibrary::ProjectWorldLocationToWidgetPosition(PlayerController, Actor->GetActorLocation(), CurrentActorScreenPosition, true); - Result = FVector2D::Distance(CurrentActorScreenPosition, ViewportSizeUnscaled / 2); - - // same as in "GetActorClosestToCenterOfScreen" - if (bDebug) - { - bool bRelativeToViewportCenter = false; - float ViewportScale = UWidgetLayoutLibrary::GetViewportScale(WorldContextObject); - FVector2D ViewportSize = UWidgetLayoutLibrary::GetViewportSize(WorldContextObject); - FLineInfo LineInfo = { - "TestLine" + Actor->GetName(), - ViewportSize / 2, - CurrentActorScreenPosition * ViewportScale, - FColor::MakeRandomColor(), - 5, - "" + Actor->GetName() + " " + FString::SanitizeFloat(Result), - FColor::Blue, - bRelativeToViewportCenter, - true, - }; - DrawDebugLineOnCanvas(Actor->GetWorld(), LineInfo, bRelativeToViewportCenter); - } - - return Result; -} - -AActor* UUnrealHelperLibraryBPL::GetActorClosestToCenterOfScreen(UObject* WorldContextObject, const TArray& Actors, APlayerController* PlayerController, FVector2D& ScreenPosition, bool bPlayerViewportRelative, const bool bDebug, const float DebugLifetime) -{ - AActor* Result = nullptr; - FVector2D ResultScreenPosition = FVector2D(133700.322, 133700.322); - float ResultDistance = FVector2D::Distance(ResultScreenPosition, FVector2D::ZeroVector); - - for (AActor* Actor : Actors) - { - float CurrentDistance = GetActorDistanceToCenterOfScreen(Actor, Actor, PlayerController, true, bDebug, DebugLifetime); - - if (CurrentDistance < ResultDistance) - { - ResultDistance = CurrentDistance; - Result = Actor; - } - } - - ScreenPosition = ResultScreenPosition; - return Result; -} - -AActor* UUnrealHelperLibraryBPL::GetMostDistantActor(const TArray& Actors, float& MaxDistance_Out, FVector Location, const bool bDebug, const float DebugLifetime) -{ - // TODO use GetMostDistantVector if possible - AActor* Result = nullptr; - float GreatestDistance = -9999999; - TMap ActorsAndDistances = {}; - - for (AActor* Actor : Actors) - { - float Distance = FVector::Distance(Actor->GetActorLocation(), Location); - ActorsAndDistances.Add(Actor, Distance); - if (Distance > GreatestDistance) - { - GreatestDistance = Distance; - Result = Actor; - MaxDistance_Out = Distance; - } - } - - if (bDebug) - { - for (const TTuple& ActorWithDist : ActorsAndDistances) - { - bool bMostDistant = Result == ActorWithDist.Key; - DrawDebugLine(ActorWithDist.Key->GetWorld(), ActorWithDist.Key->GetActorLocation(), Location, bMostDistant ? FColor::Green : FColor::Red, false, DebugLifetime, -1, 2.0f); - DrawDebugString(ActorWithDist.Key->GetWorld(), FVector::ZeroVector, FString::Printf(TEXT("Distance: %.2f"), ActorWithDist.Value), ActorWithDist.Key, bMostDistant ? FColor::Green : FColor::Red, 0, true, 1); - } - } - - return Result; -} - -FVector UUnrealHelperLibraryBPL::GetMostDistantVector( - const UObject* WorldContextObject, - const TArray Vectors, FVector Location, - float& MaxDistance_Out, int32& Index_Out, bool bUseNavigation, - const bool bDebug, const float DebugLifetime) -{ - FVector Result = VECTOR_ERROR; - - TArray Distances = {}; - float GreatestDistance = -9999999; - - for (int32 i = 0; i < Vectors.Num(); i++) - { - float Distance = FLOAT_ERROR; - if (bUseNavigation) - { - double DistanceInDouble; - UNavigationSystemV1::GetPathLength(WorldContextObject->GetWorld(), Vectors[i], Location, DistanceInDouble); - Distance = DistanceInDouble; - } - else - { - Distance = FVector::Distance(Vectors[i], Location); - } - - Distances[i] = Distance; - - if (Distance > GreatestDistance) - { - GreatestDistance = Distance; - Result = Vectors[i]; - MaxDistance_Out = Distance; - Index_Out = i; - } - } - - if (bDebug) - { - for (int32 i = 0; i < Vectors.Num(); i++) - { - bool bMostDistant = i == Index_Out; - DrawDebugLine(WorldContextObject->GetWorld(), Vectors[i], Location, bMostDistant ? FColor::Green : FColor::Red, false, DebugLifetime, -1, 2.0f); - DrawDebugString(WorldContextObject->GetWorld(), FVector::ZeroVector, FString::Printf(TEXT("Distance: %.2f"), Distances[i]), nullptr, bMostDistant ? FColor::Green : FColor::Red, 0, true, 1); - } - } - - return Result; -} - -FVector UUnrealHelperLibraryBPL::GetMostDistantActorComponent( - const UObject* WorldContextObject, const TArray SceneComponents, - FVector Location, float& MaxDistance_Out, int32& Index_Out, bool bUseNavigation, - const bool bDebug, const float DebugLifetime) -{ - TArray Vectors = {}; - for (int32 i = 0; i < SceneComponents.Num(); i++) - { - if (IsValid(SceneComponents[i])) - { - Vectors.Add(SceneComponents[i]->GetComponentToWorld().GetLocation()); - } - else - { - Vectors.Add(VECTOR_ERROR); - } - } - return GetMostDistantVector(WorldContextObject, - Vectors, Location, - MaxDistance_Out, Index_Out, bUseNavigation, - bDebug, DebugLifetime); -} - -void UUnrealHelperLibraryBPL::DrawDebugLineOnCanvas(UObject* WorldContextObject, const FLineInfo& LineInfo, const bool bRelativeToViewportCenter) -{ - const UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(WorldContextObject); - const APlayerController* PlayerController = GameInstance->GetFirstLocalPlayerController(WorldContextObject->GetWorld()); - AUHLHUD* HUD = PlayerController->GetHUD(); - if (!IsValid(HUD)) return; - - HUD->AddOrUpdateLineInfoToDrawNextTick(LineInfo); -} - -void UUnrealHelperLibraryBPL::DrawDebugCrossHair( - UObject* WorldContextObject, - const float CrossHairLineLength, - const float LineThickness, - const float AngleToRotate, - const FVector2f& CrossHairCenterScreenSpace, - const FLinearColor& LineColor, - const bool bRelativeToViewportCenter - ) -{ - const UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(WorldContextObject); - const APlayerController* PlayerController = GameInstance->GetFirstLocalPlayerController(WorldContextObject->GetWorld()); - AUHLHUD* HUD = PlayerController->GetHUD(); - if (!IsValid(HUD)) return; - - FLineInfo LineInfo = { - "TestLine", - FVector2D(0, 0), - FVector2D(200, 500), - FColor::Red, - 2, - "Test123", - FColor::Blue, - bRelativeToViewportCenter, - true, - }; - DrawDebugLineOnCanvas(WorldContextObject, LineInfo, bRelativeToViewportCenter); -} - -UActorComponent* UUnrealHelperLibraryBPL::GetActorComponentByName(AActor* Actor, FString Name) -{ - if (!IsValid(Actor)) - return nullptr; - - for (UActorComponent* Component : Actor->GetComponents()) - { - if (Component->GetName() == Name) - { - return Component; - } - } - return nullptr; -} - -USceneComponent* UUnrealHelperLibraryBPL::GetSceneComponentByName(AActor* Actor, FString Name) -{ - if (!IsValid(Actor)) - return nullptr; - - return Cast(GetActorComponentByName(Actor, Name)); -} - -FVector UUnrealHelperLibraryBPL::GetRandomPointInBox(const USceneComponent* Component, bool bOnGround, bool bDrawDebug, float DebugDrawTime) -{ - FVector Origin; - FVector BoxExtent; - float SphereRadius; - - UKismetSystemLibrary::GetComponentBounds(Component, Origin, BoxExtent, SphereRadius); - FVector RandomPoint = UKismetMathLibrary::RandomPointInBoundingBox(Origin, BoxExtent); - - if (bOnGround) - { - RandomPoint.Z = GetHighestPointInBox(Component).Z; - FHitResult OutHit; - UKismetSystemLibrary::LineTraceSingle(Component->GetWorld(), RandomPoint, FVector(0, 0, -999999), TraceTypeQuery1, false, TArray(), - bDrawDebug ? EDrawDebugTrace::Type::ForDuration : EDrawDebugTrace::Type::None, OutHit, true, FLinearColor::Red, FLinearColor::Green, DebugDrawTime); - if (OutHit.IsValidBlockingHit()) - { - RandomPoint = OutHit.Location; - } - } - - return RandomPoint; -} - -FVector UUnrealHelperLibraryBPL::GetHighestPointInBox(const USceneComponent* Component) -{ - if (!IsValid(Component)) - return VECTOR_ERROR; - - FVector Origin; - FVector BoxExtent; - float SphereRadius = 0.0f; - UKismetSystemLibrary::GetComponentBounds(Component, Origin, BoxExtent, SphereRadius); - - const FVector BoxMin = Origin - BoxExtent; - const FVector BoxMax = Origin + BoxExtent; - return FBox(BoxMin, BoxMax).Max; -} - -FVector UUnrealHelperLibraryBPL::GetCenterPointInBox(const USceneComponent* Component) -{ - if (!IsValid(Component)) - { - return VECTOR_ERROR; - } - - FVector Origin; - FVector BoxExtent; - float SphereRadius = 0.0f; - UKismetSystemLibrary::GetComponentBounds(Component, Origin, BoxExtent, SphereRadius); - - const FVector BoxMin = Origin - BoxExtent; - const FVector BoxMax = Origin + BoxExtent; - return FBox(BoxMin, BoxMax).GetCenter(); -} - -FBox UUnrealHelperLibraryBPL::GetComponentBox(const USceneComponent* Component) -{ - if (!IsValid(Component)) - { - return FBox(); - } - - FVector Origin; - FVector BoxExtent; - float SphereRadius = 0.0f; - UKismetSystemLibrary::GetComponentBounds(Component, Origin, BoxExtent, SphereRadius); - - const FVector BoxMin = Origin - BoxExtent; - const FVector BoxMax = Origin + BoxExtent; - return FBox(BoxMin, BoxMax); -} - -FVector UUnrealHelperLibraryBPL::GetCenterPointBetweenVectors( - const UObject* WorldContextObject, const FVector& PointA, const FVector& PointB, - const bool bDebug, const float DebugLifetime, const FLinearColor DebugColor) -{ - FVector Result = (PointB - PointA) / 2 + PointA; - - if (bDebug) - { - UWorld* DebugWorld = WorldContextObject->GetWorld(); - DrawDebugSphere(DebugWorld, Result, 10.0f, 12, DebugColor.ToFColor(true), true, DebugLifetime, DEPTH_PRIORITY, 1); - } - - return Result; -} - -void UUnrealHelperLibraryBPL::GetPointAtRelativeAngleUsingVector( - FVector& Point, FRotator& PointRotation, const UObject* WorldContextObject, const FVector& Location, const FVector& ForwardVector, const float Angle, const float Distance, const float OverrideZ, const bool bDebug, const float DebugLifetime, const FLinearColor DebugColor) -{ - if (!WorldContextObject) - { - Point = VECTOR_ERROR; - return; - } - - FVector LocationLocal = Location; - // Override Z if specified (using -999999.f as sentinel value to indicate no override) - if (OverrideZ > -999999.f) - { - LocationLocal.Z = OverrideZ; - } - - FVector NormalizedForward = ForwardVector.GetSafeNormal(); - FVector Result = LocationLocal + NormalizedForward.RotateAngleAxis(Angle, FVector(0, 0, 1)) * Distance; - - if (bDebug) - { - UWorld* DebugWorld = WorldContextObject->GetWorld(); - FString DebugText = FString::Printf(TEXT("Angle %.2f°\nDistance %.2f"), Angle, Distance); - if (OverrideZ > -999999.f) - { - DebugText += FString::Printf(TEXT("\nZ Override: %.2f"), OverrideZ); - } - DrawDebugString(DebugWorld, Result, DebugText, 0, DebugColor.ToFColor(true), DebugLifetime, true, 1.0f); - DrawDebugSphere(DebugWorld, Result, 10.0f, 12, DebugColor.ToFColor(true), true, DebugLifetime, DEPTH_PRIORITY, 1); - FVector ArrowLineEnd = LocationLocal + NormalizedForward.RotateAngleAxis(Angle, FVector(0, 0, 1)) * (Distance - 10); - if (OverrideZ > -999999.f) - { - ArrowLineEnd.Z = OverrideZ; - } - DrawDebugDirectionalArrow(DebugWorld, LocationLocal, ArrowLineEnd, RELATIVE_POINT_ARROW_SIZE, FColor::White, true, DebugLifetime, DEPTH_PRIORITY, 2); - } - - Point = Result; - PointRotation = (Point - LocationLocal).ToOrientationRotator(); -} - -void UUnrealHelperLibraryBPL::GetPointAtRelativeAngle( - FVector& Point, FRotator& PointRotation, const AActor* ActorIn, const float Angle, const float Distance, const bool bDebug, const float DebugLifetime, const FLinearColor DebugColor) -{ - if (!IsValid(ActorIn)) - { - Point = VECTOR_ERROR; - return; - } - FVector Result = ActorIn->GetActorLocation() + ActorIn->GetActorForwardVector().RotateAngleAxis(Angle, FVector(0, 0, 1)) * Distance; - if (bDebug) - { - DrawDebugString(ActorIn->GetWorld(), Result, FString::Printf(TEXT("Angle %.2f°\nDistance %.2f"), Angle, Distance), 0, DebugColor.ToFColor(true), DebugLifetime, true, 1.0f); - DrawDebugSphere(ActorIn->GetWorld(), Result, 10.0f, 12, DebugColor.ToFColor(true), true, DebugLifetime, DEPTH_PRIORITY, 1); - FVector ArrowLineEnd = ActorIn->GetActorLocation() + ActorIn->GetActorForwardVector().RotateAngleAxis(Angle, FVector(0, 0, 1)) * (Distance - 10); - DrawDebugDirectionalArrow(ActorIn->GetWorld(), ActorIn->GetActorLocation(), ArrowLineEnd, RELATIVE_POINT_ARROW_SIZE, FColor::White, true, DebugLifetime, DEPTH_PRIORITY, 2); - } - Point = Result; - PointRotation = (Point - ActorIn->GetActorLocation()).ToOrientationRotator(); -} - -void UUnrealHelperLibraryBPL::GetPointAtRelativeDirection(FVector& Point, FRotator& PointRotation, const AActor* ActorIn, const EUHLDirection Direction, const float Distance, const bool bDebug, - const float DebugLifetime, const FLinearColor DebugColor, const FText DebugText) -{ - if (!IsValid(ActorIn)) - return; - - float Angle = DirectionToAngle(Direction); - GetPointAtRelativeAngle(Point, PointRotation, ActorIn, Angle, Distance); - - if (bDebug) - { - const UEnum* EnumPtr = FindObject(nullptr, TEXT("EUHLDirection"), true); - if (EnumPtr) - { - DrawDebugString(ActorIn->GetWorld(), Point, - FString::Printf(TEXT("%s \nDirection %s\nDistance %.2f"), *DebugText.BuildSourceString(), *EnumPtr->GetNameStringByValue((uint8)Direction), Distance), 0, DebugColor.ToFColor(true), - DebugLifetime, true, 1.0f); - } - DrawDebugSphere(ActorIn->GetWorld(), Point, 10.0f, 12, DebugColor.ToFColor(true), true, DebugLifetime, DEPTH_PRIORITY, 1); - FVector ArrowLineEnd; - FRotator ArrowLineEndRotation; - GetPointAtRelativeAngle(ArrowLineEnd, ArrowLineEndRotation, ActorIn, Angle, Distance - 10); - DrawDebugDirectionalArrow(ActorIn->GetWorld(), ActorIn->GetActorLocation(), ArrowLineEnd, RELATIVE_POINT_ARROW_SIZE, FColor::White, true, DebugLifetime, DEPTH_PRIORITY, 2); - } -} - -void UUnrealHelperLibraryBPL::GetPointAtAngleRelativeToOtherActor(FVector& Point, FRotator& PointRotation, const AActor* Actor1, const AActor* Actor2, const float Angle, const float Distance, - const bool bTakeZFromActor1, const bool bDebug, const float DebugLifetime, const FLinearColor DebugColor) -{ - if (!IsValid(Actor1) || !IsValid(Actor2)) - return; - - const FVector Actor1Location = Actor1->GetActorLocation(); - const FVector Actor2Location = Actor2->GetActorLocation(); - const FVector DirectionBetweenActors = (Actor2Location - Actor1Location).GetSafeNormal(); - Point = Actor1Location + (DirectionBetweenActors.RotateAngleAxis(Angle, FVector(0, 0, 1)) * Distance); - Point.Z = bTakeZFromActor1 ? Actor1Location.Z : Actor2Location.Z; - PointRotation = (Point - Actor1Location).ToOrientationRotator(); - - if (bDebug) - { - UWorld* DebugWorld = Actor1->GetWorld(); - DrawDebugString(DebugWorld, Point, FString::Printf(TEXT("Angle %.2f°\nDistance %.2f"), Angle, Distance), 0, DebugColor.ToFColor(true), DebugLifetime, true, 1.0f); - DrawDebugSphere(DebugWorld, Point, 10.0f, 12, DebugColor.ToFColor(true), true, DebugLifetime, DEPTH_PRIORITY, 1); - FVector ArrowLineEnd = Actor1Location + (DirectionBetweenActors.RotateAngleAxis(Angle, FVector(0, 0, 1)) * (Distance - 10)); - Point.Z = bTakeZFromActor1 ? Actor1Location.Z : Actor2Location.Z; - DrawDebugDirectionalArrow(DebugWorld, Actor1Location, Actor2Location, RELATIVE_POINT_ARROW_SIZE, FColor::White, true, DebugLifetime, DEPTH_PRIORITY, 1); - DrawDebugDirectionalArrow(DebugWorld, Actor1Location, ArrowLineEnd, RELATIVE_POINT_ARROW_SIZE, FColor::White, true, DebugLifetime, DEPTH_PRIORITY, 2); - } -} - -void UUnrealHelperLibraryBPL::GetPointAtDirectionRelativeToOtherActor(FVector& Point, FRotator& PointRotation, const AActor* Actor1, const AActor* Actor2, const EUHLDirection Direction, - const float Distance, const bool bTakeZFromActor1, const bool bDebug, const float DebugLifetime, const FLinearColor DebugColor) -{ - if (!IsValid(Actor1) || !IsValid(Actor2)) - return; - - float Angle = DirectionToAngle(Direction); - GetPointAtAngleRelativeToOtherActor(Point, PointRotation, Actor1, Actor2, Angle, Distance, bTakeZFromActor1); - - if (bDebug) - { - const UEnum* EnumPtr = FindObject(nullptr, TEXT("EUHLDirection"), true); - if (EnumPtr) - { - DrawDebugString(Actor1->GetWorld(), Point, FString::Printf(TEXT("Direction %s\nDistance %.2f"), *EnumPtr->GetNameStringByValue((uint8)Direction), Distance), 0, DebugColor.ToFColor(true), - DebugLifetime, true, 1.0f); - } - DrawDebugSphere(Actor1->GetWorld(), Point, 10.0f, 12, DebugColor.ToFColor(true), true, DebugLifetime, DEPTH_PRIORITY, 1); - FVector ArrowLineEnd; - FRotator ArrowLineEndRotation; - GetPointAtAngleRelativeToOtherActor(ArrowLineEnd, ArrowLineEndRotation, Actor1, Actor2, Angle, Distance, bTakeZFromActor1); - DrawDebugDirectionalArrow(Actor1->GetWorld(), Actor1->GetActorLocation(), Actor2->GetActorLocation(), RELATIVE_POINT_ARROW_SIZE, FColor::White, true, DebugLifetime, DEPTH_PRIORITY, 1); - DrawDebugDirectionalArrow(Actor1->GetWorld(), Actor1->GetActorLocation(), ArrowLineEnd, RELATIVE_POINT_ARROW_SIZE, FColor::White, true, DebugLifetime, DEPTH_PRIORITY, 2); - } -} - -void UUnrealHelperLibraryBPL::GetPointAtDirectionRelativeToOtherVector(FVector& Point, FRotator& PointRotation, const FVector& Vector1, const FVector& Vector2, const EUHLDirection Direction, - const float Distance, const bool bTakeZFromVector1, const bool bDebug, const float DebugLifetime, const FLinearColor DebugColor) -{ - float Angle = DirectionToAngle(Direction); - const FVector DirectionBetweenVectors = (Vector2 - Vector1).GetSafeNormal(); - Point = Vector1 + (DirectionBetweenVectors.RotateAngleAxis(Angle, FVector(0, 0, 1)) * Distance); - Point.Z = bTakeZFromVector1 ? Vector1.Z : Vector2.Z; - PointRotation = (Point - Vector1).ToOrientationRotator(); - - if (bDebug) - { - UWorld* DebugWorld = GEngine->GetWorld(); - if (!DebugWorld) return; - - const UEnum* EnumPtr = FindObject(nullptr, TEXT("EUHLDirection"), true); - if (EnumPtr) - { - DrawDebugString(DebugWorld, Point, FString::Printf(TEXT("Direction %s\nDistance %.2f"), *EnumPtr->GetNameStringByValue((uint8)Direction), Distance), 0, DebugColor.ToFColor(true), - DebugLifetime, true, 1.0f); - } - DrawDebugSphere(DebugWorld, Point, 10.0f, 12, DebugColor.ToFColor(true), true, DebugLifetime, DEPTH_PRIORITY, 1); - FVector ArrowLineEnd = Vector1 + (DirectionBetweenVectors.RotateAngleAxis(Angle, FVector(0, 0, 1)) * (Distance - 10)); - Point.Z = bTakeZFromVector1 ? Vector1.Z : Vector2.Z; - DrawDebugDirectionalArrow(DebugWorld, Vector1, Vector2, RELATIVE_POINT_ARROW_SIZE, FColor::White, true, DebugLifetime, DEPTH_PRIORITY, 1); - DrawDebugDirectionalArrow(DebugWorld, Vector1, ArrowLineEnd, RELATIVE_POINT_ARROW_SIZE, FColor::White, true, DebugLifetime, DEPTH_PRIORITY, 2); - } -} - -float UUnrealHelperLibraryBPL::DirectionToAngle(const EUHLDirection DirectionIn) -{ - if (DirectionIn == EUHLDirection::Front) - return 0.0f; - if (DirectionIn == EUHLDirection::Back) - return 180.0f; - if (DirectionIn == EUHLDirection::Left) - return -90.0f; - if (DirectionIn == EUHLDirection::Right) - return 90.0f; - if (DirectionIn == EUHLDirection::FrontLeft) - return -45.0f; - if (DirectionIn == EUHLDirection::FrontRight) - return 45.0f; - if (DirectionIn == EUHLDirection::BackLeft) - return -135.0f; - if (DirectionIn == EUHLDirection::BackRight) - return 135.0f; - return 0.0f; -} - -EUHLDirection UUnrealHelperLibraryBPL::ConvertMovementInputVectorToDirection(const FVector& InputVector) -{ - // Project to 2D - float X = InputVector.X; - float Y = InputVector.Y; - - // atan2 returns radians from -π to +π - float Radians = FMath::Atan2(Y, X); - float Degrees = FMath::RadiansToDegrees(Radians); - - // Normalize into [0, 360) - if (Degrees < 0.f) - { - Degrees += 360.f; - } - - // Divide into 8 slices, round to nearest integer [0..7] - int32 Slice = FMath::RoundToInt(Degrees / 45.f) % 8; - - switch (Slice) - { - case 0: return EUHLDirection::Right; - case 1: return EUHLDirection::FrontRight; - case 2: return EUHLDirection::Front; - case 3: return EUHLDirection::FrontLeft; - case 4: return EUHLDirection::Left; - case 5: return EUHLDirection::BackLeft; - case 6: return EUHLDirection::Back; - case 7: return EUHLDirection::BackRight; - default: return EUHLDirection::Front; // fall-back - } -} - -EUHLDirection UUnrealHelperLibraryBPL::GetMovementDirection( - const FVector& Velocity, const FRotator& ActorRotation, float DeadZone) -{ - // 1) Flatten to horizontal plane - FVector FlatVel = Velocity; - FlatVel.Z = 0.f; - - // 2) Early-out if below threshold - if (FlatVel.SizeSquared() <= FMath::Square(DeadZone)) - { - return EUHLDirection::None; - } - - // 3) Compute world-space yaw of movement - const float MovementYaw = FlatVel.Rotation().Yaw; - - // 4) Your actor's facing yaw - const float ForwardYaw = ActorRotation.Yaw; - - // 5) Signed difference in [-180, +180] - float DeltaYaw = FMath::UnwindDegrees(MovementYaw - ForwardYaw); - - // 6) Snap into 8 slices of 45° each - float SliceF = DeltaYaw / 45.f; - int32 SliceI = FMath::RoundToInt(SliceF); - - // 7) Wrap the exact 180° case: -4 → +4 - if (SliceI == -4) SliceI = 4; - - // 8) Ensure index in [0..7] - SliceI = (SliceI + 8) % 8; - - // 9) Map to your enum - switch (SliceI) - { - case 0: return EUHLDirection::Front; - case 1: return EUHLDirection::FrontRight; - case 2: return EUHLDirection::Right; - case 3: return EUHLDirection::BackRight; - case 4: return EUHLDirection::Back; - case 5: return EUHLDirection::BackLeft; - case 6: return EUHLDirection::Left; - case 7: return EUHLDirection::FrontLeft; - default: return EUHLDirection::None; // should never hit this - } -} - -EUHLDirection UUnrealHelperLibraryBPL::GetEnemyMovementDirectionRelativeToCharacter( - UObject* WorldContextObject, - const FVector& EnemyVelocity, - const FVector& MyVelocity, - const FVector& ActorLocation, - const FRotator& ActorRotation, - float DeadZone, - float AngleToleranceDeg, - bool bFourWay, - bool bDebug, - float DebugDuration, - float DebugThickness -) -{ - // If enemy isn't moving, return None immediately - if (EnemyVelocity.IsNearlyZero(KINDA_SMALL_NUMBER)) - { - if (bDebug && WorldContextObject) - { - UWorld* World = GEngine->GetWorldFromContextObjectChecked(WorldContextObject); - DrawDebugString(World, ActorLocation + FVector(0,0,50), TEXT("None"), nullptr, FColor::White, DebugDuration, true); - } - return EUHLDirection::None; - } - - // Compute relative movement and flatten to XY - FVector RelVel = EnemyVelocity - MyVelocity; - RelVel.Z = 0.f; - - // Effective dead zone threshold - const float EffectiveDeadZone = (DeadZone > 0.f) ? DeadZone : KINDA_SMALL_NUMBER; - if (RelVel.SizeSquared() <= FMath::Square(EffectiveDeadZone)) - { - if (bDebug && WorldContextObject) - { - UWorld* World = GEngine->GetWorldFromContextObjectChecked(WorldContextObject); - DrawDebugString(World, ActorLocation + FVector(0,0,50), TEXT("None"), nullptr, FColor::White, DebugDuration, true); - } - return EUHLDirection::None; - } - - // Compute yaw difference - const float MovementYaw = RelVel.Rotation().Yaw; - const float ForwardYaw = ActorRotation.Yaw; - float DeltaYaw = FMath::UnwindDegrees(MovementYaw - ForwardYaw); - - // Determine octant index with tolerance - const float SliceF = DeltaYaw / 45.f; - const float TolSlice = AngleToleranceDeg / 45.f; - int32 SliceI = INDEX_NONE; - for (int32 i = 0; i < 8; ++i) - { - if (FMath::Abs(SliceF - i) <= TolSlice) - { - SliceI = i; - break; - } - } - if (SliceI == INDEX_NONE) - { - SliceI = FMath::RoundToInt(SliceF); - } - if (SliceI == -4) SliceI = 4; - SliceI = (SliceI + 8) % 8; - - // Map index to enum - EUHLDirection DirEnum; - switch (SliceI) - { - case 0: DirEnum = EUHLDirection::Front; break; - case 1: DirEnum = EUHLDirection::FrontRight; break; - case 2: DirEnum = EUHLDirection::Right; break; - case 3: DirEnum = EUHLDirection::BackRight; break; - case 4: DirEnum = EUHLDirection::Back; break; - case 5: DirEnum = EUHLDirection::BackLeft; break; - case 6: DirEnum = EUHLDirection::Left; break; - case 7: DirEnum = EUHLDirection::FrontLeft; break; - default: DirEnum = EUHLDirection::None; break; - } - - // Collapse to 4-way if requested - if (bFourWay) - { - if (DirEnum == EUHLDirection::FrontLeft || DirEnum == EUHLDirection::FrontRight) - DirEnum = EUHLDirection::Front; - else if (DirEnum == EUHLDirection::BackLeft || DirEnum == EUHLDirection::BackRight) - DirEnum = EUHLDirection::Back; - } - - // Debug visuals - if (bDebug && WorldContextObject) - { - UWorld* World = GEngine->GetWorldFromContextObjectChecked(WorldContextObject); - const float DebugLen = 200.f; - - // Draw octant boundaries - for (int32 i = 0; i < 8; ++i) - { - float Yaw = ForwardYaw + i * 45.f; - FVector DirVec = FRotator(0.f, Yaw, 0.f).Vector() * DebugLen; - DrawDebugLine(World, ActorLocation, ActorLocation + DirVec, FColor::Silver, false, DebugDuration, 0, DebugThickness * 0.5f); - } - - // Draw relative movement arrow (cyan) - DrawDebugDirectionalArrow(World, ActorLocation, ActorLocation + RelVel.GetSafeNormal() * DebugLen, - 50.f, FColor::Cyan, false, DebugDuration, 0, DebugThickness); - - // Draw forward axis (green) - FVector FwdVec = ActorRotation.Vector() * DebugLen; - DrawDebugLine(World, ActorLocation, ActorLocation + FwdVec, FColor::Green, false, DebugDuration, 0, DebugThickness); - - // Draw chosen direction arrow (red) - float ChosenYaw = ForwardYaw + SliceI * 45.f; - FVector ChosenVec = FRotator(0.f, ChosenYaw, 0.f).Vector() * DebugLen; - DrawDebugLine(World, ActorLocation, ActorLocation + ChosenVec, FColor::Red, false, DebugDuration, 0, DebugThickness); - - // Label result using clean name - UEnum* EnumPtr = FindObject(ANY_PACKAGE, TEXT("EUHLDirection"), true); - FString Name = EnumPtr ? EnumPtr->GetNameStringByValue((int64)DirEnum) : TEXT("None"); - DrawDebugString(World, ActorLocation + FVector(0,0,50), Name, nullptr, FColor::White, DebugDuration, true); - } - - return DirEnum; -} - - -float UUnrealHelperLibraryBPL::ConvertPercentToMultiplier(float Percent) { return (100.0f - Percent) / 100.0f; } - -AActor* UUnrealHelperLibraryBPL::FindAttachedActorByTag(AActor* ActorIn, FName Tag) -{ - TArray OutActors; - ActorIn->GetAttachedActors(OutActors, true, true); - - AActor** ActorSearchResult = OutActors.FindByPredicate([Tag](const AActor* Actor) - { - return Actor->ActorHasTag(Tag); - }); - - if (ActorSearchResult) - { - return *ActorSearchResult; - } - return nullptr; -} - -bool UUnrealHelperLibraryBPL::IsPreviewWorld(UObject* WorldContextObject) { return WorldContextObject->GetWorld()->IsPreviewWorld(); } - -bool UUnrealHelperLibraryBPL::IsGameWorld(UObject* WorldContextObject) { return WorldContextObject->GetWorld()->IsGameWorld(); } - -bool UUnrealHelperLibraryBPL::IsEditorWorld(UObject* WorldContextObject) { return WorldContextObject->GetWorld()->IsEditorWorld(); } - -bool UUnrealHelperLibraryBPL::IsObjectInPreviewWorld(UObject* Object) { return Object->GetWorld()->IsPreviewWorld(); } - -bool UUnrealHelperLibraryBPL::IsObjectInEditorWorld(UObject* Object) { return Object->GetWorld()->IsEditorWorld(); } - -bool UUnrealHelperLibraryBPL::IsObjectInGameWorld(UObject* Object) { return Object->GetWorld()->IsGameWorld(); } - -bool UUnrealHelperLibraryBPL::IsWorldTearingDown(UObject* WorldContextObject) { return WorldContextObject->GetWorld()->bIsTearingDown; } - -bool UUnrealHelperLibraryBPL::IsOtherActorInAngle(AActor* Actor, AActor* OtherActor, TArray Ranges) -{ - float RelativeAngle = RelativeAngleToActor(Actor, OtherActor); - bool bInAngle = false; - for (FFloatRange Range : Ranges) - { - bInAngle = UKismetMathLibrary::InRange_FloatFloat(RelativeAngle, Range.GetLowerBoundValue(), Range.GetUpperBoundValue(), true, true); - if (bInAngle) - break; - } - return bInAngle; -} - -bool UUnrealHelperLibraryBPL::InRangeToOtherCharacter(ACharacter* Character, ACharacter* OtherCharacter, FFloatRange Range, bool bIncludeSelfCapsuleRadius, bool bIncludeTargetCapsuleRadius) -{ - if (!Character || !OtherCharacter) - { - return false; - } - - float CurrentDistance = Character->GetDistanceTo(OtherCharacter); - - if (bIncludeSelfCapsuleRadius) - { - CurrentDistance -= Character->GetCapsuleComponent()->GetScaledCapsuleRadius(); - } - if (bIncludeTargetCapsuleRadius) - { - CurrentDistance -= OtherCharacter->GetCapsuleComponent()->GetScaledCapsuleRadius(); - } - - bool bInRange = UKismetMathLibrary::InRange_FloatFloat(CurrentDistance, Range.GetLowerBoundValue(), Range.GetUpperBoundValue()); - return bInRange; -} - -bool UUnrealHelperLibraryBPL::InRangeToLocation( - ACharacter* Character, FVector Location, FFloatRange Range, bool bIncludeSelfCapsuleRadius) -{ - if (!Character) - { - return false; - } - - float CurrentDistance = FVector::Dist2D(Character->GetActorLocation(), Location); - - if (bIncludeSelfCapsuleRadius) - { - CurrentDistance -= Character->GetCapsuleComponent()->GetScaledCapsuleRadius(); - } - - bool bInRange = UKismetMathLibrary::InRange_FloatFloat(CurrentDistance, Range.GetLowerBoundValue(), Range.GetUpperBoundValue()); - return bInRange; -} - -FString UUnrealHelperLibraryBPL::GetPathToFile(UObject* Object) -{ - FString NameAndWithSlash = FString::Printf(TEXT("/%s"), *Object->GetName()); - return Object->GetPathName(NULL).Replace(*Object->GetName(), TEXT("")); -} - -bool UUnrealHelperLibraryBPL::IsDebugBuild() -{ - EBuildConfiguration BuildConfiguration = FApp::GetBuildConfiguration(); - if (BuildConfiguration == EBuildConfiguration::Debug || BuildConfiguration == EBuildConfiguration::DebugGame) - { - return true; - } - return false; -} - -bool UUnrealHelperLibraryBPL::IsDevelopmentBuild() -{ - EBuildConfiguration BuildConfiguration = FApp::GetBuildConfiguration(); - return BuildConfiguration == EBuildConfiguration::Development; -} - -bool UUnrealHelperLibraryBPL::IsShippingBuild() -{ - EBuildConfiguration BuildConfiguration = FApp::GetBuildConfiguration(); - return BuildConfiguration == EBuildConfiguration::Shipping; -} - -bool UUnrealHelperLibraryBPL::IsTestBuild() -{ - EBuildConfiguration BuildConfiguration = FApp::GetBuildConfiguration(); - return BuildConfiguration == EBuildConfiguration::Test; -} - -bool UUnrealHelperLibraryBPL::IsInEditor() -{ -#if WITH_EDITOR - return true; -#else - return false; -#endif -} - -EUHLBuildType UUnrealHelperLibraryBPL::GetBuildType() -{ - if (IsInEditor()) - return EUHLBuildType::Editor; - - EBuildConfiguration BuildConfiguration = FApp::GetBuildConfiguration(); - switch (BuildConfiguration) - { - case EBuildConfiguration::Debug: - return EUHLBuildType::Debug; - break; - case EBuildConfiguration::DebugGame: - return EUHLBuildType::Debug; - break; - case EBuildConfiguration::Development: - return EUHLBuildType::Development; - break; - case EBuildConfiguration::Shipping: - return EUHLBuildType::Shipping; - break; - case EBuildConfiguration::Test: - return EUHLBuildType::Test; - break; - default: - return IsInEditor() ? EUHLBuildType::Editor : EUHLBuildType::None; - break; - } -} - -float UUnrealHelperLibraryBPL::RandomValueInInterval(FFloatInterval Range) -{ - // Ensure correct ordering - const float Lower = FMath::Min(Range.Min, Range.Max); - const float Upper = FMath::Max(Range.Min, Range.Max); - - return FMath::FRandRange(Lower, Upper); -} - -bool UUnrealHelperLibraryBPL::IsWorldPartitionEnabled(UObject* WorldContextObject) -{ - if (!WorldContextObject) return false; - - UWorld* World = WorldContextObject->GetWorld(); - return World && World->GetWorldPartition() != nullptr; -} - -bool UUnrealHelperLibraryBPL::IsLevelHasSublevels(UObject* WorldContextObject) -{ - UWorld* World = WorldContextObject->GetWorld(); - const TArray& StreamingLevels = World->GetStreamingLevels(); - - return StreamingLevels.Num() > 0; -} - -void UUnrealHelperLibraryBPL::GetAllStreamingLevels( - UObject* WorldContextObject, TArray& OutStreamingLevels) -{ - OutStreamingLevels.Empty(); - - if (!WorldContextObject) - { - UE_LOG(LogTemp, Warning, TEXT("UUnrealHelperLibraryBPL::GetAllStreamingLevels: Invalid WorldContextObject")); - return; - } - - UWorld* World = GEngine - ? GEngine->GetWorldFromContextObjectChecked(WorldContextObject) - : nullptr; - - if (!World) - { - UE_LOG(LogTemp, Warning, TEXT("UUnrealHelperLibraryBPL::GetAllStreamingLevels: Could not resolve UWorld from context")); - return; - } - - // Grab the streaming levels array - OutStreamingLevels = World->GetStreamingLevels(); -} - -void UUnrealHelperLibraryBPL::GetAllSubLevels(UObject* WorldContextObject, TArray& OutSubLevels) -{ - OutSubLevels.Empty(); - - if (!WorldContextObject) - { - UE_LOG(LogTemp, Warning, TEXT("GetAllSubLevels: Invalid WorldContextObject")); - return; - } - - // Resolve the world from the context object - UWorld* World = GEngine - ? GEngine->GetWorldFromContextObjectChecked(WorldContextObject) - : nullptr; - - if (!World) - { - UE_LOG(LogTemp, Warning, TEXT("GetAllSubLevels: Could not resolve UWorld from context")); - return; - } - - // World->GetLevels() returns every ULevel* currently loaded: - // - The Persistent Level - // - Any Streaming Levels that are loaded into memory - OutSubLevels = World->GetLevels(); -} - -bool UUnrealHelperLibraryBPL::IsMapPackageName(const FString& PackageName) -{ - // Convert to filename to check extension - FString Filename; - if (FPackageName::TryConvertLongPackageNameToFilename(PackageName, Filename, FPackageName::GetMapPackageExtension())) - { - // Ensure the file actually exists on disk (optional) - return FPaths::FileExists(Filename); - } - return false; -} - -FString UUnrealHelperLibraryBPL::GetCleanLevelName(const FString& PackageName) -{ - // Turn "/Game/Maps/MyMap" into "MyMap" (or "UEDPIE_0_MyMap" if in PIE) - const FString ShortName = FPackageName::GetShortName(PackageName); - - // If PIE, find the first "_" and strip off the prefix - if (ShortName.StartsWith(TEXT("UEDPIE_"))) - { - int32 UnderscoreIndex = INDEX_NONE; - // Finds the first underscore after "UEDPIE" - if (ShortName.FindChar(TEXT('_'), UnderscoreIndex)) - { - // Chop off everything up to (and including) that underscore - return ShortName.Mid(UnderscoreIndex + 1); - } - } - - // Otherwise, just return the plain short name - return ShortName; -} - -void UUnrealHelperLibraryBPL::GetAllSubLevelPackageNames(UObject* WorldContextObject, TArray& OutLevelPackageNames) -{ - OutLevelPackageNames.Empty(); - - if (!WorldContextObject) { return; } - - UWorld* World = GEngine->GetWorldFromContextObjectChecked(WorldContextObject); - if (!World) { return; } - - // 1) Persistent Level - // if (ULevel* Persistent = World->PersistentLevel) - // { - // const FString Raw = Persistent->GetOutermost()->GetName(); - // if (IsMapPackageName(Raw)) - // { - // OutLevelPackageNames.Add(Raw); - // } - // } - - // 2) All streaming levels (loaded or not) - for (ULevelStreaming* StreamingLevel : World->GetStreamingLevels()) - { - if (!StreamingLevel) continue; - - const FString Raw = StreamingLevel->GetWorldAssetPackageName(); - const FString CleanName = GetCleanLevelName(Raw); - - // Only include if it’s actually a .umap in your project - if (IsMapPackageName(Raw)) - { - OutLevelPackageNames.Add(CleanName); - } - } -} - - -FColor UUnrealHelperLibraryBPL::RandomColor(int32 Seed) -{ - if (Seed >= 0) - { - return FColor::MakeRandomSeededColor(Seed); - } - return FColor::MakeRandomColor(); -} - -FLinearColor UUnrealHelperLibraryBPL::RandomLinearColor(int32 Seed) -{ - if (Seed >= 0) - { - return FLinearColor::MakeRandomSeededColor(Seed); - } - return FLinearColor::MakeRandomColor(); -} diff --git a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_ChangeCapsuleBase.h b/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_ChangeCapsuleBase.h deleted file mode 100644 index 08302306..00000000 --- a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_ChangeCapsuleBase.h +++ /dev/null @@ -1,214 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "ANS_UHL_Base.h" -#include "Components/CapsuleComponent.h" -#include "Curves/CurveFloat.h" -#include "CoreMinimal.h" -#include "AlphaBlend.h" -#include "Curves/CurveFloat.h" -#include "ANS_ChangeCapsuleBase.generated.h" - -USTRUCT(BlueprintType) -struct FChangeCapsuleCollisionSettings -{ - GENERATED_BODY() - - /** Override Collision Enabled */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Change Capsule", meta=(InlineEditConditionToggle)) - bool bOverrideCollisionEnabled = false; - /** Collision enabled state (None / QueryOnly / QueryAndPhysics) */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Change Capsule", meta=(EditCondition="bOverrideCollisionEnabled")) - TEnumAsByte CollisionEnabled = ECollisionEnabled::QueryAndPhysics; - - /** Override Collision Profile Name */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Change Capsule", meta=(InlineEditConditionToggle)) - bool bOverrideCollisionProfileName = false; - /** Collision profile name from your Project Settings → Collision */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Change Capsule", meta=(EditCondition="bOverrideCollisionProfileName")) - FName CollisionProfileName = TEXT("Pawn"); - - /** Override Generate Overlap Events */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Change Capsule", meta=(InlineEditConditionToggle)) - bool bOverrideGenerateOverlapEvents = false; - /** Generate overlap events? */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Change Capsule", meta=(EditCondition="bOverrideGenerateOverlapEvents")) - bool bGenerateOverlapEvents = true; - - /** Override Force Query Only */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Change Capsule", meta=(InlineEditConditionToggle)) - bool bOverrideForceQueryOnly = false; - /** If true, forces query‑only even if CollisionEnabled is set to Physics */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Change Capsule", meta=(EditCondition="bOverrideForceQueryOnly")) - bool bForceQueryOnly = false; - - /** Override Custom Responses */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Change Capsule", meta=(InlineEditConditionToggle)) - bool bOverrideCustomResponses = false; - /** Per‑channel responses (Block / Overlap / Ignore) */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Change Capsule", meta=(EditCondition="bOverrideCustomResponses")) - TMap, TEnumAsByte> CustomResponses; -}; - -/** - * Base ANS that handles “modify capsule properties + blend in/out via FAlphaBlend - * + optional custom EaseCurve + debug visualization.” - * Subclasses must override FindCapsuleComponent(...) to choose which capsule to edit. - */ -UCLASS(Abstract, Blueprintable, meta = (DisplayName = "Change Capsule Base")) -class UNREALHELPERLIBRARY_API UANS_ChangeCapsuleBase : public UANS_UHL_Base -{ - GENERATED_BODY() - -public: - /** Change the capsule’s radius for this notify. */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Change Capsule", meta=(InlineEditConditionToggle)) - bool bModifyRadius = false; - - /** Target radius to interpolate to (only if bModifyRadius == true). */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Change Capsule", - meta = (EditCondition = "bModifyRadius", ClampMin = "0.0")) - float NewRadius = 42.0f; - - /** Change the capsule’s half-height for this notify. */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Change Capsule", meta=(InlineEditConditionToggle)) - bool bModifyHalfHeight = false; - - /** Target half-height to interpolate to (only if bModifyHalfHeight == true). */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Change Capsule", - meta = (EditCondition = "bModifyHalfHeight", ClampMin = "0.0")) - float NewHalfHeight = 96.0f; - - /** Change the capsule’s component scale for this notify. */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Change Capsule", meta=(InlineEditConditionToggle)) - bool bModifyScale = false; - - /** Target relative scale to interpolate to (only if bModifyScale == true). */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Change Capsule", - meta = (EditCondition = "bModifyScale", EditConditionInline)) - FVector NewScale = FVector(1.0f, 1.0f, 1.0f); - - /** Change the capsule’s wireframe line thickness for this notify. */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Change Capsule", meta=(InlineEditConditionToggle)) - bool bModifyLineThickness = false; - - /** Target wireframe line thickness to interpolate to (only if bModifyLineThickness == true). */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Change Capsule", - meta = (EditCondition = "bModifyLineThickness", ClampMin = "0.1")) - float NewLineThickness = 1.0f; - - /** Change the capsule’s wireframe shape color for this notify. */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Change Capsule", meta=(InlineEditConditionToggle)) - bool bModifyShapeColor = false; - - /** Target wireframe shape color to interpolate to (only if bModifyShapeColor == true). */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Change Capsule", - meta = (EditCondition = "bModifyShapeColor", EditConditionInline)) - FLinearColor NewShapeColor = FLinearColor::Red; - - /** How long (seconds) to blend from original → target when notify begins. */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Change Capsule", meta = (ClampMin = "0.0")) - float BlendTimeIn = 0.0f; - - /** Blend function to use when blending in (Linear, Cubic, Exponential, etc.). */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Change Capsule") - EAlphaBlendOption BlendOptionIn = EAlphaBlendOption::Linear; - - /** How long (seconds) to blend from target → original when notify ends. */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Change Capsule", meta = (ClampMin = "0.0")) - float BlendTimeOut = 0.0f; - - /** Blend function to use when blending out. */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Change Capsule") - EAlphaBlendOption BlendOptionOut = EAlphaBlendOption::Linear; - - /** Collision settings with independent toggles */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Change Capsule") - FChangeCapsuleCollisionSettings CapsuleCollisionSettings; - - /** - * Optional custom Ease Curve: - * If you assign a valid FRuntimeFloatCurve here, the raw alpha (from FAlphaBlend) - * will be remapped through this curve. If left empty, interpolation uses FAlphaBlend only. - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Change Capsule", meta = (DisplayName = "Custom Ease Curve (Optional)")) - FRuntimeFloatCurve EaseCurve; - - /** If true, draw a debug visualization of the capsule each tick. */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Change Capsule") - bool bDebug = false; - - - virtual void NotifyBegin( - USkeletalMeshComponent* MeshComp, - UAnimSequenceBase* Animation, - float TotalDuration, - const FAnimNotifyEventReference& EventReference - ) override; - - virtual void NotifyTick( - USkeletalMeshComponent* MeshComp, - UAnimSequenceBase* Animation, - float FrameDeltaTime, - const FAnimNotifyEventReference& EventReference - ) override; - - virtual void NotifyEnd( - USkeletalMeshComponent* MeshComp, - UAnimSequenceBase* Animation, - const FAnimNotifyEventReference& EventReference - ) override; - - -protected: - /** - * Subclasses must return the UCapsuleComponent to modify (e.g. Character’s capsule or named capsule). - * Return nullptr if none found. - */ - virtual UCapsuleComponent* FindCapsuleComponent(USkeletalMeshComponent* MeshComp) const PURE_VIRTUAL(UANS_ChangeCapsuleBase::FindCapsuleComponent, return nullptr;); - - -private: - /** The capsule component we’ll modify. */ - UPROPERTY(Transient) - UCapsuleComponent* CapsuleComp = nullptr; - - /** Stored “original” values from NotifyBegin. */ - float OriginalRadius = 0.0f; - float OriginalHalfHeight = 0.0f; - FVector OriginalScale = FVector::OneVector; - float OriginalLineThickness = 1.0f; - FLinearColor OriginalShapeColor = FLinearColor::White; - - /** Cached “target” values (NewX if flagged; otherwise OriginalX). */ - float TargetRadius = 0.0f; - float TargetHalfHeight = 0.0f; - FVector TargetScale = FVector::OneVector; - float TargetLineThickness = 1.0f; - FLinearColor TargetShapeColor = FLinearColor::White; - - /** FAlphaBlend instances for in/out. */ - FAlphaBlend BlendInAlpha; - FAlphaBlend BlendOutAlpha; - - /** Total duration of this notify (from NotifyBegin). */ - float NotifyTotalDuration = 0.0f; - - /** Elapsed time (since NotifyBegin). */ - float ElapsedTime = 0.0f; - - /** Whether we successfully grabbed “originals” in NotifyBegin. */ - bool bHasValidOriginals = false; - - /** Snapshot of original capsule settings for revert */ - FChangeCapsuleCollisionSettings OriginalCapsuleSettings; - - // Save original collision settings - void SaveOriginalCollisionSettings(); - // Restore capsule to original state - void RestoreOriginalCollisionSettings(); - // Applies settings: restores original then applies overrides - void ApplyCollisionSettings(); -}; \ No newline at end of file diff --git a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_ChangeCharacterCapsule.h b/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_ChangeCharacterCapsule.h deleted file mode 100644 index 7c2746b7..00000000 --- a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_ChangeCharacterCapsule.h +++ /dev/null @@ -1,20 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "ANS_ChangeCapsuleBase.h" -#include "ANS_ChangeCharacterCapsule.generated.h" - -/** - * ANS that always targets the owning ACharacter’s capsule component. - */ -UCLASS(Blueprintable, meta = (DisplayName = "Change Character Capsule")) -class UNREALHELPERLIBRARY_API UANS_ChangeCharacterCapsule : public UANS_ChangeCapsuleBase -{ - GENERATED_BODY() - -protected: - /** Return the Character’s UCapsuleComponent, or nullptr if none. */ - virtual UCapsuleComponent* FindCapsuleComponent(USkeletalMeshComponent* MeshComp) const override; -}; diff --git a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_ChangeNamedCapsule.h b/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_ChangeNamedCapsule.h deleted file mode 100644 index dc422184..00000000 --- a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_ChangeNamedCapsule.h +++ /dev/null @@ -1,25 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "ANS_ChangeCapsuleBase.h" -#include "ANS_ChangeNamedCapsule.generated.h" - -/** - * ANS that looks for a UCapsuleComponent by its component‐name on the actor. - */ -UCLASS(Blueprintable, meta = (DisplayName = "Change Named Capsule")) -class UNREALHELPERLIBRARY_API UANS_ChangeNamedCapsule : public UANS_ChangeCapsuleBase -{ - GENERATED_BODY() - -public: - /** Exact component‐name (FName) of the UCapsuleComponent to modify (e.g. "CapsuleVisual"). */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Capsule|Lookup") - FName CapsuleComponentName = NAME_None; - -protected: - /** Return the capsule whose Component Name matches. */ - virtual UCapsuleComponent* FindCapsuleComponent(USkeletalMeshComponent* MeshComp) const override; -}; diff --git a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_ChangeRotationRate.h b/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_ChangeRotationRate.h deleted file mode 100644 index 250d66f9..00000000 --- a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_ChangeRotationRate.h +++ /dev/null @@ -1,51 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Animation/Notifies/ANS_UHL_Base.h" -#include "ANS_ChangeRotationRate.generated.h" - -class UCharacterMovementComponent; - -/** - * better to use UANS_UHL_AllowCharacterRotation it combines both - * - bAllowPhysicsRotationDuringAnimRootMotion - * - and opportunity to change RotationRate - * thats much common use case than just changing rotation rate - */ -UCLASS() -class UNREALHELPERLIBRARY_API UANS_ChangeRotationRate : public UANS_UHL_Base -{ - GENERATED_BODY() - -public: - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="ActivateAbility") - FRotator RotationRate = FRotator::ZeroRotator; - -protected: -#if WITH_EDITOR - /** Override this to prevent firing this notify state type in animation editors */ - virtual bool ShouldFireInEditor() { return false; } -#endif - - virtual FLinearColor GetEditorColor() override { return FLinearColor(0.53f, 0.6f, 0.85f); }; - virtual FString GetNotifyName_Implementation() const override; - - virtual void NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) override; - virtual void NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override; - - virtual void OnMontageBlendingOut(UAnimMontage* Montage, bool bInterrupted) override; - -private: - UPROPERTY() - FRotator InitialRotationRate = FRotator::ZeroRotator; - - TWeakObjectPtr CharacterMovementComponent; - - UFUNCTION() - void ReturnInitialRotationRate(); - - // UFUNCTION() - // UUHLCharacterMovementComponent* GetUHLCharacterMovementComponent(ACharacter* Character); -}; diff --git a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_EnableRootMotionZAxisMovement.h b/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_EnableRootMotionZAxisMovement.h deleted file mode 100644 index 2ed69691..00000000 --- a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_EnableRootMotionZAxisMovement.h +++ /dev/null @@ -1,57 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "ANS_UHL_Base.h" -#include "Animation/AnimMontage.h" -#include "Animation/AnimNotifies/AnimNotifyState.h" -#include "Engine/EngineTypes.h" -#include "ANS_EnableRootMotionZAxisMovement.generated.h" - -class ACharacter; - -/** - * Usefull for root motion jumps (characters/enemies) - * - * Enables MOVE_Flying mode during ANS, - * on end if movement mode is still MOVE_Flying - changes it on MOVE_Falling - * - * if "bStopMontageIfLandCheckFails" - stops montage if land check failed on NotifyEnd - */ -UCLASS() -class UNREALHELPERLIBRARY_API UANS_EnableRootMotionZAxisMovement : public UANS_UHL_Base -{ - GENERATED_BODY() - -public: - UANS_EnableRootMotionZAxisMovement(const FObjectInitializer& ObjectInitializer); - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="EnableRootMotionZAxisMovement") - bool bStopMontageIfLandCheckFails = false; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="EnableRootMotionZAxisMovement", meta=(EditCondition = "bStopMontageIfLandCheckFails", EditConditionHides)) - float LandCheckDistance = 50.0f; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="EnableRootMotionZAxisMovement", meta=(EditCondition = "bStopMontageIfLandCheckFails", EditConditionHides)) - TEnumAsByte CollisionChannel = ECC_Pawn; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="EnableRootMotionZAxisMovement", meta=(EditCondition = "bStopMontageIfLandCheckFails", EditConditionHides)) - FMontageBlendSettings LandCheckBlendOutSettings; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, AdvancedDisplay, Category="EnableRootMotionZAxisMovement") - bool bDebug = false; - -#if WITH_EDITOR - /** Override this to prevent firing this notify state type in animation editors */ - virtual bool ShouldFireInEditor() { return false; } -#endif - - virtual FLinearColor GetEditorColor() override { return FLinearColor(0.0f, 0.74f, 1.0f, 1.0f); }; - virtual FString GetNotifyName_Implementation() const override { return FString("EnableRootMotionZAxisMovement"); }; - - virtual void NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) override; - - virtual bool ShouldUseExperimentalUHLFeatures() const override { return true; }; - virtual void NotifyEndOrBlendOut(USkeletalMeshComponent* MeshComp) override; - -private: - EMovementMode InitialMovementMode = EMovementMode::MOVE_None; -}; diff --git a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_MagnetTo.h b/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_MagnetTo.h deleted file mode 100644 index 2e1deeee..00000000 --- a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_MagnetTo.h +++ /dev/null @@ -1,56 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Animation/AnimNotifies/AnimNotifyState.h" -#include "BehaviorTree/BlackboardData.h" -#include "ANS_MagnetTo.generated.h" - -class ACharacter; - -/** - * - */ -UCLASS() -class UNREALHELPERLIBRARY_API UANS_MagnetTo : public UAnimNotifyState -{ - GENERATED_BODY() - -public: - // UPROPERTY(Category=Decorator, EditAnywhere) - // bool bUseBlackboardActor = false; - UPROPERTY(Category="Decorator", EditAnywhere) - bool bMagnetToActorFromBlackboard = false; - UPROPERTY(Category="Decorator", EditAnywhere, meta=(EditCondition="bMagnetToActorFromBlackboard", EditConditionHides)) - FBlackboardKeySelector BlackboardActor; - - UPROPERTY(Category="Decorator", EditAnywhere, meta=(Units = "Centimeters")) - float Distance = 200.0f; - UPROPERTY(Category="Decorator", EditAnywhere, meta=(EditCondition="!bMagnetToActorFromBlackboard", EditConditionHides)) - float Angle = 0.0f; - - UPROPERTY(Category="Decorator", EditAnywhere) - bool bCustomTime = false; - -#if WITH_EDITOR - /** Override this to prevent firing this notify state type in animation editors */ - virtual bool ShouldFireInEditor() { return false; } -#endif - - virtual FLinearColor GetEditorColor() override { return FLinearColor(0.0f, 0.74f, 1.0f, 1.0f); }; - virtual FString GetNotifyName_Implementation() const override { return FString("MagnetTo"); }; - - virtual void NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) override; - virtual void NotifyTick(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float FrameDeltaTime, const FAnimNotifyEventReference& EventReference) override; - virtual void NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override; - -private: - TWeakObjectPtr BaseCharacter; - // EMovementMode InitialMovementMode; - float Speed = 0.0f; - float Alpha = 0.0f; - - // UFUNCTION() - // void OnMontageBlendingOut(UAnimMontage* Montage, bool bInterrupted); -}; diff --git a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_SpawnAndSwitchPlayerCamera.h b/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_SpawnAndSwitchPlayerCamera.h deleted file mode 100644 index 493515d6..00000000 --- a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_SpawnAndSwitchPlayerCamera.h +++ /dev/null @@ -1,92 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Animation/Notifies/ANS_UHL_Base.h" -#include "Camera/CameraActor.h" -#include "Core/UHLAttachmentRules.h" -#include "ANS_SpawnAndSwitchPlayerCamera.generated.h" - -// TODO: probably offset property required - -/** - * When this AnimNotifyState begins, it spawns a camera (CameraToSpawnClass), - * blends the view to it over BlendInTime, and when the notify ends, - * blends back to the original view target over BlendTimeOut and destroys the spawned camera. - */ -UCLASS(Blueprintable, meta=(DisplayName="Spawn and Switch Camera")) -class UNREALHELPERLIBRARY_API UANS_SpawnAndSwitchPlayerCamera : public UANS_UHL_Base -{ - GENERATED_BODY() - -public: - - /** - * The CameraActor subclass to spawn when this notify begins. - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AnimNotify|Camera") - TSubclassOf CameraToSpawnClass = ACameraActor::StaticClass(); - - /** - * If set, the socket or bone name on the owning SkeletalMeshComponent to attach the spawned camera to. - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AnimNotify|Camera") - FName AttachSocketName = NAME_None; - - /** - * How to attach Camera to Actor - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AnimNotify|Camera") - FUHLAttachmentRules AttachRules; - - /** - * How long (in seconds) to blend into the spawned camera. - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AnimNotify|Camera", meta=(ClampMin="0.0")) - float BlendInTime = 0.5f; - - /** - * Curve - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AnimNotify|Camera") - TEnumAsByte BlendInFunction = EViewTargetBlendFunction::VTBlend_Cubic; - - /** - * How long (in seconds) to blend back to the player pawn when the notify ends. - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AnimNotify|Camera", meta=(ClampMin="0.0")) - float BlendOutTime = 0.5f; - - /** - * Curve - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AnimNotify|Camera") - TEnumAsByte BlendOutFunction = EViewTargetBlendFunction::VTBlend_Cubic; - - /** - * PlayerController that should be used for camera switching - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AnimNotify|Camera") - int32 PlayerControllerIndex = 0; - - /** - * How much time camera will live after end - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AnimNotify|Camera") - float LifeSpanAfterEnd = 3.0f; - - // UAnimNotifyState interface - virtual void NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) override; - virtual void NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override; - // End of UAnimNotifyState interface - -private: - /** The camera actor instance we spawned at NotifyBegin. */ - UPROPERTY() - ACameraActor* SpawnedCameraInstance = nullptr; - - /** The original view target we stored so we can restore at NotifyEnd. */ - UPROPERTY() - AActor* PreviousViewTarget = nullptr; -}; diff --git a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_UHL_AllowCharacterRotation.h b/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_UHL_AllowCharacterRotation.h deleted file mode 100644 index 01767d53..00000000 --- a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_UHL_AllowCharacterRotation.h +++ /dev/null @@ -1,48 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" -#include "Animation/Notifies/ANS_UHL_Base.h" -#include "GameFramework/CharacterMovementComponent.h" -#include "ANS_UHL_AllowCharacterRotation.generated.h" - -/** - * CharacterMovementComponent->bAllowPhysicsRotationDuringAnimRootMotion = true - * and opportunity to change RotationRate - */ -UCLASS() -class UNREALHELPERLIBRARY_API UANS_UHL_AllowCharacterRotation : public UANS_UHL_Base -{ - GENERATED_BODY() - -public: - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="ActivateAbility") - bool bChangeRotationRate = false; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="ActivateAbility", meta=(EditCondition="bChangeRotationRate")) - FRotator RotationRate = FRotator(0.0f, 0.0f, 90.0f); - -protected: -#if WITH_EDITOR - /** Override this to prevent firing this notify state type in animation editors */ - virtual bool ShouldFireInEditor() { return false; } -#endif - - virtual FLinearColor GetEditorColor() override { return FLinearColor(0.799103f, 0.254152f, 0.730461f); }; - virtual FString GetNotifyName_Implementation() const override; - - virtual void NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) override; - virtual void NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override; - - virtual void OnMontageBlendingOut(UAnimMontage* Montage, bool bInterrupted) override; - -private: - UPROPERTY() - FRotator InitialRotationRate = FRotator::ZeroRotator; - - TWeakObjectPtr CharacterMovementComponent; - - UFUNCTION() - void ReturnDefaults(); -}; diff --git a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_UHL_Base.h b/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_UHL_Base.h deleted file mode 100644 index dde8e10f..00000000 --- a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_UHL_Base.h +++ /dev/null @@ -1,38 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Animation/AnimInstance.h" -#include "Animation/AnimNotifies/AnimNotifyState.h" -#include "ANS_UHL_Base.generated.h" - -class USkeletalMeshComponent; - -/** - * with events like OnMontageBlendOut, OnMontageInterrupted... - * you can disable subscribing OnMontageBlendOut, by "bUseOnMontageBlendingOut=false" in constructor - */ -UCLASS(Blueprintable, Category="UnrealHelperLibrary") -class UNREALHELPERLIBRARY_API UANS_UHL_Base : public UAnimNotifyState -{ - GENERATED_BODY() - -protected: - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="ANS_UHL_Base") - bool bUseOnMontageBlendingOut = true; - - virtual void NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) override; - virtual void NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override; - -/** Experimental **/ - // Should use experimental features like "NotifyEndOrBlendOut" - virtual bool ShouldUseExperimentalUHLFeatures() const { return false; }; - // experimental works only with "ShouldUseExperimentalUHLFeatures" enabled - virtual void NotifyEndOrBlendOut(USkeletalMeshComponent* MeshComp); -/** ~Experimental **/ - - UFUNCTION() - virtual void OnMontageBlendingOut(UAnimMontage* Montage, bool bInterrupted); - // TODO OnMontageBlendOut, OnMontageInterrupted, OnCancelled ... -}; diff --git a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_UHL_DisableWalkOffLedges.h b/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_UHL_DisableWalkOffLedges.h deleted file mode 100644 index 4ca1afaf..00000000 --- a/Source/UnrealHelperLibrary/Public/Animation/Notifies/ANS_UHL_DisableWalkOffLedges.h +++ /dev/null @@ -1,30 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Animation/Notifies/ANS_UHL_Base.h" -#include "ANS_UHL_DisableWalkOffLedges.generated.h" - -/** - * - */ -UCLASS() -class UNREALHELPERLIBRARY_API UANS_UHL_DisableWalkOffLedges : public UANS_UHL_Base -{ - GENERATED_BODY() - -public: - /** By default half capsule radius will be used - * but If >= 0, will override the movement component's PerchRadiusThreshold. */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ledge Settings") - float PerchRadiusThreshold = -1.0f; - - virtual void NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) override; - virtual void NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override; - -private: - // To restore after end - bool bOriginalCanWalkOffLedges; - float OriginalPerchRadius; -}; diff --git a/Source/UnrealHelperLibrary/Public/Animation/Notifies/AN_AttachActorWithUniqueId.h b/Source/UnrealHelperLibrary/Public/Animation/Notifies/AN_AttachActorWithUniqueId.h deleted file mode 100644 index 9723a33f..00000000 --- a/Source/UnrealHelperLibrary/Public/Animation/Notifies/AN_AttachActorWithUniqueId.h +++ /dev/null @@ -1,61 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Animation/Notifies/AN_UHL_Base.h" -#include "Core/UHLAttachmentRules.h" -#include "Engine/EngineTypes.h" -#include "AN_AttachActorWithUniqueId.generated.h" - -/** - * Spawns an actor of the specified class, attaches it to a given component socket, - * and tags it with a user-defined unique identifier. The tag allows you to - * later retrieve this exact attached actor by searching your owner’s attached - * actors for the matching tag. - * - * Typical usage: - * 1. During an animation or setup phase, call AN_AttachActorWithUniqueId to - * spawn and attach, for example, a projectile to your character mesh: - * - It spawns the projectile actor at the socket transform. - * - It adds a tag (e.g. “Projectile_42”) so you can distinguish it. - * 2. Later (e.g. when firing), call LaunchProjectile: - * - It searches the character’s attached actors for the tag “Projectile_42”. - * - It finds the correct spawned actor and applies your launch logic. - * - * @param ActorToAttach The UClass of the actor to spawn and attach. - * @param SocketName The name of the socket on OwnerComponent to attach to. - * @param UniqueId A user-defined string used as a tag on the spawned actor. - * @param AttachmentTransformRules Attachment rules - */ -UCLASS() -class UNREALHELPERLIBRARY_API UAN_AttachActorWithUniqueId : public UAN_UHL_Base -{ - GENERATED_BODY() - -public: - UPROPERTY(EditAnywhere, Category="AttachActorWithUniqueId") - TSoftClassPtr ActorToAttach; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="AttachActorWithUniqueId") - FName UniqueId = "Unique_ID"; - - UPROPERTY(EditAnywhere, Category="AttachActorWithUniqueId", meta = (AnimNotifyBoneName = "true")) - FName SocketName = ""; - - UPROPERTY(EditAnywhere, Category="AttachActorWithUniqueId") - FUHLAttachmentRules AttachmentRules; - -protected: -#if WITH_EDITOR - /** Override this to prevent firing this notify state type in animation editors */ - virtual bool ShouldFireInEditor() { return false; } - virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override; -#endif - - virtual FLinearColor GetEditorColor() override { return FColor::FromHex("#FF7DE7"); }; - virtual FString GetNotifyName_Implementation() const override; - - virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override; - -}; diff --git a/Source/UnrealHelperLibrary/Public/Animation/Notifies/AN_DetachActorWithUniqueId.h b/Source/UnrealHelperLibrary/Public/Animation/Notifies/AN_DetachActorWithUniqueId.h deleted file mode 100644 index 48991700..00000000 --- a/Source/UnrealHelperLibrary/Public/Animation/Notifies/AN_DetachActorWithUniqueId.h +++ /dev/null @@ -1,62 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Animation/Notifies/AN_UHL_Base.h" -#include "Core/UHLAttachmentRules.h" -#include "AN_DetachActorWithUniqueId.generated.h" - -/** - * - */ -UCLASS() -class UNREALHELPERLIBRARY_API UAN_DetachActorWithUniqueId : public UAN_UHL_Base -{ - GENERATED_BODY() - -public: - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="DetachActorWithUniqueId") - FName UniqueId = "Unique_ID"; - - UPROPERTY(EditAnywhere, Category="DetachActorWithUniqueId") - FUHLDetachmentRules DetachmentRules; - - UPROPERTY(EditAnywhere, Category="DetachActorWithUniqueId") - bool bEnablePhysicsOnDetach = true; - - UPROPERTY(EditAnywhere, Category="DetachActorWithUniqueId", meta=(EditCondition="bEnablePhysicsOnDetach", EditConditionHides)) - float EnablePhysicsDelay = 0.2f; - - // TODO: add choosing preset or PhysicsSettings - // UPROPERTY(EditAnywhere, Category="DetachActorWithUniqueId", meta=(EditCondition="bEnablePhysicsOnDetach", EditConditionHides)) - // float EnablePhysicsDelay = 1.0f; - - // TODO add option to choose blueprint and click on what component what phys settings should be applied - - // TODO: choosing Impulse and force of detaching - - UPROPERTY(EditAnywhere, Category="DetachActorWithUniqueId") - bool bAutoDestroy = false; - - UPROPERTY(EditAnywhere, Category="DetachActorWithUniqueId", meta=(EditCondition="bAutoDestroy", EditConditionHides)) - float AutoDestroyDelay = 1.0f; - -protected: -#if WITH_EDITOR - /** Override this to prevent firing this notify state type in animation editors */ - virtual bool ShouldFireInEditor() { return false; } - virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override; -#endif - - virtual FLinearColor GetEditorColor() override { return FColor::FromHex("#FF7DE7"); }; - virtual FString GetNotifyName_Implementation() const override; - - virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override; - - -private: - UPROPERTY() - FName CollisionProfileName = FName("PhysicsActor"); - FTimerHandle TimerHandle; -}; diff --git a/Source/UnrealHelperLibrary/Public/Animation/Notifies/AN_UHL_Base.h b/Source/UnrealHelperLibrary/Public/Animation/Notifies/AN_UHL_Base.h deleted file mode 100644 index 773b5d3f..00000000 --- a/Source/UnrealHelperLibrary/Public/Animation/Notifies/AN_UHL_Base.h +++ /dev/null @@ -1,20 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Animation/AnimNotifies/AnimNotify.h" -#include "AN_UHL_Base.generated.h" - -class USkeletalMeshComponent; -DECLARE_MULTICAST_DELEGATE_OneParam(FOnNotifySignature, USkeletalMeshComponent*) - -UCLASS() -class UNREALHELPERLIBRARY_API UAN_UHL_Base : public UAnimNotify -{ - GENERATED_BODY() - -public: - virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override; - FOnNotifySignature OnNotified; -}; diff --git a/Source/UnrealHelperLibrary/Public/Core/UHLAttachmentRules.h b/Source/UnrealHelperLibrary/Public/Core/UHLAttachmentRules.h deleted file mode 100644 index d062f2a9..00000000 --- a/Source/UnrealHelperLibrary/Public/Core/UHLAttachmentRules.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once - -#include "Engine/EngineTypes.h" -#include "UHLAttachmentRules.generated.h" - -USTRUCT(BlueprintType) -struct FUHLAttachmentRules -{ - GENERATED_BODY() - - UPROPERTY(EditAnywhere, Category="Attachment") - EAttachmentRule LocationRule = EAttachmentRule::SnapToTarget; - - UPROPERTY(EditAnywhere, Category="Attachment") - EAttachmentRule RotationRule = EAttachmentRule::SnapToTarget; - - UPROPERTY(EditAnywhere, Category="Attachment") - EAttachmentRule ScaleRule = EAttachmentRule::KeepWorld; - - UPROPERTY(EditAnywhere, Category="Attachment") - bool bWeldSimulatedBodies = true; - - // Conversion to engine struct - FAttachmentTransformRules ToEngineRules() const - { - return FAttachmentTransformRules(LocationRule, RotationRule, ScaleRule, bWeldSimulatedBodies); - } -}; - -USTRUCT(BlueprintType) -struct FUHLDetachmentRules -{ - GENERATED_BODY() - - /** - * Which transform to preserve when detaching: - * KeepRelative or KeepWorld - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Detachment") - EDetachmentRule DetachmentRule = EDetachmentRule::KeepWorld; - - /** - * If true, calls Modify() on the component so that the detach - * is recorded in the transaction buffer (undo/redo) - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Detachment") - bool bCallModify = false; - - /** - * Convert to Unreal’s native struct, for use in DetachFromComponent / DetachFromActor - */ - FDetachmentTransformRules ToEngineRules() const - { - return FDetachmentTransformRules(DetachmentRule, bCallModify); - } -}; \ No newline at end of file diff --git a/Source/UnrealHelperLibrary/Public/Core/UHLGameplayTags.h b/Source/UnrealHelperLibrary/Public/Core/UHLGameplayTags.h deleted file mode 100644 index bf911043..00000000 --- a/Source/UnrealHelperLibrary/Public/Core/UHLGameplayTags.h +++ /dev/null @@ -1,32 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "NativeGameplayTags.h" - -namespace UHLGameplayTags -{ - UNREALHELPERLIBRARY_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_Gameplay_AbilityInputBlocked); - - UNREALHELPERLIBRARY_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_UHL_Debug_CheckGASGameplayTagsOnActor); - - // Abilities - UNREALHELPERLIBRARY_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_UHL_Abilities_Character_GlobalTimeDilation); - - // AbilityInputCache - UNREALHELPERLIBRARY_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_UHL_AbilityInputCache_Catching); - - // Debug Categories - UNREALHELPERLIBRARY_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_UHL_DebugCategory_AbilitySystem); - UNREALHELPERLIBRARY_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_UHL_DebugCategory_AbilitySystem_Attributes); - UNREALHELPERLIBRARY_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_UHL_DebugCategory_AbilitySystem_Effects); - UNREALHELPERLIBRARY_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_UHL_DebugCategory_AbilitySystem_Abilities); - UNREALHELPERLIBRARY_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_UHL_DebugCategory_AbilitySystem_DebugBasicHUD); - UNREALHELPERLIBRARY_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_UHL_DebugCategory_AbilitySystem_DebugAbilityTags); - UNREALHELPERLIBRARY_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_UHL_DebugCategory_InputSystem_EnhancedInputSystem); - UNREALHELPERLIBRARY_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_UHL_DebugCategory_InputSystem_AbilityInputCache); - UNREALHELPERLIBRARY_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_UHL_DebugCategory_Collisions); - - // Errors - // UNREALHELPERLIBRARY_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_Error); -}; diff --git a/Source/UnrealHelperLibrary/Public/Development/UHLSettings.h b/Source/UnrealHelperLibrary/Public/Development/UHLSettings.h deleted file mode 100644 index 8e48b41f..00000000 --- a/Source/UnrealHelperLibrary/Public/Development/UHLSettings.h +++ /dev/null @@ -1,26 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Engine/DeveloperSettings.h" -#include "Subsystems/EnemyTickManager/EnemyTickOptimizerSubsystem.h" -#include "UHLSettings.generated.h" - -/** - * - */ -UCLASS(config="Game", defaultconfig) -class UNREALHELPERLIBRARY_API UUHLSettings : public UDeveloperSettings -{ - GENERATED_BODY() - -public: - UPROPERTY(config, EditAnywhere, Category="EnemyTickOptimizerSubsystemSettings") - FEnemyTickOptimizerSubsystemSettings EnemyTickOptimizerSubsystemSettings; - -protected: -//~UDeveloperSettings interface - virtual FName GetCategoryName() const override { return TEXT("Plugins"); }; -//~End of UDeveloperSettings interface -}; diff --git a/Source/UnrealHelperLibrary/Public/Subsystems/EnemyTickManager/EnemyTickOptimizerSubsystem.h b/Source/UnrealHelperLibrary/Public/Subsystems/EnemyTickManager/EnemyTickOptimizerSubsystem.h deleted file mode 100644 index 20efd792..00000000 --- a/Source/UnrealHelperLibrary/Public/Subsystems/EnemyTickManager/EnemyTickOptimizerSubsystem.h +++ /dev/null @@ -1,88 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "GameFramework/Character.h" -#include "Subsystems/GameInstanceSubsystem.h" -#include "EnemyTickOptimizerSubsystem.generated.h" - - -USTRUCT(BlueprintType) -struct FEnemyTickOptimizerSubsystemSettings -{ - GENERATED_BODY() - - UPROPERTY(EditAnywhere, Category = "Tick Optimization") - bool bEnable = false; - - // How often we update enemies ticks rate - UPROPERTY(EditAnywhere, Category = "Tick Optimization") - float UpdateInterval = 0.5f; - - UPROPERTY(EditAnywhere, Category = "Tick Optimization") - float DefaultEnemyTickInterval = 1.0f; - - UPROPERTY(EditAnywhere, Category = "Tick Optimization") - float CloseDistance = 1000.0f; - - UPROPERTY(EditAnywhere, Category = "Tick Optimization") - float MediumDistance = 3000.0f; - - UPROPERTY(EditAnywhere, Category = "Tick Optimization") - float FarDistance = 5000.0f; - - UPROPERTY(EditAnywhere, Category = "Tick Optimization") - float CloseTickInterval = 0.0f; // Every frame - - UPROPERTY(EditAnywhere, Category = "Tick Optimization") - float MediumTickInterval = 0.1f; - - UPROPERTY(EditAnywhere, Category = "Tick Optimization") - float FarTickInterval = 0.5f; - - UPROPERTY(EditAnywhere, Category = "Tick Optimization") - bool bSetTickOnActorComponentsAlso = true; - - UPROPERTY(EditAnywhere, Category = "Tick Optimization") - bool bDontTickIfNotRenderedRecently = true; - - UPROPERTY(EditAnywhere, Category = "Tick Optimization") - float RecentlyNotRenderedTickInterval = 1.0f; -}; - -/** - * - */ -UCLASS() -class UNREALHELPERLIBRARY_API UEnemyTickOptimizerSubsystem : public UGameInstanceSubsystem -{ - GENERATED_BODY() - -public: - virtual void Initialize(FSubsystemCollectionBase& Collection) override; - virtual void Deinitialize() override; - - // Register an enemy with the subsystem - void RegisterEnemy(ACharacter* Enemy); - - // Unregister an enemy from the subsystem - void UnregisterEnemy(ACharacter* Enemy); - -private: - // Array to store all registered enemies - TArray RegisteredEnemies; - - // Timer handle for periodic tick interval updates - FTimerHandle TickOptimizerTimerHandle; - - // Function to update tick intervals based on distance to the player - void UpdateTickIntervals(); - - // Configurable properties for distance thresholds and tick intervals - FEnemyTickOptimizerSubsystemSettings Settings; - - bool bTickAllowed = false; - float AccumulatedTime = 0.0f; - float DesiredInterval = 0.5f; -}; diff --git a/Source/UnrealHelperLibrary/Public/UI/UHLHUD.h b/Source/UnrealHelperLibrary/Public/UI/UHLHUD.h deleted file mode 100644 index 0dc8481f..00000000 --- a/Source/UnrealHelperLibrary/Public/UI/UHLHUD.h +++ /dev/null @@ -1,51 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "GameFramework/HUD.h" -#include "UHLHUD.generated.h" - -USTRUCT(BlueprintType) -struct FLineInfo -{ - GENERATED_BODY() - - FString Id = ""; - FVector2D Start = FVector2D::ZeroVector; - FVector2D End = FVector2D::ZeroVector; - FColor Color = FColor::White; - float LineThickness = 1.0f; - - FString Text = ""; - FColor TextColor = FColor::White; - - bool bRelativeToViewportCenter = false; - bool bPersistent = false; - -// private: -// float TimePassed = 0.0f; -}; - -/** - * - */ -UCLASS() -class UNREALHELPERLIBRARY_API AUHLHUD : public AHUD -{ - GENERATED_BODY() - -public: - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="UHL HUD") - bool bEnabledDrawDebug = true; - - UFUNCTION(BlueprintCallable, Category="UHL HUD") - void AddOrUpdateLineInfoToDrawNextTick(FLineInfo LineInfo_In); - -protected: - virtual void DrawHUD() override; - -private: - UPROPERTY() - TArray LineInfos; -}; diff --git a/Source/UnrealHelperLibrary/Public/UnrealHelperLibrary.h b/Source/UnrealHelperLibrary/Public/UnrealHelperLibrary.h deleted file mode 100644 index 1e0b039a..00000000 --- a/Source/UnrealHelperLibrary/Public/UnrealHelperLibrary.h +++ /dev/null @@ -1,15 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "Modules/ModuleManager.h" - -UNREALHELPERLIBRARY_API DECLARE_LOG_CATEGORY_EXTERN(LogUnrealHelperLibrary, Log, All); - -class FUnrealHelperLibraryModule : public IModuleInterface -{ -public: - /** IModuleInterface implementation */ - virtual void StartupModule() override; - virtual void ShutdownModule() override; -}; diff --git a/Source/UnrealHelperLibrary/Public/UnrealHelperLibraryTypes.h b/Source/UnrealHelperLibrary/Public/UnrealHelperLibraryTypes.h deleted file mode 100644 index 6c931f84..00000000 --- a/Source/UnrealHelperLibrary/Public/UnrealHelperLibraryTypes.h +++ /dev/null @@ -1,55 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" // This includes FVector definition -#include "UnrealHelperLibraryTypes.generated.h" // Required for UENUM macros - -const FVector VECTOR_ERROR = FVector(404.0f, 404.0f, 404.0f); -const float FLOAT_ERROR = -99999.0f; - - -UENUM(BlueprintType) -enum class EUHLDirection: uint8 -{ - None, - - Front, - Back, - Left, - Right, - - FrontLeft, - FrontRight, - BackLeft, - BackRight, - - MAX UMETA(Hidden) -}; - -UENUM(BlueprintType) -enum class EUHLSettingsSource: uint8 -{ - None UMETA(Hidden), - - Node, - DataAsset, - Actor, - - MAX UMETA(Hidden) -}; - -// EUHLBuildType not same as EBuildConfiguration, if we WITH_EDITOR returns Editor, -// no matter what EBuildConfiguration is currently used(mostly WITH_EDITOR is Development) -// if real build returns EBuildConfiguration -UENUM(BlueprintType) -enum class EUHLBuildType: uint8 -{ - None UMETA(Hidden), - Editor UMETA(ToolTip="Are you in editor"), - - Debug, - Development, - Shipping, - Test, -}; diff --git a/Source/UnrealHelperLibrary/Public/Utils/UHLLoadingUtilLibrary.h b/Source/UnrealHelperLibrary/Public/Utils/UHLLoadingUtilLibrary.h deleted file mode 100644 index 73a75c18..00000000 --- a/Source/UnrealHelperLibrary/Public/Utils/UHLLoadingUtilLibrary.h +++ /dev/null @@ -1,46 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Kismet/BlueprintFunctionLibrary.h" -#include "UHLLoadingUtilLibrary.generated.h" - -class UObject; -struct FFrame; - -/** - * Mostly copy-pasted from Lyra - */ -UCLASS() -class UNREALHELPERLIBRARY_API UUHLLoadingUtilLibrary : public UBlueprintFunctionLibrary -{ - GENERATED_BODY() - -public: - UFUNCTION(BlueprintCallable, Category = "Loading", meta = (WorldContext = "WorldContextObject")) - static void ApplyDefaultPriorityLoading(const UObject* WorldContextObject); - - UFUNCTION(BlueprintCallable, Category = "Loading", meta = (WorldContext = "WorldContextObject")) - static void ApplyStreamingPriorityLoading(const UObject* WorldContextObject); - - UFUNCTION(BlueprintCallable, Category = "Loading", meta = (WorldContext = "WorldContextObject")) - static void ApplyHighestPriorityLoading(const UObject* WorldContextObject); - - UFUNCTION(BlueprintCallable, Category = "Loading", meta = (WorldContext = "WorldContextObject")) - static void ApplyCustomPriorityLoading(const UObject* WorldContextObject, bool UseHighPriorityLoading, float MaxAsyncLoadingMilliSeconds, float MaxActorUpdateMilliSeconds); - - UFUNCTION(BlueprintCallable, Category = "Loading") - static void ForceGarbageCollection(); - - UFUNCTION(BlueprintCallable, Category = "Loading", meta = (WorldContext = "WorldContextObject")) - static void FlushLevelStreaming(const UObject* WorldContextObject); - -private: - static void CaptureDefaultLoadingSettings(); - static bool HasCapturedDefaults; - static float DefaultLevelStreamingActorsUpdateTimeLimit; - static float DefaultLevelStreamingComponentsRegistrationGranularity; - static float DefaultAsyncLoadingTimeLimit; - -}; diff --git a/Source/UnrealHelperLibrary/Public/Utils/UHLTraceUtilsBPL.h b/Source/UnrealHelperLibrary/Public/Utils/UHLTraceUtilsBPL.h deleted file mode 100644 index 71043aa1..00000000 --- a/Source/UnrealHelperLibrary/Public/Utils/UHLTraceUtilsBPL.h +++ /dev/null @@ -1,54 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Engine/EngineTypes.h" -#include "CollisionQueryParams.h" -#include "Kismet/BlueprintFunctionLibrary.h" -#include "UHLTraceUtilsBPL.generated.h" - -/** - * - */ -UCLASS() -class UNREALHELPERLIBRARY_API UUHLTraceUtilsBPL : public UBlueprintFunctionLibrary -{ - GENERATED_BODY() - -public: - static bool SweepCapsuleSingleByChannel(const UWorld* World, struct FHitResult& OutHit, const FVector& Start, - const FVector& End, float Radius, float HalfHeight, const FQuat& Rot, - ECollisionChannel TraceChannel, const FCollisionQueryParams& Params, - const FCollisionResponseParams& ResponseParam, bool bDrawDebug = false, - float DrawTime = -1.0f, FColor TraceColor = FColor::Black, - FColor HitColor = FColor::Red, float FailDrawTime = -1.0f); - static bool SweepCapsuleMultiByChannel(const UWorld* World, TArray& OutHits, const FVector& Start, - const FVector& End, float Radius, float HalfHeight, const FQuat& Rot, - ECollisionChannel TraceChannel, const FCollisionQueryParams& Params, - const FCollisionResponseParams& ResponseParam, bool bDrawDebug = false, - float DrawTime = -1.0f, FColor TraceColor = FColor::Black, - FColor HitColor = FColor::Red, float FailDrawTime = -1.0f); - - static bool SweepSphereSingleByChannel(const UWorld* World, struct FHitResult& OutHit, const FVector& Start, - const FVector& End, float Radius, - ECollisionChannel TraceChannel, const FCollisionQueryParams& Params, - const FCollisionResponseParams& ResponseParam, bool bDrawDebug = false, - float DrawTime = -1.0f, FColor TraceColor = FColor::Black, - FColor HitColor = FColor::Red); - static bool OverlapCapsuleAnyByProfile(const UWorld* World, const FVector& Pos, float Radius, float HalfHeight, - FQuat Rot, FName ProfileName, const FCollisionQueryParams& QueryParams, - bool bDrawDebug = false, float DrawTime = -1.0f, - FColor HitColor = FColor::Red); - static bool OverlapBlockingTestByProfile(const UWorld* World, const FVector& Pos, float Radius, float HalfHeight, - FQuat Rot, FName ProfileName, const FCollisionQueryParams& QueryParams, - bool bDrawDebug = false, float DrawTime = -1.0f, - FColor HitColor = FColor::Red); - static bool SweepCapsuleMultiByProfile(const UWorld* World, TArray& OutHits, const FVector& Start, - const FVector& End, float Radius, float HalfHeight, - const FQuat& Rot, FName ProfileName, - const FCollisionQueryParams& Params, - bool bDrawDebug = false, float DrawTime = -1.0f, - FColor TraceColor = FColor::Black, FColor HitColor = FColor::Red); - // SweepCapsuleMultiByProfile -}; diff --git a/Source/UnrealHelperLibrary/Public/Utils/UnrealHelperLibraryBPL.h b/Source/UnrealHelperLibrary/Public/Utils/UnrealHelperLibraryBPL.h deleted file mode 100644 index 953a1a81..00000000 --- a/Source/UnrealHelperLibrary/Public/Utils/UnrealHelperLibraryBPL.h +++ /dev/null @@ -1,354 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -#pragma once - -#include "UnrealHelperLibraryTypes.h" -#include "AssetRegistry/AssetData.h" -#include "AssetRegistry/AssetRegistryModule.h" -#include "Kismet/BlueprintFunctionLibrary.h" -#include "Math/UnrealMathUtility.h" -#include "UI/UHLHUD.h" -#include "UnrealHelperLibraryBPL.generated.h" - -class UWidget; -struct FBlackboardKeySelector; - -const float RELATIVE_POINT_ARROW_SIZE = 200.0f; - -// TODO improve -// - validations if Actor1/Actors2 is nullptr - DebugPrintString it -// - keywords for every method - -/* - * Function library class. - * Each function in it is expected to be static and represents blueprint node that can be called in any blueprint. - * - * When declaring function you can define metadata for the node. Key function specifiers will be BlueprintPure and BlueprintCallable. - * BlueprintPure - means the function does not affect the owning object in any way and thus creates a node without Exec pins. - * BlueprintCallable - makes a function which can be executed in Blueprints - Thus it has Exec pins. - * DisplayName - full name of the node, shown when you mouse over the node and in the blueprint drop down menu. - * Its lets you name the node using characters not allowed in C++ function names. - * CompactNodeTitle - the word(s) that appear on the node. - * Keywords - the list of keywords that helps you to find node when you search for it using Blueprint drop-down menu. - * Good example is "Print String" node which you can find also by using keyword "log". - * Category - the category your node will be under in the Blueprint drop-down menu. - * - * For more info on custom blueprint nodes visit documentation: - * https://wiki.unrealengine.com/Custom_Blueprint_Node_Creation - */ -UCLASS() -class UNREALHELPERLIBRARY_API UUnrealHelperLibraryBPL : public UBlueprintFunctionLibrary -{ - GENERATED_BODY() - -public: - // UFUNCTION(BlueprintCallable, meta = (Keywords = "UnrealHelperLibrary sample test testing"), Category = "UnrealHelperLibraryTesting") - // static float UnrealHelperLibraryRandomWeight(TMap); - - /** Gameplay **/ - // Get HitReactDirection - direction(front/back/left/right) opposite to character(SourceActorLocation) that made hit - // TODO add - // - GetHitSourceDirection - // - bool bUse8Directions - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary") - static EUHLDirection GetHitReactDirection(const FVector& SourceActorLocation, const AActor* TargetActor); - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary", meta = (WorldContext = "WorldContextObject", Keywords = "UnrealHelperLibrary ui widget editor viewport")) - static FVector2D GetViewportSizeUnscaled(UObject* WorldContextObject); - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary", meta = (WorldContext = "WorldContextObject", Keywords = "UnrealHelperLibrary ui widget editor viewport")) - static FVector2D GetWidgetCenterPosition(UObject* WorldContextObject, UWidget* Widget); - // UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary") - // static bool ProjectWorldLocationToWidgetPositionWithScales(APlayerController* PlayerController, FVector WorldLocation, FVector2D& ViewportPosition, bool bPlayerViewportRelative); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary", meta = (WorldContext = "WorldContextObject")) - static float GetActorDistanceToCenterOfScreen(UObject* WorldContextObject, const AActor* Actor, APlayerController* PlayerController, bool bPlayerViewportRelative = true, const bool bDebug = false, const float DebugLifetime = -1); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary", meta = (WorldContext = "WorldContextObject")) - static AActor* GetActorClosestToCenterOfScreen(UObject* WorldContextObject, const TArray& Actors, APlayerController* PlayerController, FVector2D& ScreenPosition, bool bPlayerViewportRelative = true, const bool bDebug = false, const float DebugLifetime = -1); - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary") - static AActor* GetMostDistantActor(const TArray& Actors, float& MaxDistance_Out, FVector Location, const bool bDebug = false, const float DebugLifetime = -1); - - // TODO GetDistanceOperation - MostDistant/LeastDistant/Average/Medium/... - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary", meta = (WorldContext = "WorldContextObject")) - static FVector GetMostDistantVector(const UObject* WorldContextObject, - const TArray Vectors, FVector Location, - float& MaxDistance_Out, int32& Index_Out, - bool bUseNavigation = false, - const bool bDebug = false, const float DebugLifetime = -1); - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary", meta = (WorldContext = "WorldContextObject")) - static FVector GetMostDistantActorComponent(const UObject* WorldContextObject, - const TArray SceneComponents, FVector Location, - float& MaxDistance_Out, int32& Index_Out, - bool bUseNavigation = false, - const bool bDebug = false, const float DebugLifetime = -1); - - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary") - static void DrawDebugLineOnCanvas( - UObject* WorldContextObject, - const FLineInfo& LineInfo, - const bool bRelativeToViewportCenter = false - ); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary") - static void DrawDebugCrossHair( - UObject* WorldContextObject, - const float CrossHairLineLength, const float LineThickness, - const float AngleToRotate, - const FVector2f& CrossHairCenterScreenSpace, - const FLinearColor& LineColor, - const bool bRelativeToViewportCenter = false - ); - /** Gameplay **/ - - /** Debug **/ - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|Debug", meta = (Keywords = "UnrealHelperLibrary debug Development", AdvancedDisplay = "D,E,F,G,H,I,J,Duration")) - static void DebugPrintStrings(const FString& A, const FString& B = "", const FString& C = "", const FString& D = "", const FString& E = "", const FString& F = "", const FString& G = "", - const FString& H = "", const FString& I = "", const FString& J = "", float Duration = 2.0f, const FName Key = NAME_None, const bool bEnabled = true); - UFUNCTION(Category = "UnrealHelperLibrary", meta = (WorldContext = "WorldContextObject", Keywords = "UnrealHelperLibrary debug Development", AdvancedDisplay = "D,E,F,G,H,I,J,Duration")) - static void DebugPrintString(const UObject* WorldContextObject, const FString& A, float Duration = 2.0f, const FName Key = NAME_None, const bool bEnabled = true); - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|Debug", meta = (Keywords = "UnrealHelperLibrary debug Development")) - static void DrawDebugBar(); - /** ~Debug **/ - - /** Anims **/ - // TODO dont work correctly, fix - // if SectionName not specified will be used first section - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Animations", meta = (Keywords = "UnrealHelperLibrary anim montage")) - static float GetAnimMontageSectionLengthByName(UAnimMontage* AnimMontage, FName SectionName = NAME_None); - /** ~Anims **/ - - /** Angles **/ - /** - * Calculates relative angle to other actor [-180, 180] - * @param ActorRelativeToWhomAngleCalculated - * @param TargetActor - * @param bRelativeToActorBack sometimes you want to know actors that nearest to character backside - * @param bDebug - * @param DebugLifetime - * @param DebugColor - */ - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Angles", - meta = (DefaultToSelf = "ActorRelativeToWhomAngleCalculated", Keywords = "UnrealHelperLibrary debug Development angle relative GetAngle RelativeTo", - AdvancedDisplay = "bDebug,DebugLifetime,DebugColor,bRelativeToActorBack")) - static float RelativeAngleToActor(AActor* ActorRelativeToWhomAngleCalculated, AActor* TargetActor, bool bRelativeToActorBack = false, const bool bDebug = false, const float DebugLifetime = -1, - const FLinearColor DebugColor = FLinearColor::White); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Angles", - meta = (DefaultToSelf = "ActorRelativeToWhomAngleCalculated", Keywords = "UnrealHelperLibrary debug Development angle relative GetAngle RelativeTo")) - static float RelativeAngleToVector(AActor* ActorRelativeToWhomAngleCalculated, FVector TargetVector); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Angles", meta = (Keywords = "UnrealHelperLibrary debug Development angle relative GetAngle RelativeTo")) - static float RelativeAngleVectorToVector(FVector VectorRelativeToWhomAngleCalculated, FVector TargetVector); - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|Angles") - static EUHLDirection GetOppositeDirection(EUHLDirection Direction_In); - /** ~Angles **/ - - /** Utils **/ - // Get project version from "Project Settings" - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (Keywords = "UnrealHelperLibrary version")) - static FString GetProjectVersion(); - UFUNCTION(BlueprintCallable, Category = "UnrealHelperLibrary|Utils", meta = (Keywords = "UnrealHelperLibrary debug Development")) - static TArray GetNamesOfComponentsOnObject(UObject* OwnerObject, UClass* Class); - - // return all assets of specified class in template - template - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils") - static void GetAssetsOfClass(TArray& OutArray) - { - FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked("AssetRegistry"); - TArray AssetData; - AssetRegistryModule.Get().GetAssetsByClass(T::StaticClass()->GetClassPathName(), AssetData); - for (int i = 0; i < AssetData.Num(); i++) - { - T* Object = Cast(AssetData[i].GetAsset()); - OutArray.Add(Object); - } - } - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils") - static UActorComponent* GetActorComponentByName(AActor* Actor, FString Name); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils") - static USceneComponent* GetSceneComponentByName(AActor* Actor, FString Name); - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (Keywords = "UnrealHelperLibrary bounds box extent")) - static FVector GetRandomPointInBox(const USceneComponent* Component, bool bOnGround, bool bDrawDebug = false, float DebugDrawTime = 5.0f); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (Keywords = "UnrealHelperLibrary bounds box extent")) - static FVector GetHighestPointInBox(const USceneComponent* Component); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (Keywords = "UnrealHelperLibrary bounds box extent")) - static FVector GetCenterPointInBox(const USceneComponent* Component); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (Keywords = "UnrealHelperLibrary bounds box extent")) - static FBox GetComponentBox(const USceneComponent* Component); - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (WorldContext = "WorldContextObject", Keywords = "UnrealHelperLibrary vector center")) - static FVector GetCenterPointBetweenVectors(const UObject* WorldContextObject, const FVector& PointA, const FVector& PointB, - const bool bDebug = false, const float DebugLifetime = -1, const FLinearColor DebugColor = FLinearColor::White); - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (WorldContext = "WorldContextObject", AdvancedDisplay = "OverrideZ,bDebug,DebugLifetime,DebugColor")) - static void GetPointAtRelativeAngleUsingVector(FVector& Point, FRotator& PointRotation, const UObject* WorldContextObject, const FVector& Location, const FVector& ForwardVector, const float Angle, const float Distance, const float OverrideZ = -999999.f, const bool bDebug = false, - const float DebugLifetime = -1, const FLinearColor DebugColor = FLinearColor::White); - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (DefaultToSelf = "ActorIn", AdvancedDisplay = "bDebug,DebugLifetime,DebugColor")) - static void GetPointAtRelativeAngle(FVector& Point, FRotator& PointRotation, const AActor* ActorIn, const float Angle, const float Distance, const bool bDebug = false, - const float DebugLifetime = -1, const FLinearColor DebugColor = FLinearColor::White); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (DefaultToSelf = "ActorIn", AdvancedDisplay = "bDebug,DebugLifetime,DebugColor,DebugText")) - static void GetPointAtRelativeDirection(FVector& Point, FRotator& PointRotation, const AActor* ActorIn, const EUHLDirection Direction, const float Distance, const bool bDebug = false, - const float DebugLifetime = -1, const FLinearColor DebugColor = FLinearColor::White, const FText DebugText = FText()); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (DefaultToSelf = "Actor1", AdvancedDisplay = "bTakeZFromActor1,bDebug,DebugLifetime,DebugColor")) - static void GetPointAtAngleRelativeToOtherActor(FVector& Point, FRotator& PointRotation, const AActor* Actor1, const AActor* Actor2, const float Angle, const float Distance, - const bool bTakeZFromActor1 = true, const bool bDebug = false, const float DebugLifetime = -1, const FLinearColor DebugColor = FLinearColor::White); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (DefaultToSelf = "Actor1", AdvancedDisplay = "bTakeZFromActor1,bDebug,DebugLifetime,DebugColor")) - static void GetPointAtDirectionRelativeToOtherActor(FVector& Point, FRotator& PointRotation, const AActor* Actor1, const AActor* Actor2, const EUHLDirection Direction, const float Distance, - const bool bTakeZFromActor1 = true, const bool bDebug = false, const float DebugLifetime = -1, const FLinearColor DebugColor = FLinearColor::White); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (AdvancedDisplay = "bTakeZFromVector1,bDebug,DebugLifetime,DebugColor")) - static void GetPointAtDirectionRelativeToOtherVector(FVector& Point, FRotator& PointRotation, const FVector& Vector1, const FVector& Vector2, const EUHLDirection Direction, const float Distance, - const bool bTakeZFromVector1 = true, const bool bDebug = false, const float DebugLifetime = -1, const FLinearColor DebugColor = FLinearColor::White); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils") - static float DirectionToAngle(const EUHLDirection DirectionIn); - - // TODO test not sure that it works like i wanted - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Directions") - static EUHLDirection ConvertMovementInputVectorToDirection(const FVector& Vector); - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Directions") - static EUHLDirection GetMovementDirection(const FVector& Velocity, const FRotator& ActorRotation, float DeadZone); - - /** - * Determines the enemy's movement direction relative to your character's facing, - * compensating for your own movement velocity. Supports both 8-way and 4-way output, - * and can draw debug visualization in world space. - * - * @param WorldContextObject Context for drawing (usually 'self' in Blueprint) - * @param EnemyVelocity World-space velocity of the enemy pawn - * @param MyVelocity World-space velocity of your pawn - * @param ActorLocation Your pawn’s world location (for debug drawing) - * @param ActorRotation Your pawn’s world rotation (defines forward) - * @param DeadZone Speed threshold below which returns None (<=0 uses KINDA_SMALL_NUMBER) - * @param AngleToleranceDeg Degrees tolerance around boundaries to snap - * @param bFourWay If true, collapse diagonals into nearest cardinal (4-way) - * @param bDebug If true, draw debug arrows, lines, and labels in world - * @param DebugDuration Lifetime for debug drawings (0 = single frame) - * @param DebugThickness Line thickness for debug drawings - * @return The calculated direction enum (EUHLDirection) - */ - UFUNCTION(BlueprintCallable, Category="Movement|Direction", meta=(WorldContext="WorldContextObject")) - static EUHLDirection GetEnemyMovementDirectionRelativeToCharacter( - UObject* WorldContextObject, - const FVector& EnemyVelocity, - const FVector& MyVelocity, - const FVector& ActorLocation, - const FRotator& ActorRotation, - float DeadZone, - float AngleToleranceDeg = 5.f, - bool bFourWay = false, - bool bDebug = false, - float DebugDuration = 0.f, - float DebugThickness = 2.f - ); - - - // e.g. 60% -> x0.4, 40% -> x0.6, 100% -> x0.0, 0% -> x1.0 - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils") - static float ConvertPercentToMultiplier(float Percent); - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary", meta = (DefaultToSelf = "ActorIn", Keywords = "UnrealHelperLibrary attach")) - static AActor* FindAttachedActorByTag(AActor* ActorIn, FName Tag); - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (WorldContext = "WorldContextObject", Keywords = "UnrealHelperLibrary preview editor")) - static bool IsPreviewWorld(UObject* WorldContextObject); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (WorldContext = "WorldContextObject", Keywords = "UnrealHelperLibrary")) - static bool IsGameWorld(UObject* WorldContextObject); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (WorldContext = "WorldContextObject", Keywords = "UnrealHelperLibrary editor")) - static bool IsEditorWorld(UObject* WorldContextObject); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (Keywords = "UnrealHelperLibrary preview editor")) - static bool IsObjectInPreviewWorld(UObject* Object); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (Keywords = "UnrealHelperLibrary preview editor")) - static bool IsObjectInEditorWorld(UObject* Object); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (Keywords = "UnrealHelperLibrary game preview editor")) - static bool IsObjectInGameWorld(UObject* Object); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (WorldContext = "WorldContextObject", Keywords = "UnrealHelperLibrary")) - static bool IsWorldTearingDown(UObject* WorldContextObject); - // TODO: ??? - // UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary") - // static EUHLDirection AngleToDirection(const float AngleIn); - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Angles", meta = (DefaultToSelf = "Actor", Keywords = "UnrealHelperLibrary angle distance")) - static bool IsOtherActorInAngle(AActor* Actor, AActor* OtherActor, TArray Ranges); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Angles", meta = (DefaultToSelf = "Character", Keywords = "UnrealHelperLibrary angle distance")) - static bool InRangeToOtherCharacter(ACharacter* Character, ACharacter* OtherCharacter, FFloatRange Range, bool bIncludeSelfCapsuleRadius, bool bIncludeTargetCapsuleRadius); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Angles", meta = (DefaultToSelf = "Character", Keywords = "UnrealHelperLibrary angle distance")) - static bool InRangeToLocation(ACharacter* Character, FVector Location, FFloatRange Range, bool bIncludeSelfCapsuleRadius); - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (Keywords = "UnrealHelperLibrary file path")) - static FString GetPathToFile(UObject* Object); - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (Keywords = "UnrealHelperLibrary build debug")) - static bool IsDebugBuild(); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (Keywords = "UnrealHelperLibrary build debug development")) - static bool IsDevelopmentBuild(); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (Keywords = "UnrealHelperLibrary build debug production release shipping")) - static bool IsShippingBuild(); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (Keywords = "UnrealHelperLibrary build debug test")) - static bool IsTestBuild(); - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (Keywords = "UnrealHelperLibrary editor InEditor withEditor")) - static bool IsInEditor(); - // Are in Debug/Development/Shipping/Test build or Editor. If we WITH_EDITOR returns Editor, - // no matter what EBuildConfiguration is currently used(mostly WITH_EDITOR is Development) - // if real build returns - FApp::GetBuildConfiguration() result, except Debug and DebugGame are same "Debug" - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Utils", meta = (Keywords = "UnrealHelperLibrary build debug test")) - static EUHLBuildType GetBuildType(); - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Random", meta = (Keywords = "UnrealHelperLibrary random interval")) - static float RandomValueInInterval(FFloatInterval Range); - - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|World", meta = (Keywords = "UnrealHelperLibrary world map level")) - static bool IsWorldPartitionEnabled(UObject* WorldContextObject); - - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|World", meta = (Keywords = "UnrealHelperLibrary world map level")) - static bool IsLevelHasSublevels(UObject* WorldContextObject); - /** ~Utils **/ - - /** World **/ - - /** - * Returns all ULevelStreaming objects in the current world. - * @param WorldContextObject Context (e.g. self, GetGameInstance, etc.) - * @param OutStreamingLevels Array of streaming‐level objects. - */ - UFUNCTION(BlueprintCallable, Category="World|Streaming Levels", meta=(WorldContext="WorldContextObject")) - static void GetAllStreamingLevels(UObject* WorldContextObject, TArray& OutStreamingLevels); - - /** - * Returns all sub‐levels currently loaded in the world (persistent + streamed‑in). - * @param WorldContextObject Context object to resolve the UWorld (e.g. self, GetGameInstance, etc.). - * @param OutSubLevels Array of all ULevel pointers in this world. - */ - UFUNCTION(BlueprintCallable, Category="World|Levels", meta=(WorldContext="WorldContextObject")) - static void GetAllSubLevels(UObject* WorldContextObject, TArray& OutSubLevels); - - static bool IsMapPackageName(const FString& PackageName); - static FString GetCleanLevelName(const FString& PackageName); - - /** - * Returns the package names of *all* sub‑levels in the world: - * - The persistent level - * - Every streaming‐level, regardless of whether it's loaded yet - * - * @param WorldContextObject Any object in the target world (e.g. Self, GameInstance, etc.) - * @param OutLevelPackageNames Array of level package names (e.g. "/Game/Maps/MySubLevel") - */ - UFUNCTION(BlueprintCallable, Category="World|Levels", meta=(WorldContext="WorldContextObject")) - static void GetAllSubLevelPackageNames(UObject* WorldContextObject, TArray& OutLevelPackageNames); - - /** ~World **/ - - /** Colors **/ - // "Makes a random but quite nice color" - literally C++ FColor::MakeRandomColor - // if seed >= 0 than FColor::MakeRandomSeededColor will be used - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Colors", meta = (Keywords = "UnrealHelperLibrary color random", AdvancedDisplay = "Seed")) - static FColor RandomColor(int32 Seed = -1); - // "Makes a random but quite nice color" - literally C++ FLinearColor::MakeRandomColor - // if seed >= 0 than FLinearColor::MakeRandomSeededColor will be used - UFUNCTION(BlueprintPure, Category = "UnrealHelperLibrary|Colors", meta = (Keywords = "UnrealHelperLibrary color random", AdvancedDisplay = "Seed")) - static FLinearColor RandomLinearColor(int32 Seed = -1); - /** ~Colors **/ -}; diff --git a/Source/UnrealHelperLibrary/UnrealHelperLibrary.Build.cs b/Source/UnrealHelperLibrary/UnrealHelperLibrary.Build.cs deleted file mode 100644 index ddeb069e..00000000 --- a/Source/UnrealHelperLibrary/UnrealHelperLibrary.Build.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Pavel Penkov 2025 All Rights Reserved. - -using UnrealBuildTool; - -public class UnrealHelperLibrary : ModuleRules -{ - public UnrealHelperLibrary(ReadOnlyTargetRules Target) : base(Target) - { - PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; - - PublicIncludePaths.AddRange( - new string[] { - // ... add public include paths required here ... - } - ); - - - PrivateIncludePaths.AddRange( - new string[] { - // ... add other private include paths required here ... - } - ); - - - PublicDependencyModuleNames.AddRange( - new string[] - { - "Core", - // ... add other public dependencies that you statically link with here ... - "GameplayAbilities", - "GameplayTags", - "GameplayTasks", - "AIModule", - "EnhancedInput", - } - ); - - - PrivateDependencyModuleNames.AddRange( - new string[] - { - "CoreUObject", - "Engine", - "Slate", - "SlateCore", - "UMG", - "AnimGraphRuntime", - "DeveloperSettings", - "NavigationSystem" - // ... add private dependencies that you statically link with here ... - } - ); - - - DynamicallyLoadedModuleNames.AddRange( - new string[] - { - // ... add any modules that your module loads dynamically here ... - } - ); - } -} diff --git a/UHL b/UHL new file mode 160000 index 00000000..995a1865 --- /dev/null +++ b/UHL @@ -0,0 +1 @@ +Subproject commit 995a18654e15f1fbe72fb776b1ba75d234556f8d diff --git a/UHLAI b/UHLAI new file mode 160000 index 00000000..dfb2c785 --- /dev/null +++ b/UHLAI @@ -0,0 +1 @@ +Subproject commit dfb2c785cf5195fff438f086ccbf324ff13fd39b diff --git a/UHLBehaviorTree b/UHLBehaviorTree new file mode 160000 index 00000000..bd248218 --- /dev/null +++ b/UHLBehaviorTree @@ -0,0 +1 @@ +Subproject commit bd248218303d004765d574b22ee54e81ab799f8d diff --git a/UHLCharacter b/UHLCharacter new file mode 160000 index 00000000..4b25eae0 --- /dev/null +++ b/UHLCharacter @@ -0,0 +1 @@ +Subproject commit 4b25eae08749bdf7d63736844117eb9aa6283634 diff --git a/UHLCommonMaps b/UHLCommonMaps new file mode 160000 index 00000000..6c79cf3d --- /dev/null +++ b/UHLCommonMaps @@ -0,0 +1 @@ +Subproject commit 6c79cf3dcabd489f624fa60ae1cc938a65af955f diff --git a/UHLDebugSystem b/UHLDebugSystem new file mode 160000 index 00000000..3daa6fee --- /dev/null +++ b/UHLDebugSystem @@ -0,0 +1 @@ +Subproject commit 3daa6fee1a925412a7d8106b35b0d2cb562ce57c diff --git a/UHLGAS b/UHLGAS new file mode 160000 index 00000000..33a8f65f --- /dev/null +++ b/UHLGAS @@ -0,0 +1 @@ +Subproject commit 33a8f65fa0d34f7f7fe3659b4cb53fbeff5d01e4 diff --git a/UHLStateTree b/UHLStateTree new file mode 160000 index 00000000..a2916cc9 --- /dev/null +++ b/UHLStateTree @@ -0,0 +1 @@ +Subproject commit a2916cc981ec153c3235c7905b1a7c3e204b48c5 diff --git a/UnrealHelperLibrary.uplugin b/UnrealHelperLibrary.uplugin deleted file mode 100644 index b932891c..00000000 --- a/UnrealHelperLibrary.uplugin +++ /dev/null @@ -1,130 +0,0 @@ -{ - "FileVersion": 3, - "Version": 150, - "VersionName": "1.5.0", - "FriendlyName": "UnrealHelperLibrary", - "Description": "Helps working with AI, GAS, customizing editor and so on", - "Category": "AI", - "CreatedBy": "Ciberus", - "CreatedByURL": "https://github.com/Ciberusps", - "DocsURL": "https://github.com/Ciberusps/unreal-helper-library", - "MarketplaceURL": "", - "SupportURL": "https://github.com/Ciberusps/unreal-helper-library/issues", - "FabURL": "com.epicgames.launcher://ue/Fab/product/19390f7a-1d31-46ee-a54c-511b7f1a8166", - "EnabledByDefault": true, - "CanContainContent": true, - "Installed": false, - "IsBetaVersion": false, - "IsExperimentalVersion": false, - "Modules": [ - { - "Name": "UnrealHelperLibrary", - "Type": "Runtime", - "LoadingPhase": "Default", - "PlatformAllowList": [ - "Win64" - ] - }, - { - "Name": "UHLAI", - "Type": "Runtime", - "LoadingPhase": "Default", - "PlatformAllowList": [ - "Win64" - ] - }, - { - "Name": "UHLAIEditor", - "Type": "Editor", - "LoadingPhase": "PostEngineInit", - "PlatformAllowList": [ - "Win64" - ] - }, - { - "Name": "UHLGAS", - "Type": "Runtime", - "LoadingPhase": "Default", - "PlatformAllowList": [ - "Win64" - ] - }, - { - "Name": "UHLDebugSystem", - "Type": "Runtime", - "LoadingPhase": "Default", - "PlatformAllowList": [ - "Win64" - ] - }, - { - "Name": "UHLDebugSystemEditor", - "Type": "Editor", - "LoadingPhase": "PostEngineInit", - "PlatformAllowList": [ - "Win64" - ] - }, - { - "Name": "UHLDebug", - "Type": "Runtime", - "LoadingPhase": "Default", - "PlatformAllowList": [ - "Win64" - ] - }, - { - "Name": "UHLCharacter", - "Type": "Runtime", - "LoadingPhase": "Default", - "PlatformAllowList": [ - "Win64" - ] - }, - { - "Name": "UHLEditor", - "Type": "Editor", - "LoadingPhase": "PostEngineInit", - "PlatformAllowList": [ - "Win64" - ] - }, - { - "Name": "UHLModulesHelper", - "Type": "Editor", - "LoadingPhase": "PostEngineInit", - "PlatformAllowList": [ - "Win64" - ] - }, - { - "Name": "CommonMaps", - "Type": "Editor", - "LoadingPhase": "PostEngineInit", - "PlatformAllowList": [ - "Win64" - ] - } - ], - "Plugins": [ - { - "Name": "GameplayAbilities", - "Enabled": true - }, - { - "Name": "DataRegistry", - "Enabled": true - }, - { - "Name": "GameplayTagsEditor", - "Enabled": true, - "TargetAllowList": [ - "Editor" - ] - }, - { - "Name": "EnhancedInput", - "Enabled": true - } - ] -}