public override void Construct(MyObjectBuilder_BehaviorTreeNode nodeDefinition, MyBehaviorTree.MyBehaviorTreeDesc treeDesc)
        {
            base.Construct(nodeDefinition, treeDesc);
            var ob = nodeDefinition as MyObjectBuilder_BehaviorTreeDecoratorNode;

            m_defaultReturnValue = (MyBehaviorTreeState)((byte)ob.DefaultReturnValue);
            m_decoratorLogicName = ob.DecoratorLogic.GetType().Name;

            m_decoratorLogic = GetDecoratorLogic(ob.DecoratorLogic);
            m_decoratorLogic.Construct(ob.DecoratorLogic);

            if (ob.BTNode != null)
            {
                m_child = MyBehaviorTreeNodeFactory.CreateBTNode(ob.BTNode);
                m_child.Construct(ob.BTNode, treeDesc);
            }
        }
 private static Color GetColorByState(MyBehaviorTreeState state)
 {
     switch (state)
     {
         case MyBehaviorTreeState.ERROR:
             return Color.Bisque;
         case MyBehaviorTreeState.FAILURE:
             return Color.Red;
         case MyBehaviorTreeState.NOT_TICKED:
             return Color.White;
         case MyBehaviorTreeState.RUNNING:
             return Color.Yellow;
         case MyBehaviorTreeState.SUCCESS:
             return Color.Green;
         default:
             Debug.Fail("It shouldn't get here.");
             return Color.Black;
     }
 }
        void RecordRunningNodeName(MyBehaviorTreeState state, MyBehaviorTreeNode node)
        {
            if (!Sandbox.Engine.Utils.MyDebugDrawSettings.DEBUG_DRAW_BOTS)
                return;

            m_runningActionName = "";
            if (state == MyBehaviorTreeState.RUNNING)
            {
                if (node is MyBehaviorTreeActionNode)
                {
                    MyBehaviorTreeActionNode action = (MyBehaviorTreeActionNode)node;
                    m_runningActionName = action.GetActionName();
                }
                else
                {
                    string str = node.m_runningActionName;
                    if (str.Contains(ParentName))
                        str = str.Replace(ParentName, m_name + "-");
                    m_runningActionName = str;
                }
            }
        }
        void RecordRunningNodeName(IMyBot bot, MyBehaviorTreeState state)
        {
            if (!Sandbox.Engine.Utils.MyDebugDrawSettings.DEBUG_DRAW_BOTS || !(bot is MyAgentBot))
                return;

            switch(state)
            {
                case MyBehaviorTreeState.RUNNING:
                    (bot as MyAgentBot).LastActions.AddLastAction(m_child.m_runningActionName);
                    break;
                case MyBehaviorTreeState.ERROR:
                    (bot as MyAgentBot).LastActions.AddLastAction("error");
                    break;
                case MyBehaviorTreeState.FAILURE:
                    (bot as MyAgentBot).LastActions.AddLastAction("failure");
                    break;
                case MyBehaviorTreeState.SUCCESS:
                    (bot as MyAgentBot).LastActions.AddLastAction("failure");
                    break;
                case MyBehaviorTreeState.NOT_TICKED:
                    (bot as MyAgentBot).LastActions.AddLastAction("not ticked");
                    break;
            }
        }
        void RecordRunningNodeName(MyBehaviorTreeState state)
        {
            if (!Sandbox.Engine.Utils.MyDebugDrawSettings.DEBUG_DRAW_BOTS)
                return;

            if (state == MyBehaviorTreeState.RUNNING)
                m_runningActionName = m_child.m_runningActionName;
        }
        private MyBehaviorTreeState InvertState(MyBehaviorTreeState state)
        {
            if (state == MyBehaviorTreeState.SUCCESS)
                return MyBehaviorTreeState.FAILURE;
            else if (state == MyBehaviorTreeState.FAILURE)
                return MyBehaviorTreeState.SUCCESS;

            return state;
        }