using System; using System.Collections.Generic; namespace Model { public class BehaviorTree { private readonly Node node; public Scene Scene { get; } public string Discription { get { return this.node.Description; } } public BehaviorTree(Scene scene, Node node) { this.Scene = scene; this.node = node; } public bool Run(BTEnv env) { try { bool ret = this.node.DoRun(this, env); List pathList = env.Get>(BTEnvKey.NodePath); Game.Scene.GetComponent().Run(EventIdType.BehaviorTreeRunTreeEvent, this, pathList); return ret; } catch (Exception e) { string source = env.Get(BTEnvKey.BTSource) ?? ""; Log.Error($"树运行出错, 树名: {this.Discription} 来源: {source}" + e); return false; } } } }