NBTExplorer/Substrate/SubstrateCS/Source/TileEntities/TileEntityRecordPlayer.cs
2011-06-28 03:41:44 +00:00

84 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
namespace Substrate.TileEntities
{
using Substrate.NBT;
public class TileEntityRecordPlayer : TileEntity
{
public static readonly SchemaNodeCompound RecordPlayerSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("")
{
new SchemaNodeString("id", "RecordPlayer"),
new SchemaNodeScaler("Record", TagType.TAG_INT, SchemaOptions.OPTIONAL),
});
private int? _record = null;
public int? Record
{
get { return _record; }
set { _record = value; }
}
public TileEntityRecordPlayer ()
: base("RecordPlayer")
{
}
public TileEntityRecordPlayer (TileEntity te)
: base(te)
{
TileEntityRecordPlayer tes = te as TileEntityRecordPlayer;
if (tes != null) {
_record = tes._record;
}
}
#region ICopyable<TileEntity> Members
public override TileEntity Copy ()
{
return new TileEntityRecordPlayer(this);
}
#endregion
#region INBTObject<TileEntity> Members
public override TileEntity LoadTree (TagNode tree)
{
TagNodeCompound ctree = tree as TagNodeCompound;
if (ctree == null || base.LoadTree(tree) == null) {
return null;
}
if (ctree.ContainsKey("Record")) {
_record = ctree["Record"].ToTagInt();
}
return this;
}
public override TagNode BuildTree ()
{
TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
if (_record != null) {
tree["Record"] = new TagNodeInt((int)_record);
}
return tree;
}
public override bool ValidateTree (TagNode tree)
{
return new NBTVerifier(tree, RecordPlayerSchema).Verify();
}
#endregion
}
}