public static bool LoadUploadedBehaviorTree(out MyBehaviorDefinition definition) { MyBehaviorDefinition definition2 = LoadBehaviorTreeFromFile(Path.Combine(MyFileSystem.UserDataPath, "UploadTree" + DEFAULT_EXTENSION)); definition = definition2; return(definition != null); }
public static bool LoadUploadedBehaviorTree(out MyBehaviorDefinition definition) { string dataPath = MyFileSystem.UserDataPath; MyBehaviorDefinition uploadedDefinition = LoadBehaviorTreeFromFile(Path.Combine(dataPath, "UploadTree" + DEFAULT_EXTENSION)); definition = uploadedDefinition; return(definition != null); }
public bool RebuildBehaviorTree(MyBehaviorDefinition newDefinition, out MyBehaviorTree outBehaviorTree) { if (!this.m_BTDataByName.ContainsKey(newDefinition.Id.SubtypeId)) { outBehaviorTree = null; return(false); } outBehaviorTree = this.m_BTDataByName[newDefinition.Id.SubtypeId].BehaviorTree; outBehaviorTree.ReconstructTree(newDefinition); return(true); }
private bool BuildBehaviorTree(MyBehaviorDefinition behaviorDefinition) { if (this.m_BTDataByName.ContainsKey(behaviorDefinition.Id.SubtypeId)) { return(false); } MyBehaviorTree behaviorTree = new MyBehaviorTree(behaviorDefinition); behaviorTree.Construct(); BTData data = new BTData(behaviorTree); this.m_BTDataByName.Add(behaviorDefinition.Id.SubtypeId, data); return(true); }
private bool BuildBehaviorTree(MyBehaviorDefinition behaviorDefinition) { Debug.Assert(!m_BTDataByName.ContainsKey(behaviorDefinition.Id.SubtypeId), "Tree with given behavior definition already exists."); if (m_BTDataByName.ContainsKey(behaviorDefinition.Id.SubtypeId)) { return(false); } MyBehaviorTree newInstance = new MyBehaviorTree(behaviorDefinition); newInstance.Construct(); BTData behaviorTreeData = new BTData(newInstance); m_BTDataByName.Add(behaviorDefinition.Id.SubtypeId, behaviorTreeData); return(true); }
private static MyBehaviorDefinition LoadBehaviorTreeFromFile(string path) { MyObjectBuilder_Definitions allDefinitions = null; MyObjectBuilderSerializer.DeserializeXML(path, out allDefinitions); if (allDefinitions != null && allDefinitions.AIBehaviors != null && allDefinitions.AIBehaviors.Length > 0) { var firstDef = allDefinitions.AIBehaviors[0]; // only one tree can be uploaded at one time MyBehaviorDefinition behaviorDefinition = new MyBehaviorDefinition(); MyModContext context = new MyModContext(); context.Init("BehaviorDefinition", Path.GetFileName(path)); behaviorDefinition.Init(firstDef, context); return(behaviorDefinition); } return(null); }
private static MyBehaviorDefinition LoadBehaviorTreeFromFile(string path) { MyObjectBuilder_Definitions objectBuilder = null; MyObjectBuilderSerializer.DeserializeXML <MyObjectBuilder_Definitions>(path, out objectBuilder); if (((objectBuilder == null) || (objectBuilder.AIBehaviors == null)) || (objectBuilder.AIBehaviors.Length == 0)) { return(null); } MyObjectBuilder_BehaviorTreeDefinition builder = objectBuilder.AIBehaviors[0]; MyModContext modContext = new MyModContext(); modContext.Init("BehaviorDefinition", Path.GetFileName(path), null); MyBehaviorDefinition definition1 = new MyBehaviorDefinition(); definition1.Init(builder, modContext); return(definition1); }
private void OnUploadNewTree(ref System.Windows.Forms.Message msg) { if (this.m_behaviorTreeCollection != null) { MyBehaviorTree outBehaviorTree = null; MyBehaviorDefinition definition = null; if (MyBehaviorTreeCollection.LoadUploadedBehaviorTree(out definition) && this.m_behaviorTreeCollection.HasBehavior(definition.Id.SubtypeId)) { this.m_botCollection.ResetBots(definition.Id.SubtypeName); this.m_behaviorTreeCollection.RebuildBehaviorTree(definition, out outBehaviorTree); this.m_botCollection.CheckCompatibilityWithBots(outBehaviorTree); } IntPtr zero = IntPtr.Zero; if (this.m_behaviorTreeCollection.TryGetValidToolWindow(out zero)) { WinApi.PostMessage(zero, 0x404, IntPtr.Zero, IntPtr.Zero); } } }
private void OnUploadNewTree(ref Message msg) { if (m_behaviorTreeCollection != null) { MyBehaviorTree behaviorTree = null; MyBehaviorDefinition behaviorDefinition = null; bool success = MyBehaviorTreeCollection.LoadUploadedBehaviorTree(out behaviorDefinition); if (success && m_behaviorTreeCollection.HasBehavior(behaviorDefinition.Id.SubtypeId)) { m_botCollection.ResetBots(behaviorDefinition.Id.SubtypeName); m_behaviorTreeCollection.RebuildBehaviorTree(behaviorDefinition, out behaviorTree); m_botCollection.CheckCompatibilityWithBots(behaviorTree); } IntPtr toolWindowHandle = IntPtr.Zero; #if !XB1 if (m_behaviorTreeCollection.TryGetValidToolWindow(out toolWindowHandle)) WinApi.PostMessage(toolWindowHandle, MyWMCodes.BEHAVIOR_TOOL_TREE_UPLOAD_SUCCESS, IntPtr.Zero, IntPtr.Zero); #endif // !XB1 } }
public void ReconstructTree(MyBehaviorDefinition def) { m_behaviorDefinition = def; Construct(); }
public MyBehaviorTree(MyBehaviorDefinition def) { m_behaviorDefinition = def; m_treeDesc = new MyBehaviorTreeDesc(); }