protected override void ExpandCore()
        {
            if (_tree == null)
            {
                NBTFile file = new NBTFile(_path);
                _tree = new NbtTree();
                _tree.ReadFrom(file.GetDataInputStream(_compressionType));

                if (_tree.Root != null)
                {
                    _container = new CompoundTagContainer(_tree.Root);
                }
            }

            var list = new SortedList <TagKey, TagNode>();

            foreach (var item in _tree.Root)
            {
                list.Add(new TagKey(item.Key, item.Value.GetTagType()), item.Value);
            }

            foreach (TagNode tag in list.Values)
            {
                TagDataNode node = TagDataNode.CreateFromTag(tag);
                if (node != null)
                {
                    Nodes.Add(node);
                }
            }
        }
        public override void SyncTag()
        {
            Dictionary <TagNode, TagDataNode> lookup = new Dictionary <TagNode, TagDataNode>();

            foreach (TagDataNode node in Nodes)
            {
                lookup[node.Tag] = node;
            }

            foreach (var kvp in lookup)
            {
                if (!Tag.Values.Contains(kvp.Key))
                {
                    Nodes.Remove(kvp.Value);
                }
            }

            foreach (TagNode tag in Tag.Values)
            {
                if (!lookup.ContainsKey(tag))
                {
                    TagDataNode newnode = TagDataNode.CreateFromTag(tag);
                    if (newnode != null)
                    {
                        Nodes.Add(newnode);
                        newnode.Expand();
                    }
                }
            }

            foreach (TagDataNode node in Nodes)
            {
                node.SyncTag();
            }
        }
示例#3
0
 protected override void ExpandCore()
 {
     foreach (TagNode tag in Tag)
     {
         TagDataNode node = TagDataNode.CreateFromTag(tag);
         if (node != null)
         {
             Nodes.Add(node);
         }
     }
 }
示例#4
0
        private void AddTag(TagNode tag, string name)
        {
            _container.AddTag(tag, name);
            IsDataModified = true;

            if (IsExpanded)
            {
                var node = TagDataNode.CreateFromTag(tag);
                if (node != null)
                    Nodes.Add(node);
            }
        }
示例#5
0
        private void AppendTag(TagNode tag)
        {
            _container.InsertTag(tag, _container.TagCount);
            IsDataModified = true;

            if (IsExpanded)
            {
                TagDataNode node = TagDataNode.CreateFromTag(tag);
                if (node != null)
                {
                    Nodes.Add(node);
                }
            }
        }
示例#6
0
        public override bool CreateNode(TagType type)
        {
            if (!CanCreateTag(type))
            {
                return(false);
            }

            if (Tag.Count == 0)
            {
                Tag.ChangeValueType(type);
            }

            AppendTag(TagDataNode.DefaultTag(type));
            return(true);
        }
        protected override void ExpandCore()
        {
            var list = new SortedList <TagKey, TagNode>();

            foreach (var item in Tag)
            {
                list.Add(new TagKey(item.Key, item.Value.GetTagType()), item.Value);
            }

            foreach (var item in list)
            {
                TagDataNode node = TagDataNode.CreateFromTag(item.Value);
                if (node != null)
                {
                    Nodes.Add(node);
                }
            }
        }
        public bool AppendTag(TagNode tag)
        {
            if (tag == null || !CanCreateTag(tag.GetTagType()))
            {
                return(false);
            }

            _container.InsertTag(tag, _container.TagCount);
            IsDataModified = true;

            if (IsExpanded)
            {
                TagDataNode node = TagDataNode.CreateFromTag(tag);
                if (node != null)
                {
                    Nodes.Add(node);
                }
            }

            return(true);
        }
示例#9
0
        public bool AddTag(TagNode tag, string name)
        {
            if (tag == null)
            {
                return(false);
            }

            _container.AddTag(tag, name);
            IsDataModified = true;

            if (IsExpanded)
            {
                TagDataNode node = TagDataNode.CreateFromTag(tag);
                if (node != null)
                {
                    Nodes.Add(node);
                }
            }

            return(true);
        }
示例#10
0
        protected override void ExpandCore()
        {
            if (_tree == null)
            {
                _tree = new NbtTree();
                _tree.ReadFrom(_regionFile.GetChunkDataInputStream(_x, _z));

                if (_tree.Root != null)
                {
                    _container = new CompoundTagContainer(_tree.Root);
                }
            }

            foreach (TagNode tag in _tree.Root.Values)
            {
                TagDataNode node = TagDataNode.CreateFromTag(tag);
                if (node != null)
                {
                    Nodes.Add(node);
                }
            }
        }
示例#11
0
        protected override void ExpandCore()
        {
            if (_tree == null)
            {
                NBTFile file = new NBTFile(_path);
                _tree = new NbtTree();
                _tree.ReadFrom(file.GetDataInputStream(_compressionType));

                if (_tree.Root != null)
                {
                    _container = new CompoundTagContainer(_tree.Root);
                }
            }

            foreach (TagNode tag in _tree.Root.Values)
            {
                TagDataNode node = TagDataNode.CreateFromTag(tag);
                if (node != null)
                {
                    Nodes.Add(node);
                }
            }
        }