Пример #1
0
        protected override void OnLoaded(BinaryReader r)
        {
            //清空当前容器节点,避免被重复添加
            _contenNodeList.Clear();

            base.OnLoaded(r);
            bool running = r.ReadBoolean();

            //恢复初始节点
            int count = r.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                string       fullName = r.ReadString();
                NodeModifier node     = ReflectionHelper.CreateInstance <NodeModifier>(fullName);
                if (node == null)
                {
                    node = ReflectionHelper.CreateInstance <NodeModifier>("CryDialog.Runtime._MissingNode");
                    //It's mission
                    //return;
                }
                node.SetContent(this);
                node.Deserialize(r);
                NodeModifier.SetContent(node, this);
            }

            if (running)
            {
                //恢复运行节点(以ID为主)
                count = r.ReadInt32();
                List <NodeModifier> runningNode = new List <NodeModifier>();
                for (int i = 0; i < count; i++)
                {
                    for (int j = 0; j < _contenNodeList.Count; j++)
                    {
                        NodeModifier node = _contenNodeList[j].GetNextNodeByID(r.ReadInt32());
                        if (node != null)
                        {
                            runningNode.Add(node);
                            break;
                        }
                    }
                }

                //装填缓存节点
                _tempNodeList = _contenNodeList.ToArray();

                //移除初始节点
                for (int i = 0; i < _tempNodeList.Length; i++)
                {
                    RemoveContenNode(_tempNodeList[i]);
                }

                //重新加入已运行节点
                for (int i = 0; i < runningNode.Count; i++)
                {
                    AddContentNode(runningNode[i]);
                }
            }

            if (OnNodeLoaded != null)
            {
                OnNodeLoaded.Invoke(this);
            }
        }
Пример #2
0
 public static void SetContent(NodeModifier node, NodeContent content)
 {
     node.RemoveFromContent();
     node.DeleteParent();
     node.SetContent(content);
 }