You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Fixed hashing when adding shared fragment for smart object slot definition - Added per slot Runtime Tags - Added common event handling for Smart Object and Slot changes and events - Added annotations, which are slot definition data that has visualization - Added linked slot annotation which allows behavior reuse on slots - Added editor only ID for each slot so that they can be identified during edits - Added SmartObject slot reference type that can be used to reference other slots in the Smart Object - Changed Smart Object bDisable to bEnabled - Added separate enabled state for slots - Changed Smart Object disable to send an event, not forcefully unclaim - Added more visualization support for Smart Object editor (canvas, visualize annotations) - Changed Smart Object editor to use the commonly transform for slots - Remove Smart Object Component instance from the asset editor as it was not needed #rb Stephen.Holmes #preflight 6360f0cf63608aee36e01ba5 [CL 22888712 by mikko mononen in ue5-main branch]
72 lines
2.3 KiB
C++
72 lines
2.3 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "SmartObjectRuntime.h"
|
|
|
|
#include "SmartObjectSubsystem.h"
|
|
#include "MassEntityManager.h"
|
|
|
|
#include UE_INLINE_GENERATED_CPP_BY_NAME(SmartObjectRuntime)
|
|
|
|
const FSmartObjectClaimHandle FSmartObjectClaimHandle::InvalidHandle = {};
|
|
|
|
//----------------------------------------------------------------------//
|
|
// FSmartObjectRuntime
|
|
//----------------------------------------------------------------------//
|
|
FSmartObjectRuntime::FSmartObjectRuntime(const USmartObjectDefinition& InDefinition)
|
|
: Definition(&InDefinition)
|
|
, bEnabled(true)
|
|
{
|
|
const int32 NumSlotDefinitions = InDefinition.GetSlots().Num();
|
|
SlotHandles.SetNum(NumSlotDefinitions);
|
|
}
|
|
|
|
//----------------------------------------------------------------------//
|
|
// FSmartObjectRuntimeSlot
|
|
//----------------------------------------------------------------------//
|
|
bool FSmartObjectRuntimeSlot::Claim(const FSmartObjectUserHandle& InUser)
|
|
{
|
|
if (bEnabled && State == ESmartObjectSlotState::Free)
|
|
{
|
|
State = ESmartObjectSlotState::Claimed;
|
|
User = InUser;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool FSmartObjectRuntimeSlot::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.Invalidate();
|
|
bReleased = true;
|
|
}
|
|
|
|
return bReleased;
|
|
}
|
|
|