Added remaining entities. Fixed a few remaining namespace inconsistencies.

This commit is contained in:
Justin Aquadro 2011-04-06 22:01:22 +00:00
parent 2ac3252702
commit 50375d326d
18 changed files with 505 additions and 18 deletions

View file

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Substrate.Entities
{
using Substrate.NBT;
public class EntityBoat : Entity
{
public static readonly NBTCompoundNode BoatSchema = BaseSchema.MergeInto(new NBTCompoundNode("")
{
new NBTStringNode("id", "Boat"),
});
public EntityBoat ()
: base("Boat")
{
}
public EntityBoat (Entity e)
: base(e)
{
}
#region INBTObject<Entity> Members
public override bool ValidateTree (NBT_Value tree)
{
return new NBTVerifier(tree, BoatSchema).Verify();
}
#endregion
#region ICopyable<Entity> Members
public override Entity Copy ()
{
return new EntityBoat(this);
}
#endregion
}
}

View file

@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Substrate.Entities
{
using Substrate.NBT;
public class EntityFallingSand : Entity
{
public static readonly NBTCompoundNode FallingSandSchema = BaseSchema.MergeInto(new NBTCompoundNode("")
{
new NBTStringNode("id", "FallingSand"),
new NBTScalerNode("Tile", NBT_Type.TAG_BYTE),
});
private byte _tile;
public int Tile
{
get { return _tile; }
set { _tile = (byte)value; }
}
public EntityFallingSand ()
: base("PrimedTnt")
{
}
public EntityFallingSand (Entity e)
: base(e)
{
EntityFallingSand e2 = e as EntityFallingSand;
if (e2 != null) {
_tile = e2._tile;
}
}
#region INBTObject<Entity> Members
public override Entity LoadTree (NBT_Value tree)
{
NBT_Compound ctree = tree as NBT_Compound;
if (ctree == null || base.LoadTree(tree) == null) {
return null;
}
_tile = ctree["Tile"].ToNBTByte();
return this;
}
public override NBT_Value BuildTree ()
{
NBT_Compound tree = base.BuildTree() as NBT_Compound;
tree["Tile"] = new NBT_Byte(_tile);
return tree;
}
public override bool ValidateTree (NBT_Value tree)
{
return new NBTVerifier(tree, FallingSandSchema).Verify();
}
#endregion
#region ICopyable<Entity> Members
public override Entity Copy ()
{
return new EntityFallingSand(this);
}
#endregion
}
}

View file

