From fae1cd6c6767126f40d939cc3ab358714360cb2c Mon Sep 17 00:00:00 2001 From: William Moorehouse Date: Thu, 11 Jun 2015 23:06:00 -0400 Subject: [PATCH] Added XML comments to most types/fields/methods in the TrueCraft.API namespace --- TrueCraft.API/ArmorMaterial.cs | 22 +++++ TrueCraft.API/Biome.cs | 104 +++++++++++++++++++++-- TrueCraft.API/BlockFace.cs | 26 ++++++ TrueCraft.API/BoundingBox.cs | 100 +++++++++++++++++++++- TrueCraft.API/ChatColor.cs | 71 ++++++++++++++++ TrueCraft.API/Configuration.cs | 9 ++ TrueCraft.API/Coordinates2D.cs | 77 ++++++++++++++++- TrueCraft.API/Coordinates3D.cs | 118 +++++++++++++++++++++++++- TrueCraft.API/Difficulty.cs | 18 ++++ TrueCraft.API/Dimension.cs | 10 +++ TrueCraft.API/GameMode.cs | 10 +++ TrueCraft.API/IAccessConfiguration.cs | 14 +++ TrueCraft.API/ItemStack.cs | 93 ++++++++++++++++++++ TrueCraft.API/OreTypes.cs | 26 ++++++ TrueCraft.API/PlantSpecies.cs | 30 +++++++ TrueCraft.API/Ray.cs | 43 +++++++++- TrueCraft.API/Size.cs | 95 +++++++++++++++++++++ TrueCraft.API/ToolMaterial.cs | 26 ++++++ TrueCraft.API/TreeSpecies.cs | 47 ++++++++-- TrueCraft.API/Vector3.cs | 99 +++++++++++++++++++++ 20 files changed, 1021 insertions(+), 17 deletions(-) diff --git a/TrueCraft.API/ArmorMaterial.cs b/TrueCraft.API/ArmorMaterial.cs index f0107c2..11d0a6e 100644 --- a/TrueCraft.API/ArmorMaterial.cs +++ b/TrueCraft.API/ArmorMaterial.cs @@ -5,12 +5,34 @@ using System.Text; namespace TrueCraft.API { + /// + /// Enumerates the materials armor can be crafted from. + /// public enum ArmorMaterial { + /// + /// The armor is made of leather. + /// Leather, + + /// + /// The armor is made of chain (fire). + /// Chain, + + /// + /// The armor is made of iron ingots. + /// Iron, + + /// + /// The armor is made of gold ingots. + /// Gold, + + /// + /// The armor is made of diamonds. + /// Diamond } } \ No newline at end of file diff --git a/TrueCraft.API/Biome.cs b/TrueCraft.API/Biome.cs index b8f1b6e..39567bd 100644 --- a/TrueCraft.API/Biome.cs +++ b/TrueCraft.API/Biome.cs @@ -5,27 +5,119 @@ using System.Text; namespace TrueCraft.API { + /// + /// Enumerates the biomes in TrueCraft. + /// + /// + /// The 13 vanilla b1.7.3 biomes as found on http://b.wiki.vg/json/b1.7 + /// public enum Biome { - //The 13 vanilla b1.7.3 biomes as found on http://b.wiki.vg/json/b1.7 + /// + /// A plains biome. + /// Plains = 0, + + /// + /// A desert biome. + /// Desert = 1, + + /// + /// A forest biome. + /// Forest = 2, + + /// + /// A rainforest biome. + /// Rainforest = 3, + + /// + /// A seasonal forest biome. + /// SeasonalForest = 4, + + /// + /// A savanna biome. + /// Savanna = 5, + + /// + /// A shrubland biome. + /// Shrubland = 6, + + /// + /// A swampland biome. + /// Swampland = 7, + + /// + /// A Nether biome. + /// Hell = 8, - Sky = 9,//Implementation into truecraft is undetermined at this point + + /// + /// An End biome. + /// + /// + /// Implementation into TrueCraft is undetermined at this point + /// + Sky = 9, + + /// + /// A taiga biome. + /// Taiga = 10, + + /// + /// A tundra biome. + /// Tundra = 11, - IceDesert = 12,//Implementation into truecraft is undetermined at this point + + /// + /// An ice desert biome. + /// + /// + /// Implementation into TrueCraft is undetermined at this point + /// + IceDesert = 12, + //Below are "transitional" biomes/biomes which are not in b1.7.3 + + /// + /// An ocean biome. + /// Ocean = 13, - River = 14,//Implementation into truecraft is undetermined at this point - Beach = 15,//Implementation into truecraft is undetermined at this point + + /// + /// A river biome. + /// + /// + /// Implementation into TrueCraft is undetermined at this point + /// + River = 14, + + /// + /// A beach biome. + /// + /// + /// Implementation into TrueCraft is undetermined at this point + /// + Beach = 15, + + /// + /// A frozen ocean biome. + /// FrozenOcean = 16, - FrozenRiver = 17,//Implementation into truecraft is undetermined at this point + + /// + /// A frozen river biome. + /// + /// + /// Implementation into TrueCraft is undetermined at this point + /// + FrozenRiver = 17, } } diff --git a/TrueCraft.API/BlockFace.cs b/TrueCraft.API/BlockFace.cs index 54e9c9f..a70b3a1 100644 --- a/TrueCraft.API/BlockFace.cs +++ b/TrueCraft.API/BlockFace.cs @@ -2,13 +2,39 @@ using System; namespace TrueCraft.API { + /// + /// Enumerates the directions of block faces. + /// public enum BlockFace { + /// + /// The block face points towards -Y. + /// NegativeY = 0, + + /// + /// The block face points towards +Y. + /// PositiveY = 1, + + /// + /// The block face points towards -Z. + /// NegativeZ = 2, + + /// + /// The block face points towards +Z. + /// PositiveZ = 3, + + /// + /// The block face points towards -X. + /// NegativeX = 4, + + /// + /// The block face points towards +X. + /// PositiveX = 5 } } \ No newline at end of file diff --git a/TrueCraft.API/BoundingBox.cs b/TrueCraft.API/BoundingBox.cs index 37b8b13..77fe424 100644 --- a/TrueCraft.API/BoundingBox.cs +++ b/TrueCraft.API/BoundingBox.cs @@ -5,20 +5,50 @@ using System.Text; namespace TrueCraft.API { + /// + /// Enumerates the different types of containment between two bounding boxes. + /// public enum ContainmentType { + /// + /// The two bounding boxes are disjoint. + /// Disjoint, + + /// + /// One bounding box contains the other. + /// Contains, + + /// + /// The two bounding boxes intersect. + /// Intersects } - // Mostly taken from the MonoXna project, which is licensed under the MIT license + /// + /// Represents an axis-aligned bounding box. + /// + /// + /// Mostly taken from the MonoXna project, which is licensed under the MIT license + /// public struct BoundingBox : IEquatable { #region Public Fields + /// + /// The minimum vector for the bounding box. + /// public Vector3 Min; + + /// + /// The maximum vector for the bounding box. + /// public Vector3 Max; + + /// + /// The number of corners a bounding box has. + /// public const int CornerCount = 8; #endregion Public Fields @@ -26,12 +56,21 @@ namespace TrueCraft.API #region Public Constructors + /// + /// Creates a new bounding box from specified values + /// + /// The minimum vector for the bounding box. + /// The number of corners a bounding box has. public BoundingBox(Vector3 min, Vector3 max) { this.Min = min; this.Max = max; } + /// + /// Creates a new bounding box by copying another. + /// + /// The bounding box to clone. public BoundingBox(BoundingBox b) { this.Min = new Vector3(b.Min); @@ -43,6 +82,11 @@ namespace TrueCraft.API #region Public Methods + /// + /// Determines the type of containment between this and another bounding box. + /// + /// The other bounding box. + /// 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; } + /// + /// Determines whether the specified vector is contained within this bounding box. + /// + /// The vector. + /// 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; } + /// + /// Creates and returns a new bounding box from an enumeration of corner points. + /// + /// The enumeration of corner points. + /// public static BoundingBox CreateFromPoints(IEnumerable points) { if (points == null) @@ -107,6 +161,10 @@ namespace TrueCraft.API return new BoundingBox(Min + Offset, Max + Offset); } + /// + /// Returns an array of vectors containing the corners of this bounding box. + /// + /// public Vector3[] GetCorners() { return new Vector3[] @@ -122,21 +180,40 @@ namespace TrueCraft.API }; } + /// + /// Determines whether this and another bounding box are equal. + /// + /// The other bounding box. + /// public bool Equals(BoundingBox other) { return (this.Min == other.Min) && (this.Max == other.Max); } + /// + /// Determines whether this and another object are equal. + /// + /// The other object. + /// public override bool Equals(object obj) { return (obj is BoundingBox) && this.Equals((BoundingBox)obj); } + /// + /// Returns the hash code for this bounding box. + /// + /// public override int GetHashCode() { return this.Min.GetHashCode() + this.Max.GetHashCode(); } + /// + /// Determines whether this bounding box intersects another. + /// + /// The other bounding box. + /// public bool Intersects(BoundingBox box) { bool result; @@ -144,6 +221,11 @@ namespace TrueCraft.API return result; } + /// + /// Determines whether this bounding box intersects another. + /// + /// The other bounding box. + /// Set to whether the two bounding boxes intersect. 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); } + /// + /// Returns a string representation of this bounding box. + /// + /// 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 + /// + /// Gets the height of this bounding box. + /// public double Height { get { return Max.Y - Min.Y; } } + /// + /// Gets the width of this bounding box. + /// public double Width { get { return Max.X - Min.X; } } + /// + /// Gets the depth of this bounding box. + /// public double Depth { get { return Max.Z - Min.Z; } } + /// + /// Gets the center of this bounding box. + /// public Vector3 Center { get diff --git a/TrueCraft.API/ChatColor.cs b/TrueCraft.API/ChatColor.cs index 6f34ee9..75b13d0 100644 --- a/TrueCraft.API/ChatColor.cs +++ b/TrueCraft.API/ChatColor.cs @@ -5,25 +5,96 @@ using System.Text; namespace TrueCraft.API { + /// + /// Provides constants and functions for working with chat colors. + /// public static class ChatColor { + /// + /// The color code for black. + /// public const string Black = "§0"; + + /// + /// The color code for dark blue. + /// public const string DarkBlue = "§1"; + + /// + /// The color code for dark green. + /// public const string DarkGreen = "§2"; + + /// + /// The color code for dark cyan. + /// public const string DarkCyan = "§3"; + + /// + /// The color code for dark red. + /// public const string DarkRed = "§4"; + + /// + /// The color code for dark purple. + /// public const string Purple = "§5"; + + /// + /// The color code for dark orange. + /// public const string Orange = "§6"; + + /// + /// The color code for gray. + /// public const string Gray = "§7"; + + /// + /// The color code for dark gray. + /// public const string DarkGray = "§8"; + + /// + /// The color code for blue. + /// public const string Blue = "§9"; + + /// + /// The color code for bright green. + /// public const string BrightGreen = "§a"; + + /// + /// The color code for cyan. + /// public const string Cyan = "§b"; + + /// + /// The color code for red. + /// public const string Red = "§c"; + + /// + /// The color code for pink. + /// public const string Pink = "§d"; + + /// + /// The color code for yellow. + /// public const string Yellow = "§e"; + + /// + /// The color code for white. + /// public const string White = "§f"; + /// + /// Removes the color codes from the specified string. + /// + /// The string to remove color codes from. + /// public static string RemoveColors(string text) { var sb = new StringBuilder(text.Length); diff --git a/TrueCraft.API/Configuration.cs b/TrueCraft.API/Configuration.cs index 67632b6..1a0ad74 100644 --- a/TrueCraft.API/Configuration.cs +++ b/TrueCraft.API/Configuration.cs @@ -3,8 +3,17 @@ using YamlDotNet.Serialization; namespace TrueCraft.API { + /// + /// Abstract base class for configurations read from YAML files. + /// public abstract class Configuration { + /// + /// Creates and returns a new configuration read from a YAML file. + /// + /// The configuration type. + /// The path to the YAML file. + /// public static T LoadConfiguration(string configFileName) where T : new() { T config; diff --git a/TrueCraft.API/Coordinates2D.cs b/TrueCraft.API/Coordinates2D.cs index 1689c19..196f758 100644 --- a/TrueCraft.API/Coordinates2D.cs +++ b/TrueCraft.API/Coordinates2D.cs @@ -2,21 +2,45 @@ namespace TrueCraft.API { + /// + /// Represents a tuple of 2D coordinates. + /// public struct Coordinates2D : IEquatable { - public int X, Z; + /// + /// The X component of the coordinates. + /// + public int X; + /// + /// The Y component of the coordinates. + /// + public int Z; + + /// + /// Creates a new pair of coordinates from the specified value. + /// + /// The value for the components of the coordinates. public Coordinates2D(int value) { X = Z = value; } + /// + /// Creates a new pair of coordinates from the specified values. + /// + /// The X component of the coordinates. + /// The Y component of the coordinates. public Coordinates2D(int x, int z) { X = x; Z = z; } + /// + /// Creates a new pair of coordinates by copying another. + /// + /// The coordinates to copy. public Coordinates2D(Coordinates2D v) { X = v.X; @@ -24,7 +48,7 @@ namespace TrueCraft.API } /// - /// Converts this Coordinates2D to a string in the format <x,z>. + /// Returns the string representation of this 2D coordinates. /// /// public override string ToString() @@ -62,6 +86,12 @@ namespace TrueCraft.API } } + /// + /// Returns the component-wise minimum of two 2D coordinates. + /// + /// The first coordinates. + /// The second coordinates. + /// public static Coordinates2D Min(Coordinates2D value1, Coordinates2D value2) { return new Coordinates2D( @@ -70,6 +100,12 @@ namespace TrueCraft.API ); } + /// + /// Returns the component-wise maximum of two 2D coordinates. + /// + /// The first coordinates. + /// The second coordinates. + /// public static Coordinates2D Max(Coordinates2D value1, Coordinates2D value2) { return new Coordinates2D( @@ -183,21 +219,54 @@ namespace TrueCraft.API #region Constants + /// + /// A pair of 2D coordinates with components set to 0.0. + /// public static readonly Coordinates2D Zero = new Coordinates2D(0); + + /// + /// A pair of 2D coordinates with components set to 1.0. + /// public static readonly Coordinates2D One = new Coordinates2D(1); + + /// + /// A pair of 2D coordinates facing forwards. + /// public static readonly Coordinates2D Forward = new Coordinates2D(0, 1); + + /// + /// A pair of 2D coordinates facing backwards. + /// public static readonly Coordinates2D Backward = new Coordinates2D(0, -1); + + /// + /// A pair of 2D coordinates facing left. + /// public static readonly Coordinates2D Left = new Coordinates2D(-1, 0); + + /// + /// A pair of 2D coordinates facing right. + /// public static readonly Coordinates2D Right = new Coordinates2D(1, 0); #endregion + /// + /// Determines whether this 2D coordinates and another are equal. + /// + /// The other coordinates. + /// public bool Equals(Coordinates2D other) { return other.X.Equals(X) && other.Z.Equals(Z); } + /// + /// Determines whether this and another object are equal. + /// + /// The other object. + /// public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; @@ -205,6 +274,10 @@ namespace TrueCraft.API return Equals((Coordinates2D)obj); } + /// + /// Returns the hash code for this 2D coordinates. + /// + /// public override int GetHashCode() { unchecked diff --git a/TrueCraft.API/Coordinates3D.cs b/TrueCraft.API/Coordinates3D.cs index f5150a0..c717e47 100644 --- a/TrueCraft.API/Coordinates3D.cs +++ b/TrueCraft.API/Coordinates3D.cs @@ -5,15 +5,42 @@ using System.Text; namespace TrueCraft.API { + /// + /// Represents a tuple of 3D coordinates. + /// public struct Coordinates3D : IEquatable { - public int X, Y, Z; + /// + /// The X component of the coordinates. + /// + public int X; + /// + /// The Y component of the coordinates. + /// + public int Y; + + /// + /// The Z component of the coordinates. + /// + public int Z; + + + /// + /// Creates a new trio of coordinates from the specified value. + /// + /// The value for the components of the coordinates. public Coordinates3D(int value) { X = Y = Z = value; } + /// + /// Creates a new trio of coordinates from the specified values. + /// + /// The X component of the coordinates. + /// The Y component of the coordinates. + /// The Z component of the coordinates. public Coordinates3D(int x = 0, int y = 0, int z = 0) { X = x; @@ -21,6 +48,10 @@ namespace TrueCraft.API Z = z; } + /// + /// Creates a new trio of coordinates by copying another. + /// + /// The coordinates to copy. public Coordinates3D(Coordinates3D v) { X = v.X; @@ -83,6 +114,12 @@ namespace TrueCraft.API } } + /// + /// Returns the component-wise minimum of two 3D coordinates. + /// + /// The first coordinates. + /// The second coordinates. + /// public static Coordinates3D Min(Coordinates3D value1, Coordinates3D value2) { return new Coordinates3D( @@ -92,6 +129,12 @@ namespace TrueCraft.API ); } + /// + /// Returns the component-wise maximum of two 3D coordinates. + /// + /// The first coordinates. + /// The second coordinates. + /// public static Coordinates3D Max(Coordinates3D value1, Coordinates3D value2) { return new Coordinates3D( @@ -222,32 +265,101 @@ namespace TrueCraft.API #region Constants + /// + /// A trio of 3D coordinates with components set to 0.0. + /// public static readonly Coordinates3D Zero = new Coordinates3D(0); + + /// + /// A trio of 3D coordinates with components set to 0.0. + /// public static readonly Coordinates3D One = new Coordinates3D(1); + + /// + /// A trio of 3D coordinates facing up. + /// public static readonly Coordinates3D Up = new Coordinates3D(0, 1, 0); + + /// + /// A trio of 3D coordinates facing down. + /// public static readonly Coordinates3D Down = new Coordinates3D(0, -1, 0); + + /// + /// A trio of 3D coordinates facing left. + /// public static readonly Coordinates3D Left = new Coordinates3D(-1, 0, 0); + + /// + /// A trio of 3D coordinates facing right. + /// public static readonly Coordinates3D Right = new Coordinates3D(1, 0, 0); + + /// + /// A trio of 3D coordinates facing backwards. + /// public static readonly Coordinates3D Backwards = new Coordinates3D(0, 0, -1); + + /// + /// A trio of 3D coordinates facing forwards. + /// public static readonly Coordinates3D Forwards = new Coordinates3D(0, 0, 1); + + /// + /// A trio of 3D coordinates facing to the east. + /// public static readonly Coordinates3D East = new Coordinates3D(1, 0, 0); + + /// + /// A trio of 3D coordinates facing to the west. + /// public static readonly Coordinates3D West = new Coordinates3D(-1, 0, 0); + + /// + /// A trio of 3D coordinates facing to the north. + /// public static readonly Coordinates3D North = new Coordinates3D(0, 0, -1); + + /// + /// A trio of 3D coordinates facing to the south. + /// public static readonly Coordinates3D South = new Coordinates3D(0, 0, 1); + + /// + /// A trio of 3D coordinates facing the X axis at unit length. + /// public static readonly Coordinates3D OneX = new Coordinates3D(1, 0, 0); + + /// + /// A trio of 3D coordinates facing the Y axis at unit length. + /// public static readonly Coordinates3D OneY = new Coordinates3D(0, 1, 0); + + /// + /// A trio of 3D coordinates facing the Z axis at unit length. + /// public static readonly Coordinates3D OneZ = new Coordinates3D(0, 0, 1); #endregion + /// + /// Determines whether this 3D coordinates and another are equal. + /// + /// The other coordinates. + /// public bool Equals(Coordinates3D other) { return other.X.Equals(X) && other.Y.Equals(Y) && other.Z.Equals(Z); } + /// + /// Determines whether this and another object are equal. + /// + /// The other object. + /// public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; @@ -255,6 +367,10 @@ namespace TrueCraft.API return Equals((Coordinates3D)obj); } + /// + /// Returns the hash code for this 3D coordinates. + /// + /// public override int GetHashCode() { unchecked diff --git a/TrueCraft.API/Difficulty.cs b/TrueCraft.API/Difficulty.cs index 192a3a5..ed010c7 100644 --- a/TrueCraft.API/Difficulty.cs +++ b/TrueCraft.API/Difficulty.cs @@ -2,11 +2,29 @@ namespace TrueCraft.API { + /// + /// Enumerates the difficulty levels in TrueCraft. + /// public enum Difficulty { + /// + /// Peaceful difficulty. + /// Peaceful = 0, + + /// + /// Easy difficulty. + /// Easy = 1, + + /// + /// Normal difficulty. + /// Normal = 2, + + /// + /// Hard difficulty. + /// Hard = 3 } } \ No newline at end of file diff --git a/TrueCraft.API/Dimension.cs b/TrueCraft.API/Dimension.cs index fb9bd09..879b5f1 100644 --- a/TrueCraft.API/Dimension.cs +++ b/TrueCraft.API/Dimension.cs @@ -2,9 +2,19 @@ namespace TrueCraft.API { + /// + /// Enumerates the different dimensions in the world in TrueCraft. + /// public enum Dimension { + /// + /// The Nether dimension. + /// Nether = -1, + + /// + /// The Overworld dimension. + /// Overworld = 0 } } \ No newline at end of file diff --git a/TrueCraft.API/GameMode.cs b/TrueCraft.API/GameMode.cs index c1460a2..89463e3 100644 --- a/TrueCraft.API/GameMode.cs +++ b/TrueCraft.API/GameMode.cs @@ -2,9 +2,19 @@ namespace TrueCraft.API { + /// + /// Enumerates the different game modes in TrueCraft. + /// public enum GameMode { + /// + /// The survival game mode. + /// Survival = 0, + + /// + /// The creative game mode. + /// Creative = 1 } } \ No newline at end of file diff --git a/TrueCraft.API/IAccessConfiguration.cs b/TrueCraft.API/IAccessConfiguration.cs index 5190fcd..254f149 100644 --- a/TrueCraft.API/IAccessConfiguration.cs +++ b/TrueCraft.API/IAccessConfiguration.cs @@ -3,10 +3,24 @@ using TrueCraft.API.Networking; namespace TrueCraft.API { + /// + /// Interface for objects providing server access configuration. + /// public interface IAccessConfiguration { + /// + /// Gets a list of blacklisted players for the configuration. + /// IList Blacklist { get; } + + /// + /// Gets a list of whitelisted players for the configuration. + /// IList Whitelist { get; } + + /// + /// Gets a list of opped players for the configuration. + /// IList Oplist { get; } } } diff --git a/TrueCraft.API/ItemStack.cs b/TrueCraft.API/ItemStack.cs index 397a742..6921d34 100644 --- a/TrueCraft.API/ItemStack.cs +++ b/TrueCraft.API/ItemStack.cs @@ -10,8 +10,15 @@ using TrueCraft.API.Networking; namespace TrueCraft.API { + /// + /// Represents a stack of items. + /// public struct ItemStack : ICloneable, IEquatable { + /// + /// Returns the hash code for this item stack. + /// + /// public override int GetHashCode() { unchecked @@ -35,6 +42,10 @@ namespace TrueCraft.API return !left.Equals(right); } + /// + /// Creates a new item stack with the specified values. + /// + /// The item ID for the item stack. public ItemStack(short id) : this() { _Id = id; @@ -44,16 +55,34 @@ namespace TrueCraft.API Index = 0; } + /// + /// Creates a new item stack with the specified values. + /// + /// The item ID for the item stack. + /// The item count for the item stack. public ItemStack(short id, sbyte count) : this(id) { Count = count; } + /// + /// Creates a new item stack with the specified values. + /// + /// The item ID for the item stack. + /// The item count for the item stack. + /// The metadata for the item stack. public ItemStack(short id, sbyte count, short metadata) : this(id, count) { Metadata = metadata; } + /// + /// Creates a new item stack with the specified values. + /// + /// The item ID for the item stack. + /// The item count for the item stack. + /// The metadata for the item stack. + /// The NBT compound tag for the item stack. public ItemStack(short id, sbyte count, short metadata, NbtCompound nbt) : this(id, count, metadata) { Nbt = nbt; @@ -65,6 +94,11 @@ namespace TrueCraft.API } } + /// + /// Creates and returns a new item stack read from a Minecraft stream. + /// + /// The stream to read from. + /// public static ItemStack FromStream(IMinecraftStream stream) { var slot = ItemStack.EmptyStack; @@ -84,6 +118,10 @@ namespace TrueCraft.API return slot; } + /// + /// Writes this item stack to a Minecraft stream. + /// + /// The stream to write to. public void WriteTo(IMinecraftStream stream) { stream.WriteInt16(ID); @@ -103,6 +141,11 @@ namespace TrueCraft.API stream.WriteUInt8Array(mStream.GetBuffer()); } + /// + /// Creates and returns a new item stack created from an NBT compound tag. + /// + /// The compound tag to create the item stack from. + /// public static ItemStack FromNbt(NbtCompound compound) { var s = ItemStack.EmptyStack; @@ -115,6 +158,10 @@ namespace TrueCraft.API return s; } + /// + /// Creates and returns a new NBT compound tag containing this item stack. + /// + /// public NbtCompound ToNbt() { var c = new NbtCompound(); @@ -127,12 +174,18 @@ namespace TrueCraft.API return c; } + /// + /// Gets whether this item stack is empty. + /// [NbtIgnore] public bool Empty { get { return ID == -1; } } + /// + /// Gets or sets the item ID for this item stack. + /// public short ID { get { return _Id; } @@ -148,6 +201,9 @@ namespace TrueCraft.API } } + /// + /// Gets or sets the item count for this item stack. + /// public sbyte Count { get { return _Count; } @@ -163,6 +219,9 @@ namespace TrueCraft.API } } + /// + /// Gets or sets the metadata for this item stack. + /// public short Metadata { get { return _Metadata; } @@ -172,11 +231,23 @@ namespace TrueCraft.API private short _Id; private sbyte _Count; private short _Metadata; + + /// + /// The NBT compound tag for this item stack, if any. + /// [IgnoreOnNull] public NbtCompound Nbt { get; set; } + + /// + /// The index (slot) of this item stack in an inventory. + /// [NbtIgnore] public int Index; + /// + /// Returns the string representation of this item stack. + /// + /// public override string ToString() { if (Empty) @@ -188,11 +259,18 @@ namespace TrueCraft.API return "(" + result + ")"; } + /// + /// Returns a clone of this item stack. + /// + /// public object Clone() { return new ItemStack(ID, Count, Metadata, Nbt); } + /// + /// Gets an empty item stack. + /// [NbtIgnore] public static ItemStack EmptyStack { @@ -202,6 +280,11 @@ namespace TrueCraft.API } } + /// + /// Determines whether this item stack can merge with another. + /// + /// The other item stack. + /// 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); } + /// + /// Determines whether this item stack and another object are equal. + /// + /// The other object. + /// public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; return obj is ItemStack && Equals((ItemStack)obj); } + /// + /// Determines whether this item stack and another are equal. + /// + /// The other item stack. + /// public bool Equals(ItemStack other) { return _Id == other._Id && _Count == other._Count && _Metadata == other._Metadata && Index == other.Index && Equals(Nbt, other.Nbt); diff --git a/TrueCraft.API/OreTypes.cs b/TrueCraft.API/OreTypes.cs index 2c14f39..99bd4b5 100644 --- a/TrueCraft.API/OreTypes.cs +++ b/TrueCraft.API/OreTypes.cs @@ -5,13 +5,39 @@ using System.Text; namespace TrueCraft.API { + /// + /// Enumerates the different types of ore in TrueCraft. + /// public enum OreTypes { + /// + /// Coal ore. + /// Coal, + + /// + /// Lapis lazuli ore. + /// Lapiz, + + /// + /// Iron ore. + /// Iron, + + /// + /// Gold ore. + /// Gold, + + /// + /// Redstone ore. + /// Redstone, + + /// + /// Diamond ore. + /// Diamond } } diff --git a/TrueCraft.API/PlantSpecies.cs b/TrueCraft.API/PlantSpecies.cs index bcd107d..d87d0b8 100644 --- a/TrueCraft.API/PlantSpecies.cs +++ b/TrueCraft.API/PlantSpecies.cs @@ -5,14 +5,44 @@ using System.Text; namespace TrueCraft.API { + /// + /// Enumerates the different species of plants in TrueCraft. + /// public enum PlantSpecies { + /// + /// Rose flower. + /// Rose, + + /// + /// Dandelion flower. + /// Dandelion, + + /// + /// Tall grass. + /// TallGrass, + + /// + /// Fern. + /// Fern, + + /// + /// Dead bush. + /// Deadbush, + + /// + /// Cactus. + /// Cactus, + + /// + /// Sugarcane. + /// SugarCane, } } \ No newline at end of file diff --git a/TrueCraft.API/Ray.cs b/TrueCraft.API/Ray.cs index fe68bd5..4c427d2 100644 --- a/TrueCraft.API/Ray.cs +++ b/TrueCraft.API/Ray.cs @@ -5,12 +5,24 @@ using System.Text; namespace TrueCraft.API { - // Mostly taken from the MonoXna project, which is licensed under the MIT license + /// + /// Represents a ray; a line with a start and direction, but no end. + /// + /// + /// Mostly taken from the MonoXna project, which is licensed under the MIT license + /// public struct Ray : IEquatable { #region Public Fields + /// + /// The direction of the ray. + /// public readonly Vector3 Direction; + + /// + /// The position of the ray (its origin). + /// public readonly Vector3 Position; #endregion @@ -18,6 +30,11 @@ namespace TrueCraft.API #region Public Constructors + /// + /// Creates a new ray from specified values. + /// + /// The position of the ray (its origin). + /// The direction of the ray. public Ray(Vector3 position, Vector3 direction) { this.Position = position; @@ -29,23 +46,41 @@ namespace TrueCraft.API #region Public Methods + /// + /// Determines whether this and another object are equal. + /// + /// The other object. + /// public override bool Equals(object obj) { return (obj is Ray) && Equals((Ray)obj); } + /// + /// Determines whether this and another ray are equal. + /// + /// The other ray. + /// public bool Equals(Ray other) { return Position.Equals(other.Position) && Direction.Equals(other.Direction); } - + /// + /// Returns the hash code for this ray. + /// + /// public override int GetHashCode() { return Position.GetHashCode() ^ Direction.GetHashCode(); } + /// + /// Returns the distance along the ray where it intersects the specified bounding box, if it intersects at all. + /// + /// The bounding box to check intersection with. + /// public double? Intersects(BoundingBox box) { //first test if start in box @@ -129,6 +164,10 @@ namespace TrueCraft.API return a.Equals(b); } + /// + /// Returns a string representation of this ray. + /// + /// public override string ToString() { return string.Format("{{Position:{0} Direction:{1}}}", Position.ToString(), Direction.ToString()); diff --git a/TrueCraft.API/Size.cs b/TrueCraft.API/Size.cs index 11d7efa..e6a8706 100644 --- a/TrueCraft.API/Size.cs +++ b/TrueCraft.API/Size.cs @@ -9,19 +9,41 @@ namespace TrueCraft.API [StructLayout(LayoutKind.Explicit)] public struct Size : IEquatable { + /// + /// The width component for the size. + /// [FieldOffset(0)] public double Width; + + /// + /// The height component for the size. + /// [FieldOffset(8)] public double Height; + + /// + /// The depth component for the size. + /// [FieldOffset(16)] public double Depth; #region Constructors + /// + /// Creates a new size from a specified value. + /// + /// The value of the components for the size. public Size(double d) { this.Width = this.Height = this.Depth = d; } + + /// + /// Creates a new size from specified values. + /// + /// The width component for the size. + /// The height component for the size. + /// The depth component for the size. public Size(double width, double height, double depth) { this.Width = width; @@ -29,6 +51,10 @@ namespace TrueCraft.API this.Depth = depth; } + /// + /// Creates a new size by copying another. + /// + /// The size to copy. public Size(Size s) { this.Width = s.Width; @@ -230,6 +256,12 @@ namespace TrueCraft.API #region Math methods + /// + /// Returns the component-wise minimum of two sizes. + /// + /// The first size. + /// The second size. + /// 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)); } + /// + /// Returns the component-wise minimum of this and another size. + /// + /// The other size. + /// 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)); } + /// + /// Returns the component-wise maximum of two sizes. + /// + /// The first size. + /// The second size. + /// 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)); } + /// + /// Returns the component-wise maximum of this and another size. + /// + /// The other size. + /// 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)); } + /// + /// Returns the negate of a size. + /// + /// The size to negate. + /// public static Size Negate(Size a) { return -a; } + /// + /// Returns the negate of this size. + /// + /// public Size Negate() { return -this; } + /// + /// Returns the component-wise absolute value of a size. + /// + /// The size. + /// public static Size Abs(Size a) { return new Size(Math.Abs(a.Width), @@ -275,6 +337,10 @@ namespace TrueCraft.API Math.Abs(a.Depth)); } + /// + /// Returns the component-wise absolute value of this size. + /// + /// public Size Abs() { return new Size(Math.Abs(this.Width), @@ -284,6 +350,9 @@ namespace TrueCraft.API #endregion + /// + /// Gets the volume of a cuboid with the same dimensions as this size. + /// public double Volume { get @@ -292,6 +361,9 @@ namespace TrueCraft.API } } + /// + /// Gets the surface area of a cuboid with the same dimensions as this size. + /// public double SurfaceArea { get @@ -302,6 +374,9 @@ namespace TrueCraft.API } } + /// + /// Gets the lateral surface area of a cuboid with the same dimensions as this size. + /// public double LateralSurfaceArea { get @@ -311,6 +386,9 @@ namespace TrueCraft.API } } + /// + /// Gets the length of a diagonal line passing through a cuboid with the same dimensions as this size. + /// public double Diagonal { get @@ -321,6 +399,9 @@ namespace TrueCraft.API } } + /// + /// Returns the average dimension for this size. + /// public double Average { get @@ -329,6 +410,11 @@ namespace TrueCraft.API } } + /// + /// Determines whether this size and another are equal. + /// + /// The other size. + /// public bool Equals(Size other) { return this.Width == other.Width && @@ -336,11 +422,20 @@ namespace TrueCraft.API this.Depth == other.Depth; } + /// + /// Determines whether this and another object are equal. + /// + /// The other object. + /// public override bool Equals(object obj) { return obj is Size && Equals((Size)obj); } + /// + /// Returns the hash code for this size. + /// + /// public override int GetHashCode() { unchecked diff --git a/TrueCraft.API/ToolMaterial.cs b/TrueCraft.API/ToolMaterial.cs index 1f27122..87a3587 100644 --- a/TrueCraft.API/ToolMaterial.cs +++ b/TrueCraft.API/ToolMaterial.cs @@ -5,13 +5,39 @@ using System.Text; namespace TrueCraft.API { + /// + /// Enumerates the materials tools can be crafted from. + /// public enum ToolMaterial { + /// + /// The tool is crafted from no material (special). + /// None, + + /// + /// The tool is crafted from wood. + /// Wood, + + /// + /// The tool is crafted from cobblestone. + /// Stone, + + /// + /// The tool is crafted from iron ingots. + /// Iron, + + /// + /// The tool is crafted from gold ingots. + /// Gold, + + /// + /// The tool is crafted from diamonds. + /// Diamond } } \ No newline at end of file diff --git a/TrueCraft.API/TreeSpecies.cs b/TrueCraft.API/TreeSpecies.cs index cafd923..7ecb95b 100644 --- a/TrueCraft.API/TreeSpecies.cs +++ b/TrueCraft.API/TreeSpecies.cs @@ -5,24 +5,61 @@ using System.Text; namespace TrueCraft.API { + /// + /// Enumerates the different species of trees in TrueCraft. + /// public enum TreeSpecies { + /// + /// An oak tree. + /// Oak, + + /// + /// A birch tree. + /// Birch, + + /// + /// A spruce tree. + /// Spruce } - //The following enums are mainly for generation purposes only. + /// + /// Enumerates the different types of spruce trees in TrueCraft. + /// + /// + /// The following enums are mainly for generation purposes only. + /// public enum SpruceType { //TODO: Spruce types. } + /// + /// Enumerates the different types of oak trees in TrueCraft. + /// 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 + /// + /// Uses layered circles for leaves + /// + Normal, + + /// + /// Uses a "blocky" sphere for leaves + /// + BalloonBlocky, + + /// + /// Uses a sphere for leaves + /// + Balloon, + + /// + /// Uses multiple spheres for leaves and random extra logs acting as branches + /// + Branched } } \ No newline at end of file diff --git a/TrueCraft.API/Vector3.cs b/TrueCraft.API/Vector3.cs index f95cf5e..26970ef 100644 --- a/TrueCraft.API/Vector3.cs +++ b/TrueCraft.API/Vector3.cs @@ -9,18 +9,39 @@ namespace TrueCraft.API [StructLayout(LayoutKind.Explicit)] public struct Vector3 : IEquatable { + /// + /// The X component of this vector. + /// [FieldOffset(0)] public double X; + + /// + /// The Y component of this vector. + /// [FieldOffset(8)] public double Y; + + /// + /// The Z component of this vector. + /// [FieldOffset(16)] public double Z; + /// + /// Creates a new vector from the specified value. + /// + /// The value for the components of the vector. public Vector3(double value) { X = Y = Z = value; } + /// + /// Creates a new vector from the specified values. + /// + /// The X component of the vector. + /// The Y component of the vector. + /// The Z component of the vector. public Vector3(double x, double y, double z) { X = x; @@ -28,6 +49,10 @@ namespace TrueCraft.API Z = z; } + /// + /// Creates a new vector from copying another. + /// + /// The vector to copy. public Vector3(Vector3 v) { X = v.X; @@ -97,6 +122,12 @@ namespace TrueCraft.API } } + /// + /// Returns the component-wise minumum of two vectors. + /// + /// The first vector. + /// The second vector. + /// public static Vector3 Min(Vector3 value1, Vector3 value2) { return new Vector3( @@ -106,6 +137,12 @@ namespace TrueCraft.API ); } + /// + /// Returns the component-wise maximum of two vectors. + /// + /// The first vector. + /// The second vector. + /// 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 + /// + /// A vector with its components set to 0.0. + /// public static readonly Vector3 Zero = new Vector3(0); + + /// + /// A vector with its components set to 1.0. + /// public static readonly Vector3 One = new Vector3(1); + + /// + /// A vector that points upward. + /// public static readonly Vector3 Up = new Vector3(0, 1, 0); + + /// + /// A vector that points downward. + /// public static readonly Vector3 Down = new Vector3(0, -1, 0); + + /// + /// A vector that points to the left. + /// public static readonly Vector3 Left = new Vector3(-1, 0, 0); + + /// + /// A vector that points to the right. + /// public static readonly Vector3 Right = new Vector3(1, 0, 0); + + /// + /// A vector that points backward. + /// public static readonly Vector3 Backwards = new Vector3(0, 0, -1); + + /// + /// A vector that points forward. + /// public static readonly Vector3 Forwards = new Vector3(0, 0, 1); + + /// + /// A vector that points to the east. + /// public static readonly Vector3 East = new Vector3(1, 0, 0); + + /// + /// A vector that points to the west. + /// public static readonly Vector3 West = new Vector3(-1, 0, 0); + + /// + /// A vector that points to the north. + /// public static readonly Vector3 North = new Vector3(0, 0, -1); + + /// + /// A vector that points to the south. + /// public static readonly Vector3 South = new Vector3(0, 0, 1); #endregion + /// + /// Determines whether this and another vector are equal. + /// + /// The other vector. + /// public bool Equals(Vector3 other) { return other.X.Equals(X) && other.Y.Equals(Y) && other.Z.Equals(Z); } + /// + /// Determines whether this and another object are equal. + /// + /// The other object. + /// public override bool Equals(object obj) { return obj is Vector3 && Equals((Vector3)obj); } + /// + /// Gets the hash code for this vector. + /// + /// public override int GetHashCode() { unchecked