private static string GetActionResultStr(EActionResult actionResult)
        {
#if !BEHAVIAC_RELEASE
            if (Config.IsLoggingOrSocketing)
            {
                string actionResultStr = "";

                if (actionResult == EActionResult.EAR_success)
                {
                    actionResultStr = " [success]";
                }
                else if (actionResult == EActionResult.EAR_failure)
                {
                    actionResultStr = " [failure]";
                }
                else if (actionResult == EActionResult.EAR_all)
                {
                    actionResultStr = " [all]";
                }
                else
                {
                    //although actionResult can be EAR_none or EAR_all, but, as this is the real result of an action
                    //it can only be success or failure
                    Debug.Check(false);
                }

                return(actionResultStr);
            }
#endif
            return(string.Empty);
        }
        private static void _MY_BREAKPOINT_BREAK_(Agent pAgent, string btMsg, EActionResult actionResult)
        {
#if !BEHAVIAC_RELEASE
            if (Config.IsLoggingOrSocketing)
            {
                string actionResultStr = GetActionResultStr(actionResult);
                string msg             = string.Format("BehaviorTreeTask Breakpoints at: '{0}{1}'\n\nOk to continue.", btMsg, actionResultStr);

                Workspace.Instance.RespondToBreak(msg, "BehaviorTreeTask Breakpoints");
            }
#endif
        }
        //CheckBreakpoint should be after log of onenter/onexit/update, as it needs to flush msg to the client
        public static void CHECK_BREAKPOINT(Agent pAgent, BehaviorNode b, string action, EActionResult actionResult)
        {
#if !BEHAVIAC_RELEASE
            if (Config.IsLoggingOrSocketing)
            {
                string bpstr = GetTickInfo(pAgent, b, action);

                if (!string.IsNullOrEmpty(bpstr))
                {
                    LogManager.Instance.Log(pAgent, bpstr, actionResult, LogMode.ELM_tick);

                    if (Workspace.Instance.CheckBreakpoint(pAgent, b, action, actionResult))
                    {
                        LogManager.Instance.Log(pAgent, bpstr, actionResult, LogMode.ELM_breaked);
                        LogManager.Instance.Flush(pAgent);
                        SocketUtils.Flush();

                        _MY_BREAKPOINT_BREAK_(pAgent, bpstr, actionResult);

                        LogManager.Instance.Log(pAgent, bpstr, actionResult, LogMode.ELM_continue);
                        LogManager.Instance.Flush(pAgent);
                        SocketUtils.Flush();
                    }
                }
            }
#endif
        }
示例#4
0
        //action
        public void Log(Agent pAgent, string btMsg, EActionResult actionResult, LogMode mode)
        {
#if !BEHAVIAC_RELEASE
            if (Config.IsLoggingOrSocketing)
            {
                //BEHAVIAC_PROFILE("LogManager.Instance.LogAction");
                if (!System.Object.ReferenceEquals(pAgent, null) && pAgent.IsMasked())
                {
                    if (!string.IsNullOrEmpty(btMsg))
                    {
                        string agentClassName = pAgent.GetClassTypeName();

                        agentClassName = agentClassName.Replace(".", "::");

                        string agentName = agentClassName;
                        agentName += "#";
                        agentName += pAgent.GetName();

                        string actionResultStr = "";

                        if (actionResult == EActionResult.EAR_success)
                        {
                            actionResultStr = "success";
                        }
                        else if (actionResult == EActionResult.EAR_failure)
                        {
                            actionResultStr = "failure";
                        }
                        else if (actionResult == EActionResult.EAR_all)
                        {
                            actionResultStr = "all";
                        }
                        else
                        {
                            //although actionResult can be EAR_none or EAR_all, but, as this is the real result of an action
                            //it can only be success or failure
                            //when it is EAR_none, it is for update
                            if (actionResult == behaviac.EActionResult.EAR_none && mode == behaviac.LogMode.ELM_tick)
                            {
                                actionResultStr = "running";
                            }
                            else
                            {
                                actionResultStr = "none";
                            }
                        }

                        if (mode == LogMode.ELM_continue)
                        {
                            //[continue]Ship.Ship_1 ships\suicide.xml.BehaviorTreeTask[0]:enter [all/success/failure] [1]
                            int count = Workspace.Instance.GetActionCount(btMsg);
                            Debug.Check(count > 0);
                            string buffer = string.Format("[continue]{0} {1} [{2}] [{3}]\n", agentName, btMsg, actionResultStr, count);

                            Output(pAgent, buffer);
                        }
                        else if (mode == LogMode.ELM_breaked)
                        {
                            //[breaked]Ship.Ship_1 ships\suicide.xml.BehaviorTreeTask[0]:enter [all/success/failure] [1]
                            int count = Workspace.Instance.GetActionCount(btMsg);
                            Debug.Check(count > 0);
                            string buffer = string.Format("[breaked]{0} {1} [{2}] [{3}]\n", agentName, btMsg, actionResultStr, count);

                            Output(pAgent, buffer);
                        }
                        else if (mode == LogMode.ELM_tick)
                        {
                            //[tick]Ship.Ship_1 ships\suicide.xml.BehaviorTreeTask[0]:enter [all/success/failure] [1]
                            //[tick]Ship.Ship_1 ships\suicide.xml.BehaviorTreeTask[0]:update [1]
                            //[tick]Ship.Ship_1 ships\suicide.xml.Selector[1]:enter [all/success/failure] [1]
                            //[tick]Ship.Ship_1 ships\suicide.xml.Selector[1]:update [1]
                            int count = Workspace.Instance.UpdateActionCount(btMsg);

                            string buffer = string.Format("[tick]{0} {1} [{2}] [{3}]\n", agentName, btMsg, actionResultStr, count);

                            Output(pAgent, buffer);
                        }
                        else if (mode == LogMode.ELM_jump)
                        {
                            string buffer = string.Format("[jump]{0} {1}\n", agentName, btMsg);

                            Output(pAgent, buffer);
                        }
                        else if (mode == LogMode.ELM_return)
                        {
                            string buffer = string.Format("[return]{0} {1}\n", agentName, btMsg);

                            Output(pAgent, buffer);
                        }
                        else
                        {
                            Debug.Check(false);
                        }
                    }
                }
            }
#endif
        }
