You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
* Created Default SmartObjectOctree * Created Default SmartObjectHashGrid * Type of space partition to use can be set in the smartobject config file: [/Script/SmartObjectsModule.SmartObjectSubsystem] SpacePartitionClassName=<ClassPath> * Created DebugSceneProxy and RenderingComponent to share functionalities between susbystem and testing actor rendering components #rnx #rb mieszko.zielinski #preflight 620fb51dec6f84cdfa3b2772 #ROBOMERGE-OWNER: yoan.stamant #ROBOMERGE-AUTHOR: yoan.stamant #ROBOMERGE-SOURCE: CL 19050433 via CL 19050556 via CL 19050564 via CL 19057424 #ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v918-19018356) [CL 19066037 by yoan stamant in ue5-main branch]
68 lines
2.2 KiB
C++
68 lines
2.2 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "SmartObjectRuntime.h"
|
|
|
|
#include "SmartObjectSubsystem.h"
|
|
#include "MassEntitySubsystem.h"
|
|
|
|
const FSmartObjectClaimHandle FSmartObjectClaimHandle::InvalidHandle = {};
|
|
|
|
//----------------------------------------------------------------------//
|
|
// FSmartObjectRuntime
|
|
//----------------------------------------------------------------------//
|
|
FSmartObjectRuntime::FSmartObjectRuntime(const USmartObjectDefinition& InDefinition)
|
|
: Definition(&InDefinition)
|
|
{
|
|
const int32 NumSlotDefinitions = InDefinition.GetSlots().Num();
|
|
SlotHandles.SetNum(NumSlotDefinitions);
|
|
}
|
|
|
|
//----------------------------------------------------------------------//
|
|
// FSmartObjectSlotClaimState
|
|
//----------------------------------------------------------------------//
|
|
bool FSmartObjectSlotClaimState::Claim(const FSmartObjectUserHandle& InUser)
|
|
{
|
|
if (State == ESmartObjectSlotState::Free)
|
|
{
|
|
State = ESmartObjectSlotState::Claimed;
|
|
User = InUser;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool FSmartObjectSlotClaimState::Release(const FSmartObjectClaimHandle& ClaimHandle, const bool bAborted)
|
|
{
|
|
if (!ensureMsgf(ClaimHandle.IsValid(), TEXT("Attempting to release a slot using an invalid handle: %s"), *LexToString(ClaimHandle)))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool bReleased = false;
|
|
|
|
if (State != ESmartObjectSlotState::Claimed && State != ESmartObjectSlotState::Occupied)
|
|
{
|
|
UE_LOG(LogSmartObject, Error, TEXT("Expected slot state is 'Claimed' or 'Occupied' but current state is '%s'. Slot will not be released"),
|
|
*UEnum::GetValueAsString(State));
|
|
}
|
|
else if (ClaimHandle.UserHandle != User)
|
|
{
|
|
UE_LOG(LogSmartObject, Error, TEXT("User '%s' is trying to release slot claimed or used by other user '%s'. Slot will not be released"),
|
|
*LexToString(ClaimHandle.UserHandle), *LexToString(User));
|
|
}
|
|
else
|
|
{
|
|
if (bAborted)
|
|
{
|
|
const bool bFunctionWasExecuted = OnSlotInvalidatedDelegate.ExecuteIfBound(ClaimHandle, State);
|
|
UE_LOG(LogSmartObject, Verbose, TEXT("Slot invalidated callback was%scalled for %s"), bFunctionWasExecuted ? TEXT(" ") : TEXT(" not "), *LexToString(ClaimHandle));
|
|
}
|
|
|
|
State = ESmartObjectSlotState::Free;
|
|
User.Reset();
|
|
bReleased = true;
|
|
}
|
|
|
|
return bReleased;
|
|
}
|