Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion ALSV4_CPP.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"CreatedByURL": "https://github.com/dyanikoglu",
"DocsURL": "https://github.com/dyanikoglu/ALS-Community",
"SupportURL": "https://github.com/dyanikoglu/ALS-Community/issues",
"EngineVersion": "5.1",
"EngineAssociation": "5.1",
"EnabledByDefault": true,
"CanContainContent": true,
"IsBetaVersion": false,
Expand All @@ -24,6 +24,7 @@
"Engine",
"AIModule",
"GameplayTasks",
"GameplayAbilities",
"PhysicsCore"
]
}
Expand All @@ -36,6 +37,42 @@
{
"Name": "EnhancedInput",
"Enabled": true
},
{
"Name": "GameplayMessageRouter",
"Enabled": true
},
{
"Name": "GameFeatures",
"Enabled": true
},
{
"Name": "CommonLoadingScreen",
"Enabled": true
},
{
"Name": "CommonUI",
"Enabled": true
},
{
"Name": "CommonUser",
"Enabled": true
},
{
"Name": "CommonGame",
"Enabled": true
},
{
"Name": "GameplayAbilities",
"Enabled": true
},
{
"Name": "ModularGameplay",
"Enabled": true
},
{
"Name": "ModularGameplayActors",
"Enabled": true
}
]
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Content/AdvancedLocomotionV4/Blueprints/UI/ALS_HUD.uasset
Binary file not shown.
Binary file modified Content/AdvancedLocomotionV4/Levels/ALS_DemoLevel.umap
Binary file not shown.
42 changes: 38 additions & 4 deletions Source/ALSV4_CPP/ALSV4_CPP.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,45 @@ public class ALSV4_CPP : ModuleRules
public ALSV4_CPP(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

PublicDependencyModuleNames.AddRange(new[]
{"Core", "CoreUObject", "Engine", "InputCore", "NavigationSystem", "AIModule", "GameplayTasks","PhysicsCore", "Niagara", "EnhancedInput"
});
{
"GameplayAbilities",
"GameplayTags",
"GameplayTasks",
"Core",
"CoreUObject",
"Engine",
"InputCore",
"NavigationSystem",
"AIModule",
"ModularGameplay",
"ModularGameplayActors",
"GameplayTasks",
"GameFeatures",
"PhysicsCore",
"Niagara",
"CommonLoadingScreen",
"EnhancedInput"
}
);

PrivateDependencyModuleNames.AddRange(new[] {"Slate", "SlateCore"});
PrivateDependencyModuleNames.AddRange(
new string[]
{
"InputCore",
"AudioMixer",
"AudioModulation",
"EnhancedInput",
"NetCore",
"CommonInput",
"CommonGame",
"CommonUser",
"CommonUI",
"GameplayMessageRuntime",
"Slate",
"SlateCore"
}
);
}
}
100 changes: 100 additions & 0 deletions Source/ALSV4_CPP/Private/ALSGameplayTags.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#include "ALSGameplayTags.h"
#include "ALSLogChannels.h"
#include "GameplayTagsManager.h"
#include "Engine/EngineTypes.h"

FALSGameplayTags FALSGameplayTags::GameplayTags;

void FALSGameplayTags::InitializeNativeTags()
{
UE_LOG(LogTemp, Warning, TEXT("FALSGameplayTags::InitializeNativeTags"))
UGameplayTagsManager& Manager = UGameplayTagsManager::Get();

GameplayTags.AddAllTags(Manager);

// Notify manager that we are done adding native tags.
Manager.DoneAddingNativeTags();
}