示例#5
0
        //action
        public void Log(Agent pAgent, string btMsg, EActionResult actionResult, LogMode mode)
        {
#if !BEHAVIAC_RELEASE

            if (Config.IsLoggingOrSocketing)
            {
                //BEHAVIAC_PROFILE("LogManager.Instance.LogAction");
                if (!System.Object.ReferenceEquals(pAgent, null) && pAgent.IsMasked())
                {
                    if (!string.IsNullOrEmpty(btMsg))
                    {
                        string agentClassName = pAgent.GetClassTypeName();

                        agentClassName = agentClassName.Replace(".", "::");

                        string agentName = agentClassName;
                        agentName += "#";
                        agentName += pAgent.GetName();

                        string actionResultStr = "";

                        if (actionResult == EActionResult.EAR_success)
                        {
                            actionResultStr = "success";
                        }
                        else if (actionResult == EActionResult.EAR_failure)
                        {
                            actionResultStr = "failure";
                        }
                        else if (actionResult == EActionResult.EAR_all)
                        {
                            actionResultStr = "all";
                        }
                        else
                        {
                            //although actionResult can be EAR_none or EAR_all, but, as this is the real result of an action
                            //it can only be success or failure
                            //when it is EAR_none, it is for update
                            if (actionResult == behaviac.EActionResult.EAR_none && mode == behaviac.LogMode.ELM_tick)
                            {
                                actionResultStr = "running";
                            }
                            else
                            {
                                actionResultStr = "none";
                            }
                        }

                        if (mode == LogMode.ELM_continue)
                        {
                            //[continue]Ship.Ship_1 ships\suicide.xml.BehaviorTreeTask[0]:enter [all/success/failure] [1]
                            int count = Workspace.Instance.GetActionCount(btMsg);
                            Debug.Check(count > 0);
                            string buffer = string.Format("[continue]{0} {1} [{2}] [{3}]\n", agentName, btMsg, actionResultStr, count);

                            Output(pAgent, buffer);
                        }
                        else if (mode == LogMode.ELM_breaked)
                        {
                            //[breaked]Ship.Ship_1 ships\suicide.xml.BehaviorTreeTask[0]:enter [all/success/failure] [1]
                            int count = Workspace.Instance.GetActionCount(btMsg);
                            Debug.Check(count > 0);
                            string buffer = string.Format("[breaked]{0} {1} [{2}] [{3}]\n", agentName, btMsg, actionResultStr, count);

                            Output(pAgent, buffer);
                        }
                        else if (mode == LogMode.ELM_tick)
                        {
                            //[tick]Ship.Ship_1 ships\suicide.xml.BehaviorTreeTask[0]:enter [all/success/failure] [1]
                            //[tick]Ship.Ship_1 ships\suicide.xml.BehaviorTreeTask[0]:update [1]
                            //[tick]Ship.Ship_1 ships\suicide.xml.Selector[1]:enter [all/success/failure] [1]
                            //[tick]Ship.Ship_1 ships\suicide.xml.Selector[1]:update [1]
                            int count = Workspace.Instance.UpdateActionCount(btMsg);

                            string buffer = string.Format("[tick]{0} {1} [{2}] [{3}]\n", agentName, btMsg, actionResultStr, count);

                            Output(pAgent, buffer);
                        }
                        else if (mode == LogMode.ELM_jump)
                        {
                            string buffer = string.Format("[jump]{0} {1}\n", agentName, btMsg);

                            Output(pAgent, buffer);
                        }
                        else if (mode == LogMode.ELM_return)
                        {
                            string buffer = string.Format("[return]{0} {1}\n", agentName, btMsg);

                            Output(pAgent, buffer);
                        }
                        else
                        {
                            Debug.Check(false);
                        }
                    }
                }
            }

#endif
        }
