From 792531c3f34f2204013f044014571f3f73d61321 Mon Sep 17 00:00:00 2001 From: berniebwang Date: Fri, 3 Dec 2021 20:49:24 +0800 Subject: [PATCH 1/6] add .gitignore --- .gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..3dd19397 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +# Generated files +build/cmake_binary/** +lib/** +**/bin/ +**/obj/ +**/out/** +!**/out/config.xml +*.suo \ No newline at end of file From a52f071cdeca7358a93b323579cec0cc8a872420 Mon Sep 17 00:00:00 2001 From: berniebwang Date: Fri, 3 Dec 2021 20:54:59 +0800 Subject: [PATCH 2/6] Add support for vs2017 and vs2019 No longer supports vs2013 --- build/cmake_generate_projects.bat | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/build/cmake_generate_projects.bat b/build/cmake_generate_projects.bat index 69dad7b2..41f8cee0 100644 --- a/build/cmake_generate_projects.bat +++ b/build/cmake_generate_projects.bat @@ -9,14 +9,6 @@ IF %ERRORLEVEL% NEQ 0 GOTO l_cmake_error mkdir cmake_binary cd cmake_binary -echo --------------------------------------------------------------------------------- -mkdir vs2013 -cd vs2013 -REM cmake -G "Visual Studio 12 2013 Win64" --build ../../.. -REM cmake -G "Visual Studio 12 2013" -DBEHAVIAC_VERSION_MODE=ForeUseRelease --build ../../.. -cmake -G "Visual Studio 12 2013" --build ../../.. -cd .. - REM echo --------------------------------------------------------------------------------- REM mkdir vs2015 REM cd vs2015 @@ -25,6 +17,21 @@ REM cmake -G "Visual Studio 14 2015" -DBEHAVIAC_VERSION_MODE=ForeUseRelease --bu REM cmake -G "Visual Studio 14 2015" --build ../../.. REM cd .. +REM echo --------------------------------------------------------------------------------- +REM mkdir vs2017 +REM cd vs2017 +REM cmake -G "Visual Studio 15 2017 Win64" --build ../../.. +REM cmake -G "Visual Studio 15 2017" -DBEHAVIAC_VERSION_MODE=ForeUseRelease --build ../../.. +REM cmake -G "Visual Studio 15 2017" --build ../../.. +REM cd .. + +echo --------------------------------------------------------------------------------- +mkdir vs2019 +cd vs2019 +cmake -G "Visual Studio 16 2019" -A x64 --build ../../.. +REM cmake -G "Visual Studio 16 2019" -DBEHAVIAC_VERSION_MODE=ForeUseRelease --build ../../.. +REM cmake -G "Visual Studio 16 2019" --build ../../.. +cd .. where make IF %ERRORLEVEL% NEQ 0 GOTO l_no_make From 64f04b932b29187f523e678b15c0a7cd402c53f9 Mon Sep 17 00:00:00 2001 From: berniebwang Date: Mon, 4 Jul 2022 19:00:32 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BehaviacDesignerBase/Utilities.cs | 63 ++++++++++++++++--- 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/tools/designer/BehaviacDesignerBase/Utilities.cs b/tools/designer/BehaviacDesignerBase/Utilities.cs index 4cfae1c4..1110ab14 100644 --- a/tools/designer/BehaviacDesignerBase/Utilities.cs +++ b/tools/designer/BehaviacDesignerBase/Utilities.cs @@ -22,6 +22,8 @@ using System.Management; using System.Threading; using System.Net.NetworkInformation; +using System.Net.Sockets; +using System.Security.Cryptography; using Behaviac.Design.Properties; @@ -213,6 +215,7 @@ private static string GetHarddiskID() private static string _gatwway = ""; private static IPStatus _netWorkStatus = IPStatus.Unknown; + private static UdpClient _udpClient = null; private static bool CheckNetWork() { try @@ -277,7 +280,7 @@ private static bool ReportToTQOS(int intNum, string intList, int strNum, string qosData += strList; qosData += "]}}}]}}}"; - using(var client = new WebClient()) + using (var client = new WebClient()) { Uri uri = new Uri(qosData); client.OpenReadAsync(uri); @@ -292,6 +295,44 @@ private static bool ReportToTQOS(int intNum, string intList, int strNum, string return true; } + private static string _userInfo = ""; + private static bool ReportToGStatistic(OperationData operation) + { + try + { + if (_udpClient == null) + { + _udpClient = new UdpClient(); + _udpClient.Connect("101.226.141.148", 8080); + Thread.Sleep(2000); + } + + string qosDataStr = string.Format("cmd=0&tag=gcloud.behavic.times&event={0}&OperationNum={1}", operation.Type.ToString(), operation.Count); + + if (string.IsNullOrEmpty(_userInfo)) + { + HashAlgorithm algorithm = MD5.Create(); + String EncryptedUserName = BitConverter.ToString(algorithm.ComputeHash(Encoding.UTF8.GetBytes(Dns.GetHostName() + GetLocalMac()))); + + _userInfo = string.Format("&IP={0}&user_name={1}&version={2}", + GetLocalIP(), + EncryptedUserName, + System.Reflection.Assembly.GetEntryAssembly().GetName().Version); + } + qosDataStr += _userInfo; + + byte[] qosData = Encoding.UTF8.GetBytes(qosDataStr); + _udpClient.Send(qosData, qosData.Length); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + return false; + } + + return true; + } + [Serializable] enum OperationTypes { @@ -425,13 +466,19 @@ private static bool SendOperations() { foreach (OperationData operation in _allOperations) { - int intNum = 8; - string intList = string.Format("0,0,0,0,0,0,{0},{1}", (int)operation.Type, operation.Count); - - int strNum = 8; - string strList = getHeaderString(); - - if (!ReportToTQOS(intNum, intList, strNum, strList)) + //int intNum = 8; + //string intList = string.Format("0,0,0,0,0,0,{0},{1}", (int)operation.Type, operation.Count); + + //int strNum = 8; + //string strList = getHeaderString(); + + //if (!ReportToTQOS(intNum, intList, strNum, strList)) + //{ + // sendSuccess = false; + // break; + //} + + if (!ReportToGStatistic(operation)) { sendSuccess = false; break; From c14297c81fd16bc98f6abda623377f70f533148b Mon Sep 17 00:00:00 2001 From: berniebwang Date: Mon, 4 Jul 2022 19:32:11 +0800 Subject: [PATCH 4/6] =?UTF-8?q?behaviac=E6=80=A7=E8=83=BD=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=9A=E5=88=A4=E5=AE=9ASelf=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E8=80=83=E8=99=91=E5=A4=A7=E5=B0=8F=E5=86=99=EF=BC=8C=E5=8F=82?= =?UTF-8?q?=E8=80=83935=E8=A1=8C=E4=B9=9F=E6=98=AF=E8=BF=99=E6=A0=B7=20con?= =?UTF-8?q?tributed=20by=20denniswu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/agent/agent.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/agent/agent.cpp b/src/agent/agent.cpp index 922aa6c1..aea8c8c6 100644 --- a/src/agent/agent.cpp +++ b/src/agent/agent.cpp @@ -1158,11 +1158,11 @@ namespace behaviac { Agent* Agent::GetParentAgent(const Agent* pAgent, const char* instanceName) { Agent* pParent = const_cast(pAgent); - if (!StringUtils::IsNullOrEmpty(instanceName) && !StringUtils::Compare(instanceName, "Self")) { + if (!StringUtils::IsNullOrEmpty(instanceName) && !StringUtils::StringEqual(instanceName, "Self")) { pParent = Agent::GetInstance(instanceName, (pParent != NULL) ? pParent->GetContextId() : 0); //if (pAgent != NULL && pParent == NULL && !Utils.IsStaticClass(instanceName)) - if (pAgent != NULL && pParent == NULL /*&& !Utils.IsStaticClass(instanceName)*/) { //TODO how to handle Statice Class + if (pAgent != NULL && pParent == NULL) { //TODO how to handle Statice Class pParent = (Agent*)pAgent->GetVariable(instanceName); BEHAVIAC_ASSERT(pParent != NULL); } From c3ad9355bfb2fadee3b1d1408de59db995128c24 Mon Sep 17 00:00:00 2001 From: summerhou Date: Thu, 5 Nov 2020 10:10:06 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BC=98=E5=8C=96=EF=BC=9A=201.=20=E5=A2=9E=E5=8A=A0B?= =?UTF-8?q?TVector3f=E7=9A=84=E5=88=9D=E5=A7=8B=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=202.=20=E7=A6=81=E7=94=A8=E8=A1=8C=E4=B8=BA=E6=A0=91=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E6=97=B6=E9=A1=B5=E7=AD=BE=E4=B8=8D=E6=96=AD=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E7=9A=84=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=94=B9=E6=88=90?= =?UTF-8?q?=E5=8F=AA=E5=81=9C=E7=95=99=E5=9C=A8=E5=BD=93=E5=89=8D=E6=89=93?= =?UTF-8?q?=E5=BC=80=E7=9A=84=E9=A1=B5=E7=AD=BE=E4=B8=8A=203.=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=80=9A=E8=BF=87=E8=B0=83=E8=AF=95=E5=A0=86=E6=A0=88?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E7=9B=B4=E6=8E=A5=E6=89=93=E5=BC=80=E8=A1=8C?= =?UTF-8?q?=E4=B8=BA=E6=A0=91=E7=9A=84=E5=8A=9F=E8=83=BD=20contributed=20b?= =?UTF-8?q?y=20summerhou@tencent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BehaviacDesigner/BehaviorTreeViewDock.cs | 19 +++++++++++++++ .../CallStackDock.Designer.cs | 1 + .../BehaviacDesigner/CallStackDock.cs | 24 +++++++++++++++++++ tools/designer/BehaviacDesigner/MainWindow.cs | 7 ++++-- .../designer/BehaviacDesigner/TimelineDock.cs | 2 +- .../designer/BehaviacDesigner/UIUtilities.cs | 23 ++++++++++++------ .../DataExporters/Cpp/DataCppExporter.cs | 4 ++++ 7 files changed, 70 insertions(+), 10 deletions(-) diff --git a/tools/designer/BehaviacDesigner/BehaviorTreeViewDock.cs b/tools/designer/BehaviacDesigner/BehaviorTreeViewDock.cs index c3102048..e5a08912 100644 --- a/tools/designer/BehaviacDesigner/BehaviorTreeViewDock.cs +++ b/tools/designer/BehaviacDesigner/BehaviorTreeViewDock.cs @@ -38,6 +38,8 @@ using System.Drawing; using System.Text; using System.Windows.Forms; +using System.IO; +using Behaviac.Design.Nodes; namespace Behaviac.Design { @@ -161,6 +163,23 @@ internal static BehaviorTreeViewDock GetBehaviorTreeViewDock(Nodes.BehaviorNode return null; } + internal static BehaviorTreeViewDock GetBehaviorTreeViewDockByName(string behaviorFilename) + { + if (!Path.IsPathRooted(behaviorFilename)) + { + behaviorFilename = FileManagers.FileManager.GetFullPath(behaviorFilename); + } + + BehaviorTreeViewDock dock = null; + BehaviorNode behaviornode = BehaviorManager.Instance.GetBehavior(behaviorFilename); + if (behaviornode != null) + { + dock = GetBehaviorTreeViewDock(behaviornode); + } + + return dock; + } + internal static BehaviorTreeView GetBehaviorTreeView(Nodes.BehaviorNode node) { foreach (BehaviorTreeViewDock dock in __instances) diff --git a/tools/designer/BehaviacDesigner/CallStackDock.Designer.cs b/tools/designer/BehaviacDesigner/CallStackDock.Designer.cs index 3d1018db..890afc19 100644 --- a/tools/designer/BehaviacDesigner/CallStackDock.Designer.cs +++ b/tools/designer/BehaviacDesigner/CallStackDock.Designer.cs @@ -97,6 +97,7 @@ private void InitializeComponent() this.callstackListBox.Name = "callstackListBox"; this.callstackListBox.SelectedIndexChanged += new System.EventHandler(this.logListBox_SelectedIndexChanged); this.callstackListBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.logListBox_KeyDown); + this.callstackListBox.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.logListBox_MouseDoubleClick); // // CallStackDock // diff --git a/tools/designer/BehaviacDesigner/CallStackDock.cs b/tools/designer/BehaviacDesigner/CallStackDock.cs index c154757d..627973f7 100644 --- a/tools/designer/BehaviacDesigner/CallStackDock.cs +++ b/tools/designer/BehaviacDesigner/CallStackDock.cs @@ -24,6 +24,7 @@ using Behaviac.Design.Nodes; using Behaviac.Design.Properties; + namespace Behaviac.Design { internal partial class CallStackDock : WeifenLuo.WinFormsUI.Docking.DockContent @@ -122,14 +123,18 @@ private void UpdateStackCb(string tree, bool bAdd) } } + /* if (callstackListBox.Items.Count > 0) { //callstackListBox.SelectedIndex = -1; + callstackListBox.SelectedIndex = 0; + string currentBt = (string)callstackListBox.Items[0]; UIUtilities.ShowBehaviorTree(currentBt); } + */ } private void copyMenuItem_Click(object sender, EventArgs e) @@ -184,5 +189,24 @@ private void logListBox_KeyDown(object sender, KeyEventArgs e) callstackListBox.EndUpdate(); } } + + private void logListBox_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (callstackListBox.SelectedItem != null) + { + String behaviorFilename = callstackListBox.SelectedItem.ToString(); + BehaviorTreeView behaviorTreeView = UIUtilities.ShowBehaviorTree(behaviorFilename, true); + if (behaviorTreeView != null) + { + BehaviorTreeViewDock dock = BehaviorTreeViewDock.GetBehaviorTreeViewDockByName(behaviorFilename); + if (dock != null) + { + dock.Focus(); + dock.MakeFocused(); + } + } + } + } } } + diff --git a/tools/designer/BehaviacDesigner/MainWindow.cs b/tools/designer/BehaviacDesigner/MainWindow.cs index cc525190..ae600079 100644 --- a/tools/designer/BehaviacDesigner/MainWindow.cs +++ b/tools/designer/BehaviacDesigner/MainWindow.cs @@ -1129,8 +1129,11 @@ private BehaviorTreeViewDock behaviorTreeList_ShowBehavior(BehaviorNode node) if (dock != null) { - dock.Focus(); - dock.MakeFocused(); + if (Plugin.EditMode == EditModes.Design) + { + dock.Focus(); + dock.MakeFocused(); + } } } catch (Exception ex) diff --git a/tools/designer/BehaviacDesigner/TimelineDock.cs b/tools/designer/BehaviacDesigner/TimelineDock.cs index a2228a00..fbb6ed43 100644 --- a/tools/designer/BehaviacDesigner/TimelineDock.cs +++ b/tools/designer/BehaviacDesigner/TimelineDock.cs @@ -281,7 +281,7 @@ private void updateParameters(AgentType agentType, string agentName, int frame) if (agentFullname == Plugin.DebugAgentInstance) { - behavior = UIUtilities.ShowBehavior(behaviorFilename); + behavior = UIUtilities.ShowBehavior(behaviorFilename, false); } List values = AgentDataPool.GetValidValues(agentType, agentFullname, frame); diff --git a/tools/designer/BehaviacDesigner/UIUtilities.cs b/tools/designer/BehaviacDesigner/UIUtilities.cs index 479aeb99..485da5b3 100644 --- a/tools/designer/BehaviacDesigner/UIUtilities.cs +++ b/tools/designer/BehaviacDesigner/UIUtilities.cs @@ -28,7 +28,7 @@ internal class UIUtilities /// Show the behavior tree view. /// /// The behavior filename in the workspace folder. - public static BehaviorNode ShowBehavior(string behaviorFilename) + public static BehaviorNode ShowBehavior(string behaviorFilename, bool forceshowFlag = true) { if (string.IsNullOrEmpty(behaviorFilename)) { @@ -81,16 +81,19 @@ public static BehaviorNode ShowBehavior(string behaviorFilename) if (behaviorTreeList != null) { - behaviorTreeList.ShowNode(behavior as Node); + if (forceshowFlag) + { + behaviorTreeList.ShowNode(behavior as Node); + } } } return behavior; } - public static BehaviorTreeView ShowBehaviorTree(string behaviorFilename) + public static BehaviorTreeView ShowBehaviorTree(string behaviorFilename, bool forceshowFlag = true) { - BehaviorNode behavior = ShowBehavior(behaviorFilename); + BehaviorNode behavior = ShowBehavior(behaviorFilename, forceshowFlag); return BehaviorTreeViewDock.GetBehaviorTreeView(behavior); } @@ -105,7 +108,7 @@ public static BehaviorNode ShowBehaviorTree(string agentFullname, int frame, Lis if (!string.IsNullOrEmpty(behaviorFilename)) { - BehaviorTreeView behaviorTreeView = ShowBehaviorTree(behaviorFilename); + BehaviorTreeView behaviorTreeView = ShowBehaviorTree(behaviorFilename, false); if (behaviorTreeView != null) { @@ -114,8 +117,14 @@ public static BehaviorNode ShowBehaviorTree(string agentFullname, int frame, Lis profileInfos = null; } - behaviorTreeView.SetHighlights(highlightedTransitionIds, highlightNodeIds, updatedNodeIds, highlightBreakPoint, profileInfos); - //behaviorTreeView.Focus(); + // check if there is a tab for the behaviour, add by j2 server start + BehaviorTreeViewDock dock = BehaviorTreeViewDock.GetBehaviorTreeViewDockByName(behaviorFilename); + if (dock != null && dock == BehaviorTreeViewDock.LastFocused) + { + behaviorTreeView.SetHighlights(highlightedTransitionIds, highlightNodeIds, updatedNodeIds, highlightBreakPoint, profileInfos); + } + + // behaviorTreeView.SetHighlights(highlightedTransitionIds, highlightNodeIds, updatedNodeIds, highlightBreakPoint, profileInfos); return behaviorTreeView.RootNode; } diff --git a/tools/designer/Plugins/PluginBehaviac/DataExporters/Cpp/DataCppExporter.cs b/tools/designer/Plugins/PluginBehaviac/DataExporters/Cpp/DataCppExporter.cs index ea5f9dd0..3efd7cb7 100644 --- a/tools/designer/Plugins/PluginBehaviac/DataExporters/Cpp/DataCppExporter.cs +++ b/tools/designer/Plugins/PluginBehaviac/DataExporters/Cpp/DataCppExporter.cs @@ -204,6 +204,10 @@ public static string GetGeneratedDefaultValue(Type type, string typename, string { value = "NULL"; } + else if(typename.Equals("BTVector3f")) + { + value = "{0, 0, 0}"; + } else { value = null; From e346051e9367e70d7a4fea83f765aebdf113990f Mon Sep 17 00:00:00 2001 From: berniebwang Date: Mon, 4 Jul 2022 20:37:23 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=9Areset=E8=B0=83=E7=94=A8=20CompositeTask::traverse?= =?UTF-8?q?=E8=80=97=E6=97=B6=E8=BE=83=E9=AB=98=EF=BC=8C=E5=AF=B9=E4=BA=8E?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E8=BF=90=E8=A1=8C=E8=BF=87=E7=9A=84=E8=8A=82?= =?UTF-8?q?=E7=82=B9=EF=BC=8C=E5=B0=B1=E4=B8=8D=E5=81=9A=E5=A4=84=E7=90=86?= =?UTF-8?q?=E4=BA=86=20contributed=20by=20denniswu@tencent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/behaviortree/behaviortree_task.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/behaviortree/behaviortree_task.cpp b/src/behaviortree/behaviortree_task.cpp index 9e16bafe..790954a0 100644 --- a/src/behaviortree/behaviortree_task.cpp +++ b/src/behaviortree/behaviortree_task.cpp @@ -1152,6 +1152,11 @@ namespace behaviac { } void CompositeTask::traverse(bool childFirst, NodeHandler_t handler, Agent* pAgent, void* user_data) { + if (m_status == BT_INVALID) + { + return; + } + if (childFirst) { for (BehaviorTasks_t::iterator it = this->m_children.begin(); it != this->m_children.end(); ++it) { @@ -1187,7 +1192,12 @@ namespace behaviac { } void SingeChildTask::traverse(bool childFirst, NodeHandler_t handler, Agent* pAgent, void* user_data) { - if (childFirst) { + if (m_status == BT_INVALID) + { + return; + } + + if (childFirst) { if (this->m_root) { this->m_root->traverse(childFirst, handler, pAgent, user_data); }