void FALSGameplayTags::AddAllTags(UGameplayTagsManager& Manager)
{
AddTag(Ability_ActivateFail_IsDead, "Ability.ActivateFail.IsDead", "Ability failed to activate because its owner is dead.");
AddTag(Ability_ActivateFail_Cooldown, "Ability.ActivateFail.Cooldown", "Ability failed to activate because it is on cool down.");
AddTag(Ability_ActivateFail_Cost, "Ability.ActivateFail.Cost", "Ability failed to activate because it did not pass the cost checks.");
AddTag(Ability_ActivateFail_TagsBlocked, "Ability.ActivateFail.TagsBlocked", "Ability failed to activate because tags are blocking it.");
AddTag(Ability_ActivateFail_TagsMissing, "Ability.ActivateFail.TagsMissing", "Ability failed to activate because tags are missing.");
AddTag(Ability_ActivateFail_Networking, "Ability.ActivateFail.Networking", "Ability failed to activate because it did not pass the network checks.");
AddTag(Ability_ActivateFail_ActivationGroup, "Ability.ActivateFail.ActivationGroup", "Ability failed to activate because of its activation group.");

AddTag(Ability_Behavior_SurvivesDeath, "Ability.Behavior.SurvivesDeath", "An ability with this type tag should not be canceled due to death.");

AddTag(InputTag_Move, "InputTag.Move", "Move input.");
AddTag(InputTag_Look_Mouse, "InputTag.Look.Mouse", "Look (mouse) input.");
AddTag(InputTag_Look_Stick, "InputTag.Look.Stick", "Look (stick) input.");
AddTag(InputTag_Crouch, "InputTag.Crouch", "Crouch input.");
AddTag(InputTag_AutoRun, "InputTag.AutoRun", "Auto-run input.");

AddTag(GameplayEvent_Death, "GameplayEvent.Death", "Event that fires on death. This event only fires on the server.");
AddTag(GameplayEvent_Reset, "GameplayEvent.Reset", "Event that fires once a player reset is executed.");
AddTag(GameplayEvent_RequestReset, "GameplayEvent.RequestReset", "Event to request a player's pawn to be instantly replaced with a new one at a valid spawn location.");

AddTag(SetByCaller_Damage, "SetByCaller.Damage", "SetByCaller tag used by damage gameplay effects.");
AddTag(SetByCaller_Heal, "SetByCaller.Heal", "SetByCaller tag used by healing gameplay effects.");

AddTag(Cheat_GodMode, "Cheat.GodMode", "GodMode cheat is active on the owner.");
AddTag(Cheat_UnlimitedHealth, "Cheat.UnlimitedHealth", "UnlimitedHealth cheat is active on the owner.");

AddTag(Status_Crouching, "Status.Crouching", "Target is crouching.");
AddTag(Status_AutoRunning, "Status.AutoRunning", "Target is auto-running.");
AddTag(Status_Death, "Status.Death", "Target has the death status.");
AddTag(Status_Death_Dying, "Status.Death.Dying", "Target has begun the death process.");
AddTag(Status_Death_Dead, "Status.Death.Dead", "Target has finished the death process.");

AddMovementModeTag(Movement_Mode_Walking, "Movement.Mode.Walking", MOVE_Walking);
AddMovementModeTag(Movement_Mode_NavWalking, "Movement.Mode.NavWalking", MOVE_NavWalking);
AddMovementModeTag(Movement_Mode_Falling, "Movement.Mode.Falling", MOVE_Falling);
AddMovementModeTag(Movement_Mode_Swimming, "Movement.Mode.Swimming", MOVE_Swimming);
AddMovementModeTag(Movement_Mode_Flying, "Movement.Mode.Flying", MOVE_Flying);
AddMovementModeTag(Movement_Mode_Custom, "Movement.Mode.Custom", MOVE_Custom);
}

void FALSGameplayTags::AddTag(FGameplayTag& OutTag, const ANSICHAR* TagName, const ANSICHAR* TagComment)
{
OutTag = UGameplayTagsManager::Get().AddNativeGameplayTag(FName(TagName), FString(TEXT("(Native) ")) + FString(TagComment));
}

void FALSGameplayTags::AddMovementModeTag(FGameplayTag& OutTag, const ANSICHAR* TagName, uint8 MovementMode)
{
AddTag(OutTag, TagName, "Character movement mode tag.");
GameplayTags.MovementModeTagMap.Add(MovementMode, OutTag);
}

void FALSGameplayTags::AddCustomMovementModeTag(FGameplayTag& OutTag, const ANSICHAR* TagName, uint8 CustomMovementMode)
{
AddTag(OutTag, TagName, "Character custom movement mode tag.");
GameplayTags.CustomMovementModeTagMap.Add(CustomMovementMode, OutTag);
}

