Add BehaviorKnowledgeSelector for Behavior Knowledge unified data access

This commit is contained in:
Wojtek Figat
2023-08-19 19:50:17 +02:00
parent dee2f11ae4
commit eee53dfbdc
12 changed files with 775 additions and 43 deletions

View File

@@ -6,8 +6,10 @@ using System.Xml;
using FlaxEditor.Content;
using FlaxEditor.CustomEditors;
using FlaxEditor.GUI;
using FlaxEditor.SceneGraph;
using FlaxEditor.Scripting;
using FlaxEditor.Surface;
using FlaxEditor.Viewport;
using FlaxEngine;
using FlaxEngine.GUI;
using FlaxEngine.Utilities;
@@ -19,7 +21,7 @@ namespace FlaxEditor.Windows.Assets
/// </summary>
/// <seealso cref="BehaviorTree" />
/// <seealso cref="BehaviorTreeSurface" />
public sealed class BehaviorTreeWindow : AssetEditorWindowBase<BehaviorTree>, IVisjectSurfaceWindow
public sealed class BehaviorTreeWindow : AssetEditorWindowBase<BehaviorTree>, IVisjectSurfaceWindow, IPresenterOwner
{
private readonly SplitPanel _split1;
private readonly SplitPanel _split2;
@@ -44,6 +46,11 @@ namespace FlaxEditor.Windows.Assets
/// </summary>
public Undo Undo => _undo;
/// <summary>
/// Current instance of the Behavior Knowledge's blackboard type or null.
/// </summary>
public object Blackboard => _knowledgePropertiesEditor.Selection.Count != 0 ? _knowledgePropertiesEditor.Selection[0] : null;
/// <inheritdoc />
public BehaviorTreeWindow(Editor editor, BinaryAssetItem item)
: base(editor, item)
@@ -81,11 +88,11 @@ namespace FlaxEditor.Windows.Assets
_surface.SelectionChanged += OnNodeSelectionChanged;
// Properties editors
_nodePropertiesEditor = new CustomEditorPresenter(null); // Surface handles undo for nodes editing
_nodePropertiesEditor = new CustomEditorPresenter(null, null, this); // Surface handles undo for nodes editing
_nodePropertiesEditor.Features = FeatureFlags.UseDefault;
_nodePropertiesEditor.Panel.Parent = _split2.Panel1;
_nodePropertiesEditor.Modified += OnNodePropertyEdited;
_knowledgePropertiesEditor = new CustomEditorPresenter(null, "No blackboard type assigned"); // No undo for knowledge editing
_knowledgePropertiesEditor = new CustomEditorPresenter(null, "No blackboard type assigned", this); // No undo for knowledge editing
_knowledgePropertiesEditor.Features = FeatureFlags.None;
_knowledgePropertiesEditor.Panel.Parent = _split2.Panel2;
@@ -429,5 +436,13 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
public VisjectSurface VisjectSurface => _surface;
/// <inheritdoc />
public EditorViewport PresenterViewport => null;
/// <inheritdoc />
public void Select(List<SceneGraphNode> nodes)
{
}
}
}