NBTExplorer/Substrate/SubstrateCS/Source/Entities/EntitySlime.cs

80 lines
1.8 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Text;
2011-04-06 21:20:35 +00:00
namespace Substrate.Entities
{
2011-04-06 21:20:35 +00:00
using Substrate.NBT;
public class EntitySlime : EntityMob
{
public static readonly SchemaNodeCompound SlimeSchema = MobSchema.MergeInto(new SchemaNodeCompound("")
{
new SchemaNodeString("id", "Slime"),
new SchemaNodeScaler("Size", TagType.TAG_INT),
});
private int _size;
public int Size
{
get { return _size; }
set { _size = value; }
}
public EntitySlime ()
: base("Slime")
{
}
public EntitySlime (Entity e)
: base(e)
{
EntitySlime e2 = e as EntitySlime;
if (e2 != null) {
_size = e2._size;
}
}
#region INBTObject<Entity> Members
public override Entity LoadTree (TagNode tree)
{
TagNodeCompound ctree = tree as TagNodeCompound;
if (ctree == null || base.LoadTree(tree) == null) {
return null;
}
_size = ctree["Size"].ToTagInt();
return this;
}
public override TagNode BuildTree ()
{
TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
tree["Size"] = new TagNodeInt(_size);
return tree;
}
public override bool ValidateTree (TagNode tree)
{
return new NBTVerifier(tree, SlimeSchema).Verify();
}
#endregion
#region ICopyable<Entity> Members
public override Entity Copy ()
{
return new EntitySlime(this);
}
#endregion
}
}