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-06-30 04:41:29 +00:00
|
|
|
|
using Substrate.Nbt;
|
2011-04-06 21:18:48 +00:00
|
|
|
|
|
2011-06-30 03:59:20 +00:00
|
|
|
|
public class EntityPainting : EntityTyped
|
2011-04-06 21:18:48 +00:00
|
|
|
|
{
|
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,
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-30 03:59:20 +00:00
|
|
|
|
public static readonly SchemaNodeCompound PaintingSchema = EntityTyped.Schema.MergeInto(new SchemaNodeCompound("")
|
2011-04-06 21:18:48 +00:00
|
|
|
|
{
|
2011-06-20 03:51:40 +00:00
|
|
|
|
new SchemaNodeString("id", "Painting"),
|
|
|
|
|
new SchemaNodeScaler("Dir", TagType.TAG_BYTE),
|
2011-07-07 04:27:48 +00:00
|
|
|
|
new SchemaNodeScaler("TileX", TagType.TAG_INT),
|
|
|
|
|
new SchemaNodeScaler("TileY", TagType.TAG_INT),
|
|
|
|
|
new SchemaNodeScaler("TileZ", TagType.TAG_INT),
|
2011-06-20 03:51:40 +00:00
|
|
|
|
new SchemaNodeScaler("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;
|
2011-07-07 04:27:48 +00:00
|
|
|
|
private int _xTile;
|
|
|
|
|
private int _yTile;
|
|
|
|
|
private int _zTile;
|
2011-04-06 21:18:48 +00:00
|
|
|
|
|
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; }
|
2011-07-07 04:27:48 +00:00
|
|
|
|
set { _xTile = value; }
|
2011-04-06 21:18:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int TileY
|
|
|
|
|
{
|
|
|
|
|
get { return _yTile; }
|
2011-07-07 04:27:48 +00:00
|
|
|
|
set { _yTile = value; }
|
2011-04-06 21:18:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int TileZ
|
|
|
|
|
{
|
|
|
|
|
get { return _zTile; }
|
2011-07-07 04:27:48 +00:00
|
|
|
|
set { _zTile = value; }
|
2011-04-06 21:18:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public EntityPainting ()
|
|
|
|
|
: base("Painting")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-30 03:59:20 +00:00
|
|
|
|
public EntityPainting (EntityTyped e)
|
2011-04-06 21:18:48 +00:00
|
|
|
|
: 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-06-30 03:59:20 +00:00
|
|
|
|
public override EntityTyped LoadTree (TagNode tree)
|
2011-04-06 21:18:48 +00:00
|
|
|
|
{
|
2011-06-20 03:51:40 +00:00
|
|
|
|
TagNodeCompound ctree = tree as TagNodeCompound;
|
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();
|
2011-07-07 04:27:48 +00:00
|
|
|
|
_xTile = ctree["TileX"].ToTagInt();
|
|
|
|
|
_yTile = ctree["TileY"].ToTagInt();
|
|
|
|
|
_zTile = ctree["TileZ"].ToTagInt();
|
2011-04-06 21:18:48 +00:00
|
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-20 03:51:40 +00:00
|
|
|
|
public override TagNode BuildTree ()
|
2011-04-06 21:18:48 +00:00
|
|
|
|
{
|
2011-06-20 03:51:40 +00:00
|
|
|
|
TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
|
|
|
|
|
tree["Dir"] = new TagNodeByte((byte)_dir);
|
|
|
|
|
tree["Motive"] = new TagNodeString(_motive);
|
2011-07-07 04:27:48 +00:00
|
|
|
|
tree["TileX"] = new TagNodeInt(_xTile);
|
|
|
|
|
tree["TileY"] = new TagNodeInt(_yTile);
|
|
|
|
|
tree["TileZ"] = new TagNodeInt(_zTile);
|
2011-04-06 21:18:48 +00:00
|
|
|
|
|
|
|
|
|
return tree;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-20 03:51:40 +00:00
|
|
|
|
public override bool ValidateTree (TagNode tree)
|
2011-04-06 21:18:48 +00:00
|
|
|
|
{
|
2011-06-30 04:57:18 +00:00
|
|
|
|
return new NbtVerifier(tree, PaintingSchema).Verify();
|
2011-04-06 21:18:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region ICopyable<Entity> Members
|
|
|
|
|
|
2011-06-30 03:59:20 +00:00
|
|
|
|
public override EntityTyped Copy ()
|
2011-04-06 21:18:48 +00:00
|
|
|
|
{
|
|
|
|
|
return new EntityPainting(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|