forked from mirrors/NBTExplorer
65 lines
1.4 KiB
C#
65 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Substrate.Nbt;
|
|
|
|
namespace NBTExplorer.Model
|
|
{
|
|
public class CompoundTagContainer : INamedTagContainer
|
|
{
|
|
private TagNodeCompound _tag;
|
|
|
|
public CompoundTagContainer (TagNodeCompound tag)
|
|
{
|
|
_tag = tag;
|
|
}
|
|
|
|
public int TagCount
|
|
{
|
|
get { return _tag.Count; }
|
|
}
|
|
|
|
public IEnumerable<string> TagNamesInUse
|
|
{
|
|
get { return _tag.Keys; }
|
|
}
|
|
|
|
public string GetTagName (TagNode tag)
|
|
{
|
|
foreach (String name in _tag.Keys)
|
|
if (_tag[name] == tag)
|
|
return name;
|
|
|
|
return null;
|
|
}
|
|
|
|
public bool AddTag (TagNode tag, string name)
|
|
{
|
|
if (_tag.ContainsKey(name))
|
|
return false;
|
|
|
|
_tag.Add(name, tag);
|
|
return true;
|
|
}
|
|
|
|
public bool RenameTag (TagNode tag, string name)
|
|
{
|
|
if (_tag.ContainsKey(name))
|
|
return false;
|
|
|
|
string oldName = GetTagName(tag);
|
|
_tag.Remove(oldName);
|
|
_tag.Add(name, tag);
|
|
|
|
return true;
|
|
}
|
|
|
|
public bool DeleteTag (TagNode tag)
|
|
{
|
|
foreach (String name in _tag.Keys)
|
|
if (_tag[name] == tag)
|
|
return _tag.Remove(name);
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|