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

39 lines
1005 B
C
Raw 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
UGasaAbilitySystemComp* GetAbilitySystem(AActor* Actor, bool LookForComponent = false)
{
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
}