forked from mirrors/NBTExplorer
Adding EntityAnimal base class and Animal-centric properties
This commit is contained in:
parent
a9c6ed9de9
commit
b2981ac04f
8 changed files with 105 additions and 10 deletions
|
@ -30,8 +30,8 @@ using System.Runtime.InteropServices;
|
|||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("1.0.1.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.1.0")]
|
||||
|
||||
// This library is compatible with all CLS-compliant .NET programming languages.
|
||||
[assembly: CLSCompliant(true)]
|
93
SubstrateCS/Source/Entities/EntityAnimal.cs
Normal file
93
SubstrateCS/Source/Entities/EntityAnimal.cs
Normal file
|
@ -0,0 +1,93 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace Substrate.Entities
|
||||
{
|
||||
public class EntityAnimal : EntityMob
|
||||
{
|
||||
public static readonly SchemaNodeCompound AnimalSchema = MobSchema.MergeInto(new SchemaNodeCompound("")
|
||||
{
|
||||
new SchemaNodeScaler("Age", TagType.TAG_INT, SchemaOptions.CREATE_ON_MISSING),
|
||||
new SchemaNodeScaler("InLove", TagType.TAG_INT, SchemaOptions.CREATE_ON_MISSING),
|
||||
});
|
||||
|
||||
private int _age;
|
||||
private int _inLove;
|
||||
|
||||
public int Age
|
||||
{
|
||||
get { return _age; }
|
||||
set { _age = value; }
|
||||
}
|
||||
|
||||
public int InLove
|
||||
{
|
||||
get { return _inLove; }
|
||||
set { _inLove = value; }
|
||||
}
|
||||
|
||||
protected EntityAnimal (string id)
|
||||
: base(id)
|
||||
{
|
||||
}
|
||||
|
||||
public EntityAnimal ()
|
||||
: this(TypeId)
|
||||
{
|
||||
}
|
||||
|
||||
public EntityAnimal (TypedEntity e)
|
||||
: base(e)
|
||||
{
|
||||
EntityAnimal e2 = e as EntityAnimal;
|
||||
if (e2 != null) {
|
||||
_age = e2._age;
|
||||
_inLove = e2._inLove;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region INBTObject<Entity> Members
|
||||
|
||||
public override TypedEntity LoadTree (TagNode tree)
|
||||
{
|
||||
TagNodeCompound ctree = tree as TagNodeCompound;
|
||||
if (ctree == null || base.LoadTree(tree) == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
_age = ctree["Age"].ToTagInt();
|
||||
_inLove = ctree["InLove"].ToTagInt();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public override TagNode BuildTree ()
|
||||
{
|
||||
TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
|
||||
tree["Age"] = new TagNodeInt(_age);
|
||||
tree["InLove"] = new TagNodeInt(_inLove);
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
public override bool ValidateTree (TagNode tree)
|
||||
{
|
||||
return new NbtVerifier(tree, AnimalSchema).Verify();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ICopyable<Entity> Members
|
||||
|
||||
public override TypedEntity Copy ()
|
||||
{
|
||||
return new EntityAnimal(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -6,9 +6,9 @@ namespace Substrate.Entities
|
|||
{
|
||||
using Substrate.Nbt;
|
||||
|
||||
public class EntityChicken : EntityMob
|
||||
public class EntityChicken : EntityAnimal
|
||||
{
|
||||
public static readonly SchemaNodeCompound ChickenSchema = MobSchema.MergeInto(new SchemaNodeCompound("")
|
||||
public static readonly SchemaNodeCompound ChickenSchema = AnimalSchema.MergeInto(new SchemaNodeCompound("")
|
||||
{
|
||||
new SchemaNodeString("id", TypeId),
|
||||
});
|
||||
|
|
|
@ -6,9 +6,9 @@ namespace Substrate.Entities
|
|||
{
|
||||
using Substrate.Nbt;
|
||||
|
||||
public class EntityPig : EntityMob
|
||||
public class EntityPig : EntityAnimal
|
||||
{
|
||||
public static readonly SchemaNodeCompound PigSchema = MobSchema.MergeInto(new SchemaNodeCompound("")
|
||||
public static readonly SchemaNodeCompound PigSchema = AnimalSchema.MergeInto(new SchemaNodeCompound("")
|
||||
{
|
||||
new SchemaNodeString("id", TypeId),
|
||||
new SchemaNodeScaler("Saddle", TagType.TAG_BYTE),
|
||||
|
|
|
@ -6,9 +6,9 @@ namespace Substrate.Entities
|
|||
{
|
||||
using Substrate.Nbt;
|
||||
|
||||
public class EntitySheep : EntityMob
|
||||
public class EntitySheep : EntityAnimal
|
||||
{
|
||||
public static readonly SchemaNodeCompound SheepSchema = MobSchema.MergeInto(new SchemaNodeCompound("")
|
||||
public static readonly SchemaNodeCompound SheepSchema = AnimalSchema.MergeInto(new SchemaNodeCompound("")
|
||||
{
|
||||
new SchemaNodeString("id", TypeId),
|
||||
new SchemaNodeScaler("Sheared", TagType.TAG_BYTE),
|
||||
|
|
|
@ -6,9 +6,9 @@ namespace Substrate.Entities
|
|||
{
|
||||
using Substrate.Nbt;
|
||||
|
||||
public class EntityWolf : EntityMob
|
||||
public class EntityWolf : EntityAnimal
|
||||
{
|
||||
public static readonly SchemaNodeCompound WolfSchema = MobSchema.MergeInto(new SchemaNodeCompound("")
|
||||
public static readonly SchemaNodeCompound WolfSchema = AnimalSchema.MergeInto(new SchemaNodeCompound("")
|
||||
{
|
||||
new SchemaNodeString("id", TypeId),
|
||||
new SchemaNodeScaler("Owner", TagType.TAG_STRING),
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
<Compile Include="Source\Data\MapManagerInterface.cs" />
|
||||
<Compile Include="Source\Enchantment.cs" />
|
||||
<Compile Include="Source\EnchantmentInfo.cs" />
|
||||
<Compile Include="Source\Entities\EntityAnimal.cs" />
|
||||
<Compile Include="Source\Entities\EntityBlaze.cs" />
|
||||
<Compile Include="Source\Entities\EntityCaveSpider.cs" />
|
||||
<Compile Include="Source\Entities\EntityEnderDragon.cs" />
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
<Compile Include="Source\Data\MapManagerInterface.cs" />
|
||||
<Compile Include="Source\Enchantment.cs" />
|
||||
<Compile Include="Source\EnchantmentInfo.cs" />
|
||||
<Compile Include="Source\Entities\EntityAnimal.cs" />
|
||||
<Compile Include="Source\Entities\EntityBlaze.cs" />
|
||||
<Compile Include="Source\Entities\EntityCaveSpider.cs" />
|
||||
<Compile Include="Source\Entities\EntityEnderDragon.cs" />
|
||||
|
|
Loading…
Reference in a new issue