2011-04-06 19:41:57 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
2011-04-06 21:20:35 +00:00
|
|
|
|
namespace Substrate.Entities
|
2011-04-06 19:41:57 +00:00
|
|
|
|
{
|
2011-06-30 04:41:29 +00:00
|
|
|
|
using Substrate.Nbt;
|
2011-04-06 19:41:57 +00:00
|
|
|
|
|
2011-12-16 04:20:03 +00:00
|
|
|
|
public class EntitySheep : EntityAnimal
|
2011-04-06 19:41:57 +00:00
|
|
|
|
{
|
2011-12-16 04:20:03 +00:00
|
|
|
|
public static readonly SchemaNodeCompound SheepSchema = AnimalSchema.MergeInto(new SchemaNodeCompound("")
|
2011-04-06 19:41:57 +00:00
|
|
|
|
{
|
2011-11-05 18:17:57 +00:00
|
|
|
|
new SchemaNodeString("id", TypeId),
|
2011-06-20 03:51:40 +00:00
|
|
|
|
new SchemaNodeScaler("Sheared", TagType.TAG_BYTE),
|
|
|
|
|
new SchemaNodeScaler("Color", TagType.TAG_BYTE, SchemaOptions.CREATE_ON_MISSING),
|
2011-04-06 19:41:57 +00:00
|
|
|
|
});
|
|
|
|
|
|
2011-11-10 03:00:09 +00:00
|
|
|
|
public static new string TypeId
|
2011-11-05 18:17:57 +00:00
|
|
|
|
{
|
|
|
|
|
get { return "Sheep"; }
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-06 19:41:57 +00:00
|
|
|
|
private bool _sheared;
|
|
|
|
|
private byte _color;
|
|
|
|
|
|
|
|
|
|
public bool IsSheared
|
|
|
|
|
{
|
|
|
|
|
get { return _sheared; }
|
|
|
|
|
set { _sheared = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Color
|
|
|
|
|
{
|
|
|
|
|
get { return _color; }
|
|
|
|
|
set { _color = (byte)value; }
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-05 18:17:57 +00:00
|
|
|
|
protected EntitySheep (string id)
|
|
|
|
|
: base(id)
|
2011-04-06 19:41:57 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-05 18:17:57 +00:00
|
|
|
|
public EntitySheep ()
|
|
|
|
|
: this(TypeId)
|
2011-11-05 17:36:04 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-14 19:34:49 +00:00
|
|
|
|
public EntitySheep (TypedEntity e)
|
2011-04-06 19:41:57 +00:00
|
|
|
|
: base(e)
|
|
|
|
|
{
|
|
|
|
|
EntitySheep e2 = e as EntitySheep;
|
|
|
|
|
if (e2 != null) {
|
|
|
|
|
_sheared = e2._sheared;
|
|
|
|
|
_color = e2._color;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region INBTObject<Entity> Members
|
|
|
|
|
|
2011-08-14 19:34:49 +00:00
|
|
|
|
public override TypedEntity LoadTree (TagNode tree)
|
2011-04-06 19:41:57 +00:00
|
|
|
|
{
|
2011-06-20 03:51:40 +00:00
|
|
|
|
TagNodeCompound ctree = tree as TagNodeCompound;
|
2011-04-06 19:41:57 +00:00
|
|
|
|
if (ctree == null || base.LoadTree(tree) == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-09 02:50:42 +00:00
|
|
|
|
_sheared = ctree["Sheared"].ToTagByte() == 1;
|
|
|
|
|
_color = ctree["Color"].ToTagByte();
|
2011-04-06 19:41:57 +00:00
|
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-20 03:51:40 +00:00
|
|
|
|
public override TagNode BuildTree ()
|
2011-04-06 19:41:57 +00:00
|
|
|
|
{
|
2011-06-20 03:51:40 +00:00
|
|
|
|
TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
|
|
|
|
|
tree["Sheared"] = new TagNodeByte((byte)(_sheared ? 1 : 0));
|
|
|
|
|
tree["Color"] = new TagNodeByte(_color);
|
2011-04-06 19:41:57 +00:00
|
|
|
|
|
|
|
|
|
return tree;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-20 03:51:40 +00:00
|
|
|
|
public override bool ValidateTree (TagNode tree)
|
2011-04-06 19:41:57 +00:00
|
|
|
|
{
|
2011-06-30 04:57:18 +00:00
|
|
|
|
return new NbtVerifier(tree, SheepSchema).Verify();
|
2011-04-06 19:41:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region ICopyable<Entity> Members
|
|
|
|
|
|
2011-08-14 19:34:49 +00:00
|
|
|
|
public override TypedEntity Copy ()
|
2011-04-06 19:41:57 +00:00
|
|
|
|
{
|
|
|
|
|
return new EntitySheep(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|