2022-05-23 18:41:30 +00:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
#include "LyraWeaponInstance.h"
|
2022-09-13 07:18:28 +00:00
|
|
|
|
2022-05-23 18:41:30 +00:00
|
|
|
#include "Engine/World.h"
|
2022-09-13 07:18:28 +00:00
|
|
|
#include "Math/UnrealMathUtility.h"
|
|
|
|
#include "Misc/AssertionMacros.h"
|
|
|
|
|
|
|
|
class UAnimInstance;
|
|
|
|
struct FGameplayTagContainer;
|
2022-05-23 18:41:30 +00:00
|
|
|
|
|
|
|
ULyraWeaponInstance::ULyraWeaponInstance(const FObjectInitializer& ObjectInitializer)
|
|
|
|
: Super(ObjectInitializer)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ULyraWeaponInstance::OnEquipped()
|
|
|
|
{
|
|
|
|
Super::OnEquipped();
|
|
|
|
|
|
|
|
UWorld* World = GetWorld();
|
|
|
|
check(World);
|
|
|
|
TimeLastEquipped = World->GetTimeSeconds();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ULyraWeaponInstance::OnUnequipped()
|
|
|
|
{
|
|
|
|
Super::OnUnequipped();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ULyraWeaponInstance::UpdateFiringTime()
|
|
|
|
{
|
|
|
|
UWorld* World = GetWorld();
|
|
|
|
check(World);
|
|
|
|
TimeLastFired = World->GetTimeSeconds();
|
|
|
|
}
|
|
|
|
|
|
|
|
float ULyraWeaponInstance::GetTimeSinceLastInteractedWith() const
|
|
|
|
{
|
|
|
|
UWorld* World = GetWorld();
|
|
|
|
check(World);
|
|
|
|
const double WorldTime = World->GetTimeSeconds();
|
|
|
|
|
|
|
|
double Result = WorldTime - TimeLastEquipped;
|
|
|
|
|
|
|
|
if (TimeLastFired > 0.0)
|
|
|
|
{
|
|
|
|
const double TimeSinceFired = WorldTime - TimeLastFired;
|
|
|
|
Result = FMath::Min(Result, TimeSinceFired);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
TSubclassOf<UAnimInstance> ULyraWeaponInstance::PickBestAnimLayer(bool bEquipped, const FGameplayTagContainer& CosmeticTags) const
|
|
|
|
{
|
|
|
|
const FLyraAnimLayerSelectionSet& SetToQuery = (bEquipped ? EquippedAnimSet : UneuippedAnimSet);
|
|
|
|
return SetToQuery.SelectBestLayer(CosmeticTags);
|
|
|
|
}
|