Пример #1
0
        public override void Construct(MyObjectBuilder_BehaviorTreeNode nodeDefinition, MyBehaviorTree.MyBehaviorTreeDesc treeDesc)
        {
            base.Construct(nodeDefinition, treeDesc);
            MyObjectBuilder_BehaviorTreeActionNode node = (MyObjectBuilder_BehaviorTreeActionNode)nodeDefinition;

            if (!string.IsNullOrEmpty(node.ActionName))
            {
                this.m_actionName = MyStringId.GetOrCompute(node.ActionName);
                treeDesc.ActionIds.Add(this.m_actionName);
            }
            if (node.Parameters != null)
            {
                MyObjectBuilder_BehaviorTreeActionNode.TypeValue[] parameters = node.Parameters;
                this.m_parameters = new object[parameters.Length];
                for (int i = 0; i < this.m_parameters.Length; i++)
                {
                    MyObjectBuilder_BehaviorTreeActionNode.TypeValue value2 = parameters[i];
                    if (value2 is MyObjectBuilder_BehaviorTreeActionNode.MemType)
                    {
                        this.m_parameters[i] = (VRage.Boxed <MyStringId>)MyStringId.GetOrCompute((string)value2.GetValue());
                    }
                    else
                    {
                        this.m_parameters[i] = value2.GetValue();
                    }
                }
            }
        }
        public override void Construct(MyObjectBuilder_BehaviorTreeNode nodeDefinition, MyBehaviorTree.MyBehaviorTreeDesc treeDesc)
        {
            base.Construct(nodeDefinition, treeDesc);

            var controlBaseNode = (MyObjectBuilder_BehaviorControlBaseNode)nodeDefinition;

            m_children    = new List <MyBehaviorTreeNode>(controlBaseNode.BTNodes.Length);
            m_isMemorable = controlBaseNode.IsMemorable;
            foreach (var ob in controlBaseNode.BTNodes)
            {
                var childInst = MyBehaviorTreeNodeFactory.CreateBTNode(ob);
                childInst.Construct(ob, treeDesc);
                m_children.Add(childInst);
            }
        }
Пример #3
0
        public override void Construct(MyObjectBuilder_BehaviorTreeNode nodeDefinition, MyBehaviorTree.MyBehaviorTreeDesc treeDesc)
        {
            base.Construct(nodeDefinition, treeDesc);

            var ob = (MyObjectBuilder_BehaviorTreeActionNode)nodeDefinition;

            Debug.Assert(!string.IsNullOrEmpty(ob.ActionName), "Action name was not provided");
            if (!string.IsNullOrEmpty(ob.ActionName))
            {
                m_actionName = MyStringId.GetOrCompute(ob.ActionName);
                treeDesc.ActionIds.Add(m_actionName);
            }

            if (ob.Parameters != null)
            {
                var obParameters = ob.Parameters;
                m_parameters = new object[obParameters.Length];
                for (int i = 0; i < m_parameters.Length; i++)
                {
                    var obParam = obParameters[i];
                    if (obParam is MyObjectBuilder_BehaviorTreeActionNode.MemType)
                    {
                        string value = (string)obParam.GetValue();
                        m_parameters[i] = (Boxed <MyStringId>)MyStringId.GetOrCompute(value);
                    }
                    else
                    {
                        m_parameters[i] = obParam.GetValue();
                    }
                }
            }
        }