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
|
|
|
|
|
|
|
|
|
public class EntityCreeper : EntityMob
|
|
|
|
|
{
|
2011-06-20 03:51:40 +00:00
|
|
|
|
public static readonly SchemaNodeCompound CreeperSchema = MobSchema.MergeInto(new SchemaNodeCompound("")
|
2011-04-06 19:41:57 +00:00
|
|
|
|
{
|
2011-06-20 03:51:40 +00:00
|
|
|
|
new SchemaNodeString("id", "Creeper"),
|
2011-07-07 04:27:48 +00:00
|
|
|
|
new SchemaNodeScaler("powered", TagType.TAG_BYTE, SchemaOptions.OPTIONAL),
|
2011-04-06 19:41:57 +00:00
|
|
|
|
});
|
|
|
|
|
|
2011-07-07 04:27:48 +00:00
|
|
|
|
private bool? _powered;
|
|
|
|
|
|
|
|
|
|
public bool Powered
|
|
|
|
|
{
|
|
|
|
|
get { return _powered ?? false; }
|
|
|
|
|
set { _powered = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-06 19:41:57 +00:00
|
|
|
|
public EntityCreeper ()
|
|
|
|
|
: base("Creeper")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-05 17:36:04 +00:00
|
|
|
|
protected EntityCreeper (string id)
|
|
|
|
|
: base(id)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-14 19:34:49 +00:00
|
|
|
|
public EntityCreeper (TypedEntity e)
|
2011-04-06 19:41:57 +00:00
|
|
|
|
: base(e)
|
|
|
|
|
{
|
2011-07-07 04:27:48 +00:00
|
|
|
|
EntityCreeper e2 = e as EntityCreeper;
|
|
|
|
|
if (e2 != null) {
|
|
|
|
|
_powered = e2._powered;
|
|
|
|
|
}
|
2011-04-06 19:41:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region INBTObject<Entity> Members
|
|
|
|
|
|
2011-08-14 19:34:49 +00:00
|
|
|
|
public override TypedEntity LoadTree (TagNode tree)
|
2011-07-07 04:27:48 +00:00
|
|
|
|
{
|
|
|
|
|
TagNodeCompound ctree = tree as TagNodeCompound;
|
|
|
|
|
if (ctree == null || base.LoadTree(tree) == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ctree.ContainsKey("powered")) {
|
|
|
|
|
_powered = ctree["powered"].ToTagByte() == 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override TagNode BuildTree ()
|
|
|
|
|
{
|
|
|
|
|
TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
|
|
|
|
|
|
|
|
|
|
if (_powered != null) {
|
|
|
|
|
tree["powered"] = new TagNodeByte((byte)((_powered ?? false) ? 1 : 0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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, CreeperSchema).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 EntityCreeper(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|