-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for linking BehaviorTree nodes
- Loading branch information
Showing
6 changed files
with
263 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,81 @@ | ||
{ | ||
"FileVersion": 3, | ||
"Version": 1, | ||
"VersionName": "1.1.0", | ||
"FriendlyName": "RedTalaria", | ||
"Description": "A collection of Hermes endpoints. Hermes icons created by max.icons - Flaticon : https://www.flaticon.com/free-icons/hermes", | ||
"Category": "Other", | ||
"CreatedBy": "CD PROJEKT S.A.", | ||
"CreatedByURL": "", | ||
"DocsURL": "", | ||
"MarketplaceURL": "", | ||
"SupportURL": "", | ||
"CanContainContent": true, | ||
"IsBetaVersion": false, | ||
"IsExperimentalVersion": false, | ||
"Installed": false, | ||
"Modules": [ | ||
{ | ||
"Name": "RedTalariaUrls", | ||
"Type": "Runtime", | ||
"LoadingPhase": "Default" | ||
}, | ||
{ | ||
"Name": "RedTalaria", | ||
"Type": "EditorNoCommandlet", | ||
"LoadingPhase": "Default", | ||
"WhitelistPlatforms": [ | ||
"Win64" | ||
] | ||
}, | ||
{ | ||
"Name": "RedHermesGraphNodeEndpoint", | ||
"Type": "EditorNoCommandlet", | ||
"LoadingPhase": "Default", | ||
"WhitelistPlatforms": [ | ||
"Win64" | ||
] | ||
}, | ||
{ | ||
"Name": "RedHermesBlueprintNodeEndpoint", | ||
"Type": "EditorNoCommandlet", | ||
"LoadingPhase": "PostEngineInit", | ||
"WhitelistPlatforms": [ | ||
"Win64" | ||
] | ||
}, | ||
{ | ||
"Name": "RedHermesLevelAtCameraCoordsEndpoint", | ||
"Type": "EditorNoCommandlet", | ||
"LoadingPhase": "PostEngineInit", | ||
"WhitelistPlatforms": [ | ||
"Win64" | ||
] | ||
}, | ||
{ | ||
"Name": "RedHermesContentFolderEndpoint", | ||
"Type": "EditorNoCommandlet", | ||
"LoadingPhase": "Default", | ||
"WhitelistPlatforms": [ | ||
"Win64" | ||
] | ||
} | ||
], | ||
"Plugins": [ | ||
{ | ||
"Name": "HermesCore", | ||
"Enabled": true, | ||
"WhitelistPlatforms": [ | ||
"Win64" | ||
] | ||
} | ||
] | ||
"FileVersion": 3, | ||
"Version": 1, | ||
"VersionName": "1.1.0", | ||
"FriendlyName": "RedTalaria", | ||
"Description": "A collection of Hermes endpoints. Hermes icons created by max.icons - Flaticon : https://www.flaticon.com/free-icons/hermes", | ||
"Category": "Other", | ||
"CreatedBy": "CD PROJEKT S.A.", | ||
"CreatedByURL": "", | ||
"DocsURL": "", | ||
"MarketplaceURL": "", | ||
"SupportURL": "", | ||
"CanContainContent": true, | ||
"IsBetaVersion": false, | ||
"IsExperimentalVersion": false, | ||
"Installed": false, | ||
"Modules": [ | ||
{ | ||
"Name": "RedTalariaUrls", | ||
"Type": "Runtime", | ||
"LoadingPhase": "Default" | ||
}, | ||
{ | ||
"Name": "RedTalaria", | ||
"Type": "EditorNoCommandlet", | ||
"LoadingPhase": "Default", | ||
"WhitelistPlatforms": [ | ||
"Win64" | ||
] | ||
}, | ||
{ | ||
"Name": "RedHermesGraphNodeEndpoint", | ||
"Type": "EditorNoCommandlet", | ||
"LoadingPhase": "Default", | ||
"WhitelistPlatforms": [ | ||
"Win64" | ||
] | ||
}, | ||
{ | ||
"Name": "RedHermesBlueprintNodeEndpoint", | ||
"Type": "EditorNoCommandlet", | ||
"LoadingPhase": "PostEngineInit", | ||
"WhitelistPlatforms": [ | ||
"Win64" | ||
] | ||
}, | ||
{ | ||
"Name": "RedHermesBehaviorTreeNodeEndpoint", | ||
"Type": "EditorNoCommandlet", | ||
"LoadingPhase": "PostEngineInit", | ||
"WhitelistPlatforms": [ | ||
"Win64" | ||
] | ||
}, | ||
{ | ||
"Name": "RedHermesLevelAtCameraCoordsEndpoint", | ||
"Type": "EditorNoCommandlet", | ||
"LoadingPhase": "PostEngineInit", | ||
"WhitelistPlatforms": [ | ||
"Win64" | ||
] | ||
}, | ||
{ | ||
"Name": "RedHermesContentFolderEndpoint", | ||
"Type": "EditorNoCommandlet", | ||
"LoadingPhase": "Default", | ||
"WhitelistPlatforms": [ | ||
"Win64" | ||
] | ||
} | ||
], | ||
"Plugins": [ | ||
{ | ||
"Name": "HermesCore", | ||
"Enabled": true, | ||
"WhitelistPlatforms": [ | ||
"Win64" | ||
] | ||
} | ||
] | ||
} |
106 changes: 106 additions & 0 deletions
106
Source/RedHermesBehaviorTreeNodeEndpoint/Private/RedHermesBehaviorTreeNodeEndpoint.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// Copyright (c) CD PROJEKT S.A. | ||
|
||
#include "RedHermesBehaviorTreeNodeEndpoint.h" | ||
|
||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 3 | ||
#include "BehaviorTreeGraphNode.h" | ||
#include "Editor.h" | ||
#include "IBehaviorTreeEditor.h" | ||
#include "RedHermesGraphNodeEndpoint.h" | ||
#include "RedHermesGraphNodeEndpointEditorExtension.h" | ||
#include "BehaviorTree/BehaviorTree.h" | ||
#include "EdGraph/EdGraph.h" | ||
#include "Toolkits/ToolkitManager.h" | ||
#endif | ||
|
||
#define LOCTEXT_NAMESPACE "FRedHermesBehaviorTreeNodeEndpointModule" | ||
|
||
void FRedHermesBehaviorTreeNodeEndpointModule::StartupModule() | ||
{ | ||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 3 | ||
if (const auto RedHermesGraphNodeEndpoint = GEditor->GetEditorSubsystem<URedHermesGraphNodeEndpoint>()) | ||
{ | ||
OnRequestDelegateHandle = RedHermesGraphNodeEndpoint->OnRequest().AddStatic(&FRedHermesBehaviorTreeNodeEndpointModule::HandleRequest); | ||
} | ||
|
||
if (const auto NodeExtensionSubsystem = GEditor->GetEditorSubsystem<URedHermesGraphNodeEndpointEditorExtension>()) | ||
{ | ||
OnNodeMenuExtensionHookRequestDelegateHandle = NodeExtensionSubsystem->OnNodeMenuExtensionHookRequest().AddStatic(&FRedHermesBehaviorTreeNodeEndpointModule::ProvideNodeExtensionHook); | ||
} | ||
#endif | ||
} | ||
|
||
void FRedHermesBehaviorTreeNodeEndpointModule::ShutdownModule() | ||
{ | ||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 3 | ||
if (OnRequestDelegateHandle.IsValid()) | ||
{ | ||
if (GEditor != nullptr) | ||
{ | ||
if (const auto RedHermesGraphNodeEndpoint = GEditor->GetEditorSubsystem<URedHermesGraphNodeEndpoint>()) | ||
{ | ||
RedHermesGraphNodeEndpoint->OnRequest().Remove(OnRequestDelegateHandle); | ||
} | ||
OnRequestDelegateHandle.Reset(); | ||
} | ||
} | ||
|
||
if (OnNodeMenuExtensionHookRequestDelegateHandle.IsValid()) | ||
{ | ||
if (GEditor != nullptr) | ||
{ | ||
if (const auto NodeExtensionSubsystem = GEditor->GetEditorSubsystem<URedHermesGraphNodeEndpointEditorExtension>()) | ||
{ | ||
NodeExtensionSubsystem->OnNodeMenuExtensionHookRequest().Remove(OnNodeMenuExtensionHookRequestDelegateHandle); | ||
} | ||
OnNodeMenuExtensionHookRequestDelegateHandle.Reset(); | ||
} | ||
} | ||
#endif | ||
} | ||
|
||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 3 | ||
UEdGraphNode* FRedHermesBehaviorTreeNodeEndpointModule::GetNodeInAsset(FGuid NodeGuid, const UObject* Asset) | ||
{ | ||
|
||
if (const auto BehaviorTreeObj = Cast<UBehaviorTree>(Asset)) | ||
{ | ||
for (UEdGraphNode* Node : BehaviorTreeObj->BTGraph->Nodes) | ||
{ | ||
if (Node->NodeGuid == NodeGuid) | ||
{ | ||
return Node; | ||
} | ||
} | ||
} | ||
|
||
return nullptr; | ||
} | ||
|
||
void FRedHermesBehaviorTreeNodeEndpointModule::HandleRequest(FGuid NodeGuid, UObject* Asset, bool bOpenJumpTarget) | ||
{ | ||
if (UEdGraphNode* Node = GetNodeInAsset(NodeGuid, Asset)) | ||
{ | ||
GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->OpenEditorForAsset(Asset); | ||
TSharedPtr<IToolkit> FoundAssetEditor = FToolkitManager::Get().FindEditorForAsset(Asset); | ||
if (FoundAssetEditor.IsValid()) | ||
{ | ||
auto BehaviorTreeEditor = StaticCastSharedPtr<IBehaviorTreeEditor>(FoundAssetEditor); | ||
BehaviorTreeEditor->FocusWindow(); | ||
bOpenJumpTarget ? BehaviorTreeEditor->DoubleClickNode(Node) : BehaviorTreeEditor->FocusAttentionOnNode(Node); | ||
} | ||
} | ||
} | ||
|
||
void FRedHermesBehaviorTreeNodeEndpointModule::ProvideNodeExtensionHook(const UEdGraphNode* Node, const UEdGraph* /*Graph*/, TSet<FName>& ExtensionHooks) | ||
{ | ||
if (Node->IsA<UBehaviorTreeGraphNode>()) | ||
{ | ||
ExtensionHooks.Emplace(FName(TEXT("BehaviorTreeGraphSchemaNodeActions"))); | ||
} | ||
} | ||
#endif | ||
|
||
#undef LOCTEXT_NAMESPACE | ||
|
||
IMPLEMENT_MODULE(FRedHermesBehaviorTreeNodeEndpointModule, RedHermesBehaviorTreeNodeEndpoint) |
35 changes: 35 additions & 0 deletions
35
Source/RedHermesBehaviorTreeNodeEndpoint/Public/RedHermesBehaviorTreeNodeEndpoint.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) CD PROJEKT S.A. | ||
|
||
#pragma once | ||
|
||
// The engine commit that is needed for this to work: https://github.com/EpicGames/UnrealEngine/commit/6bb52ead8294554e5bdb60f637729eae397942d8 . | ||
|
||
#include "Modules/ModuleInterface.h" | ||
#include "Runtime/Launch/Resources/Version.h" | ||
|
||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 3 | ||
#include "Delegates/IDelegateInstance.h" | ||
#include "UObject/NameTypes.h" | ||
|
||
class UObject; | ||
class UEdGraphNode; | ||
class UEdGraph; | ||
#endif | ||
|
||
class FRedHermesBehaviorTreeNodeEndpointModule : public IModuleInterface | ||
{ | ||
public: | ||
/** IModuleInterface implementation */ | ||
virtual void StartupModule() override; | ||
virtual void ShutdownModule() override; | ||
|
||
private: | ||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 3 | ||
FDelegateHandle OnRequestDelegateHandle; | ||
FDelegateHandle OnNodeMenuExtensionHookRequestDelegateHandle; | ||
|
||
static UEdGraphNode* GetNodeInAsset(FGuid NodeGuid, const UObject* Asset); | ||
static void HandleRequest(FGuid NodeGuid, UObject* Asset, bool bOpenJumpTarget); | ||
static void ProvideNodeExtensionHook(const UEdGraphNode* Node, const UEdGraph* Graph, TSet<FName>& ExtensionHooks); | ||
#endif | ||
}; |
34 changes: 34 additions & 0 deletions
34
Source/RedHermesBehaviorTreeNodeEndpoint/RedHermesBehaviorTreeNodeEndpoint.Build.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) CD PROJEKT S.A. | ||
|
||
using UnrealBuildTool; | ||
|
||
public class RedHermesBehaviorTreeNodeEndpoint : ModuleRules | ||
{ | ||
public RedHermesBehaviorTreeNodeEndpoint(ReadOnlyTargetRules Target) : base(Target) | ||
{ | ||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; | ||
|
||
PublicDependencyModuleNames.AddRange( | ||
new[] | ||
{ | ||
"Core", | ||
"AIModule", | ||
} | ||
); | ||
|
||
PrivateDependencyModuleNames.AddRange( | ||
new[] | ||
{ | ||
"CoreUObject", | ||
"Engine", | ||
"Slate", | ||
"SlateCore", | ||
"UnrealEd", | ||
"RedHermesGraphNodeEndpoint", | ||
"AIGraph", | ||
"BehaviorTreeEditor", | ||
"EditorFramework", | ||
} | ||
); | ||
} | ||
} |