示例#6
0
        private static string GetActionResultStr(EActionResult actionResult)
        {
            #if !BEHAVIAC_RELEASE

            if (Config.IsLoggingOrSocketing)
            {
                string actionResultStr = "";

                if (actionResult == EActionResult.EAR_success)
                {
                    actionResultStr = " [success]";
                }
                else if (actionResult == EActionResult.EAR_failure)
                {
                    actionResultStr = " [failure]";
                }
                else if (actionResult == EActionResult.EAR_all)
                {
                    actionResultStr = " [all]";
                }
                else
                {
                    //although actionResult can be EAR_none or EAR_all, but, as this is the real result of an action
                    //it can only be success or failure
                    Debug.Check(false);
                }

                return actionResultStr;
            }

            #endif
            return string.Empty;
        }
示例#7
0
        private static void _MY_BREAKPOINT_BREAK_(Agent pAgent, string btMsg, EActionResult actionResult)
        {
            #if !BEHAVIAC_RELEASE

            if (Config.IsLoggingOrSocketing)
            {
                string actionResultStr = GetActionResultStr(actionResult);
                string msg = string.Format("BehaviorTreeTask Breakpoints at: '{0}{1}'\n\nOk to continue.", btMsg, actionResultStr);

                Workspace.Instance.RespondToBreak(msg, "BehaviorTreeTask Breakpoints");
            }

            #endif
        }
示例#8
0
        //CheckBreakpoint should be after log of onenter/onexit/update, as it needs to flush msg to the client
        public static void CHECK_BREAKPOINT(Agent pAgent, BehaviorNode b, string action, EActionResult actionResult)
        {
            #if !BEHAVIAC_RELEASE

            if (Config.IsLoggingOrSocketing)
            {
                string bpstr = GetTickInfo(pAgent, b, action);

                if (!string.IsNullOrEmpty(bpstr))
                {
                    LogManager.Instance.Log(pAgent, bpstr, actionResult, LogMode.ELM_tick);

                    if (Workspace.Instance.CheckBreakpoint(pAgent, b, action, actionResult))
                    {
                        LogManager.Instance.Log(pAgent, bpstr, actionResult, LogMode.ELM_breaked);
                        LogManager.Instance.Flush(pAgent);
                        SocketUtils.Flush();

                        _MY_BREAKPOINT_BREAK_(pAgent, bpstr, actionResult);

                        LogManager.Instance.Log(pAgent, bpstr, actionResult, LogMode.ELM_continue);
                        LogManager.Instance.Flush(pAgent);
                        SocketUtils.Flush();
                    }
                }
            }

            #endif
        }
示例#9
0
		public static bool CheckBreakpoint(Agent pAgent, BehaviorTask b, string action, EActionResult actionResult)
		{
#if !BEHAVIAC_RELEASE
			if (Config.IsSocketing)
			{
				string bpStr = BehaviorTask.GetTickInfo(pAgent, b, action);
				
				uint bpid = Utils.MakeVariableId(bpStr);
				
				if (m_breakpoints.ContainsKey(bpid))
				{
					BreakpointInfo_t bp = m_breakpoints[bpid];
					
					if ((bp.action_result & actionResult) != 0)
					{
						int count = GetActionCount(bpStr);
						Debug.Check(count > 0);
						
						if (bp.hit_config == 0 || bp.hit_config == count)
						{
							return true;
						}
					}
				}
			}
			#endif
			return false;
		}
示例#10
0
			public BreakpointInfo_t()
			{
				hit_config = 0;
				action_result = EActionResult.EAR_all;
			}
示例#11
0
 public static void Log(Agent pAgent, string btMsg, EActionResult actionResult, LogMode mode)
 {
 }
示例#12
0
 public BreakpointInfo_t()
 {
     this.hit_config    = 0;
     this.action_result = EActionResult.EAR_all;
 }