public override void InitializeComponent() { ObjectProtoData proto_data = ParentObject.GetCreationContext().m_proto_data; if (proto_data != null) { var variables = proto_data.m_component_variables; if (variables != null) { string value; if (variables.TryGetValue("ai_tree_id", out value)) { m_bahavior_tree_id = int.Parse(value); } } } m_behavior_tree = BehaviorTreeFactory.Instance.CreateBehaviorTree(m_bahavior_tree_id); if (m_behavior_tree != null) { m_behavior_tree.Construct(GetLogicWorld()); BTContext context = m_behavior_tree.Context; context.SetData <IExpressionVariableProvider>(BTContextKey.ExpressionVariableProvider, this); context.SetData <Entity>(BTContextKey.OwnerEntity, GetOwnerEntity()); context.SetData <AIComponent>(BTContextKey.OwnerAIComponent, this); m_behavior_tree.Active(); } }
public override void InitializeComponent() { m_behavior_tree = BehaviorTreeFactory.Instance.CreateBehaviorTree(m_bahavior_tree_id); if (m_behavior_tree != null) { m_behavior_tree.Construct(GetLogicWorld()); BTContext context = m_behavior_tree.Context; context.SetData <IExpressionVariableProvider>(BTContextKey.ExpressionVariableProvider, this); context.SetData <Entity>(BTContextKey.OwnerEntity, GetOwnerEntity()); context.SetData <SkillComponent>(BTContextKey.OwnerSkillComponent, this); m_behavior_tree.Active(); } }