You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
* Unregister - keeps or deletes the runtime SO information based on SmartObjectComponent.RegistrationType * Remove - called on SmartObject's EndPlay and ends up removing runtime data regardless of the registration type. Also: * SmartObjectSubsystem unfriended SmartObjectComponent - it was a toxic relationship anyway! ;) * Made changes towards simplification of how things are done - Registering, Unregistering, Binding SO Component to a RuntimeInstance. #preflight 6390906fbb6fefa4721822e4 [CL 23431219 by mieszko zielinski in ue5-main branch]
69 lines
2.4 KiB
C++
69 lines
2.4 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"
|
|
|
|
#include UE_INLINE_GENERATED_CPP_BY_NAME(SmartObjectBlueprintFunctionLibrary)
|
|
|
|
//----------------------------------------------------------------------//
|
|
// 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->RemoveSmartObjectActor(*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;
|
|
}
|