#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Editor.Controls.NodeViews
{
using Opsive.Shared.Editor.UIElements.Controls;
using Opsive.BehaviorDesigner.Runtime;
using Opsive.BehaviorDesigner.Runtime.Components;
using Opsive.BehaviorDesigner.Runtime.Tasks;
using Opsive.GraphDesigner.Editor;
using Opsive.GraphDesigner.Editor.Controls.NodeViews;
using Opsive.GraphDesigner.Editor.Elements;
using Opsive.GraphDesigner.Editor.Events;
using Opsive.GraphDesigner.Runtime;
using Unity.Entities;
using UnityEngine.UIElements;
using UnityEngine;
using UnityEditor;
///
/// Adds UI elements within the task node.
///
[ControlType(typeof(IAction))]
[ControlType(typeof(IConditional))]
[ControlType(typeof(IComposite))]
[ControlType(typeof(IDecorator))]
public class TaskNodeViewControl : NodeViewBase
{
private const string c_DarkConditionalAbortLowerPriorityIconGUID = "ba6528926e3f4f7438d3b9737f595ec6";
private const string c_LightConditionalAbortLowerPriorityIconGUID = "20be04a2e46cb9d40b601dccdfbe153b";
private const string c_DarkConditionalAbortSelfIconGUID = "ff3ba64f23e708645b24cc7509b5ebe5";
private const string c_LightConditionalAbortSelfIconGUID = "5d44e66bacdbe51408dd30e519c2b318";
private const string c_DarkConditionalAbortBothIconGUID = "1c01950cc0f1c994cb5ff3576969ebbf";
private const string c_LightConditionalAbortBothIconGUID = "90b22fc04519bdb44b4d83665e86381d";
private const string c_DarkSuccessIconGUID = "240eed9b6e6dc004f94216f1e9fcc390";
private const string c_LightSuccessIconGUID = "cf3f27e8ca1f20f4680890e078c7613a";
private const string c_DarkSuccessReevaluateIconGUID = "0a5037ce131729b4fa0ffa9e1e13d387";
private const string c_LightSuccessReevaluateIconGUID = "bba6bdc3af0aac44dadd1ca3a8485b05";
private const string c_DarkFailureIconGUID = "8d159db7a8da43e41a50a77e43cfd6ba";
private const string c_LightFailureIconGUID = "c3622912d9f7bcd41a54a95add672423";
private const string c_DarkFailureReevaluateIconGUID = "26de8afeb313fd84291f98e68db44df7";
private const string c_LightFailureReevaluateIconGUID = "5a6d713911c8ec3488639e2934329033";
private ILogicNode m_Node;
private GraphWindow m_GraphWindow;
private BehaviorTree m_BehaviorTree;
private Image m_ExecutionStatusIcon;
private Image m_ConditionalAbortIcon;
private LogicNode m_LogicNode;
private Texture m_SuccessIcon;
private Texture m_SuccessReevaluateIcon;
private Texture m_FailureIcon;
private Texture m_FailureReevaluateIcon;
///
/// Addes the UIElements for the specified runtime node to the editor Node within the graph.
///
/// A reference to the GraphWindow.
/// The parent UIElement that should contain the node UIElements.
/// The node that the control represents.
public override void AddNodeView(GraphWindow graphWindow, VisualElement parent, object node)
{
m_Node = node as ILogicNode;
m_GraphWindow = graphWindow;
m_BehaviorTree = m_GraphWindow.Graph as BehaviorTree;
m_LogicNode = parent.GetFirstAncestorOfType();
if (node is IConditionalAbortParent conditionalAbortParent) {
m_ConditionalAbortIcon = new Image();
m_ConditionalAbortIcon.name = "conditional-abort-icon";
parent.parent.Add(m_ConditionalAbortIcon);
SetConditionalAbortIcon(conditionalAbortParent);
m_ConditionalAbortIcon.RegisterCallback(c =>
{
GraphEventHandler.RegisterEvent