You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
[REVIEW] [at]mikko.mononen [at]mieszko.zielinski [FYI] [at]julien.marchand [at]aaron.cox #preflight 6322243ea514fd1e3739e12a #jira none [CL 22035789 by fernando coello in ue5-main branch]
66 lines
2.3 KiB
C++
66 lines
2.3 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "SmartObjectBlueprintFunctionLibrary.h"
|
|
#include "SmartObjectSubsystem.h"
|
|
#include "BlackboardKeyType_SOClaimHandle.h"
|
|
#include "BehaviorTree/BlackboardComponent.h"
|
|
#include "BehaviorTree/BTFunctionLibrary.h"
|
|
|
|
//----------------------------------------------------------------------//
|
|
// USmartObjectBlueprintFunctionLibrary
|
|
//----------------------------------------------------------------------//
|
|
FSmartObjectClaimHandle USmartObjectBlueprintFunctionLibrary::GetValueAsSOClaimHandle(UBlackboardComponent* BlackboardComponent, const FName& KeyName)
|
|
{
|
|
if (BlackboardComponent == nullptr)
|
|
{
|
|
return {};
|
|
}
|
|
return BlackboardComponent->GetValue<UBlackboardKeyType_SOClaimHandle>(KeyName);
|
|
}
|
|
|
|
void USmartObjectBlueprintFunctionLibrary::SetValueAsSOClaimHandle(UBlackboardComponent* BlackboardComponent, const FName& KeyName, const FSmartObjectClaimHandle Value)
|
|
{
|
|
if (BlackboardComponent == nullptr)
|
|
{
|
|
return;
|
|
}
|
|
const FBlackboard::FKey KeyID = BlackboardComponent->GetKeyID(KeyName);
|
|
BlackboardComponent->SetValue<UBlackboardKeyType_SOClaimHandle>(KeyID, Value);
|
|
}
|
|
|
|
bool USmartObjectBlueprintFunctionLibrary::K2_SetSmartObjectEnabled(AActor* SmartObject, const bool bEnabled)
|
|
{
|
|
if (SmartObject == nullptr)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
UWorld* World = SmartObject->GetWorld();
|
|
if (World == nullptr)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
USmartObjectSubsystem* Subsystem = USmartObjectSubsystem::GetCurrent(World);
|
|
if (Subsystem == nullptr)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return bEnabled ? Subsystem->RegisterSmartObjectActor(*SmartObject)
|
|
: Subsystem->UnregisterSmartObjectActor(*SmartObject);
|
|
}
|
|
|
|
void USmartObjectBlueprintFunctionLibrary::SetBlackboardValueAsSOClaimHandle(UBTNode* NodeOwner, const FBlackboardKeySelector& Key, const FSmartObjectClaimHandle& Value)
|
|
{
|
|
if (UBlackboardComponent* BlackboardComp = UBTFunctionLibrary::GetOwnersBlackboard(NodeOwner))
|
|
{
|
|
BlackboardComp->SetValue<UBlackboardKeyType_SOClaimHandle>(Key.SelectedKeyName, Value);
|
|
}
|
|
}
|
|
|
|
FSmartObjectClaimHandle USmartObjectBlueprintFunctionLibrary::GetBlackboardValueAsSOClaimHandle(UBTNode* NodeOwner, const FBlackboardKeySelector& Key)
|
|
{
|
|
UBlackboardComponent* BlackboardComp = UBTFunctionLibrary::GetOwnersBlackboard(NodeOwner);
|
|
return BlackboardComp ? BlackboardComp->GetValue<UBlackboardKeyType_SOClaimHandle>(Key.SelectedKeyName) : FSmartObjectClaimHandle::InvalidHandle;
|
|
} |