RealtimeStyleTransferRuntime/Plugins/GameFeatures/TopDownArena/Source/TopDownArenaRuntime/Private/TopDownArenaMovementCompone...

37 lines
1.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "TopDownArenaMovementComponent.h"
#include "AbilitySystemComponent.h"
#include "Containers/EnumAsByte.h"
#include "Engine/EngineTypes.h"
#include "GameplayAbilities/Public/AbilitySystemGlobals.h"
#include "NativeGameplayTags.h"
#include "TopDownArenaAttributeSet.h"
UTopDownArenaMovementComponent::UTopDownArenaMovementComponent(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
float UTopDownArenaMovementComponent::GetMaxSpeed() const
{
if (UAbilitySystemComponent* ASC = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetOwner()))
{
if (MovementMode == MOVE_Walking)
{
if (ASC->HasMatchingGameplayTag(TAG_Gameplay_MovementStopped))
{
return 0;
}
const float MaxSpeedFromAttribute = ASC->GetNumericAttribute(UTopDownArenaAttributeSet::GetMovementSpeedAttribute());
if (MaxSpeedFromAttribute > 0.0f)
{
return MaxSpeedFromAttribute;
}
}
}
return Super::GetMaxSpeed();
}