From 94d38ca7a0f3b606f80457d065316f3f0b892960 Mon Sep 17 00:00:00 2001 From: jonygli Date: Thu, 3 Aug 2017 15:54:06 +0800 Subject: [PATCH] 3.6.36 --- CMakeLists.txt | 2 +- history.txt | 3 + inc/behaviac/agent/agent.h | 9 +- inc/behaviac/behaviortree/behaviortree_task.h | 2 +- inc/behaviac/common/_config.h | 2 +- .../demo_running/behaviac/Agent/Agent.cs | 18 ++- .../demo_running/behaviac/Base/LogManager.cs | 2 +- .../BehaviorTree/Attachments/Event.cs | 4 +- .../BehaviorTree/BehaviorTree_task.cs | 4 +- integration/demo_running/behaviac/version.txt | 2 +- .../BehaviorNodeTest/DecorationNodeTest.cs | 2 +- .../Scripts/behaviac/runtime/Agent/Agent.cs | 18 ++- .../behaviac/runtime/Base/LogManager.cs | 2 +- .../runtime/BehaviorTree/Attachments/Event.cs | 4 +- .../runtime/BehaviorTree/BehaviorTree_task.cs | 4 +- .../Scripts/behaviac/runtime/version.txt | 2 +- projects/gmake/Makefile | 148 ------------------ src/agent/agent.cpp | 14 +- src/behaviortree/behaviortree_task.cpp | 5 +- .../Properties/AssemblyInfo.cs | 4 +- .../behaviac/runtime/Agent/Agent.cs | 18 ++- .../behaviac/runtime/Base/LogManager.cs | 2 +- .../runtime/BehaviorTree/Attachments/Event.cs | 4 +- .../runtime/BehaviorTree/BehaviorTree_task.cs | 4 +- .../CsTutorials/behaviac/runtime/version.txt | 2 +- .../Scripts/behaviac/runtime/Agent/Agent.cs | 18 ++- .../behaviac/runtime/Base/LogManager.cs | 2 +- .../runtime/BehaviorTree/Attachments/Event.cs | 4 +- .../runtime/BehaviorTree/BehaviorTree_task.cs | 4 +- .../Scripts/behaviac/runtime/version.txt | 2 +- version.txt | 2 +- 31 files changed, 99 insertions(+), 214 deletions(-) delete mode 100644 projects/gmake/Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt index f00a8ca7..f1ee8400 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ cmake_minimum_required (VERSION 2.8) # set(CMAKE_CONFIGURATION_TYPES "Debug;Release;Profile" CACHE STRING "" FORCE) set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) -set (BEHAVIAC_PACKAGE_VERSION 3.6.35) +set (BEHAVIAC_PACKAGE_VERSION 3.6.36) #option( BUILD_SHARED_LIBS "set to OFF to build static libraries" ON ) SET(BUILD_SHARED_LIBS ON CACHE BOOL "set to OFF to build static libraries") diff --git a/history.txt b/history.txt index 77c16191..fa58b330 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,6 @@ +2017-08-03 3.6.36 + fix a bug of accessing task params when calling a sub tree + 2017-7-11 3.6.35 Improve the C++ types generation. Fix a bug of time edition of the Wait node. diff --git a/inc/behaviac/agent/agent.h b/inc/behaviac/agent/agent.h index e24ccb08..a320762b 100644 --- a/inc/behaviac/agent/agent.h +++ b/inc/behaviac/agent/agent.h @@ -442,10 +442,6 @@ namespace behaviac { static bool VectorContains(IList& vector, const System::Object& element); static void VectorClear(IList& vector); - void CurrentBT(BehaviorTreeTask* value) { - m_currentBT = value; - m_excutingTreeTask = m_currentBT; - } protected: Agent(); @@ -484,6 +480,11 @@ namespace behaviac { void _btsetcurrent(const char* relativePath, TriggerMode triggerMode = TM_Transfer, bool bByEvent = false); + void _setCurrentTreeTask(BehaviorTreeTask* value) { + m_currentBT = value; + //m_excutingTreeTask = m_currentBT; + } + void btunload_pars(const BehaviorTree* bt); void LoadFromXML(const behaviac::XmlConstNodeRef& xmlNode); diff --git a/inc/behaviac/behaviortree/behaviortree_task.h b/inc/behaviac/behaviortree/behaviortree_task.h index 86e83ad5..42f15bc0 100644 --- a/inc/behaviac/behaviortree/behaviortree_task.h +++ b/inc/behaviac/behaviortree/behaviortree_task.h @@ -397,7 +397,7 @@ namespace behaviac { private: bool load(const char* file); - + BehaviorTreeTask* m_lastTreeTask; }; } // namespace behaviac diff --git a/inc/behaviac/common/_config.h b/inc/behaviac/common/_config.h index 981ded4b..e2b0c90a 100644 --- a/inc/behaviac/common/_config.h +++ b/inc/behaviac/common/_config.h @@ -11,5 +11,5 @@ #define BEHAVIAC_RELEASE 0 #endif -#define BEHAVIAC_VERSION_STRING "3.6.35" +#define BEHAVIAC_VERSION_STRING "3.6.36" diff --git a/integration/demo_running/behaviac/Agent/Agent.cs b/integration/demo_running/behaviac/Agent/Agent.cs index 8e21c5c0..e42e4642 100644 --- a/integration/demo_running/behaviac/Agent/Agent.cs +++ b/integration/demo_running/behaviac/Agent/Agent.cs @@ -243,7 +243,7 @@ private List BTStack } private BehaviorTreeTask m_currentBT; - public BehaviorTreeTask CurrentBT + public BehaviorTreeTask CurrentTreeTask { get { @@ -253,7 +253,7 @@ public BehaviorTreeTask CurrentBT private set { m_currentBT = value; - m_excutingTreeTask = m_currentBT; + //m_excutingTreeTask = m_currentBT; } } @@ -1544,7 +1544,7 @@ private void _btsetcurrent(string relativePath, TriggerMode triggerMode, bool bB this.BehaviorTreeTasks.Add(pTask); } - this.CurrentBT = pTask; + this.CurrentTreeTask = pTask; //string pThisTree = this.m_currentBT.GetName(); //this.LogJumpTree(pThisTree); @@ -1569,7 +1569,7 @@ private EBTStatus btexec_() //get the last one BehaviorTreeStackItem_t lastOne = this.BTStack[this.BTStack.Count - 1]; - this.CurrentBT = lastOne.bt; + this.CurrentTreeTask = lastOne.bt; this.BTStack.RemoveAt(this.BTStack.Count - 1); bool bExecCurrent = false; @@ -1613,6 +1613,10 @@ private EBTStatus btexec_() } } + if (s != EBTStatus.BT_RUNNING) { + this.ExcutingTreeTask = null; + } + return s; } else @@ -1711,7 +1715,7 @@ public void btunload(string relativePath) BehaviorTree bt = btNode as BehaviorTree; this.btunload_pars(bt); - this.CurrentBT = null; + this.CurrentTreeTask = null; } //remove it from stack @@ -1798,7 +1802,7 @@ public void btunloadall() this.BehaviorTreeTasks.Clear(); //just clear the name vector, don't unload it from cache - this.CurrentBT = null; + this.CurrentTreeTask = null; this.BTStack.Clear(); this.Variables.Unload(); @@ -1806,7 +1810,7 @@ public void btunloadall() public void btreloadall() { - this.CurrentBT = null; + this.CurrentTreeTask = null; this.BTStack.Clear(); if (this.m_behaviorTreeTasks != null) diff --git a/integration/demo_running/behaviac/Base/LogManager.cs b/integration/demo_running/behaviac/Base/LogManager.cs index 9d794989..2927f381 100644 --- a/integration/demo_running/behaviac/Base/LogManager.cs +++ b/integration/demo_running/behaviac/Base/LogManager.cs @@ -298,7 +298,7 @@ public void Log(Agent pAgent, string btMsg, long time) //string agentClassName = pAgent.GetObjectTypeName(); //string agentInstanceName = pAgent.GetName(); - BehaviorTreeTask bt = !System.Object.ReferenceEquals(pAgent, null) ? pAgent.CurrentBT : null; + BehaviorTreeTask bt = !System.Object.ReferenceEquals(pAgent, null) ? pAgent.CurrentTreeTask : null; string btName; diff --git a/integration/demo_running/behaviac/BehaviorTree/Attachments/Event.cs b/integration/demo_running/behaviac/BehaviorTree/Attachments/Event.cs index 64308989..7304dfb2 100644 --- a/integration/demo_running/behaviac/BehaviorTree/Attachments/Event.cs +++ b/integration/demo_running/behaviac/BehaviorTree/Attachments/Event.cs @@ -93,8 +93,8 @@ public void switchTo(Agent pAgent, Dictionary event pAgent.bteventtree(pAgent, this.m_referencedBehaviorPath, tm); - Debug.Check(pAgent.CurrentBT != null); - pAgent.CurrentBT.AddVariables(eventParams); + Debug.Check(pAgent.CurrentTreeTask != null); + pAgent.CurrentTreeTask.AddVariables(eventParams); pAgent.btexec(); } diff --git a/integration/demo_running/behaviac/BehaviorTree/BehaviorTree_task.cs b/integration/demo_running/behaviac/BehaviorTree/BehaviorTree_task.cs index b86ee798..a4135910 100644 --- a/integration/demo_running/behaviac/BehaviorTree/BehaviorTree_task.cs +++ b/integration/demo_running/behaviac/BehaviorTree/BehaviorTree_task.cs @@ -1340,6 +1340,7 @@ called when the child's tick returns success or failure. public class BehaviorTreeTask : SingeChildTask { private Dictionary m_localVars = new Dictionary(); + private BehaviorTreeTask m_excutingTreeTask = null; public Dictionary LocalVars { get @@ -1462,7 +1463,7 @@ protected override bool onenter(Agent pAgent) protected override void onexit(Agent pAgent, EBTStatus s) { - pAgent.ExcutingTreeTask = null; + pAgent.ExcutingTreeTask = this.m_excutingTreeTask; pAgent.LogReturnTree(this.GetName()); base.onexit(pAgent, s); @@ -1495,6 +1496,7 @@ protected override EBTStatus update_current(Agent pAgent, EBTStatus childStatus) Debug.Check(this.m_node != null); Debug.Check(this.m_node is BehaviorTree); + this.m_excutingTreeTask = pAgent.ExcutingTreeTask; pAgent.ExcutingTreeTask = this; BehaviorTree tree = (BehaviorTree)this.m_node; diff --git a/integration/demo_running/behaviac/version.txt b/integration/demo_running/behaviac/version.txt index 1d9b07aa..6aff5cd2 100644 --- a/integration/demo_running/behaviac/version.txt +++ b/integration/demo_running/behaviac/version.txt @@ -1 +1 @@ -3.6.35 +3.6.36 diff --git a/integration/unity/Assets/Scripts/behaviac/BehaviacUnitTest/Editor/BehaviorNodeTest/DecorationNodeTest.cs b/integration/unity/Assets/Scripts/behaviac/BehaviacUnitTest/Editor/BehaviorNodeTest/DecorationNodeTest.cs index f8571898..f8281ebe 100644 --- a/integration/unity/Assets/Scripts/behaviac/BehaviacUnitTest/Editor/BehaviorNodeTest/DecorationNodeTest.cs +++ b/integration/unity/Assets/Scripts/behaviac/BehaviacUnitTest/Editor/BehaviorNodeTest/DecorationNodeTest.cs @@ -75,7 +75,7 @@ public void test_decoration_loop_0() Assert.AreEqual(behaviac.EBTStatus.BT_RUNNING, status); Assert.AreEqual(0, testAgent.testVar_0); - behaviac.BehaviorTreeTask btTask = testAgent.CurrentBT; + behaviac.BehaviorTreeTask btTask = testAgent.CurrentTreeTask; Assert.AreNotEqual(null, btTask); List nodes = btTask.GetRunningNodes(false); diff --git a/integration/unity/Assets/Scripts/behaviac/runtime/Agent/Agent.cs b/integration/unity/Assets/Scripts/behaviac/runtime/Agent/Agent.cs index 8e21c5c0..e42e4642 100644 --- a/integration/unity/Assets/Scripts/behaviac/runtime/Agent/Agent.cs +++ b/integration/unity/Assets/Scripts/behaviac/runtime/Agent/Agent.cs @@ -243,7 +243,7 @@ private List BTStack } private BehaviorTreeTask m_currentBT; - public BehaviorTreeTask CurrentBT + public BehaviorTreeTask CurrentTreeTask { get { @@ -253,7 +253,7 @@ public BehaviorTreeTask CurrentBT private set { m_currentBT = value; - m_excutingTreeTask = m_currentBT; + //m_excutingTreeTask = m_currentBT; } } @@ -1544,7 +1544,7 @@ private void _btsetcurrent(string relativePath, TriggerMode triggerMode, bool bB this.BehaviorTreeTasks.Add(pTask); } - this.CurrentBT = pTask; + this.CurrentTreeTask = pTask; //string pThisTree = this.m_currentBT.GetName(); //this.LogJumpTree(pThisTree); @@ -1569,7 +1569,7 @@ private EBTStatus btexec_() //get the last one BehaviorTreeStackItem_t lastOne = this.BTStack[this.BTStack.Count - 1]; - this.CurrentBT = lastOne.bt; + this.CurrentTreeTask = lastOne.bt; this.BTStack.RemoveAt(this.BTStack.Count - 1); bool bExecCurrent = false; @@ -1613,6 +1613,10 @@ private EBTStatus btexec_() } } + if (s != EBTStatus.BT_RUNNING) { + this.ExcutingTreeTask = null; + } + return s; } else @@ -1711,7 +1715,7 @@ public void btunload(string relativePath) BehaviorTree bt = btNode as BehaviorTree; this.btunload_pars(bt); - this.CurrentBT = null; + this.CurrentTreeTask = null; } //remove it from stack @@ -1798,7 +1802,7 @@ public void btunloadall() this.BehaviorTreeTasks.Clear(); //just clear the name vector, don't unload it from cache - this.CurrentBT = null; + this.CurrentTreeTask = null; this.BTStack.Clear(); this.Variables.Unload(); @@ -1806,7 +1810,7 @@ public void btunloadall() public void btreloadall() { - this.CurrentBT = null; + this.CurrentTreeTask = null; this.BTStack.Clear(); if (this.m_behaviorTreeTasks != null) diff --git a/integration/unity/Assets/Scripts/behaviac/runtime/Base/LogManager.cs b/integration/unity/Assets/Scripts/behaviac/runtime/Base/LogManager.cs index 9d794989..2927f381 100644 --- a/integration/unity/Assets/Scripts/behaviac/runtime/Base/LogManager.cs +++ b/integration/unity/Assets/Scripts/behaviac/runtime/Base/LogManager.cs @@ -298,7 +298,7 @@ public void Log(Agent pAgent, string btMsg, long time) //string agentClassName = pAgent.GetObjectTypeName(); //string agentInstanceName = pAgent.GetName(); - BehaviorTreeTask bt = !System.Object.ReferenceEquals(pAgent, null) ? pAgent.CurrentBT : null; + BehaviorTreeTask bt = !System.Object.ReferenceEquals(pAgent, null) ? pAgent.CurrentTreeTask : null; string btName; diff --git a/integration/unity/Assets/Scripts/behaviac/runtime/BehaviorTree/Attachments/Event.cs b/integration/unity/Assets/Scripts/behaviac/runtime/BehaviorTree/Attachments/Event.cs index 64308989..7304dfb2 100644 --- a/integration/unity/Assets/Scripts/behaviac/runtime/BehaviorTree/Attachments/Event.cs +++ b/integration/unity/Assets/Scripts/behaviac/runtime/BehaviorTree/Attachments/Event.cs @@ -93,8 +93,8 @@ public void switchTo(Agent pAgent, Dictionary event pAgent.bteventtree(pAgent, this.m_referencedBehaviorPath, tm); - Debug.Check(pAgent.CurrentBT != null); - pAgent.CurrentBT.AddVariables(eventParams); + Debug.Check(pAgent.CurrentTreeTask != null); + pAgent.CurrentTreeTask.AddVariables(eventParams); pAgent.btexec(); } diff --git a/integration/unity/Assets/Scripts/behaviac/runtime/BehaviorTree/BehaviorTree_task.cs b/integration/unity/Assets/Scripts/behaviac/runtime/BehaviorTree/BehaviorTree_task.cs index b86ee798..a4135910 100644 --- a/integration/unity/Assets/Scripts/behaviac/runtime/BehaviorTree/BehaviorTree_task.cs +++ b/integration/unity/Assets/Scripts/behaviac/runtime/BehaviorTree/BehaviorTree_task.cs @@ -1340,6 +1340,7 @@ called when the child's tick returns success or failure. public class BehaviorTreeTask : SingeChildTask { private Dictionary m_localVars = new Dictionary(); + private BehaviorTreeTask m_excutingTreeTask = null; public Dictionary LocalVars { get @@ -1462,7 +1463,7 @@ protected override bool onenter(Agent pAgent) protected override void onexit(Agent pAgent, EBTStatus s) { - pAgent.ExcutingTreeTask = null; + pAgent.ExcutingTreeTask = this.m_excutingTreeTask; pAgent.LogReturnTree(this.GetName()); base.onexit(pAgent, s); @@ -1495,6 +1496,7 @@ protected override EBTStatus update_current(Agent pAgent, EBTStatus childStatus) Debug.Check(this.m_node != null); Debug.Check(this.m_node is BehaviorTree); + this.m_excutingTreeTask = pAgent.ExcutingTreeTask; pAgent.ExcutingTreeTask = this; BehaviorTree tree = (BehaviorTree)this.m_node; diff --git a/integration/unity/Assets/Scripts/behaviac/runtime/version.txt b/integration/unity/Assets/Scripts/behaviac/runtime/version.txt index 1d9b07aa..6aff5cd2 100644 --- a/integration/unity/Assets/Scripts/behaviac/runtime/version.txt +++ b/integration/unity/Assets/Scripts/behaviac/runtime/version.txt @@ -1 +1 @@ -3.6.35 +3.6.36 diff --git a/projects/gmake/Makefile b/projects/gmake/Makefile deleted file mode 100644 index fb418819..00000000 --- a/projects/gmake/Makefile +++ /dev/null @@ -1,148 +0,0 @@ -# GNU Make solution makefile autogenerated by Premake -# Type "make help" for usage help - -ifndef config - config=debugstatic32 -endif -export config - -PROJECTS := behaviac btunittest btremotetest demo_running usertest tutorial_1 tutorial_1_1 tutorial_1_2 tutorial_2 tutorial_3 tutorial_4 tutorial_5 tutorial_6 tutorial_7 tutorial_8 tutorial_9 tutorial_10 tutorial_11 tutorial_12 tutorial_13 - -.PHONY: all clean help $(PROJECTS) - -all: $(PROJECTS) - -behaviac: - @echo "==== Building behaviac ($(config)) ====" - @${MAKE} --no-print-directory -C . -f behaviac.make - -btunittest: behaviac - @echo "==== Building btunittest ($(config)) ====" - @${MAKE} --no-print-directory -C . -f btunittest.make - -btremotetest: behaviac - @echo "==== Building btremotetest ($(config)) ====" - @${MAKE} --no-print-directory -C . -f btremotetest.make - -demo_running: behaviac - @echo "==== Building demo_running ($(config)) ====" - @${MAKE} --no-print-directory -C . -f demo_running.make - -usertest: behaviac - @echo "==== Building usertest ($(config)) ====" - @${MAKE} --no-print-directory -C . -f usertest.make - -tutorial_1: behaviac - @echo "==== Building tutorial_1 ($(config)) ====" - @${MAKE} --no-print-directory -C . -f tutorial_1.make - -tutorial_1_1: behaviac - @echo "==== Building tutorial_1_1 ($(config)) ====" - @${MAKE} --no-print-directory -C . -f tutorial_1_1.make - -tutorial_1_2: behaviac - @echo "==== Building tutorial_1_2 ($(config)) ====" - @${MAKE} --no-print-directory -C . -f tutorial_1_2.make - -tutorial_2: behaviac - @echo "==== Building tutorial_2 ($(config)) ====" - @${MAKE} --no-print-directory -C . -f tutorial_2.make - -tutorial_3: behaviac - @echo "==== Building tutorial_3 ($(config)) ====" - @${MAKE} --no-print-directory -C . -f tutorial_3.make - -tutorial_4: behaviac - @echo "==== Building tutorial_4 ($(config)) ====" - @${MAKE} --no-print-directory -C . -f tutorial_4.make - -tutorial_5: behaviac - @echo "==== Building tutorial_5 ($(config)) ====" - @${MAKE} --no-print-directory -C . -f tutorial_5.make - -tutorial_6: behaviac - @echo "==== Building tutorial_6 ($(config)) ====" - @${MAKE} --no-print-directory -C . -f tutorial_6.make - -tutorial_7: behaviac - @echo "==== Building tutorial_7 ($(config)) ====" - @${MAKE} --no-print-directory -C . -f tutorial_7.make - -tutorial_8: behaviac - @echo "==== Building tutorial_8 ($(config)) ====" - @${MAKE} --no-print-directory -C . -f tutorial_8.make - -tutorial_9: behaviac - @echo "==== Building tutorial_9 ($(config)) ====" - @${MAKE} --no-print-directory -C . -f tutorial_9.make - -tutorial_10: behaviac - @echo "==== Building tutorial_10 ($(config)) ====" - @${MAKE} --no-print-directory -C . -f tutorial_10.make - -tutorial_11: behaviac - @echo "==== Building tutorial_11 ($(config)) ====" - @${MAKE} --no-print-directory -C . -f tutorial_11.make - -tutorial_12: behaviac - @echo "==== Building tutorial_12 ($(config)) ====" - @${MAKE} --no-print-directory -C . -f tutorial_12.make - -tutorial_13: behaviac - @echo "==== Building tutorial_13 ($(config)) ====" - @${MAKE} --no-print-directory -C . -f tutorial_13.make - -clean: - @${MAKE} --no-print-directory -C . -f behaviac.make clean - @${MAKE} --no-print-directory -C . -f btunittest.make clean - @${MAKE} --no-print-directory -C . -f btremotetest.make clean - @${MAKE} --no-print-directory -C . -f demo_running.make clean - @${MAKE} --no-print-directory -C . -f usertest.make clean - @${MAKE} --no-print-directory -C . -f tutorial_1.make clean - @${MAKE} --no-print-directory -C . -f tutorial_1_1.make clean - @${MAKE} --no-print-directory -C . -f tutorial_1_2.make clean - @${MAKE} --no-print-directory -C . -f tutorial_2.make clean - @${MAKE} --no-print-directory -C . -f tutorial_3.make clean - @${MAKE} --no-print-directory -C . -f tutorial_4.make clean - @${MAKE} --no-print-directory -C . -f tutorial_5.make clean - @${MAKE} --no-print-directory -C . -f tutorial_6.make clean - @${MAKE} --no-print-directory -C . -f tutorial_7.make clean - @${MAKE} --no-print-directory -C . -f tutorial_8.make clean - @${MAKE} --no-print-directory -C . -f tutorial_9.make clean - @${MAKE} --no-print-directory -C . -f tutorial_10.make clean - @${MAKE} --no-print-directory -C . -f tutorial_11.make clean - @${MAKE} --no-print-directory -C . -f tutorial_12.make clean - @${MAKE} --no-print-directory -C . -f tutorial_13.make clean - -help: - @echo "Usage: make [config=name] [target]" - @echo "" - @echo "CONFIGURATIONS:" - @echo " debugstatic32" - @echo " releasestatic32" - @echo "" - @echo "TARGETS:" - @echo " all (default)" - @echo " clean" - @echo " behaviac" - @echo " btunittest" - @echo " btremotetest" - @echo " demo_running" - @echo " usertest" - @echo " tutorial_1" - @echo " tutorial_1_1" - @echo " tutorial_1_2" - @echo " tutorial_2" - @echo " tutorial_3" - @echo " tutorial_4" - @echo " tutorial_5" - @echo " tutorial_6" - @echo " tutorial_7" - @echo " tutorial_8" - @echo " tutorial_9" - @echo " tutorial_10" - @echo " tutorial_11" - @echo " tutorial_12" - @echo " tutorial_13" - @echo "" - @echo "For more information, see http://industriousone.com/premake/quick-start" diff --git a/src/agent/agent.cpp b/src/agent/agent.cpp index e3005109..922aa6c1 100644 --- a/src/agent/agent.cpp +++ b/src/agent/agent.cpp @@ -614,7 +614,7 @@ namespace behaviac { this->m_behaviorTreeTasks.push_back(pTask); } - this->CurrentBT(pTask); + this->_setCurrentTreeTask(pTask); //this->_balckboard_bound = false; //this->GetVariables()->Clear(false); @@ -654,7 +654,7 @@ namespace behaviac { //get the last one BehaviorTreeStackItem_t& lastOne = this->m_btStack.back(); this->m_btStack.pop_back(); - this->CurrentBT(lastOne.bt); + this->_setCurrentTreeTask(lastOne.bt); bool bExecCurrent = false; @@ -684,6 +684,10 @@ namespace behaviac { } } + if (s != BT_RUNNING) { + this->m_excutingTreeTask = 0; + } + return s; } else { //BEHAVIAC_LOGWARNING("NO ACTIVE BT!\n"); @@ -779,7 +783,7 @@ namespace behaviac { const BehaviorTree* bt = (const BehaviorTree*)btNode; this->btunload_pars(bt); - this->CurrentBT(0); + this->_setCurrentTreeTask(0); } //remove it from stack @@ -862,7 +866,7 @@ namespace behaviac { this->m_behaviorTreeTasks.clear(); - this->CurrentBT(0); + this->_setCurrentTreeTask(0); this->m_btStack.clear(); this->GetVariables()->Unload(); @@ -870,7 +874,7 @@ namespace behaviac { } void Agent::btreloadall() { - this->CurrentBT(0); + this->_setCurrentTreeTask(0); this->m_btStack.clear(); behaviac::vector bts; diff --git a/src/behaviortree/behaviortree_task.cpp b/src/behaviortree/behaviortree_task.cpp index db3d5bc9..9ff57294 100644 --- a/src/behaviortree/behaviortree_task.cpp +++ b/src/behaviortree/behaviortree_task.cpp @@ -1342,7 +1342,7 @@ namespace behaviac { handler(this, pAgent, user_data); } - BehaviorTreeTask::BehaviorTreeTask() : SingeChildTask() + BehaviorTreeTask::BehaviorTreeTask() : SingeChildTask(), m_lastTreeTask(0) { } @@ -1429,7 +1429,7 @@ namespace behaviac { } void BehaviorTreeTask::onexit(Agent* pAgent, EBTStatus status) { - pAgent->m_excutingTreeTask = NULL; + pAgent->m_excutingTreeTask = this->m_lastTreeTask; pAgent->LogReturnTree(this->GetName()); super::onexit(pAgent, status); } @@ -1438,6 +1438,7 @@ namespace behaviac { BEHAVIAC_ASSERT(this->m_node != 0); BEHAVIAC_ASSERT(BehaviorTree::DynamicCast(this->m_node) != 0); + this->m_lastTreeTask = pAgent->m_excutingTreeTask; pAgent->m_excutingTreeTask = this; BehaviorTree* tree = (BehaviorTree*)this->m_node; diff --git a/tools/designer/BehaviacDesigner/Properties/AssemblyInfo.cs b/tools/designer/BehaviacDesigner/Properties/AssemblyInfo.cs index cd5286a6..3aaad315 100644 --- a/tools/designer/BehaviacDesigner/Properties/AssemblyInfo.cs +++ b/tools/designer/BehaviacDesigner/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("3.6.35")] -[assembly: AssemblyFileVersion("3.6.35")] +[assembly: AssemblyVersion("3.6.36")] +[assembly: AssemblyFileVersion("3.6.36")] diff --git a/tutorials/CsTutorials/behaviac/runtime/Agent/Agent.cs b/tutorials/CsTutorials/behaviac/runtime/Agent/Agent.cs index 8e21c5c0..e42e4642 100644 --- a/tutorials/CsTutorials/behaviac/runtime/Agent/Agent.cs +++ b/tutorials/CsTutorials/behaviac/runtime/Agent/Agent.cs @@ -243,7 +243,7 @@ private List BTStack } private BehaviorTreeTask m_currentBT; - public BehaviorTreeTask CurrentBT + public BehaviorTreeTask CurrentTreeTask { get { @@ -253,7 +253,7 @@ public BehaviorTreeTask CurrentBT private set { m_currentBT = value; - m_excutingTreeTask = m_currentBT; + //m_excutingTreeTask = m_currentBT; } } @@ -1544,7 +1544,7 @@ private void _btsetcurrent(string relativePath, TriggerMode triggerMode, bool bB this.BehaviorTreeTasks.Add(pTask); } - this.CurrentBT = pTask; + this.CurrentTreeTask = pTask; //string pThisTree = this.m_currentBT.GetName(); //this.LogJumpTree(pThisTree); @@ -1569,7 +1569,7 @@ private EBTStatus btexec_() //get the last one BehaviorTreeStackItem_t lastOne = this.BTStack[this.BTStack.Count - 1]; - this.CurrentBT = lastOne.bt; + this.CurrentTreeTask = lastOne.bt; this.BTStack.RemoveAt(this.BTStack.Count - 1); bool bExecCurrent = false; @@ -1613,6 +1613,10 @@ private EBTStatus btexec_() } } + if (s != EBTStatus.BT_RUNNING) { + this.ExcutingTreeTask = null; + } + return s; } else @@ -1711,7 +1715,7 @@ public void btunload(string relativePath) BehaviorTree bt = btNode as BehaviorTree; this.btunload_pars(bt); - this.CurrentBT = null; + this.CurrentTreeTask = null; } //remove it from stack @@ -1798,7 +1802,7 @@ public void btunloadall() this.BehaviorTreeTasks.Clear(); //just clear the name vector, don't unload it from cache - this.CurrentBT = null; + this.CurrentTreeTask = null; this.BTStack.Clear(); this.Variables.Unload(); @@ -1806,7 +1810,7 @@ public void btunloadall() public void btreloadall() { - this.CurrentBT = null; + this.CurrentTreeTask = null; this.BTStack.Clear(); if (this.m_behaviorTreeTasks != null) diff --git a/tutorials/CsTutorials/behaviac/runtime/Base/LogManager.cs b/tutorials/CsTutorials/behaviac/runtime/Base/LogManager.cs index 9d794989..2927f381 100644 --- a/tutorials/CsTutorials/behaviac/runtime/Base/LogManager.cs +++ b/tutorials/CsTutorials/behaviac/runtime/Base/LogManager.cs @@ -298,7 +298,7 @@ public void Log(Agent pAgent, string btMsg, long time) //string agentClassName = pAgent.GetObjectTypeName(); //string agentInstanceName = pAgent.GetName(); - BehaviorTreeTask bt = !System.Object.ReferenceEquals(pAgent, null) ? pAgent.CurrentBT : null; + BehaviorTreeTask bt = !System.Object.ReferenceEquals(pAgent, null) ? pAgent.CurrentTreeTask : null; string btName; diff --git a/tutorials/CsTutorials/behaviac/runtime/BehaviorTree/Attachments/Event.cs b/tutorials/CsTutorials/behaviac/runtime/BehaviorTree/Attachments/Event.cs index 64308989..7304dfb2 100644 --- a/tutorials/CsTutorials/behaviac/runtime/BehaviorTree/Attachments/Event.cs +++ b/tutorials/CsTutorials/behaviac/runtime/BehaviorTree/Attachments/Event.cs @@ -93,8 +93,8 @@ public void switchTo(Agent pAgent, Dictionary event pAgent.bteventtree(pAgent, this.m_referencedBehaviorPath, tm); - Debug.Check(pAgent.CurrentBT != null); - pAgent.CurrentBT.AddVariables(eventParams); + Debug.Check(pAgent.CurrentTreeTask != null); + pAgent.CurrentTreeTask.AddVariables(eventParams); pAgent.btexec(); } diff --git a/tutorials/CsTutorials/behaviac/runtime/BehaviorTree/BehaviorTree_task.cs b/tutorials/CsTutorials/behaviac/runtime/BehaviorTree/BehaviorTree_task.cs index b86ee798..a4135910 100644 --- a/tutorials/CsTutorials/behaviac/runtime/BehaviorTree/BehaviorTree_task.cs +++ b/tutorials/CsTutorials/behaviac/runtime/BehaviorTree/BehaviorTree_task.cs @@ -1340,6 +1340,7 @@ called when the child's tick returns success or failure. public class BehaviorTreeTask : SingeChildTask { private Dictionary m_localVars = new Dictionary(); + private BehaviorTreeTask m_excutingTreeTask = null; public Dictionary LocalVars { get @@ -1462,7 +1463,7 @@ protected override bool onenter(Agent pAgent) protected override void onexit(Agent pAgent, EBTStatus s) { - pAgent.ExcutingTreeTask = null; + pAgent.ExcutingTreeTask = this.m_excutingTreeTask; pAgent.LogReturnTree(this.GetName()); base.onexit(pAgent, s); @@ -1495,6 +1496,7 @@ protected override EBTStatus update_current(Agent pAgent, EBTStatus childStatus) Debug.Check(this.m_node != null); Debug.Check(this.m_node is BehaviorTree); + this.m_excutingTreeTask = pAgent.ExcutingTreeTask; pAgent.ExcutingTreeTask = this; BehaviorTree tree = (BehaviorTree)this.m_node; diff --git a/tutorials/CsTutorials/behaviac/runtime/version.txt b/tutorials/CsTutorials/behaviac/runtime/version.txt index 1d9b07aa..6aff5cd2 100644 --- a/tutorials/CsTutorials/behaviac/runtime/version.txt +++ b/tutorials/CsTutorials/behaviac/runtime/version.txt @@ -1 +1 @@ -3.6.35 +3.6.36 diff --git a/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/Agent/Agent.cs b/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/Agent/Agent.cs index 8e21c5c0..e42e4642 100644 --- a/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/Agent/Agent.cs +++ b/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/Agent/Agent.cs @@ -243,7 +243,7 @@ private List BTStack } private BehaviorTreeTask m_currentBT; - public BehaviorTreeTask CurrentBT + public BehaviorTreeTask CurrentTreeTask { get { @@ -253,7 +253,7 @@ public BehaviorTreeTask CurrentBT private set { m_currentBT = value; - m_excutingTreeTask = m_currentBT; + //m_excutingTreeTask = m_currentBT; } } @@ -1544,7 +1544,7 @@ private void _btsetcurrent(string relativePath, TriggerMode triggerMode, bool bB this.BehaviorTreeTasks.Add(pTask); } - this.CurrentBT = pTask; + this.CurrentTreeTask = pTask; //string pThisTree = this.m_currentBT.GetName(); //this.LogJumpTree(pThisTree); @@ -1569,7 +1569,7 @@ private EBTStatus btexec_() //get the last one BehaviorTreeStackItem_t lastOne = this.BTStack[this.BTStack.Count - 1]; - this.CurrentBT = lastOne.bt; + this.CurrentTreeTask = lastOne.bt; this.BTStack.RemoveAt(this.BTStack.Count - 1); bool bExecCurrent = false; @@ -1613,6 +1613,10 @@ private EBTStatus btexec_() } } + if (s != EBTStatus.BT_RUNNING) { + this.ExcutingTreeTask = null; + } + return s; } else @@ -1711,7 +1715,7 @@ public void btunload(string relativePath) BehaviorTree bt = btNode as BehaviorTree; this.btunload_pars(bt); - this.CurrentBT = null; + this.CurrentTreeTask = null; } //remove it from stack @@ -1798,7 +1802,7 @@ public void btunloadall() this.BehaviorTreeTasks.Clear(); //just clear the name vector, don't unload it from cache - this.CurrentBT = null; + this.CurrentTreeTask = null; this.BTStack.Clear(); this.Variables.Unload(); @@ -1806,7 +1810,7 @@ public void btunloadall() public void btreloadall() { - this.CurrentBT = null; + this.CurrentTreeTask = null; this.BTStack.Clear(); if (this.m_behaviorTreeTasks != null) diff --git a/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/Base/LogManager.cs b/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/Base/LogManager.cs index 9d794989..2927f381 100644 --- a/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/Base/LogManager.cs +++ b/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/Base/LogManager.cs @@ -298,7 +298,7 @@ public void Log(Agent pAgent, string btMsg, long time) //string agentClassName = pAgent.GetObjectTypeName(); //string agentInstanceName = pAgent.GetName(); - BehaviorTreeTask bt = !System.Object.ReferenceEquals(pAgent, null) ? pAgent.CurrentBT : null; + BehaviorTreeTask bt = !System.Object.ReferenceEquals(pAgent, null) ? pAgent.CurrentTreeTask : null; string btName; diff --git a/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/BehaviorTree/Attachments/Event.cs b/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/BehaviorTree/Attachments/Event.cs index 64308989..7304dfb2 100644 --- a/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/BehaviorTree/Attachments/Event.cs +++ b/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/BehaviorTree/Attachments/Event.cs @@ -93,8 +93,8 @@ public void switchTo(Agent pAgent, Dictionary event pAgent.bteventtree(pAgent, this.m_referencedBehaviorPath, tm); - Debug.Check(pAgent.CurrentBT != null); - pAgent.CurrentBT.AddVariables(eventParams); + Debug.Check(pAgent.CurrentTreeTask != null); + pAgent.CurrentTreeTask.AddVariables(eventParams); pAgent.btexec(); } diff --git a/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/BehaviorTree/BehaviorTree_task.cs b/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/BehaviorTree/BehaviorTree_task.cs index b86ee798..a4135910 100644 --- a/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/BehaviorTree/BehaviorTree_task.cs +++ b/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/BehaviorTree/BehaviorTree_task.cs @@ -1340,6 +1340,7 @@ called when the child's tick returns success or failure. public class BehaviorTreeTask : SingeChildTask { private Dictionary m_localVars = new Dictionary(); + private BehaviorTreeTask m_excutingTreeTask = null; public Dictionary LocalVars { get @@ -1462,7 +1463,7 @@ protected override bool onenter(Agent pAgent) protected override void onexit(Agent pAgent, EBTStatus s) { - pAgent.ExcutingTreeTask = null; + pAgent.ExcutingTreeTask = this.m_excutingTreeTask; pAgent.LogReturnTree(this.GetName()); base.onexit(pAgent, s); @@ -1495,6 +1496,7 @@ protected override EBTStatus update_current(Agent pAgent, EBTStatus childStatus) Debug.Check(this.m_node != null); Debug.Check(this.m_node is BehaviorTree); + this.m_excutingTreeTask = pAgent.ExcutingTreeTask; pAgent.ExcutingTreeTask = this; BehaviorTree tree = (BehaviorTree)this.m_node; diff --git a/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/version.txt b/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/version.txt index 1d9b07aa..6aff5cd2 100644 --- a/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/version.txt +++ b/tutorials/tutorial_1/unity/Assets/Scripts/behaviac/runtime/version.txt @@ -1 +1 @@ -3.6.35 +3.6.36 diff --git a/version.txt b/version.txt index 1d9b07aa..6aff5cd2 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -3.6.35 +3.6.36