FGameplayTag FALSGameplayTags::FindTagByString(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(LogALS, 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;
}
37 changes: 37 additions & 0 deletions Source/ALSV4_CPP/Private/ALSLogChannels.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "ALSLogChannels.h"
#include "GameFramework/Actor.h"

DEFINE_LOG_CATEGORY(LogALS);
DEFINE_LOG_CATEGORY(LogALSAbilitySystem);
DEFINE_LOG_CATEGORY(LogALSExperience);

FString GetClientServerContextString(UObject* ContextObject)
{
ENetRole Role = ROLE_None;

if (AActor* Actor = Cast<AActor>(ContextObject))
{
Role = Actor->GetLocalRole();
}
else if (UActorComponent* Component = Cast<UActorComponent>(ContextObject))
{
Role = Component->GetOwnerRole();
}

if (Role != ROLE_None)
{
return (Role == ROLE_Authority) ? TEXT("Server") : TEXT("Client");
}
else
{
#if WITH_EDITOR
if (GIsEditor)
{
extern ENGINE_API FString GPlayInEditorContextString;
return GPlayInEditorContextString;
}
#endif
}

return TEXT("[]");
}
145 changes: 145 additions & 0 deletions Source/ALSV4_CPP/Private/AbilitySystem/ALSAbilitySet.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// Fill out your copyright notice in the Description page of Project Settings.


#include "AbilitySystem/ALSAbilitySet.h"
#include "ALSLogChannels.h"
#include "AbilitySystem/ALSAbilitySystemComponent.h"
#include "AbilitySystem/Abilities/ALSGameplayAbility.h"

void FALSAbilitySet_GrantedHandles::AddAbilitySpecHandle(const FGameplayAbilitySpecHandle& Handle)
{
if (Handle.IsValid())
{
AbilitySpecHandles.Add(Handle);
}
}

void FALSAbilitySet_GrantedHandles::AddGameplayEffectHandle(const FActiveGameplayEffectHandle& Handle)
{
if (Handle.IsValid())
{
GameplayEffectHandles.Add(Handle);
}
}

void FALSAbilitySet_GrantedHandles::AddAttributeSet(UAttributeSet* Set)
{
GrantedAttributeSets.Add(Set);
}

void FALSAbilitySet_GrantedHandles::TakeFromAbilitySystem(UALSAbilitySystemComponent* ALSASC)
{
check(ALSASC);

if (!ALSASC->IsOwnerActorAuthoritative())
{
// Must be authoritative to give or take ability sets.
return;
}

for (const FGameplayAbilitySpecHandle& Handle : AbilitySpecHandles)
{
if (Handle.IsValid())
{
ALSASC->ClearAbility(Handle);
}
}

for (const FActiveGameplayEffectHandle& Handle : GameplayEffectHandles)
{
if (Handle.IsValid())
{
ALSASC->RemoveActiveGameplayEffect(Handle);
}
}

for (UAttributeSet* Set : GrantedAttributeSets)
{
ALSASC->GetSpawnedAttributes_Mutable().Remove(Set);
}

AbilitySpecHandles.Reset();
GameplayEffectHandles.Reset();
GrantedAttributeSets.Reset();
}

UALSAbilitySet::UALSAbilitySet(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}

void UALSAbilitySet::GiveToAbilitySystem(UALSAbilitySystemComponent* ALSASC, FALSAbilitySet_GrantedHandles* OutGrantedHandles, UObject* SourceObject) const
{
check(ALSASC);

if (!ALSASC->IsOwnerActorAuthoritative())
{
// Must be authoritative to give or take ability sets.
return;
}

// Grant the gameplay abilities.
for (int32 AbilityIndex = 0; AbilityIndex < GrantedGameplayAbilities.Num(); ++AbilityIndex)
{
const FALSAbilitySet_GameplayAbility& AbilityToGrant = GrantedGameplayAbilities[AbilityIndex];

if (!IsValid(AbilityToGrant.Ability))
{
UE_LOG(LogALSAbilitySystem, Error, TEXT("GrantedGameplayAbilities[%d] on ability set [%s] is not valid."), AbilityIndex, *GetNameSafe(this));
continue;
}

UALSGameplayAbility* AbilityCDO = AbilityToGrant.Ability->GetDefaultObject<UALSGameplayAbility>();

FGameplayAbilitySpec AbilitySpec(AbilityCDO, AbilityToGrant.AbilityLevel);
AbilitySpec.SourceObject = SourceObject;
AbilitySpec.DynamicAbilityTags.AddTag(AbilityToGrant.InputTag);

const FGameplayAbilitySpecHandle AbilitySpecHandle = ALSASC->GiveAbility(AbilitySpec);

if (OutGrantedHandles)
{
OutGrantedHandles->AddAbilitySpecHandle(AbilitySpecHandle);
}
}

// Grant the gameplay effects.
for (int32 EffectIndex = 0; EffectIndex < GrantedGameplayEffects.Num(); ++EffectIndex)
{
const FALSAbilitySet_GameplayEffect& EffectToGrant = GrantedGameplayEffects[EffectIndex];

if (!IsValid(EffectToGrant.GameplayEffect))
{
UE_LOG(LogALSAbilitySystem, Error, TEXT("GrantedGameplayEffects[%d] on ability set [%s] is not valid"), EffectIndex, *GetNameSafe(this));
continue;
}

const UGameplayEffect* GameplayEffect = EffectToGrant.GameplayEffect->GetDefaultObject<UGameplayEffect>();
const FActiveGameplayEffectHandle GameplayEffectHandle = ALSASC->ApplyGameplayEffectToSelf(GameplayEffect, EffectToGrant.EffectLevel, ALSASC->MakeEffectContext());

if (OutGrantedHandles)
{
OutGrantedHandles->AddGameplayEffectHandle(GameplayEffectHandle);
}
}

// Grant the attribute sets.
for (int32 SetIndex = 0; SetIndex < GrantedAttributes.Num(); ++SetIndex)
{
const FALSAbilitySet_AttributeSet& SetToGrant = GrantedAttributes[SetIndex];

if (!IsValid(SetToGrant.AttributeSet))
{
UE_LOG(LogALSAbilitySystem, Error, TEXT("GrantedAttributes[%d] on ability set [%s] is not valid"), SetIndex, *GetNameSafe(this));
continue;
}

UAttributeSet* NewSet = NewObject<UAttributeSet>(ALSASC->GetOwner(), SetToGrant.AttributeSet);
ALSASC->AddAttributeSetSubobject(NewSet);

if (OutGrantedHandles)
{
OutGrantedHandles->AddAttributeSet(NewSet);
}
}
}
Loading