Files
UnrealEngineUWP/Engine/Plugins/Runtime/StateTree/Source/StateTreeModule/Private/StateTreeEvents.cpp
mikko mononen a82ca89e98 StateTree: Added support for event payload in transitions and event capture for states. (contributed) [take 2]
- Transitions can now be set up to require a specific payload type and/or a gameplay tag
- Required transition event payload is visible to property bindind for transition conditions
- States can require an event type as enter condition, the event is captured when state is selected
- Required state event payload is visible to binding for state enter conditions, tasks and transistions

[CL 32150454 by mikko mononen in ue5-main branch]
2024-03-11 04:54:44 -04:00

33 lines
1.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "StateTreeEvents.h"
#include "StateTreeTypes.h"
#include "VisualLogger/VisualLogger.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(StateTreeEvents)
//----------------------------------------------------------------//
// FStateTreeSharedEvent
//----------------------------------------------------------------//
void FStateTreeSharedEvent::AddStructReferencedObjects(FReferenceCollector& Collector)
{
Collector.AddPropertyReferencesWithStructARO(FStateTreeEvent::StaticStruct(), Event.Get());
}
//----------------------------------------------------------------//
// FStateTreeEventQueue
//----------------------------------------------------------------//
void FStateTreeEventQueue::SendEvent(const UObject* Owner, const FGameplayTag& Tag, const FConstStructView Payload, const FName Origin)
{
if (SharedEvents.Num() >= MaxActiveEvents)
{
UE_VLOG_UELOG(Owner, LogStateTree, Error, TEXT("%s: Too many events send on '%s'. Dropping event %s"), ANSI_TO_TCHAR(__FUNCTION__), *GetNameSafe(Owner), *Tag.ToString());
return;
}
SharedEvents.Emplace(Tag, Payload, Origin);
}