unitysamples / LyraStarterGame /Source /LyraGame /AbilitySystem /Abilities /LyraGameplayAbility_Jump.cpp
Download LyraStarterGame/Source/LyraGame/AbilitySystem/Abilities/LyraGameplayAbility_Jump.cpp from Alexhas2/unitysamples: direct link, hf CLI and curl.
- Browser
- Download file 2.22 kB
-
https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Source/LyraGame/AbilitySystem/Abilities/LyraGameplayAbility_Jump.cpp
- Command line
-
hf download hf://datasets/Alexhas2/unitysamples/LyraStarterGame/Source/LyraGame/AbilitySystem/Abilities/LyraGameplayAbility_Jump.cpp
-
curl -L -o LyraGameplayAbility_Jump.cpp https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Source/LyraGame/AbilitySystem/Abilities/LyraGameplayAbility_Jump.cpp
2.22 kB
| // Copyright Epic Games, Inc. All Rights Reserved. | |
| struct FGameplayTagContainer; | |
| ULyraGameplayAbility_Jump::ULyraGameplayAbility_Jump(const FObjectInitializer& ObjectInitializer) | |
| : Super(ObjectInitializer) | |
| { | |
| InstancingPolicy = EGameplayAbilityInstancingPolicy::InstancedPerActor; | |
| NetExecutionPolicy = EGameplayAbilityNetExecutionPolicy::LocalPredicted; | |
| } | |
| bool ULyraGameplayAbility_Jump::CanActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayTagContainer* SourceTags, const FGameplayTagContainer* TargetTags, FGameplayTagContainer* OptionalRelevantTags) const | |
| { | |
| if (!ActorInfo || !ActorInfo->AvatarActor.IsValid()) | |
| { | |
| return false; | |
| } | |
| const ALyraCharacter* LyraCharacter = Cast<ALyraCharacter>(ActorInfo->AvatarActor.Get()); | |
| if (!LyraCharacter || !LyraCharacter->CanJump()) | |
| { | |
| return false; | |
| } | |
| if (!Super::CanActivateAbility(Handle, ActorInfo, SourceTags, TargetTags, OptionalRelevantTags)) | |
| { | |
| return false; | |
| } | |
| return true; | |
| } | |
| void ULyraGameplayAbility_Jump::EndAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, bool bReplicateEndAbility, bool bWasCancelled) | |
| { | |
| // Stop jumping in case the ability blueprint doesn't call it. | |
| CharacterJumpStop(); | |
| Super::EndAbility(Handle, ActorInfo, ActivationInfo, bReplicateEndAbility, bWasCancelled); | |
| } | |
| void ULyraGameplayAbility_Jump::CharacterJumpStart() | |
| { | |
| if (ALyraCharacter* LyraCharacter = GetLyraCharacterFromActorInfo()) | |
| { | |
| if (LyraCharacter->IsLocallyControlled() && !LyraCharacter->bPressedJump) | |
| { | |
| LyraCharacter->UnCrouch(); | |
| LyraCharacter->Jump(); | |
| } | |
| } | |
| } | |
| void ULyraGameplayAbility_Jump::CharacterJumpStop() | |
| { | |
| if (ALyraCharacter* LyraCharacter = GetLyraCharacterFromActorInfo()) | |
| { | |
| if (LyraCharacter->IsLocallyControlled() && LyraCharacter->bPressedJump) | |
| { | |
| LyraCharacter->StopJumping(); | |
| } | |
| } | |
| } | |