You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
[FYI] Yoan.StAmant Original CL Desc ----------------------------------------------------------------- [SmartObject] updated the smartobject blueprint library: - renamed 'K2_SetSmartObjectEnabled' to 'AddOrRemoveSmartObject' since 'Enabled= false' is a concept used when the object is no longer available for queries but active interactions can finish. - added functions to add to/remove from the simulation all smart objects from a single or a list of actors. - added functions to enable/disable smart objects on a single or a list of actors. #jira UE-165689 #rb mikko.mononen #rb maxime.mercier #rb patrick.carroll #preflight 63c6fda33f587d9e1403726c [CL 23752173 by bob tellez 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;
|
|
}
|