You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Added support for shared event buffer, so that multiple instance data can use the same - Added API to consume events - Removed double buffering from events - Treat TriggerTransitions() as event handler (events flushed after each call to the method) - Event handlers (including tasks) are executed in priority order - Transitions and event capturing states can consume events on successful selection - Added API to tick a StateTree in two passes (update tasks and trigger transitions) - Change parallel tree tasks to do the task update in Tick(), and event handling in TriggerTransitions() - Small improvements to the ST debugger to display events - NOTE: this is breaking change for implementations that has relied events emitted during tick to be available on next EnterState() #okfirgithub public #rb Yoan.StAmant [CL 32924765 by mikko mononen in ue5-main branch]
41 lines
1.3 KiB
C++
41 lines
1.3 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);
|
|
}
|
|
|
|
void FStateTreeEventQueue::ConsumeEvent(const FStateTreeSharedEvent& Event)
|
|
{
|
|
SharedEvents.RemoveAll([&EventToRemove = Event](const FStateTreeSharedEvent& Event)
|
|
{
|
|
return Event == EventToRemove;
|
|
});
|
|
}
|