2024-08-13 09:09:54 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "StateTree.h"
|
|
|
|
|
#include "StateTreeViewModel.h"
|
|
|
|
|
#include "EditorSubsystem.h"
|
2024-08-27 07:06:07 -04:00
|
|
|
#include "UObject/ObjectKey.h"
|
2024-08-13 09:09:54 -04:00
|
|
|
|
|
|
|
|
#include "StateTreeEditingSubsystem.generated.h"
|
|
|
|
|
|
|
|
|
|
class SWidget;
|
|
|
|
|
class FStateTreeViewModel;
|
|
|
|
|
class FUICommandList;
|
|
|
|
|
struct FStateTreeCompilerLog;
|
|
|
|
|
|
|
|
|
|
UCLASS()
|
|
|
|
|
class STATETREEEDITORMODULE_API UStateTreeEditingSubsystem : public UEditorSubsystem
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
public:
|
2024-08-27 07:06:07 -04:00
|
|
|
UStateTreeEditingSubsystem();
|
|
|
|
|
virtual void BeginDestroy() override;
|
2024-08-13 09:09:54 -04:00
|
|
|
|
2024-09-17 08:06:50 -04:00
|
|
|
TSharedRef<FStateTreeViewModel> FindOrAddViewModel(const gsl::not_null<UStateTree*> InStateTree);
|
2024-08-13 09:09:54 -04:00
|
|
|
|
2024-09-17 08:06:50 -04:00
|
|
|
static bool CompileStateTree(const gsl::not_null<UStateTree*> InStateTree, FStateTreeCompilerLog& InOutLog);
|
2024-08-13 09:09:54 -04:00
|
|
|
|
2024-08-27 07:06:07 -04:00
|
|
|
/** Create a StateTreeView widget for the viewmodel. */
|
2024-08-13 09:09:54 -04:00
|
|
|
static TSharedRef<SWidget> GetStateTreeView(TSharedRef<FStateTreeViewModel> InViewModel, const TSharedRef<FUICommandList>& TreeViewCommandList);
|
|
|
|
|
|
2024-08-27 07:06:07 -04:00
|
|
|
/**
|
|
|
|
|
* Validates and applies the schema restrictions on the StateTree.
|
|
|
|
|
* Updates state's link, removes the unused node while validating the StateTree asset.
|
|
|
|
|
*/
|
2024-09-17 08:06:50 -04:00
|
|
|
static void ValidateStateTree(const gsl::not_null<UStateTree*> InStateTree);
|
2024-08-13 09:09:54 -04:00
|
|
|
|
2024-08-27 07:06:07 -04:00
|
|
|
/** Calculates editor data hash of the asset. */
|
2024-09-17 08:06:50 -04:00
|
|
|
static uint32 CalculateStateTreeHash(const gsl::not_null<const UStateTree*> InStateTree);
|
2024-08-13 09:09:54 -04:00
|
|
|
|
2024-08-27 07:06:07 -04:00
|
|
|
private:
|
|
|
|
|
void HandlePostGarbageCollect();
|
|
|
|
|
|
2024-08-13 09:09:54 -04:00
|
|
|
protected:
|
2024-08-27 07:06:07 -04:00
|
|
|
TMap<FObjectKey, TSharedPtr<FStateTreeViewModel>> StateTreeViewModels;
|
|
|
|
|
FDelegateHandle PostGarbageCollectHandle;
|
2024-08-13 09:09:54 -04:00
|
|
|
};
|