@ -2,9 +2,9 @@
using System.Collections.Generic;
using System.Text;
namespace Substrate.Map.Entities
namespace Substrate.Entities
{
using Substrate.Map.NBT;
using Substrate.NBT;
public class EntityItem : Entity
{

View file

@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Substrate.Entities
{
using Substrate.NBT;
public class EntityMinecart : Entity
{
public enum CartType
{
EMPTY = 0,
CHEST = 1,
FURNACE = 2,
}
public static readonly NBTCompoundNode MinecartSchema = BaseSchema.MergeInto(new NBTCompoundNode("")
{
new NBTStringNode("id", "Minecart"),
new NBTScalerNode("Type", NBT_Type.TAG_BYTE),
});
private CartType _type;
public CartType Type
{
get { return _type; }
}
public EntityMinecart ()
: base("Minecart")
{
}
public EntityMinecart (Entity e)
: base(e)
{
EntityMinecart e2 = e as EntityMinecart;
if (e2 != null) {
_type = e2._type;
}
}
#region INBTObject<Entity> Members
public override Entity LoadTree (NBT_Value tree)
{
NBT_Compound ctree = tree as NBT_Compound;
if (ctree == null || base.LoadTree(tree) == null) {
return null;
}
_type = (CartType)ctree["Type"].ToNBTByte().Data;
switch (_type) {
case CartType.EMPTY:
return this;
case CartType.CHEST:
return new EntityMinecartChest().LoadTreeSafe(tree);
case CartType.FURNACE:
return new EntityMinecartFurnace().LoadTreeSafe(tree);
default:
return this;
}
}
public override NBT_Value BuildTree ()
{
NBT_Compound tree = base.BuildTree() as NBT_Compound;
tree["Type"] = new NBT_Byte((byte)_type);
return tree;
}
public override bool ValidateTree (NBT_Value tree)
{
return new NBTVerifier(tree, MinecartSchema).Verify();
}
#endregion
#region ICopyable<Entity> Members
public override Entity Copy ()
{
return new EntityMinecart(this);
}
#endregion
}
}

View file

@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Substrate.Entities
{
using Substrate.NBT;
public class EntityMinecartChest : EntityMinecart, IItemContainer
{
public static readonly NBTCompoundNode MinecartChestSchema = MinecartSchema.MergeInto(new NBTCompoundNode("")
{
new NBTListNode("Items", NBT_Type.TAG_COMPOUND, ItemCollection.InventorySchema),
});
private static int _CAPACITY = 27;
private ItemCollection _items;
public EntityMinecartChest ()
: base()
{
_items = new ItemCollection(_CAPACITY);
}
public EntityMinecartChest (Entity e)
: base(e)
{
EntityMinecartChest e2 = e as EntityMinecartChest;
if (e2 != null) {
_items = e2._items.Copy();
}
}
#region IItemContainer Members
public ItemCollection Items
{
get { return _items; }
}
#endregion
#region INBTObject<Entity> Members
public override Entity LoadTree (NBT_Value tree)
{
NBT_Compound ctree = tree as NBT_Compound;
if (ctree == null || base.LoadTree(tree) == null) {
return null;
}
NBT_List items = ctree["Items"].ToNBTList();
_items = _items.LoadTree(items);
return this;
}
public override NBT_Value BuildTree ()
{
NBT_Compound tree = base.BuildTree() as NBT_Compound;
tree["Items"] = _items.BuildTree();
return tree;
}
public override bool ValidateTree (NBT_Value tree)
{
return new NBTVerifier(tree, MinecartChestSchema).Verify();
}
#endregion
#region ICopyable<Entity> Members
public override Entity Copy ()
{
return new EntityMinecartChest(this);
}
#endregion
}
}

View file

@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Substrate.Entities
{
using Substrate.NBT;
public class EntityMinecartFurnace : EntityMinecart
{
public static readonly NBTCompoundNode MinecartFurnaceSchema = MinecartSchema.MergeInto(new NBTCompoundNode("")
{
new NBTScalerNode("PushX", NBT_Type.TAG_DOUBLE),
new NBTScalerNode("PushZ", NBT_Type.TAG_DOUBLE),
new NBTScalerNode("Fuel", NBT_Type.TAG_SHORT),
});
private double _pushX;
private double _pushZ;
private short _fuel;
public double PushX
{
get { return _pushX; }
set { _pushX = value; }
}
public double PushZ
{
get { return _pushZ; }
set { _pushZ = value; }
}
public int Fuel
{
get { return _fuel; }
set { _fuel = (short)value; }
}
public EntityMinecartFurnace ()
: base()
{
}
public EntityMinecartFurnace (Entity e)
: base(e)
{
EntityMinecartFurnace e2 = e as EntityMinecartFurnace;
if (e2 != null) {
_pushX = e2._pushX;
_pushZ = e2._pushZ;
_fuel = e2._fuel;
}
}
#region INBTObject<Entity> Members
public override Entity LoadTree (NBT_Value tree)
{
NBT_Compound ctree = tree as NBT_Compound;
if (ctree == null || base.LoadTree(tree) == null) {
return null;
}
_pushX = ctree["PushX"].ToNBTDouble();
_pushZ = ctree["PushZ"].ToNBTDouble();
_fuel = ctree["Fuel"].ToNBTShort();
return this;
}
public override NBT_Value BuildTree ()
{
NBT_Compound tree = base.BuildTree() as NBT_Compound;
tree["PushX"] = new NBT_Double(_pushX);
tree["PushZ"] = new NBT_Double(_pushZ);
tree["Fuel"] = new NBT_Short(_fuel);
return tree;
}
public override bool ValidateTree (NBT_Value tree)
{
return new NBTVerifier(tree, MinecartFurnaceSchema).Verify();
}
#endregion
#region ICopyable<Entity> Members
public override Entity Copy ()
{
return new EntityMinecartFurnace(this);
}
#endregion
}
}

View file

@ -2,9 +2,9 @@
using System.Collections.Generic;
using System.Text;
namespace Substrate.Map.Entities
namespace Substrate.Entities
{
using Substrate.Map.NBT;
using Substrate.NBT;
public class EntityMob : Entity
{

View file

@ -8,7 +8,7 @@ namespace Substrate.Entities
public class EntityPainting : Entity
{
public enum Direction
public enum DirectionType
{
EAST = 0,
NORTH = 1,
@ -26,13 +26,13 @@ namespace Substrate.Entities
new NBTScalerNode("Motive", NBT_Type.TAG_STRING),
});
private Direction _dir;
private DirectionType _dir;
private string _motive;
private short _xTile;
private short _yTile;
private short _zTile;
public Direction Direction
public DirectionType Direction
{
get { return _dir; }
set { _dir = value; }
@ -90,7 +90,7 @@ namespace Substrate.Entities
return null;
}
_dir = (Direction) ctree["Dir"].ToNBTByte().Data;
_dir = (DirectionType) ctree["Dir"].ToNBTByte().Data;
_motive = ctree["Motive"].ToNBTString();
_xTile = ctree["TileX"].ToNBTShort();
_yTile = ctree["TileY"].ToNBTShort();

View file

@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Substrate.Entities
{
using Substrate.NBT;
public class EntityPrimedTnt : Entity
{
public static readonly NBTCompoundNode PrimedTntSchema = BaseSchema.MergeInto(new NBTCompoundNode("")
{
new NBTStringNode("id", "PrimedTnt"),
new NBTScalerNode("Fuse", NBT_Type.TAG_BYTE),
});
private byte _fuse;
public int Fuse
{
get { return _fuse; }
set { _fuse = (byte)value; }
}
public EntityPrimedTnt ()
: base("PrimedTnt")
{
}
public EntityPrimedTnt (Entity e)
: base(e)
{
EntityPrimedTnt e2 = e as EntityPrimedTnt;
if (e2 != null) {
_fuse = e2._fuse;
}
}
#region INBTObject<Entity> Members
public override Entity LoadTree (NBT_Value tree)
{
NBT_Compound ctree = tree as NBT_Compound;
if (ctree == null || base.LoadTree(tree) == null) {
return null;
}
_fuse = ctree["Fuse"].ToNBTByte();
return this;
}
public override NBT_Value BuildTree ()
{
NBT_Compound tree = base.BuildTree() as NBT_Compound;
tree["Fuse"] = new NBT_Byte(_fuse);
return tree;
}
public override bool ValidateTree (NBT_Value tree)
{
return new NBTVerifier(tree, PrimedTntSchema).Verify();
}
#endregion
#region ICopyable<Entity> Members
public override Entity Copy ()
{
return new EntityPrimedTnt(this);
}
#endregion
}
}

View file

@ -2,9 +2,9 @@
using System.Collections.Generic;
using System.Text;
namespace Substrate.Map.Entities
namespace Substrate.Entities
{
using Substrate.Map.NBT;
using Substrate.NBT;
public class EntityThrowable : Entity
{

View file

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Substrate.Map
namespace Substrate
{
using NBT;
using Utility;

View file

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Substrate.Map
namespace Substrate
{
using NBT;
using Entities;
@ -55,18 +55,22 @@ namespace Substrate.Map
_registry = new Dictionary<string, Type>();
_registry["Arrow"] = typeof(EntityArrow);
_registry["Boat"] = typeof(EntityBoat);
_registry["Chicken"] = typeof(EntityChicken);
_registry["Cow"] = typeof(EntityCow);
_registry["Creeper"] = typeof(EntityCreeper);
_registry["Egg"] = typeof(EntityEgg);
_registry["FallingSand"] = typeof(EntityFallingSand);
_registry["Ghast"] = typeof(EntityGhast);
_registry["Giant"] = typeof(EntityGiant);
_registry["Item"] = typeof(EntityItem);
_registry["Minecart"] = typeof(EntityMinecart);
_registry["Mob"] = typeof(EntityMob);
_registry["Monster"] = typeof(EntityMonster);
_registry["Painting"] = typeof(EntityPainting);
_registry["Pig"] = typeof(EntityPig);
_registry["PigZombie"] = typeof(EntityPigZombie);
_registry["PrimedTnt"] = typeof(EntityPrimedTnt);
_registry["Sheep"] = typeof(EntitySheep);
_registry["Skeleton"] = typeof(EntitySkeleton);
_registry["Slime"] = typeof(EntitySlime);

View file

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Substrate.Map
namespace Substrate
{
using NBT;
using Utility;

View file

@ -6,7 +6,7 @@ using System.IO.Compression;
namespace Substrate.NBT
{
using Map.Utility;
using Substrate.Utility;
public interface INBTObject<T>
{

View file

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Substrate.Map.NBT
namespace Substrate.NBT
{
public abstract class NBTSchemaNode
{

View file

@ -4,7 +4,7 @@ using System.Text;
namespace Substrate.NBT {
using Map.Utility;
using Substrate.Utility;
/// <summary>
/// Describes the type of value held by an NBT_Tag

View file

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Substrate.Map
namespace Substrate
{
using NBT;
using Utility;

View file

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Substrate.Map
namespace Substrate
{
using NBT;
using TileEntities;