private NodeSearchResult FindNode(BehaviorTree behaviourTree, BehaviourTreeBranchBuilder customBranch) { BehaviorNode rootNode = behaviourTree.RootNode; string[] pathNodeNames = customBranch.PathNodeNames; if (customBranch.BehaviourTreeType == BehaviorTreeIDEnum.CoreAITree) { BehaviorNode parent = rootNode; NodeSearchResult nodeSearchResults = null; for (int i = 0; i < pathNodeNames.Length; i++) { nodeSearchResults = FindNode(parent, pathNodeNames[i]); if (nodeSearchResults != null) { parent = nodeSearchResults.Node; } } if (nodeSearchResults != null) { string name = (string)AccessTools.Field(typeof(BehaviorNode), "name").GetValue(nodeSearchResults.Node); Main.LogDebug($"[FindNode] Found target from path '{customBranch.Path}'. Target found was '{name}'"); return(nodeSearchResults); } } return(null); }
public void AddCustomBehaviourBranch(BehaviorTreeIDEnum behaviourTreeType, string path, BehaviourTreeBranchBuilder customBranch) { if (!injectionBranchRoots.ContainsKey(behaviourTreeType)) { injectionBranchRoots.Add(behaviourTreeType, new List <BehaviourTreeBranchBuilder>()); } injectionBranchRoots[behaviourTreeType].Add(customBranch); }