Added XML comments to most types/fields/methods in the TrueCraft.API namespace

This commit is contained in:
William Moorehouse 2015-06-11 23:06:00 -04:00
parent 7ccdd2944a
commit fae1cd6c67
20 changed files with 1021 additions and 17 deletions

View File

@ -5,12 +5,34 @@ using System.Text;
namespace TrueCraft.API
{
/// <summary>
/// Enumerates the materials armor can be crafted from.
/// </summary>
public enum ArmorMaterial
{
/// <summary>
/// The armor is made of leather.
/// </summary>
Leather,
/// <summary>
/// The armor is made of chain (fire).
/// </summary>
Chain,
/// <summary>
/// The armor is made of iron ingots.
/// </summary>
Iron,
/// <summary>
/// The armor is made of gold ingots.
/// </summary>
Gold,
/// <summary>
/// The armor is made of diamonds.
/// </summary>
Diamond
}
}

View File

@ -5,27 +5,119 @@ using System.Text;
namespace TrueCraft.API
{
/// <summary>
/// Enumerates the biomes in TrueCraft.
/// </summary>
/// <remarks>
/// The 13 vanilla b1.7.3 biomes as found on http://b.wiki.vg/json/b1.7
/// </remarks>
public enum Biome
{
//The 13 vanilla b1.7.3 biomes as found on http://b.wiki.vg/json/b1.7
/// <summary>
/// A plains biome.
/// </summary>
Plains = 0,
/// <summary>
/// A desert biome.
/// </summary>
Desert = 1,
/// <summary>
/// A forest biome.
/// </summary>
Forest = 2,
/// <summary>
/// A rainforest biome.
/// </summary>
Rainforest = 3,
/// <summary>
/// A seasonal forest biome.
/// </summary>
SeasonalForest = 4,
/// <summary>
/// A savanna biome.
/// </summary>
Savanna = 5,
/// <summary>
/// A shrubland biome.
/// </summary>
Shrubland = 6,
/// <summary>
/// A swampland biome.
/// </summary>
Swampland = 7,
/// <summary>
/// A Nether biome.
/// </summary>
Hell = 8,
Sky = 9,//Implementation into truecraft is undetermined at this point
/// <summary>
/// An End biome.
/// </summary>
/// <remarks>
/// Implementation into TrueCraft is undetermined at this point
/// </remarks>
Sky = 9,
/// <summary>
/// A taiga biome.
/// </summary>
Taiga = 10,
/// <summary>
/// A tundra biome.
/// </summary>
Tundra = 11,
IceDesert = 12,//Implementation into truecraft is undetermined at this point
/// <summary>
/// An ice desert biome.
/// </summary>
/// <remarks>
/// Implementation into TrueCraft is undetermined at this point
/// </remarks>
IceDesert = 12,
//Below are "transitional" biomes/biomes which are not in b1.7.3
/// <summary>
/// An ocean biome.
/// </summary>
Ocean = 13,
River = 14,//Implementation into truecraft is undetermined at this point
Beach = 15,//Implementation into truecraft is undetermined at this point
/// <summary>
/// A river biome.
/// </summary>
/// <remarks>
/// Implementation into TrueCraft is undetermined at this point
/// </remarks>
River = 14,
/// <summary>
/// A beach biome.
/// </summary>
/// <remarks>
/// Implementation into TrueCraft is undetermined at this point
/// </remarks>
Beach = 15,
/// <summary>
/// A frozen ocean biome.
/// </summary>
FrozenOcean = 16,
FrozenRiver = 17,//Implementation into truecraft is undetermined at this point
/// <summary>
/// A frozen river biome.
/// </summary>
/// <remarks>
/// Implementation into TrueCraft is undetermined at this point
/// </remarks>
FrozenRiver = 17,
}
}

View File

@ -2,13 +2,39 @@ using System;
namespace TrueCraft.API
{
/// <summary>
/// Enumerates the directions of block faces.
/// </summary>
public enum BlockFace
{
/// <summary>
/// The block face points towards -Y.
/// </summary>
NegativeY = 0,
/// <summary>
/// The block face points towards +Y.
/// </summary>
PositiveY = 1,
/// <summary>
/// The block face points towards -Z.
/// </summary>
NegativeZ = 2,
/// <summary>
/// The block face points towards +Z.
/// </summary>
PositiveZ = 3,
/// <summary>
/// The block face points towards -X.
/// </summary>
NegativeX = 4,
/// <summary>
/// The block face points towards +X.
/// </summary>
PositiveX = 5
}
}

View File

