2011-04-06 21:18:48 +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 21:18:48 +00:00
|
|
|
|
{
|
2011-04-06 21:20:35 +00:00
|
|
|
|
using Substrate.NBT;
|
2011-04-06 21:18:48 +00:00
|
|
|
|
|
|
|
|
|
public class EntityPainting : Entity
|
|
|
|
|
{
|
2011-04-06 22:01:22 +00:00
|
|
|
|
public enum DirectionType
|
2011-04-06 21:18:48 +00:00
|
|
|
|
{
|
|
|
|
|
EAST = 0,
|
|
|
|
|
NORTH = 1,
|
|
|
|
|
WEST = 2,
|
|
|
|
|
SOUTH = 3,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static readonly NBTCompoundNode PaintingSchema = BaseSchema.MergeInto(new NBTCompoundNode("")
|
|
|
|
|
{
|
|
|
|
|
new NBTStringNode("id", "Painting"),
|
2011-04-09 02:50:42 +00:00
|
|
|
|
new NBTScalerNode("Dir", TagType.TAG_BYTE),
|
|
|
|
|
new NBTScalerNode("TileX", TagType.TAG_SHORT),
|
|
|
|
|
new NBTScalerNode("TileY", TagType.TAG_SHORT),
|
|
|
|
|
new NBTScalerNode("TileZ", TagType.TAG_SHORT),
|
|
|
|
|
new NBTScalerNode("Motive", TagType.TAG_STRING),
|
2011-04-06 21:18:48 +00:00
|
|
|
|
});
|
|
|
|
|
|
2011-04-06 22:01:22 +00:00
|
|
|
|
private DirectionType _dir;
|
2011-04-06 21:18:48 +00:00
|
|
|
|
private string _motive;
|
|
|
|
|
private short _xTile;
|
|
|
|
|
private short _yTile;
|
|
|
|
|
private short _zTile;
|
|
|
|
|
|
2011-04-06 22:01:22 +00:00
|
|
|
|
public DirectionType Direction
|
2011-04-06 21:18:48 +00:00
|
|
|
|
{
|
|
|
|
|
get { return _dir; }
|
|
|
|
|
set { _dir = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Motive
|
|
|
|
|
{
|
|
|
|
|
get { return _motive; }
|
|
|
|
|
set { _motive = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int TileX
|
|
|
|
|
{
|
|
|
|
|
get { return _xTile; }
|
|
|
|
|
set { _xTile = (short)value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int TileY
|
|
|
|
|
{
|
|
|
|
|
get { return _yTile; }
|
|
|
|
|
set { _yTile = (short)value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int TileZ
|
|
|
|
|
{
|
|
|
|
|
get { return _zTile; }
|
|
|
|
|
set { _zTile = (short)value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public EntityPainting ()
|
|
|
|
|
: base("Painting")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public EntityPainting (Entity e)
|
|
|
|
|
: base(e)
|
|
|
|
|
{
|
|
|
|
|
EntityPainting e2 = e as EntityPainting;
|
|
|
|
|
if (e2 != null) {
|
|
|
|
|
_xTile = e2._xTile;
|
|
|
|
|
_yTile = e2._yTile;
|
|
|
|
|
_zTile = e2._zTile;
|
|
|
|
|
_dir = e2._dir;
|
|
|
|
|
_motive = e2._motive;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region INBTObject<Entity> Members
|
|
|
|
|
|
2011-04-09 02:50:42 +00:00
|
|
|
|
public override Entity LoadTree (TagValue tree)
|
2011-04-06 21:18:48 +00:00
|
|
|
|
{
|
2011-04-09 02:50:42 +00:00
|
|
|
|
TagCompound ctree = tree as TagCompound;
|
2011-04-06 21:18:48 +00:00
|
|
|
|
if (ctree == null || base.LoadTree(tree) == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-09 02:50:42 +00:00
|
|
|
|
_dir = (DirectionType) ctree["Dir"].ToTagByte().Data;
|
|
|
|
|
_motive = ctree["Motive"].ToTagString();
|
|
|
|
|
_xTile = ctree["TileX"].ToTagShort();
|
|
|
|
|
_yTile = ctree["TileY"].ToTagShort();
|
|
|
|
|
_zTile = ctree["TileZ"].ToTagShort();
|
2011-04-06 21:18:48 +00:00
|
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-09 02:50:42 +00:00
|
|
|
|
public override TagValue BuildTree ()
|
2011-04-06 21:18:48 +00:00
|
|
|
|
{
|
2011-04-09 02:50:42 +00:00
|
|
|
|
TagCompound tree = base.BuildTree() as TagCompound;
|
|
|
|
|
tree["Dir"] = new TagByte((byte)_dir);
|
|
|
|
|
tree["Motive"] = new TagString(_motive);
|
|
|
|
|
tree["TileX"] = new TagShort(_xTile);
|
|
|
|
|
tree["TileY"] = new TagShort(_yTile);
|
|
|
|
|
tree["TileZ"] = new TagShort(_zTile);
|
2011-04-06 21:18:48 +00:00
|
|
|
|
|
|
|
|
|
return tree;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-09 02:50:42 +00:00
|
|
|
|
public override bool ValidateTree (TagValue tree)
|
2011-04-06 21:18:48 +00:00
|
|
|
|
{
|
|
|
|
|
return new NBTVerifier(tree, PaintingSchema).Verify();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region ICopyable<Entity> Members
|
|
|
|
|
|
|
|
|
|
public override Entity Copy ()
|
|
|
|
|
{
|
|
|
|
|
return new EntityPainting(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|