using System; using System.Collections.Generic; using System.Text; namespace Substrate.Entities { using Substrate.Nbt; public class EntityCreeper : EntityMob { public static readonly SchemaNodeCompound CreeperSchema = MobSchema.MergeInto(new SchemaNodeCompound("") { new SchemaNodeString("id", "Creeper"), new SchemaNodeScaler("powered", TagType.TAG_BYTE, SchemaOptions.OPTIONAL), }); private bool? _powered; public bool Powered { get { return _powered ?? false; } set { _powered = value; } } public EntityCreeper () : base("Creeper") { } public EntityCreeper (EntityTyped e) : base(e) { EntityCreeper e2 = e as EntityCreeper; if (e2 != null) { _powered = e2._powered; } } #region INBTObject Members public override EntityTyped LoadTree (TagNode tree) { 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; } public override bool ValidateTree (TagNode tree) { return new NbtVerifier(tree, CreeperSchema).Verify(); } #endregion #region ICopyable Members public override EntityTyped Copy () { return new EntityCreeper(this); } #endregion } }