@ -5,20 +5,50 @@ using System.Text;
namespace TrueCraft.API
{
/// <summary>
/// Enumerates the different types of containment between two bounding boxes.
/// </summary>
public enum ContainmentType
{
/// <summary>
/// The two bounding boxes are disjoint.
/// </summary>
Disjoint,
/// <summary>
/// One bounding box contains the other.
/// </summary>
Contains,
/// <summary>
/// The two bounding boxes intersect.
/// </summary>
Intersects
}
// Mostly taken from the MonoXna project, which is licensed under the MIT license
/// <summary>
/// Represents an axis-aligned bounding box.
/// </summary>
/// <remarks>
/// Mostly taken from the MonoXna project, which is licensed under the MIT license
/// </remarks>
public struct BoundingBox : IEquatable<BoundingBox>
{
#region Public Fields
/// <summary>
/// The minimum vector for the bounding box.
/// </summary>
public Vector3 Min;
/// <summary>
/// The maximum vector for the bounding box.
/// </summary>
public Vector3 Max;
/// <summary>
/// The number of corners a bounding box has.
/// </summary>
public const int CornerCount = 8;
#endregion Public Fields
@ -26,12 +56,21 @@ namespace TrueCraft.API
#region Public Constructors
/// <summary>
/// Creates a new bounding box from specified values
/// </summary>
/// <param name="min">The minimum vector for the bounding box.</param>
/// <param name="max">The number of corners a bounding box has.</param>
public BoundingBox(Vector3 min, Vector3 max)
{
this.Min = min;
this.Max = max;
}
/// <summary>
/// Creates a new bounding box by copying another.
/// </summary>
/// <param name="b">The bounding box to clone.</param>
public BoundingBox(BoundingBox b)
{
this.Min = new Vector3(b.Min);
@ -43,6 +82,11 @@ namespace TrueCraft.API
#region Public Methods
/// <summary>
/// Determines the type of containment between this and another bounding box.
/// </summary>
/// <param name="box">The other bounding box.</param>
/// <returns></returns>
public ContainmentType Contains(BoundingBox box)
{
//test if all corner is in the same side of a face by just checking min and max
@ -66,6 +110,11 @@ namespace TrueCraft.API
return ContainmentType.Intersects;
}
/// <summary>
/// Determines whether the specified vector is contained within this bounding box.
/// </summary>
/// <param name="vec">The vector.</param>
/// <returns></returns>
public bool Contains(Vector3 vec)
{
return Min.X <= vec.X && vec.X <= Max.X &&
@ -73,6 +122,11 @@ namespace TrueCraft.API
Min.Z <= vec.Z && vec.Z <= Max.Z;
}
/// <summary>
/// Creates and returns a new bounding box from an enumeration of corner points.
/// </summary>
/// <param name="points">The enumeration of corner points.</param>
/// <returns></returns>
public static BoundingBox CreateFromPoints(IEnumerable<Vector3> points)
{
if (points == null)
@ -107,6 +161,10 @@ namespace TrueCraft.API
return new BoundingBox(Min + Offset, Max + Offset);
}
/// <summary>
/// Returns an array of vectors containing the corners of this bounding box.
/// </summary>
/// <returns></returns>
public Vector3[] GetCorners()
{
return new Vector3[]
@ -122,21 +180,40 @@ namespace TrueCraft.API
};
}
/// <summary>
/// Determines whether this and another bounding box are equal.
/// </summary>
/// <param name="other">The other bounding box.</param>
/// <returns></returns>
public bool Equals(BoundingBox other)
{
return (this.Min == other.Min) && (this.Max == other.Max);
}
/// <summary>
/// Determines whether this and another object are equal.
/// </summary>
/// <param name="obj">The other object.</param>
/// <returns></returns>
public override bool Equals(object obj)
{
return (obj is BoundingBox) && this.Equals((BoundingBox)obj);
}
/// <summary>
/// Returns the hash code for this bounding box.
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return this.Min.GetHashCode() + this.Max.GetHashCode();
}
/// <summary>
/// Determines whether this bounding box intersects another.
/// </summary>
/// <param name="box">The other bounding box.</param>
/// <returns></returns>
public bool Intersects(BoundingBox box)
{
bool result;
@ -144,6 +221,11 @@ namespace TrueCraft.API
return result;
}
/// <summary>
/// Determines whether this bounding box intersects another.
/// </summary>
/// <param name="box">The other bounding box.</param>
/// <param name="result">Set to whether the two bounding boxes intersect.</param>
public void Intersects(ref BoundingBox box, out bool result)
{
if ((this.Max.X > box.Min.X) && (this.Min.X < box.Max.X))
@ -171,6 +253,10 @@ namespace TrueCraft.API
return !a.Equals(b);
}
/// <summary>
/// Returns a string representation of this bounding box.
/// </summary>
/// <returns></returns>
public override string ToString()
{
return string.Format("{{Min:{0} Max:{1}}}", this.Min.ToString(), this.Max.ToString());
@ -178,21 +264,33 @@ namespace TrueCraft.API
#endregion
/// <summary>
/// Gets the height of this bounding box.
/// </summary>
public double Height
{
get { return Max.Y - Min.Y; }
}
/// <summary>
/// Gets the width of this bounding box.
/// </summary>
public double Width
{
get { return Max.X - Min.X; }
}
/// <summary>
/// Gets the depth of this bounding box.
/// </summary>
public double Depth
{
get { return Max.Z - Min.Z; }
}
/// <summary>
/// Gets the center of this bounding box.
/// </summary>
public Vector3 Center
{
get

View File

@ -5,25 +5,96 @@ using System.Text;
namespace TrueCraft.API
{
/// <summary>
/// Provides constants and functions for working with chat colors.
/// </summary>
public static class ChatColor
{
/// <summary>
/// The color code for black.
/// </summary>
public const string Black = "§0";
/// <summary>
/// The color code for dark blue.
/// </summary>
public const string DarkBlue = "§1";
/// <summary>
/// The color code for dark green.
/// </summary>
public const string DarkGreen = "§2";
/// <summary>
/// The color code for dark cyan.
/// </summary>
public const string DarkCyan = "§3";
/// <summary>
/// The color code for dark red.
/// </summary>
public const string DarkRed = "§4";
/// <summary>
/// The color code for dark purple.
/// </summary>
public const string Purple = "§5";
/// <summary>
/// The color code for dark orange.
/// </summary>
public const string Orange = "§6";
/// <summary>
/// The color code for gray.
/// </summary>
public const string Gray = "§7";
/// <summary>
/// The color code for dark gray.
/// </summary>
public const string DarkGray = "§8";
/// <summary>
/// The color code for blue.
/// </summary>
public const string Blue = "§9";
/// <summary>
/// The color code for bright green.
/// </summary>
public const string BrightGreen = "§a";
/// <summary>
/// The color code for cyan.
/// </summary>
public const string Cyan = "§b";
/// <summary>
/// The color code for red.
/// </summary>
public const string Red = "§c";
/// <summary>
/// The color code for pink.
/// </summary>
public const string Pink = "§d";
/// <summary>
/// The color code for yellow.
/// </summary>
public const string Yellow = "§e";
/// <summary>
/// The color code for white.
/// </summary>
public const string White = "§f";
/// <summary>
/// Removes the color codes from the specified string.
/// </summary>
/// <param name="text">The string to remove color codes from.</param>
/// <returns></returns>
public static string RemoveColors(string text)
{
var sb = new StringBuilder(text.Length);

View File

@ -3,8 +3,17 @@ using YamlDotNet.Serialization;
namespace TrueCraft.API
{
/// <summary>
/// Abstract base class for configurations read from YAML files.
/// </summary>
public abstract class Configuration
{
/// <summary>
/// Creates and returns a new configuration read from a YAML file.
/// </summary>
/// <typeparam name="T">The configuration type.</typeparam>
/// <param name="configFileName">The path to the YAML file.</param>
/// <returns></returns>
public static T LoadConfiguration<T>(string configFileName) where T : new()
{
T config;

View File

@ -2,21 +2,45 @@
namespace TrueCraft.API
{
/// <summary>
/// Represents a tuple of 2D coordinates.
/// </summary>
public struct Coordinates2D : IEquatable<Coordinates2D>
{
public int X, Z;
/// <summary>
/// The X component of the coordinates.
/// </summary>
public int X;
/// <summary>
/// The Y component of the coordinates.
/// </summary>
public int Z;
/// <summary>
/// Creates a new pair of coordinates from the specified value.
/// </summary>
/// <param name="value">The value for the components of the coordinates.</param>
public Coordinates2D(int value)
{
X = Z = value;
}
/// <summary>
/// Creates a new pair of coordinates from the specified values.
/// </summary>
/// <param name="x">The X component of the coordinates.</param>
/// <param name="z">The Y component of the coordinates.</param>
public Coordinates2D(int x, int z)
{
X = x;
Z = z;
}
/// <summary>
/// Creates a new pair of coordinates by copying another.
/// </summary>
/// <param name="v">The coordinates to copy.</param>
public Coordinates2D(Coordinates2D v)
{
X = v.X;
@ -24,7 +48,7 @@ namespace TrueCraft.API
}
/// <summary>
/// Converts this Coordinates2D to a string in the format &lt;x,z&gt;.
/// Returns the string representation of this 2D coordinates.
/// </summary>
/// <returns></returns>
public override string ToString()
@ -62,6 +86,12 @@ namespace TrueCraft.API
}
}
/// <summary>
/// Returns the component-wise minimum of two 2D coordinates.
/// </summary>
/// <param name="value1">The first coordinates.</param>
/// <param name="value2">The second coordinates.</param>
/// <returns></returns>
public static Coordinates2D Min(Coordinates2D value1, Coordinates2D value2)
{
return new Coordinates2D(
@ -70,6 +100,12 @@ namespace TrueCraft.API
);
}
/// <summary>
/// Returns the component-wise maximum of two 2D coordinates.
/// </summary>
/// <param name="value1">The first coordinates.</param>
/// <param name="value2">The second coordinates.</param>
/// <returns></returns>
public static Coordinates2D Max(Coordinates2D value1, Coordinates2D value2)
{
return new Coordinates2D(
@ -183,21 +219,54 @@ namespace TrueCraft.API
#region Constants
/// <summary>
/// A pair of 2D coordinates with components set to 0.0.
/// </summary>
public static readonly Coordinates2D Zero = new Coordinates2D(0);
/// <summary>
/// A pair of 2D coordinates with components set to 1.0.
/// </summary>
public static readonly Coordinates2D One = new Coordinates2D(1);
/// <summary>
/// A pair of 2D coordinates facing forwards.
/// </summary>
public static readonly Coordinates2D Forward = new Coordinates2D(0, 1);
/// <summary>
/// A pair of 2D coordinates facing backwards.
/// </summary>
public static readonly Coordinates2D Backward = new Coordinates2D(0, -1);
/// <summary>
/// A pair of 2D coordinates facing left.
/// </summary>
public static readonly Coordinates2D Left = new Coordinates2D(-1, 0);
/// <summary>
/// A pair of 2D coordinates facing right.
/// </summary>
public static readonly Coordinates2D Right = new Coordinates2D(1, 0);
#endregion
/// <summary>
/// Determines whether this 2D coordinates and another are equal.
/// </summary>
/// <param name="other">The other coordinates.</param>
/// <returns></returns>
public bool Equals(Coordinates2D other)
{
return other.X.Equals(X) && other.Z.Equals(Z);
}
/// <summary>
/// Determines whether this and another object are equal.
/// </summary>
/// <param name="obj">The other object.</param>
/// <returns></returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
@ -205,6 +274,10 @@ namespace TrueCraft.API
return Equals((Coordinates2D)obj);
}
/// <summary>
/// Returns the hash code for this 2D coordinates.
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
unchecked

View File

@ -5,15 +5,42 @@ using System.Text;
namespace TrueCraft.API
{
/// <summary>
/// Represents a tuple of 3D coordinates.
/// </summary>
public struct Coordinates3D : IEquatable<Coordinates3D>
{
public int X, Y, Z;
/// <summary>
/// The X component of the coordinates.
/// </summary>
public int X;
/// <summary>
/// The Y component of the coordinates.
/// </summary>
public int Y;
/// <summary>
/// The Z component of the coordinates.
/// </summary>
public int Z;
/// <summary>
/// Creates a new trio of coordinates from the specified value.
/// </summary>
/// <param name="value">The value for the components of the coordinates.</param>
public Coordinates3D(int value)
{
X = Y = Z = value;
}
/// <summary>
/// Creates a new trio of coordinates from the specified values.
/// </summary>
/// <param name="x">The X component of the coordinates.</param>
/// <param name="z">The Y component of the coordinates.</param>
/// <param name="z">The Z component of the coordinates.</param>
public Coordinates3D(int x = 0, int y = 0, int z = 0)
{
X = x;
@ -21,6 +48,10 @@ namespace TrueCraft.API
Z = z;
}
/// <summary>
/// Creates a new trio of coordinates by copying another.
/// </summary>
/// <param name="v">The coordinates to copy.</param>
public Coordinates3D(Coordinates3D v)
{
X = v.X;
@ -83,6 +114,12 @@ namespace TrueCraft.API
}
}
/// <summary>
/// Returns the component-wise minimum of two 3D coordinates.
/// </summary>
/// <param name="value1">The first coordinates.</param>
/// <param name="value2">The second coordinates.</param>
/// <returns></returns>
public static Coordinates3D Min(Coordinates3D value1, Coordinates3D value2)
{
return new Coordinates3D(
@ -92,6 +129,12 @@ namespace TrueCraft.API
);
}
/// <summary>
/// Returns the component-wise maximum of two 3D coordinates.
/// </summary>
/// <param name="value1">The first coordinates.</param>
/// <param name="value2">The second coordinates.</param>
/// <returns></returns>
public static Coordinates3D Max(Coordinates3D value1, Coordinates3D value2)
{
return new Coordinates3D(
@ -222,32 +265,101 @@ namespace TrueCraft.API
#region Constants
/// <summary>
/// A trio of 3D coordinates with components set to 0.0.
/// </summary>
public static readonly Coordinates3D Zero = new Coordinates3D(0);
/// <summary>
/// A trio of 3D coordinates with components set to 0.0.
/// </summary>
public static readonly Coordinates3D One = new Coordinates3D(1);
/// <summary>
/// A trio of 3D coordinates facing up.
/// </summary>
public static readonly Coordinates3D Up = new Coordinates3D(0, 1, 0);
/// <summary>
/// A trio of 3D coordinates facing down.
/// </summary>
public static readonly Coordinates3D Down = new Coordinates3D(0, -1, 0);
/// <summary>
/// A trio of 3D coordinates facing left.
/// </summary>
public static readonly Coordinates3D Left = new Coordinates3D(-1, 0, 0);
/// <summary>
/// A trio of 3D coordinates facing right.
/// </summary>
public static readonly Coordinates3D Right = new Coordinates3D(1, 0, 0);
/// <summary>
/// A trio of 3D coordinates facing backwards.
/// </summary>
public static readonly Coordinates3D Backwards = new Coordinates3D(0, 0, -1);
/// <summary>
/// A trio of 3D coordinates facing forwards.
/// </summary>
public static readonly Coordinates3D Forwards = new Coordinates3D(0, 0, 1);
/// <summary>
/// A trio of 3D coordinates facing to the east.
/// </summary>
public static readonly Coordinates3D East = new Coordinates3D(1, 0, 0);
/// <summary>
/// A trio of 3D coordinates facing to the west.
/// </summary>
public static readonly Coordinates3D West = new Coordinates3D(-1, 0, 0);
/// <summary>
/// A trio of 3D coordinates facing to the north.
/// </summary>
public static readonly Coordinates3D North = new Coordinates3D(0, 0, -1);
/// <summary>
/// A trio of 3D coordinates facing to the south.
/// </summary>
public static readonly Coordinates3D South = new Coordinates3D(0, 0, 1);
/// <summary>
/// A trio of 3D coordinates facing the X axis at unit length.
/// </summary>
public static readonly Coordinates3D OneX = new Coordinates3D(1, 0, 0);
/// <summary>
/// A trio of 3D coordinates facing the Y axis at unit length.
/// </summary>
public static readonly Coordinates3D OneY = new Coordinates3D(0, 1, 0);
/// <summary>
/// A trio of 3D coordinates facing the Z axis at unit length.
/// </summary>
public static readonly Coordinates3D OneZ = new Coordinates3D(0, 0, 1);
#endregion
/// <summary>
/// Determines whether this 3D coordinates and another are equal.
/// </summary>
/// <param name="other">The other coordinates.</param>
/// <returns></returns>
public bool Equals(Coordinates3D other)
{
return other.X.Equals(X) && other.Y.Equals(Y) && other.Z.Equals(Z);
}
/// <summary>
/// Determines whether this and another object are equal.
/// </summary>
/// <param name="obj">The other object.</param>
/// <returns></returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
@ -255,6 +367,10 @@ namespace TrueCraft.API
return Equals((Coordinates3D)obj);
}
/// <summary>
/// Returns the hash code for this 3D coordinates.
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
unchecked

View File

@ -2,11 +2,29 @@
namespace TrueCraft.API
{
/// <summary>
/// Enumerates the difficulty levels in TrueCraft.
/// </summary>
public enum Difficulty
{
/// <summary>
/// Peaceful difficulty.
/// </summary>
Peaceful = 0,
/// <summary>
/// Easy difficulty.
/// </summary>
Easy = 1,
/// <summary>
/// Normal difficulty.
/// </summary>
Normal = 2,
/// <summary>
/// Hard difficulty.
/// </summary>
Hard = 3
}
}

View File

@ -2,9 +2,19 @@
namespace TrueCraft.API
{
/// <summary>
/// Enumerates the different dimensions in the world in TrueCraft.
/// </summary>
public enum Dimension
{
/// <summary>
/// The Nether dimension.
/// </summary>
Nether = -1,
/// <summary>
/// The Overworld dimension.
/// </summary>
Overworld = 0
}
}

View File

@ -2,9 +2,19 @@
namespace TrueCraft.API
{
/// <summary>
/// Enumerates the different game modes in TrueCraft.
/// </summary>
public enum GameMode
{
/// <summary>
/// The survival game mode.
/// </summary>
Survival = 0,
/// <summary>
/// The creative game mode.
/// </summary>
Creative = 1
}
}

View File

@ -3,10 +3,24 @@ using TrueCraft.API.Networking;
namespace TrueCraft.API
{
/// <summary>
/// Interface for objects providing server access configuration.
/// </summary>
public interface IAccessConfiguration
{
/// <summary>
/// Gets a list of blacklisted players for the configuration.
/// </summary>
IList<string> Blacklist { get; }
/// <summary>
/// Gets a list of whitelisted players for the configuration.
/// </summary>
IList<string> Whitelist { get; }
/// <summary>
/// Gets a list of opped players for the configuration.
/// </summary>
IList<string> Oplist { get; }
}
}

View File

@ -10,8 +10,15 @@ using TrueCraft.API.Networking;
namespace TrueCraft.API
{
/// <summary>
/// Represents a stack of items.
/// </summary>
public struct ItemStack : ICloneable, IEquatable<ItemStack>
{
/// <summary>
/// Returns the hash code for this item stack.
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
unchecked
@ -35,6 +42,10 @@ namespace TrueCraft.API
return !left.Equals(right);
}
/// <summary>
/// Creates a new item stack with the specified values.
/// </summary>
/// <param name="id">The item ID for the item stack.</param>
public ItemStack(short id) : this()
{
_Id = id;
@ -44,16 +55,34 @@ namespace TrueCraft.API
Index = 0;
}
/// <summary>
/// Creates a new item stack with the specified values.
/// </summary>
/// <param name="id">The item ID for the item stack.</param>
/// <param name="count">The item count for the item stack.</param>
public ItemStack(short id, sbyte count) : this(id)
{
Count = count;
}
/// <summary>
/// Creates a new item stack with the specified values.
/// </summary>
/// <param name="id">The item ID for the item stack.</param>
/// <param name="count">The item count for the item stack.</param>
/// <param name="metadata">The metadata for the item stack.</param>
public ItemStack(short id, sbyte count, short metadata) : this(id, count)
{
Metadata = metadata;
}
/// <summary>
/// Creates a new item stack with the specified values.
/// </summary>
/// <param name="id">The item ID for the item stack.</param>
/// <param name="count">The item count for the item stack.</param>
/// <param name="metadata">The metadata for the item stack.</param>
/// <param name="nbt">The NBT compound tag for the item stack.</param>
public ItemStack(short id, sbyte count, short metadata, NbtCompound nbt) : this(id, count, metadata)
{
Nbt = nbt;
@ -65,6 +94,11 @@ namespace TrueCraft.API
}
}
/// <summary>
/// Creates and returns a new item stack read from a Minecraft stream.
/// </summary>
/// <param name="stream">The stream to read from.</param>
/// <returns></returns>
public static ItemStack FromStream(IMinecraftStream stream)
{
var slot = ItemStack.EmptyStack;
@ -84,6 +118,10 @@ namespace TrueCraft.API
return slot;
}
/// <summary>
/// Writes this item stack to a Minecraft stream.
/// </summary>
/// <param name="stream">The stream to write to.</param>
public void WriteTo(IMinecraftStream stream)
{
stream.WriteInt16(ID);
@ -103,6 +141,11 @@ namespace TrueCraft.API
stream.WriteUInt8Array(mStream.GetBuffer());
}
/// <summary>
/// Creates and returns a new item stack created from an NBT compound tag.
/// </summary>
/// <param name="compound">The compound tag to create the item stack from.</param>
/// <returns></returns>
public static ItemStack FromNbt(NbtCompound compound)
{
var s = ItemStack.EmptyStack;
@ -115,6 +158,10 @@ namespace TrueCraft.API
return s;
}
/// <summary>
/// Creates and returns a new NBT compound tag containing this item stack.
/// </summary>
/// <returns></returns>
public NbtCompound ToNbt()
{
var c = new NbtCompound();
@ -127,12 +174,18 @@ namespace TrueCraft.API
return c;
}
/// <summary>
/// Gets whether this item stack is empty.
/// </summary>
[NbtIgnore]
public bool Empty
{
get { return ID == -1; }
}
/// <summary>
/// Gets or sets the item ID for this item stack.
/// </summary>
public short ID
{
get { return _Id; }
@ -148,6 +201,9 @@ namespace TrueCraft.API
}
}
/// <summary>
/// Gets or sets the item count for this item stack.
/// </summary>
public sbyte Count
{
get { return _Count; }
@ -163,6 +219,9 @@ namespace TrueCraft.API
}
}
/// <summary>
/// Gets or sets the metadata for this item stack.
/// </summary>
public short Metadata
{
get { return _Metadata; }
@ -172,11 +231,23 @@ namespace TrueCraft.API
private short _Id;
private sbyte _Count;
private short _Metadata;
/// <summary>
/// The NBT compound tag for this item stack, if any.
/// </summary>
[IgnoreOnNull]
public NbtCompound Nbt { get; set; }
/// <summary>
/// The index (slot) of this item stack in an inventory.
/// </summary>
[NbtIgnore]
public int Index;
/// <summary>
/// Returns the string representation of this item stack.
/// </summary>
/// <returns></returns>
public override string ToString()
{
if (Empty)
@ -188,11 +259,18 @@ namespace TrueCraft.API
return "(" + result + ")";
}
/// <summary>
/// Returns a clone of this item stack.
/// </summary>
/// <returns></returns>
public object Clone()
{
return new ItemStack(ID, Count, Metadata, Nbt);
}
/// <summary>
/// Gets an empty item stack.
/// </summary>
[NbtIgnore]
public static ItemStack EmptyStack
{
@ -202,6 +280,11 @@ namespace TrueCraft.API
}
}
/// <summary>
/// Determines whether this item stack can merge with another.
/// </summary>
/// <param name="other">The other item stack.</param>
/// <returns></returns>
public bool CanMerge(ItemStack other)
{
if (this.Empty || other.Empty)
@ -209,12 +292,22 @@ namespace TrueCraft.API
return _Id == other._Id && _Metadata == other._Metadata && Equals(Nbt, other.Nbt);
}
/// <summary>
/// Determines whether this item stack and another object are equal.
/// </summary>
/// <param name="obj">The other object.</param>
/// <returns></returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is ItemStack && Equals((ItemStack)obj);
}
/// <summary>
/// Determines whether this item stack and another are equal.
/// </summary>
/// <param name="other">The other item stack.</param>
/// <returns></returns>
public bool Equals(ItemStack other)
{
return _Id == other._Id && _Count == other._Count && _Metadata == other._Metadata && Index == other.Index && Equals(Nbt, other.Nbt);

View File

@ -5,13 +5,39 @@ using System.Text;
namespace TrueCraft.API
{
/// <summary>
/// Enumerates the different types of ore in TrueCraft.
/// </summary>
public enum OreTypes
{
/// <summary>
/// Coal ore.
/// </summary>
Coal,
/// <summary>
/// Lapis lazuli ore.
/// </summary>
Lapiz,
/// <summary>
/// Iron ore.
/// </summary>
Iron,
/// <summary>
/// Gold ore.
/// </summary>
Gold,
/// <summary>
/// Redstone ore.
/// </summary>
Redstone,
/// <summary>
/// Diamond ore.
/// </summary>
Diamond
}
}

View File

@ -5,14 +5,44 @@ using System.Text;
namespace TrueCraft.API
{
/// <summary>
/// Enumerates the different species of plants in TrueCraft.
/// </summary>
public enum PlantSpecies
{
/// <summary>
/// Rose flower.
/// </summary>
Rose,
/// <summary>
/// Dandelion flower.
/// </summary>
Dandelion,
/// <summary>
/// Tall grass.
/// </summary>
TallGrass,
/// <summary>
/// Fern.
/// </summary>
Fern,
/// <summary>
/// Dead bush.
/// </summary>
Deadbush,
/// <summary>
/// Cactus.
/// </summary>
Cactus,
/// <summary>
/// Sugarcane.
/// </summary>
SugarCane,
}
}

View File

@ -5,12 +5,24 @@ using System.Text;
namespace TrueCraft.API
{
// Mostly taken from the MonoXna project, which is licensed under the MIT license
/// <summary>
/// Represents a ray; a line with a start and direction, but no end.
/// </summary>
/// <remarks>
/// Mostly taken from the MonoXna project, which is licensed under the MIT license
/// </remarks>
public struct Ray : IEquatable<Ray>
{
#region Public Fields
/// <summary>
/// The direction of the ray.
/// </summary>
public readonly Vector3 Direction;
/// <summary>
/// The position of the ray (its origin).
/// </summary>
public readonly Vector3 Position;
#endregion
@ -18,6 +30,11 @@ namespace TrueCraft.API
#region Public Constructors
/// <summary>
/// Creates a new ray from specified values.
/// </summary>
/// <param name="position">The position of the ray (its origin).</param>
/// <param name="direction">The direction of the ray.</param>
public Ray(Vector3 position, Vector3 direction)
{
this.Position = position;
@ -29,23 +46,41 @@ namespace TrueCraft.API
#region Public Methods
/// <summary>
/// Determines whether this and another object are equal.
/// </summary>
/// <param name="obj">The other object.</param>
/// <returns></returns>
public override bool Equals(object obj)
{
return (obj is Ray) && Equals((Ray)obj);
}
/// <summary>
/// Determines whether this and another ray are equal.
/// </summary>
/// <param name="other">The other ray.</param>
/// <returns></returns>
public bool Equals(Ray other)
{
return Position.Equals(other.Position) && Direction.Equals(other.Direction);
}
/// <summary>
/// Returns the hash code for this ray.
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return Position.GetHashCode() ^ Direction.GetHashCode();
}
/// <summary>
/// Returns the distance along the ray where it intersects the specified bounding box, if it intersects at all.
/// </summary>
/// <param name="box">The bounding box to check intersection with.</param>
/// <returns></returns>
public double? Intersects(BoundingBox box)
{
//first test if start in box
@ -129,6 +164,10 @@ namespace TrueCraft.API
return a.Equals(b);
}
/// <summary>
/// Returns a string representation of this ray.
/// </summary>
/// <returns></returns>
public override string ToString()
{
return string.Format("{{Position:{0} Direction:{1}}}", Position.ToString(), Direction.ToString());

View File

@ -9,19 +9,41 @@ namespace TrueCraft.API
[StructLayout(LayoutKind.Explicit)]
public struct Size : IEquatable<Size>
{
/// <summary>
/// The width component for the size.
/// </summary>
[FieldOffset(0)]
public double Width;
/// <summary>
/// The height component for the size.
/// </summary>
[FieldOffset(8)]
public double Height;
/// <summary>
/// The depth component for the size.
/// </summary>
[FieldOffset(16)]
public double Depth;
#region Constructors
/// <summary>
/// Creates a new size from a specified value.
/// </summary>
/// <param name="d">The value of the components for the size.</param>
public Size(double d)
{
this.Width = this.Height = this.Depth = d;
}
/// <summary>
/// Creates a new size from specified values.
/// </summary>
/// <param name="width">The width component for the size.</param>
/// <param name="height">The height component for the size.</param>
/// <param name="depth">The depth component for the size.</param>
public Size(double width, double height, double depth)
{
this.Width = width;
@ -29,6 +51,10 @@ namespace TrueCraft.API
this.Depth = depth;
}
/// <summary>
/// Creates a new size by copying another.
/// </summary>
/// <param name="s">The size to copy.</param>
public Size(Size s)
{
this.Width = s.Width;
@ -230,6 +256,12 @@ namespace TrueCraft.API
#region Math methods
/// <summary>
/// Returns the component-wise minimum of two sizes.
/// </summary>
/// <param name="a">The first size.</param>
/// <param name="b">The second size.</param>
/// <returns></returns>
public static Size Min(Size a, Size b)
{
return new Size(Math.Min(a.Width, b.Width),
@ -237,6 +269,11 @@ namespace TrueCraft.API
Math.Min(a.Depth, b.Depth));
}
/// <summary>
/// Returns the component-wise minimum of this and another size.
/// </summary>
/// <param name="b">The other size.</param>
/// <returns></returns>
public Size Min(Size b)
{
return new Size(Math.Min(this.Width, b.Width),
@ -244,6 +281,12 @@ namespace TrueCraft.API
Math.Min(this.Depth, b.Depth));
}
/// <summary>
/// Returns the component-wise maximum of two sizes.
/// </summary>
/// <param name="a">The first size.</param>
/// <param name="b">The second size.</param>
/// <returns></returns>
public static Size Max(Size a, Size b)
{
return new Size(Math.Max(a.Width, b.Width),
@ -251,6 +294,11 @@ namespace TrueCraft.API
Math.Max(a.Depth, b.Depth));
}
/// <summary>
/// Returns the component-wise maximum of this and another size.
/// </summary>
/// <param name="b">The other size.</param>
/// <returns></returns>
public Size Max(Size b)
{
return new Size(Math.Max(this.Width, b.Width),
@ -258,16 +306,30 @@ namespace TrueCraft.API
Math.Max(this.Depth, b.Depth));
}
/// <summary>
/// Returns the negate of a size.
/// </summary>
/// <param name="a">The size to negate.</param>
/// <returns></returns>
public static Size Negate(Size a)
{
return -a;
}
/// <summary>
/// Returns the negate of this size.
/// </summary>
/// <returns></returns>
public Size Negate()
{
return -this;
}
/// <summary>
/// Returns the component-wise absolute value of a size.
/// </summary>
/// <param name="a">The size.</param>
/// <returns></returns>
public static Size Abs(Size a)
{
return new Size(Math.Abs(a.Width),
@ -275,6 +337,10 @@ namespace TrueCraft.API
Math.Abs(a.Depth));
}
/// <summary>
/// Returns the component-wise absolute value of this size.
/// </summary>
/// <returns></returns>
public Size Abs()
{
return new Size(Math.Abs(this.Width),
@ -284,6 +350,9 @@ namespace TrueCraft.API
#endregion
/// <summary>
/// Gets the volume of a cuboid with the same dimensions as this size.
/// </summary>
public double Volume
{
get
@ -292,6 +361,9 @@ namespace TrueCraft.API
}
}
/// <summary>
/// Gets the surface area of a cuboid with the same dimensions as this size.
/// </summary>
public double SurfaceArea
{
get
@ -302,6 +374,9 @@ namespace TrueCraft.API
}
}
/// <summary>
/// Gets the lateral surface area of a cuboid with the same dimensions as this size.
/// </summary>
public double LateralSurfaceArea
{
get
@ -311,6 +386,9 @@ namespace TrueCraft.API
}
}
/// <summary>
/// Gets the length of a diagonal line passing through a cuboid with the same dimensions as this size.
/// </summary>
public double Diagonal
{
get
@ -321,6 +399,9 @@ namespace TrueCraft.API
}
}
/// <summary>
/// Returns the average dimension for this size.
/// </summary>
public double Average
{
get
@ -329,6 +410,11 @@ namespace TrueCraft.API
}
}
/// <summary>
/// Determines whether this size and another are equal.
/// </summary>
/// <param name="other">The other size.</param>
/// <returns></returns>
public bool Equals(Size other)
{
return this.Width == other.Width &&
@ -336,11 +422,20 @@ namespace TrueCraft.API
this.Depth == other.Depth;
}
/// <summary>
/// Determines whether this and another object are equal.
/// </summary>
/// <param name="obj">The other object.</param>
/// <returns></returns>
public override bool Equals(object obj)
{
return obj is Size && Equals((Size)obj);
}
/// <summary>
/// Returns the hash code for this size.
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
unchecked

View File

@ -5,13 +5,39 @@ using System.Text;
namespace TrueCraft.API
{
/// <summary>
/// Enumerates the materials tools can be crafted from.
/// </summary>
public enum ToolMaterial
{
/// <summary>
/// The tool is crafted from no material (special).
/// </summary>
None,
/// <summary>
/// The tool is crafted from wood.
/// </summary>
Wood,
/// <summary>
/// The tool is crafted from cobblestone.
/// </summary>
Stone,
/// <summary>
/// The tool is crafted from iron ingots.
/// </summary>
Iron,
/// <summary>
/// The tool is crafted from gold ingots.
/// </summary>
Gold,
/// <summary>
/// The tool is crafted from diamonds.
/// </summary>
Diamond
}
}

View File

@ -5,24 +5,61 @@ using System.Text;
namespace TrueCraft.API
{
/// <summary>
/// Enumerates the different species of trees in TrueCraft.
/// </summary>
public enum TreeSpecies
{
/// <summary>
/// An oak tree.
/// </summary>
Oak,
/// <summary>
/// A birch tree.
/// </summary>
Birch,
/// <summary>
/// A spruce tree.
/// </summary>
Spruce
}
//The following enums are mainly for generation purposes only.
/// <summary>
/// Enumerates the different types of spruce trees in TrueCraft.
/// </summary>
/// <remarks>
/// The following enums are mainly for generation purposes only.
/// </remarks>
public enum SpruceType
{
//TODO: Spruce types.
}
/// <summary>
/// Enumerates the different types of oak trees in TrueCraft.
/// </summary>
public enum OakType
{
Normal, //Uses layered circles for leaves
BalloonBlocky, //Uses a "blocky" sphere for leaves
Balloon, //Uses a sphere for leaves
Branched //Uses multiple spheres for leaves and random extra logs acting as branches
/// <summary>
/// Uses layered circles for leaves
/// </summary>
Normal,
/// <summary>
/// Uses a "blocky" sphere for leaves
/// </summary>
BalloonBlocky,
/// <summary>
/// Uses a sphere for leaves
/// </summary>
Balloon,
/// <summary>
/// Uses multiple spheres for leaves and random extra logs acting as branches
/// </summary>
Branched
}
}

View File

@ -9,18 +9,39 @@ namespace TrueCraft.API
[StructLayout(LayoutKind.Explicit)]
public struct Vector3 : IEquatable<Vector3>
{
/// <summary>
/// The X component of this vector.
/// </summary>
[FieldOffset(0)]
public double X;
/// <summary>
/// The Y component of this vector.
/// </summary>
[FieldOffset(8)]
public double Y;
/// <summary>
/// The Z component of this vector.
/// </summary>
[FieldOffset(16)]
public double Z;
/// <summary>
/// Creates a new vector from the specified value.
/// </summary>
/// <param name="value">The value for the components of the vector.</param>
public Vector3(double value)
{
X = Y = Z = value;
}
/// <summary>
/// Creates a new vector from the specified values.
/// </summary>
/// <param name="x">The X component of the vector.</param>
/// <param name="y">The Y component of the vector.</param>
/// <param name="z">The Z component of the vector.</param>
public Vector3(double x, double y, double z)
{
X = x;
@ -28,6 +49,10 @@ namespace TrueCraft.API
Z = z;
}
/// <summary>
/// Creates a new vector from copying another.
/// </summary>
/// <param name="v">The vector to copy.</param>
public Vector3(Vector3 v)
{
X = v.X;
@ -97,6 +122,12 @@ namespace TrueCraft.API
}
}
/// <summary>
/// Returns the component-wise minumum of two vectors.
/// </summary>
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <returns></returns>
public static Vector3 Min(Vector3 value1, Vector3 value2)
{
return new Vector3(
@ -106,6 +137,12 @@ namespace TrueCraft.API
);
}
/// <summary>
/// Returns the component-wise maximum of two vectors.
/// </summary>
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <returns></returns>
public static Vector3 Max(Vector3 value1, Vector3 value2)
{
return new Vector3(
@ -267,6 +304,7 @@ namespace TrueCraft.API
#endregion
#region Conversion operators
public static implicit operator Vector3(Coordinates3D a)
{
return new Vector3(a.X, a.Y, a.Z);
@ -285,33 +323,94 @@ namespace TrueCraft.API
#region Constants
/// <summary>
/// A vector with its components set to 0.0.
/// </summary>
public static readonly Vector3 Zero = new Vector3(0);
/// <summary>
/// A vector with its components set to 1.0.
/// </summary>
public static readonly Vector3 One = new Vector3(1);
/// <summary>
/// A vector that points upward.
/// </summary>
public static readonly Vector3 Up = new Vector3(0, 1, 0);
/// <summary>
/// A vector that points downward.
/// </summary>
public static readonly Vector3 Down = new Vector3(0, -1, 0);
/// <summary>
/// A vector that points to the left.
/// </summary>
public static readonly Vector3 Left = new Vector3(-1, 0, 0);
/// <summary>
/// A vector that points to the right.
/// </summary>
public static readonly Vector3 Right = new Vector3(1, 0, 0);
/// <summary>
/// A vector that points backward.
/// </summary>
public static readonly Vector3 Backwards = new Vector3(0, 0, -1);
/// <summary>
/// A vector that points forward.
/// </summary>
public static readonly Vector3 Forwards = new Vector3(0, 0, 1);
/// <summary>
/// A vector that points to the east.
/// </summary>
public static readonly Vector3 East = new Vector3(1, 0, 0);
/// <summary>
/// A vector that points to the west.
/// </summary>
public static readonly Vector3 West = new Vector3(-1, 0, 0);
/// <summary>
/// A vector that points to the north.
/// </summary>
public static readonly Vector3 North = new Vector3(0, 0, -1);
/// <summary>
/// A vector that points to the south.
/// </summary>
public static readonly Vector3 South = new Vector3(0, 0, 1);
#endregion
/// <summary>
/// Determines whether this and another vector are equal.
/// </summary>
/// <param name="other">The other vector.</param>
/// <returns></returns>
public bool Equals(Vector3 other)
{
return other.X.Equals(X) && other.Y.Equals(Y) && other.Z.Equals(Z);
}
/// <summary>
/// Determines whether this and another object are equal.
/// </summary>
/// <param name="obj">The other object.</param>
/// <returns></returns>
public override bool Equals(object obj)
{
return obj is Vector3 && Equals((Vector3)obj);
}
/// <summary>
/// Gets the hash code for this vector.
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
unchecked