From c3e76fafb803ddd4f197636ecb655c87a4713bc2 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 3 Feb 2017 09:57:17 +1100 Subject: [PATCH] Foliage not foilage. Embarrassing. --- MCGalaxy/Blocks/Physics/OtherPhysics.cs | 2 +- MCGalaxy/Commands/building/CmdTree.cs | 2 +- MCGalaxy/Drawing/DrawOps/TreeDrawOp.cs | 2 +- .../Generator/{Foilage => Foliage}/AshTree.cs | 2 +- .../{Foilage => Foliage}/ForesterTrees.cs | 5 +- .../Generator/{Foilage => Foliage}/OakTree.cs | 2 +- .../{Foilage => Foliage}/StandardTrees.cs | 2 +- .../Generator/{Foilage => Foliage}/Tree.cs | 2 +- MCGalaxy/Generator/RealisticMapGen.cs | 2 +- MCGalaxy/Levels/LevelOptions.cs | 2 +- MCGalaxy/MCGalaxy_.csproj | 10 +- MCGalaxy/util/Math/Vectors.cs | 99 ++++++++++++------- 12 files changed, 81 insertions(+), 51 deletions(-) rename MCGalaxy/Generator/{Foilage => Foliage}/AshTree.cs (96%) rename MCGalaxy/Generator/{Foilage => Foliage}/ForesterTrees.cs (94%) rename MCGalaxy/Generator/{Foilage => Foliage}/OakTree.cs (96%) rename MCGalaxy/Generator/{Foilage => Foliage}/StandardTrees.cs (96%) rename MCGalaxy/Generator/{Foilage => Foliage}/Tree.cs (96%) diff --git a/MCGalaxy/Blocks/Physics/OtherPhysics.cs b/MCGalaxy/Blocks/Physics/OtherPhysics.cs index b75b99bdb..89771d0cb 100644 --- a/MCGalaxy/Blocks/Physics/OtherPhysics.cs +++ b/MCGalaxy/Blocks/Physics/OtherPhysics.cs @@ -16,7 +16,7 @@ permissions and limitations under the Licenses. */ using System; -using MCGalaxy.Generator.Foilage; +using MCGalaxy.Generator.Foliage; namespace MCGalaxy.Blocks.Physics { diff --git a/MCGalaxy/Commands/building/CmdTree.cs b/MCGalaxy/Commands/building/CmdTree.cs index dc32bade8..da9b975ed 100644 --- a/MCGalaxy/Commands/building/CmdTree.cs +++ b/MCGalaxy/Commands/building/CmdTree.cs @@ -18,7 +18,7 @@ using System; using MCGalaxy.Drawing.Brushes; using MCGalaxy.Drawing.Ops; -using MCGalaxy.Generator.Foilage; +using MCGalaxy.Generator.Foliage; namespace MCGalaxy.Commands.Building { public sealed class CmdTree : Command { diff --git a/MCGalaxy/Drawing/DrawOps/TreeDrawOp.cs b/MCGalaxy/Drawing/DrawOps/TreeDrawOp.cs index 2ac1b2c8f..8c571115c 100644 --- a/MCGalaxy/Drawing/DrawOps/TreeDrawOp.cs +++ b/MCGalaxy/Drawing/DrawOps/TreeDrawOp.cs @@ -27,7 +27,7 @@ Ideas, concepts, and code were used from the following two sources: using System; using System.Collections.Generic; using MCGalaxy.Drawing.Brushes; -using MCGalaxy.Generator.Foilage; +using MCGalaxy.Generator.Foliage; namespace MCGalaxy.Drawing.Ops { public class TreeDrawOp : DrawOp { diff --git a/MCGalaxy/Generator/Foilage/AshTree.cs b/MCGalaxy/Generator/Foliage/AshTree.cs similarity index 96% rename from MCGalaxy/Generator/Foilage/AshTree.cs rename to MCGalaxy/Generator/Foliage/AshTree.cs index 4ed12add3..7cf4b79e0 100644 --- a/MCGalaxy/Generator/Foilage/AshTree.cs +++ b/MCGalaxy/Generator/Foliage/AshTree.cs @@ -20,7 +20,7 @@ using System.Collections.Generic; using MCGalaxy.Drawing.Brushes; using MCGalaxy.Drawing.Ops; -namespace MCGalaxy.Generator.Foilage { +namespace MCGalaxy.Generator.Foliage { public sealed class AshTree : Tree { int branchBaseHeight, branchAmount; diff --git a/MCGalaxy/Generator/Foilage/ForesterTrees.cs b/MCGalaxy/Generator/Foliage/ForesterTrees.cs similarity index 94% rename from MCGalaxy/Generator/Foilage/ForesterTrees.cs rename to MCGalaxy/Generator/Foliage/ForesterTrees.cs index 4dc3ec4a1..58be1f3e4 100644 --- a/MCGalaxy/Generator/Foilage/ForesterTrees.cs +++ b/MCGalaxy/Generator/Foliage/ForesterTrees.cs @@ -20,9 +20,10 @@ permissions and limitations under the Licenses. */ using System; +using System.Collections.Generic; -namespace MCGalaxy.Generator.Foilage { - +namespace MCGalaxy.Generator.Foliage { + public sealed class BambooTree : Tree { public override int DefaultValue(Random rnd) { return rnd.Next(4, 8); } diff --git a/MCGalaxy/Generator/Foilage/OakTree.cs b/MCGalaxy/Generator/Foliage/OakTree.cs similarity index 96% rename from MCGalaxy/Generator/Foilage/OakTree.cs rename to MCGalaxy/Generator/Foliage/OakTree.cs index fcf39bfbd..6bb91dd51 100644 --- a/MCGalaxy/Generator/Foilage/OakTree.cs +++ b/MCGalaxy/Generator/Foliage/OakTree.cs @@ -19,7 +19,7 @@ using System; using System.Collections.Generic; using MCGalaxy.Drawing.Ops; -namespace MCGalaxy.Generator.Foilage { +namespace MCGalaxy.Generator.Foliage { public sealed class OakTree : Tree { int numBranches, maxExtent, maxBranchHeight, trunkHeight; diff --git a/MCGalaxy/Generator/Foilage/StandardTrees.cs b/MCGalaxy/Generator/Foliage/StandardTrees.cs similarity index 96% rename from MCGalaxy/Generator/Foilage/StandardTrees.cs rename to MCGalaxy/Generator/Foliage/StandardTrees.cs index 3d99d6fdc..52409e98e 100644 --- a/MCGalaxy/Generator/Foilage/StandardTrees.cs +++ b/MCGalaxy/Generator/Foliage/StandardTrees.cs @@ -26,7 +26,7 @@ Ideas, concepts, and code were used from the following two sources: */ using System; -namespace MCGalaxy.Generator.Foilage { +namespace MCGalaxy.Generator.Foliage { public sealed class CactusTree : Tree { public override int DefaultValue(Random rnd) { return rnd.Next(3, 6); } diff --git a/MCGalaxy/Generator/Foilage/Tree.cs b/MCGalaxy/Generator/Foliage/Tree.cs similarity index 96% rename from MCGalaxy/Generator/Foilage/Tree.cs rename to MCGalaxy/Generator/Foliage/Tree.cs index cc3cfc14c..32cd6b2cd 100644 --- a/MCGalaxy/Generator/Foilage/Tree.cs +++ b/MCGalaxy/Generator/Foliage/Tree.cs @@ -19,7 +19,7 @@ using System; using System.Collections.Generic; using MCGalaxy.Drawing.Brushes; -namespace MCGalaxy.Generator.Foilage { +namespace MCGalaxy.Generator.Foliage { public delegate void TreeOutput(ushort x, ushort y, ushort z, byte block); diff --git a/MCGalaxy/Generator/RealisticMapGen.cs b/MCGalaxy/Generator/RealisticMapGen.cs index 682525db8..455318b6a 100644 --- a/MCGalaxy/Generator/RealisticMapGen.cs +++ b/MCGalaxy/Generator/RealisticMapGen.cs @@ -27,7 +27,7 @@ Ideas, concepts, and code were used from the following two sources: using System; using MCGalaxy.Drawing; using MCGalaxy.Drawing.Ops; -using MCGalaxy.Generator.Foilage; +using MCGalaxy.Generator.Foliage; namespace MCGalaxy.Generator { public sealed class RealisticMapGen { diff --git a/MCGalaxy/Levels/LevelOptions.cs b/MCGalaxy/Levels/LevelOptions.cs index d782bf26d..95a533ca9 100644 --- a/MCGalaxy/Levels/LevelOptions.cs +++ b/MCGalaxy/Levels/LevelOptions.cs @@ -17,7 +17,7 @@ */ using System; using System.Collections.Generic; -using MCGalaxy.Generator.Foilage; +using MCGalaxy.Generator.Foliage; namespace MCGalaxy { diff --git a/MCGalaxy/MCGalaxy_.csproj b/MCGalaxy/MCGalaxy_.csproj index 36fd22a3d..17b76b89f 100644 --- a/MCGalaxy/MCGalaxy_.csproj +++ b/MCGalaxy/MCGalaxy_.csproj @@ -496,11 +496,11 @@ - - - - - + + + + + diff --git a/MCGalaxy/util/Math/Vectors.cs b/MCGalaxy/util/Math/Vectors.cs index 6e8307edc..aa93d2ef6 100644 --- a/MCGalaxy/util/Math/Vectors.cs +++ b/MCGalaxy/util/Math/Vectors.cs @@ -32,26 +32,16 @@ namespace MCGalaxy { X = value; Y = value; Z = value; } - public override bool Equals(object obj) { - return (obj is Vec3U16) && Equals((Vec3U16)obj); - } - public bool Equals(Vec3U16 other) { - return X == other.X & Y == other.Y && Z == other.Z; - } - - public override int GetHashCode() { - int hashCode = 0; - hashCode += 1000000007 * X; - hashCode += 1000000009 * Y; - hashCode += 1000000021 * Z; - return hashCode; + public static explicit operator Vec3U16(Vec3S32 a) { + return new Vec3U16((ushort)a.X, (ushort)a.Y, (ushort)a.Z); } public int LengthSquared { get { return X * X + Y * Y + Z * Z; } } public float Length { get { return (float)Math.Sqrt( X * X + Y * Y + Z * Z ); } } + /// Clamps the given block coordinates to inside the map. public static Vec3U16 Clamp(ushort x, ushort y, ushort z, Level lvl) { Vec3U16 P = new Vec3U16(x, y, z); @@ -78,6 +68,23 @@ namespace MCGalaxy { return P; } + + public override bool Equals(object obj) { + return (obj is Vec3U16) && Equals((Vec3U16)obj); + } + + public bool Equals(Vec3U16 other) { + return X == other.X & Y == other.Y && Z == other.Z; + } + + public override int GetHashCode() { + int hashCode = 0; + hashCode += 1000000007 * X; + hashCode += 1000000009 * Y; + hashCode += 1000000021 * Z; + return hashCode; + } + public static bool operator == (Vec3U16 a, Vec3U16 b) { return a.X == b.X && a.Y == b.Y && a.Z == b.Z; } @@ -86,9 +93,6 @@ namespace MCGalaxy { return a.X != b.X || a.Y != b.Y || a.Z != b.Z; } - public static explicit operator Vec3U16(Vec3S32 a) { - return new Vec3U16((ushort)a.X, (ushort)a.Y, (ushort)a.Z); - } public override string ToString() { return X + "," + Y + "," + Z; @@ -110,27 +114,28 @@ namespace MCGalaxy { X = value; Y = value; Z = value; } - public override bool Equals(object obj) { - return (obj is Vec3S32) && Equals((Vec3S32)obj); - } - - public bool Equals(Vec3S32 other) { - return X == other.X & Y == other.Y && Z == other.Z; - } - - public override int GetHashCode() { - int hashCode = 0; - hashCode += 1000000007 * X; - hashCode += 1000000009 * Y; - hashCode += 1000000021 * Z; - return hashCode; - } public int LengthSquared { get { return X * X + Y * Y + Z * Z; } } public float Length { get { return (float)Math.Sqrt( X * X + Y * Y + Z * Z ); } } - public float Dot(Vec3S32 b) { return X * b.X + Y * b.Y + Z * b.Z; } + public float Dot(Vec3S32 b) { return X * b.X + Y * b.Y + Z * b.Z; } + + + public int this[int index] { + get { + if (index == 0) return X; + else if (index == 1) return Y; + else if (index == 2) return Z; + return 0; + } + set { + if (index == 0) { X = value; } + else if (index == 1) { Y = value; } + else if (index == 2) { Z = value; } + } + } + public static Vec3S32 Max(Vec3S32 a, Vec3S32 b) { return new Vec3S32(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y), Math.Max(a.Z, b.Z)); @@ -138,12 +143,13 @@ namespace MCGalaxy { public static Vec3S32 Min(Vec3S32 a, Vec3S32 b) { return new Vec3S32(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y), Math.Min(a.Z, b.Z)); - } + } public static implicit operator Vec3S32(Vec3U16 a) { return new Vec3S32(a.X, a.Y, a.Z); } + public static Vec3S32 operator + (Vec3S32 a, Vec3S32 b) { return new Vec3S32(a.X + b.X, a.Y + b.Y, a.Z + b.Z); } @@ -160,6 +166,23 @@ namespace MCGalaxy { return new Vec3S32(a.X / b, a.Y / b, a.Z / b); } + + public override bool Equals(object obj) { + return (obj is Vec3S32) && Equals((Vec3S32)obj); + } + + public bool Equals(Vec3S32 other) { + return X == other.X & Y == other.Y && Z == other.Z; + } + + public override int GetHashCode() { + int hashCode = 0; + hashCode += 1000000007 * X; + hashCode += 1000000009 * Y; + hashCode += 1000000021 * Z; + return hashCode; + } + public static bool operator == (Vec3S32 a, Vec3S32 b) { return a.X == b.X && a.Y == b.Y && a.Z == b.Z; } @@ -167,6 +190,7 @@ namespace MCGalaxy { public static bool operator != (Vec3S32 a, Vec3S32 b) { return a.X != b.X || a.Y != b.Y || a.Z != b.Z; } + public override string ToString() { return X + "," + Y + "," + Z; @@ -184,6 +208,7 @@ namespace MCGalaxy { X = x; Y = y; Z = z; } + public float LengthSquared { get { return X * X + Y * Y + Z * Z; } } @@ -196,6 +221,7 @@ namespace MCGalaxy { return a.X * b.X + a.Y * b.Y + a.Z * b.Z; } + public static Vec3F32 Cross(Vec3F32 a, Vec3F32 b) { return new Vec3F32(a.Y * b.Z - a.Z * b.Y, a.Z * b.X - a.X * b.Z, @@ -206,7 +232,8 @@ namespace MCGalaxy { float invLen = 1 / a.Length; a.X *= invLen; a.Y *= invLen; a.Z *= invLen; return a; - } + } + public static Vec3F32 operator * (float a, Vec3F32 b) { return new Vec3F32(a * b.X, a * b.Y, a * b.Z); @@ -222,7 +249,8 @@ namespace MCGalaxy { public static implicit operator Vec3F32(Vec3S32 a) { return new Vec3F32(a.X, a.Y, a.Z); - } + } + public override bool Equals(object obj) { return (obj is Vec3F32) && Equals((Vec3F32)obj); @@ -248,6 +276,7 @@ namespace MCGalaxy { return a.X != b.X || a.Y != b.Y || a.Z != b.Z; } + public override string ToString() { return X + "," + Y + "," + Z; }