GASATHON/Project/Source/Gasa/AbilitySystem/GasaAbilitySystemComponent_Inlines.h

39 lines
1004 B
C
Raw Permalink Normal View History

2024-04-21 15:56:57 -07:00
#pragma once
#include "GasaAbilitySystemComponent.h"
#include "AbilitySystemInterface.h"
2024-04-22 09:01:30 -07:00
#include "AbilitySystemGlobals.h"
2024-04-21 15:56:57 -07:00
namespace Gasa
{
inline
UGasaAbilitySystemComp* GetAbilitySystem(UObject* Object)
{
if (Object->Implements<UAbilitySystemInterface>())
{
return Cast<UGasaAbilitySystemComp>( Cast<IAbilitySystemInterface>(Object)->GetAbilitySystemComponent() );
}
return nullptr;
}
2024-04-22 09:01:30 -07:00
// From: UAbilitySystemGlobals::GetAbilitySystemComponentFromActor
inline
2024-04-24 17:18:38 -07:00
UGasaAbilitySystemComp* GetAbilitySystem(AActor* Actor, bool LookForComponent = true)
2024-04-22 09:01:30 -07:00
{
if (Actor == nullptr)
return nullptr;
const IAbilitySystemInterface* ASI = Cast<IAbilitySystemInterface>(Actor);
if (ASI)
return Cast<UGasaAbilitySystemComp>(ASI->GetAbilitySystemComponent());
if (LookForComponent)
{
// Fall back to a component search to better support BP-only actors
return Cast<UGasaAbilitySystemComp>(Actor->FindComponentByClass<UAbilitySystemComponent>());
}
return nullptr;
}
2024-04-21 15:56:57 -07:00
}