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 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 diff --git a/src/agent/agent.cpp b/src/agent/agent.cpp index fbcabc80..c0d3b778 100644 --- a/src/agent/agent.cpp +++ b/src/agent/agent.cpp @@ -1166,11 +1166,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); } 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); } 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/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; 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;