From 9e2e6bb1e236e5d99d74dca0cd5d31d533b76c2e Mon Sep 17 00:00:00 2001 From: Xavier Cho Date: Sat, 14 Apr 2018 09:15:20 +0900 Subject: Remove duplicated declaration of RoundToInt() from Mathf --- modules/mono/glue/cs_files/Mathf.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/modules/mono/glue/cs_files/Mathf.cs b/modules/mono/glue/cs_files/Mathf.cs index bbee106018..040e7bf564 100644 --- a/modules/mono/glue/cs_files/Mathf.cs +++ b/modules/mono/glue/cs_files/Mathf.cs @@ -227,11 +227,6 @@ namespace Godot return (real_t)Math.Round(s); } - public static int RoundToInt(real_t s) - { - return (int)Math.Round(s); - } - public static int Sign(int s) { return (s < 0) ? -1 : 1; -- cgit v1.2.3 From 0ef3e0577b4c3889d19e6f301e06fba39e8187d5 Mon Sep 17 00:00:00 2001 From: Xavier Cho Date: Sun, 8 Apr 2018 12:28:24 +0900 Subject: #18051: Remove redundant casts and 'using', 'else', 'this' statements --- modules/mono/glue/cs_files/AABB.cs | 38 +++----- modules/mono/glue/cs_files/Basis.cs | 103 +++++++++++---------- modules/mono/glue/cs_files/Color.cs | 70 +++++--------- modules/mono/glue/cs_files/DebuggingUtils.cs | 2 +- modules/mono/glue/cs_files/GodotMethodAttribute.cs | 2 +- .../glue/cs_files/GodotSynchronizationContext.cs | 1 - modules/mono/glue/cs_files/GodotTaskScheduler.cs | 2 +- modules/mono/glue/cs_files/IAwaiter.cs | 1 - modules/mono/glue/cs_files/Mathf.cs | 10 +- modules/mono/glue/cs_files/Plane.cs | 11 +-- modules/mono/glue/cs_files/Quat.cs | 45 ++++----- modules/mono/glue/cs_files/Rect2.cs | 17 ++-- modules/mono/glue/cs_files/SignalAttribute.cs | 3 - modules/mono/glue/cs_files/SignalAwaiter.cs | 12 +-- modules/mono/glue/cs_files/StringExtensions.cs | 41 ++++---- modules/mono/glue/cs_files/Transform.cs | 13 ++- modules/mono/glue/cs_files/Transform2D.cs | 29 +++--- modules/mono/glue/cs_files/Vector2.cs | 48 ++++------ modules/mono/glue/cs_files/Vector3.cs | 44 ++++----- 19 files changed, 211 insertions(+), 281 deletions(-) diff --git a/modules/mono/glue/cs_files/AABB.cs b/modules/mono/glue/cs_files/AABB.cs index 25458c93e1..94f27f38aa 100644 --- a/modules/mono/glue/cs_files/AABB.cs +++ b/modules/mono/glue/cs_files/AABB.cs @@ -1,12 +1,10 @@ -using System; - // file: core/math/aabb.h // commit: 7ad14e7a3e6f87ddc450f7e34621eb5200808451 // file: core/math/aabb.cpp // commit: bd282ff43f23fe845f29a3e25c8efc01bd65ffb0 // file: core/variant_call.cpp // commit: 5ad9be4c24e9d7dc5672fdc42cea896622fe5685 - +using System; #if REAL_T_IS_DOUBLE using real_t = System.Double; #else @@ -283,31 +281,25 @@ namespace Godot { return new AABB(); } - else - { - min.x = (src_min.x > dst_min.x) ? src_min.x : dst_min.x; - max.x = (src_max.x < dst_max.x) ? src_max.x : dst_max.x; - } + + min.x = (src_min.x > dst_min.x) ? src_min.x : dst_min.x; + max.x = (src_max.x < dst_max.x) ? src_max.x : dst_max.x; if (src_min.y > dst_max.y || src_max.y < dst_min.y) { return new AABB(); } - else - { - min.y = (src_min.y > dst_min.y) ? src_min.y : dst_min.y; - max.y = (src_max.y < dst_max.y) ? src_max.y : dst_max.y; - } + + min.y = (src_min.y > dst_min.y) ? src_min.y : dst_min.y; + max.y = (src_max.y < dst_max.y) ? src_max.y : dst_max.y; if (src_min.z > dst_max.z || src_max.z < dst_min.z) { return new AABB(); } - else - { - min.z = (src_min.z > dst_min.z) ? src_min.z : dst_min.z; - max.z = (src_max.z < dst_max.z) ? src_max.z : dst_max.z; - } + + min.z = (src_min.z > dst_min.z) ? src_min.z : dst_min.z; + max.z = (src_max.z < dst_max.z) ? src_max.z : dst_max.z; return new AABB(min, max - min); } @@ -341,7 +333,7 @@ namespace Godot new Vector3(position.x + size.x, position.y, position.z), new Vector3(position.x + size.x, position.y, position.z + size.z), new Vector3(position.x + size.x, position.y + size.y, position.z), - new Vector3(position.x + size.x, position.y + size.y, position.z + size.z), + new Vector3(position.x + size.x, position.y + size.y, position.z + size.z) }; bool over = false; @@ -467,8 +459,8 @@ namespace Godot { return String.Format("{0} - {1}", new object[] { - this.position.ToString(), - this.size.ToString() + position.ToString(), + size.ToString() }); } @@ -476,8 +468,8 @@ namespace Godot { return String.Format("{0} - {1}", new object[] { - this.position.ToString(format), - this.size.ToString(format) + position.ToString(format), + size.ToString(format) }); } } diff --git a/modules/mono/glue/cs_files/Basis.cs b/modules/mono/glue/cs_files/Basis.cs index aa07cf3999..660243f77f 100644 --- a/modules/mono/glue/cs_files/Basis.cs +++ b/modules/mono/glue/cs_files/Basis.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; - #if REAL_T_IS_DOUBLE using real_t = System.Double; #else @@ -188,7 +187,7 @@ namespace Godot public Vector3 GetEuler() { - Basis m = this.Orthonormalized(); + Basis m = Orthonormalized(); Vector3 euler; euler.z = 0.0f; @@ -302,7 +301,7 @@ namespace Godot zAxis = (zAxis - xAxis * (xAxis.Dot(zAxis)) - yAxis * (yAxis.Dot(zAxis))); zAxis.Normalize(); - return Basis.CreateFromAxes(xAxis, yAxis, zAxis); + return CreateFromAxes(xAxis, yAxis, zAxis); } public Basis Rotated(Vector3 axis, real_t phi) @@ -393,34 +392,38 @@ namespace Godot (_y[0] - _x[1]) * inv_s, s * 0.25f ); - } else if (_x[0] > _y[1] && _x[0] > _z[2]) { - real_t s = Mathf.Sqrt(_x[0] - _y[1] - _z[2] + 1.0f) * 2f; - real_t inv_s = 1f / s; - return new Quat( - s * 0.25f, - (_x[1] + _y[0]) * inv_s, - (_x[2] + _z[0]) * inv_s, - (_z[1] - _y[2]) * inv_s - ); - } else if (_y[1] > _z[2]) { - real_t s = Mathf.Sqrt(-_x[0] + _y[1] - _z[2] + 1.0f) * 2f; - real_t inv_s = 1f / s; - return new Quat( - (_x[1] + _y[0]) * inv_s, - s * 0.25f, - (_y[2] + _z[1]) * inv_s, - (_x[2] - _z[0]) * inv_s - ); - } else { - real_t s = Mathf.Sqrt(-_x[0] - _y[1] + _z[2] + 1.0f) * 2f; - real_t inv_s = 1f / s; - return new Quat( - (_x[2] + _z[0]) * inv_s, - (_y[2] + _z[1]) * inv_s, - s * 0.25f, - (_y[0] - _x[1]) * inv_s - ); } + + if (_x[0] > _y[1] && _x[0] > _z[2]) { + real_t s = Mathf.Sqrt(_x[0] - _y[1] - _z[2] + 1.0f) * 2f; + real_t inv_s = 1f / s; + return new Quat( + s * 0.25f, + (_x[1] + _y[0]) * inv_s, + (_x[2] + _z[0]) * inv_s, + (_z[1] - _y[2]) * inv_s + ); + } + + if (_y[1] > _z[2]) { + real_t s = Mathf.Sqrt(-_x[0] + _y[1] - _z[2] + 1.0f) * 2f; + real_t inv_s = 1f / s; + return new Quat( + (_x[1] + _y[0]) * inv_s, + s * 0.25f, + (_y[2] + _z[1]) * inv_s, + (_x[2] - _z[0]) * inv_s + ); + } else { + real_t s = Mathf.Sqrt(-_x[0] - _y[1] + _z[2] + 1.0f) * 2f; + real_t inv_s = 1f / s; + return new Quat( + (_x[2] + _z[0]) * inv_s, + (_y[2] + _z[1]) * inv_s, + s * 0.25f, + (_y[0] - _x[1]) * inv_s + ); + } } public Basis(Quat quat) @@ -440,33 +443,33 @@ namespace Godot real_t yz = quat.y * zs; real_t zz = quat.z * zs; - this._x = new Vector3(1.0f - (yy + zz), xy - wz, xz + wy); - this._y = new Vector3(xy + wz, 1.0f - (xx + zz), yz - wx); - this._z = new Vector3(xz - wy, yz + wx, 1.0f - (xx + yy)); + _x = new Vector3(1.0f - (yy + zz), xy - wz, xz + wy); + _y = new Vector3(xy + wz, 1.0f - (xx + zz), yz - wx); + _z = new Vector3(xz - wy, yz + wx, 1.0f - (xx + yy)); } public Basis(Vector3 axis, real_t phi) { Vector3 axis_sq = new Vector3(axis.x * axis.x, axis.y * axis.y, axis.z * axis.z); - real_t cosine = Mathf.Cos( (real_t)phi); - real_t sine = Mathf.Sin( (real_t)phi); + real_t cosine = Mathf.Cos( phi); + real_t sine = Mathf.Sin( phi); - this._x = new Vector3 + _x = new Vector3 ( axis_sq.x + cosine * (1.0f - axis_sq.x), axis.x * axis.y * (1.0f - cosine) - axis.z * sine, axis.z * axis.x * (1.0f - cosine) + axis.y * sine ); - this._y = new Vector3 + _y = new Vector3 ( axis.x * axis.y * (1.0f - cosine) + axis.z * sine, axis_sq.y + cosine * (1.0f - axis_sq.y), axis.y * axis.z * (1.0f - cosine) - axis.x * sine ); - this._z = new Vector3 + _z = new Vector3 ( axis.z * axis.x * (1.0f - cosine) - axis.y * sine, axis.y * axis.z * (1.0f - cosine) + axis.x * sine, @@ -476,16 +479,16 @@ namespace Godot public Basis(Vector3 xAxis, Vector3 yAxis, Vector3 zAxis) { - this._x = xAxis; - this._y = yAxis; - this._z = zAxis; + _x = xAxis; + _y = yAxis; + _z = zAxis; } public Basis(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz) { - this._x = new Vector3(xx, xy, xz); - this._y = new Vector3(yx, yy, yz); - this._z = new Vector3(zx, zy, zz); + _x = new Vector3(xx, xy, xz); + _y = new Vector3(yx, yy, yz); + _z = new Vector3(zx, zy, zz); } public static Basis operator *(Basis left, Basis right) @@ -532,9 +535,9 @@ namespace Godot { return String.Format("({0}, {1}, {2})", new object[] { - this._x.ToString(), - this._y.ToString(), - this._z.ToString() + _x.ToString(), + _y.ToString(), + _z.ToString() }); } @@ -542,9 +545,9 @@ namespace Godot { return String.Format("({0}, {1}, {2})", new object[] { - this._x.ToString(format), - this._y.ToString(format), - this._z.ToString(format) + _x.ToString(format), + _y.ToString(format), + _z.ToString(format) }); } } diff --git a/modules/mono/glue/cs_files/Color.cs b/modules/mono/glue/cs_files/Color.cs index aa42c487c8..618ae8870e 100644 --- a/modules/mono/glue/cs_files/Color.cs +++ b/modules/mono/glue/cs_files/Color.cs @@ -45,8 +45,8 @@ namespace Godot { get { - float max = (float) Mathf.Max(r, (float) Mathf.Max(g, b)); - float min = (float) Mathf.Min(r, (float) Mathf.Min(g, b)); + float max = Mathf.Max(r, Mathf.Max(g, b)); + float min = Mathf.Min(r, Mathf.Min(g, b)); float delta = max - min; @@ -79,8 +79,8 @@ namespace Godot { get { - float max = (float) Mathf.Max(r, (float) Mathf.Max(g, b)); - float min = (float) Mathf.Min(r, (float) Mathf.Min(g, b)); + float max = Mathf.Max(r, Mathf.Max(g, b)); + float min = Mathf.Min(r, Mathf.Min(g, b)); float delta = max - min; @@ -96,7 +96,7 @@ namespace Godot { get { - return (float) Mathf.Max(r, (float) Mathf.Max(g, b)); + return Mathf.Max(r, Mathf.Max(g, b)); } set { @@ -232,12 +232,10 @@ namespace Godot { return new Color(0, 0, 0, 0); } - else - { - res.r = (r * a * sa + over.r * over.a) / res.a; - res.g = (g * a * sa + over.g * over.a) / res.a; - res.b = (b * a * sa + over.b * over.a) / res.a; - } + + res.r = (r * a * sa + over.r * over.a) / res.a; + res.g = (g * a * sa + over.g * over.a) / res.a; + res.b = (b * a * sa + over.b * over.a) / res.a; return res; } @@ -269,10 +267,10 @@ namespace Godot { Color res = this; - res.r += (t * (b.r - this.r)); - res.g += (t * (b.g - this.g)); + res.r += (t * (b.r - r)); + res.g += (t * (b.g - g)); res.b += (t * (b.b - this.b)); - res.a += (t * (b.a - this.a)); + res.a += (t * (b.a - a)); return res; } @@ -328,13 +326,13 @@ namespace Godot public Color(int rgba) { - this.a = (rgba & 0xFF) / 255.0f; + a = (rgba & 0xFF) / 255.0f; rgba >>= 8; - this.b = (rgba & 0xFF) / 255.0f; + b = (rgba & 0xFF) / 255.0f; rgba >>= 8; - this.g = (rgba & 0xFF) / 255.0f; + g = (rgba & 0xFF) / 255.0f; rgba >>= 8; - this.r = (rgba & 0xFF) / 255.0f; + r = (rgba & 0xFF) / 255.0f; } private static int _parse_col(string str, int ofs) @@ -434,7 +432,7 @@ namespace Godot public static Color Color8(byte r8, byte g8, byte b8, byte a8) { - return new Color((float)r8 / 255f, (float)g8 / 255f, (float)b8 / 255f, (float)a8 / 255f); + return new Color(r8 / 255f, g8 / 255f, b8 / 255f, a8 / 255f); } public Color(string rgba) @@ -514,13 +512,10 @@ namespace Godot { if (left.b == right.b) return (left.a < right.a); - else - return (left.b < right.b); - } - else - { - return left.g < right.g; + return (left.b < right.b); } + + return left.g < right.g; } return left.r < right.r; @@ -534,13 +529,10 @@ namespace Godot { if (left.b == right.b) return (left.a > right.a); - else - return (left.b > right.b); - } - else - { - return left.g > right.g; + return (left.b > right.b); } + + return left.g > right.g; } return left.r > right.r; @@ -568,24 +560,12 @@ namespace Godot public override string ToString() { - return String.Format("{0},{1},{2},{3}", new object[] - { - this.r.ToString(), - this.g.ToString(), - this.b.ToString(), - this.a.ToString() - }); + return String.Format("{0},{1},{2},{3}", r.ToString(), g.ToString(), b.ToString(), a.ToString()); } public string ToString(string format) { - return String.Format("{0},{1},{2},{3}", new object[] - { - this.r.ToString(format), - this.g.ToString(format), - this.b.ToString(format), - this.a.ToString(format) - }); + return String.Format("{0},{1},{2},{3}", r.ToString(format), g.ToString(format), b.ToString(format), a.ToString(format)); } } } diff --git a/modules/mono/glue/cs_files/DebuggingUtils.cs b/modules/mono/glue/cs_files/DebuggingUtils.cs index ffaaf00837..bbedf2fc44 100644 --- a/modules/mono/glue/cs_files/DebuggingUtils.cs +++ b/modules/mono/glue/cs_files/DebuggingUtils.cs @@ -14,7 +14,7 @@ namespace Godot else if (type == typeof(void)) sb.Append("void"); else - sb.Append(type.ToString()); + sb.Append(type); sb.Append(" "); } diff --git a/modules/mono/glue/cs_files/GodotMethodAttribute.cs b/modules/mono/glue/cs_files/GodotMethodAttribute.cs index 21333c8dab..55848769d5 100644 --- a/modules/mono/glue/cs_files/GodotMethodAttribute.cs +++ b/modules/mono/glue/cs_files/GodotMethodAttribute.cs @@ -2,7 +2,7 @@ using System; namespace Godot { - [AttributeUsage(AttributeTargets.Method, Inherited = true)] + [AttributeUsage(AttributeTargets.Method)] internal class GodotMethodAttribute : Attribute { private string methodName; diff --git a/modules/mono/glue/cs_files/GodotSynchronizationContext.cs b/modules/mono/glue/cs_files/GodotSynchronizationContext.cs index eb4d0bed1c..da3c7bac83 100644 --- a/modules/mono/glue/cs_files/GodotSynchronizationContext.cs +++ b/modules/mono/glue/cs_files/GodotSynchronizationContext.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Threading; diff --git a/modules/mono/glue/cs_files/GodotTaskScheduler.cs b/modules/mono/glue/cs_files/GodotTaskScheduler.cs index f587645a49..6bf25a89d2 100644 --- a/modules/mono/glue/cs_files/GodotTaskScheduler.cs +++ b/modules/mono/glue/cs_files/GodotTaskScheduler.cs @@ -36,7 +36,7 @@ namespace Godot TryDequeue(task); } - return base.TryExecuteTask(task); + return TryExecuteTask(task); } protected sealed override bool TryDequeue(Task task) diff --git a/modules/mono/glue/cs_files/IAwaiter.cs b/modules/mono/glue/cs_files/IAwaiter.cs index 73c71b5634..b5aa1a5389 100644 --- a/modules/mono/glue/cs_files/IAwaiter.cs +++ b/modules/mono/glue/cs_files/IAwaiter.cs @@ -1,4 +1,3 @@ -using System; using System.Runtime.CompilerServices; namespace Godot diff --git a/modules/mono/glue/cs_files/Mathf.cs b/modules/mono/glue/cs_files/Mathf.cs index 040e7bf564..d6655aa1e2 100644 --- a/modules/mono/glue/cs_files/Mathf.cs +++ b/modules/mono/glue/cs_files/Mathf.cs @@ -1,5 +1,4 @@ using System; - #if REAL_T_IS_DOUBLE using real_t = System.Double; #else @@ -115,7 +114,8 @@ namespace Godot return Pow(s, curve); } - else if (curve < 0f) + + if (curve < 0f) { if (s < 0.5f) { @@ -144,10 +144,8 @@ namespace Godot { return x % y; } - else - { - return y - (-x % y); - } + + return y - (-x % y); } public static real_t InverseLerp(real_t from, real_t to, real_t weight) diff --git a/modules/mono/glue/cs_files/Plane.cs b/modules/mono/glue/cs_files/Plane.cs index 0f74f3b66a..edbb3545b8 100644 --- a/modules/mono/glue/cs_files/Plane.cs +++ b/modules/mono/glue/cs_files/Plane.cs @@ -1,5 +1,4 @@ using System; - #if REAL_T_IS_DOUBLE using real_t = System.Double; #else @@ -81,7 +80,7 @@ namespace Godot if (Mathf.Abs(denom) <= Mathf.Epsilon) return new Vector3(); - Vector3 result = (b.normal.Cross(c.normal) * this.d) + + Vector3 result = (b.normal.Cross(c.normal) * d) + (c.normal.Cross(normal) * b.d) + (normal.Cross(b.normal) * c.d); @@ -198,8 +197,8 @@ namespace Godot { return String.Format("({0}, {1})", new object[] { - this.normal.ToString(), - this.d.ToString() + normal.ToString(), + d.ToString() }); } @@ -207,8 +206,8 @@ namespace Godot { return String.Format("({0}, {1})", new object[] { - this.normal.ToString(format), - this.d.ToString(format) + normal.ToString(format), + d.ToString(format) }); } } diff --git a/modules/mono/glue/cs_files/Quat.cs b/modules/mono/glue/cs_files/Quat.cs index 0cf3e00ddb..cfdb5f21ee 100644 --- a/modules/mono/glue/cs_files/Quat.cs +++ b/modules/mono/glue/cs_files/Quat.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; - #if REAL_T_IS_DOUBLE using real_t = System.Double; #else @@ -106,10 +105,10 @@ namespace Godot } public void Set(Quat q) { - this.x = q.x; - this.y = q.y; - this.z = q.z; - this.w = q.w; + x = q.x; + y = q.y; + z = q.z; + w = q.w; } public Quat Slerp(Quat b, real_t t) @@ -165,7 +164,7 @@ namespace Godot public Quat Slerpni(Quat b, real_t t) { - real_t dot = this.Dot(b); + real_t dot = Dot(b); if (Mathf.Abs(dot) > 0.9999f) { @@ -179,17 +178,17 @@ namespace Godot return new Quat ( - invFactor * this.x + newFactor * b.x, - invFactor * this.y + newFactor * b.y, - invFactor * this.z + newFactor * b.z, - invFactor * this.w + newFactor * b.w + invFactor * x + newFactor * b.x, + invFactor * y + newFactor * b.y, + invFactor * z + newFactor * b.z, + invFactor * w + newFactor * b.w ); } public Vector3 Xform(Vector3 v) { Quat q = this * v; - q *= this.Inverse(); + q *= Inverse(); return new Vector3(q.x, q.y, q.z); } @@ -203,10 +202,10 @@ namespace Godot } public Quat(Quat q) { - this.x = q.x; - this.y = q.y; - this.z = q.z; - this.w = q.w; + x = q.x; + y = q.y; + z = q.z; + w = q.w; } public Quat(Vector3 axis, real_t angle) @@ -327,24 +326,12 @@ namespace Godot public override string ToString() { - return String.Format("({0}, {1}, {2}, {3})", new object[] - { - this.x.ToString(), - this.y.ToString(), - this.z.ToString(), - this.w.ToString() - }); + return String.Format("({0}, {1}, {2}, {3})", x.ToString(), y.ToString(), z.ToString(), w.ToString()); } public string ToString(string format) { - return String.Format("({0}, {1}, {2}, {3})", new object[] - { - this.x.ToString(format), - this.y.ToString(format), - this.z.ToString(format), - this.w.ToString(format) - }); + return String.Format("({0}, {1}, {2}, {3})", x.ToString(format), y.ToString(format), z.ToString(format), w.ToString(format)); } } } diff --git a/modules/mono/glue/cs_files/Rect2.cs b/modules/mono/glue/cs_files/Rect2.cs index decee35f8c..c7a29b2f0b 100644 --- a/modules/mono/glue/cs_files/Rect2.cs +++ b/modules/mono/glue/cs_files/Rect2.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; - #if REAL_T_IS_DOUBLE using real_t = System.Double; #else @@ -185,17 +184,17 @@ namespace Godot public Rect2(Vector2 position, real_t width, real_t height) { this.position = position; - this.size = new Vector2(width, height); + size = new Vector2(width, height); } public Rect2(real_t x, real_t y, Vector2 size) { - this.position = new Vector2(x, y); + position = new Vector2(x, y); this.size = size; } public Rect2(real_t x, real_t y, real_t width, real_t height) { - this.position = new Vector2(x, y); - this.size = new Vector2(width, height); + position = new Vector2(x, y); + size = new Vector2(width, height); } public static bool operator ==(Rect2 left, Rect2 right) @@ -232,8 +231,8 @@ namespace Godot { return String.Format("({0}, {1})", new object[] { - this.position.ToString(), - this.size.ToString() + position.ToString(), + size.ToString() }); } @@ -241,8 +240,8 @@ namespace Godot { return String.Format("({0}, {1})", new object[] { - this.position.ToString(format), - this.size.ToString(format) + position.ToString(format), + size.ToString(format) }); } } diff --git a/modules/mono/glue/cs_files/SignalAttribute.cs b/modules/mono/glue/cs_files/SignalAttribute.cs index d8a6cabb83..3957387be9 100644 --- a/modules/mono/glue/cs_files/SignalAttribute.cs +++ b/modules/mono/glue/cs_files/SignalAttribute.cs @@ -5,8 +5,5 @@ namespace Godot [AttributeUsage(AttributeTargets.Delegate)] public class SignalAttribute : Attribute { - public SignalAttribute() - { - } } } diff --git a/modules/mono/glue/cs_files/SignalAwaiter.cs b/modules/mono/glue/cs_files/SignalAwaiter.cs index 19ccc26e79..c06f6b05c9 100644 --- a/modules/mono/glue/cs_files/SignalAwaiter.cs +++ b/modules/mono/glue/cs_files/SignalAwaiter.cs @@ -4,15 +4,15 @@ namespace Godot { public class SignalAwaiter : IAwaiter, IAwaitable { - private bool completed = false; - private object[] result = null; - private Action action = null; + private bool completed; + private object[] result; + private Action action; - public SignalAwaiter(Godot.Object source, string signal, Godot.Object target) + public SignalAwaiter(Object source, string signal, Object target) { NativeCalls.godot_icall_Object_connect_signal_awaiter( - Godot.Object.GetPtr(source), - signal, Godot.Object.GetPtr(target), this + Object.GetPtr(source), + signal, Object.GetPtr(target), this ); } diff --git a/modules/mono/glue/cs_files/StringExtensions.cs b/modules/mono/glue/cs_files/StringExtensions.cs index cbc337ab19..a18c04b274 100644 --- a/modules/mono/glue/cs_files/StringExtensions.cs +++ b/modules/mono/glue/cs_files/StringExtensions.cs @@ -1,4 +1,5 @@ //using System; + using System; using System.Collections.Generic; using System.Globalization; @@ -43,11 +44,9 @@ namespace Godot { return instance.Substring(prev, i - prev); } - else - { - count++; - prev = i + 1; - } + + count++; + prev = i + 1; } i++; @@ -178,13 +177,13 @@ namespace Godot { if (to[to_idx] == 0 && instance[instance_idx] == 0) return 0; // We're equal - else if (instance[instance_idx] == 0) + if (instance[instance_idx] == 0) return -1; // If this is empty, and the other one is not, then we're less... I think? - else if (to[to_idx] == 0) + if (to[to_idx] == 0) return 1; // Otherwise the other one is smaller... - else if (instance[instance_idx] < to[to_idx]) // More than + if (instance[instance_idx] < to[to_idx]) // More than return -1; - else if (instance[instance_idx] > to[to_idx]) // Less than + if (instance[instance_idx] > to[to_idx]) // Less than return 1; instance_idx++; @@ -312,7 +311,7 @@ namespace Godot int hashv = 5381; int c; - while ((c = (int)instance[index++]) != 0) + while ((c = instance[index++]) != 0) hashv = ((hashv << 5) + hashv) + c; // hash * 33 + c return hashv; @@ -610,13 +609,13 @@ namespace Godot { if (to[to_idx] == 0 && instance[instance_idx] == 0) return 0; // We're equal - else if (instance[instance_idx] == 0) + if (instance[instance_idx] == 0) return -1; // If this is empty, and the other one is not, then we're less... I think? - else if (to[to_idx] == 0) + if (to[to_idx] == 0) return 1; // Otherwise the other one is smaller.. - else if (char.ToUpper(instance[instance_idx]) < char.ToUpper(to[to_idx])) // More than + if (char.ToUpper(instance[instance_idx]) < char.ToUpper(to[to_idx])) // More than return -1; - else if (char.ToUpper(instance[instance_idx]) > char.ToUpper(to[to_idx])) // Less than + if (char.ToUpper(instance[instance_idx]) > char.ToUpper(to[to_idx])) // Less than return 1; instance_idx++; @@ -724,8 +723,7 @@ namespace Godot { if (instance.Length > 0 && instance[instance.Length - 1] == '/') return instance + file; - else - return instance + "/" + file; + return instance + "/" + file; } // @@ -832,7 +830,7 @@ namespace Godot // public static string[] Split(this string instance, string divisor, bool allow_empty = true) { - return instance.Split(new string[] { divisor }, StringSplitOptions.RemoveEmptyEntries); + return instance.Split(new[] { divisor }, StringSplitOptions.RemoveEmptyEntries); } // @@ -878,13 +876,10 @@ namespace Godot { if (right) return instance.Trim(non_printable); - else - return instance.TrimStart(non_printable); - } - else - { - return instance.TrimEnd(non_printable); + return instance.TrimStart(non_printable); } + + return instance.TrimEnd(non_printable); } // diff --git a/modules/mono/glue/cs_files/Transform.cs b/modules/mono/glue/cs_files/Transform.cs index ce26c60706..ff6d386994 100644 --- a/modules/mono/glue/cs_files/Transform.cs +++ b/modules/mono/glue/cs_files/Transform.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; - #if REAL_T_IS_DOUBLE using real_t = System.Double; #else @@ -107,13 +106,13 @@ namespace Godot // Constructors public Transform(Vector3 xAxis, Vector3 yAxis, Vector3 zAxis, Vector3 origin) { - this.basis = Basis.CreateFromAxes(xAxis, yAxis, zAxis); + basis = Basis.CreateFromAxes(xAxis, yAxis, zAxis); this.origin = origin; } public Transform(Quat quat, Vector3 origin) { - this.basis = new Basis(quat); + basis = new Basis(quat); this.origin = origin; } @@ -164,8 +163,8 @@ namespace Godot { return String.Format("{0} - {1}", new object[] { - this.basis.ToString(), - this.origin.ToString() + basis.ToString(), + origin.ToString() }); } @@ -173,8 +172,8 @@ namespace Godot { return String.Format("{0} - {1}", new object[] { - this.basis.ToString(format), - this.origin.ToString(format) + basis.ToString(format), + origin.ToString(format) }); } } diff --git a/modules/mono/glue/cs_files/Transform2D.cs b/modules/mono/glue/cs_files/Transform2D.cs index 836cca129e..44e5d042b9 100644 --- a/modules/mono/glue/cs_files/Transform2D.cs +++ b/modules/mono/glue/cs_files/Transform2D.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; - #if REAL_T_IS_DOUBLE using real_t = System.Double; #else @@ -269,22 +268,22 @@ namespace Godot // Constructors public Transform2D(Vector2 xAxis, Vector2 yAxis, Vector2 origin) { - this.x = xAxis; - this.y = yAxis; - this.o = origin; + x = xAxis; + y = yAxis; + o = origin; } public Transform2D(real_t xx, real_t xy, real_t yx, real_t yy, real_t ox, real_t oy) { - this.x = new Vector2(xx, xy); - this.y = new Vector2(yx, yy); - this.o = new Vector2(ox, oy); + x = new Vector2(xx, xy); + y = new Vector2(yx, yy); + o = new Vector2(ox, oy); } public Transform2D(real_t rot, Vector2 pos) { - real_t cr = Mathf.Cos( (real_t)rot); - real_t sr = Mathf.Sin( (real_t)rot); + real_t cr = Mathf.Cos(rot); + real_t sr = Mathf.Sin(rot); x.x = cr; y.y = cr; x.y = -sr; @@ -345,9 +344,9 @@ namespace Godot { return String.Format("({0}, {1}, {2})", new object[] { - this.x.ToString(), - this.y.ToString(), - this.o.ToString() + x.ToString(), + y.ToString(), + o.ToString() }); } @@ -355,9 +354,9 @@ namespace Godot { return String.Format("({0}, {1}, {2})", new object[] { - this.x.ToString(format), - this.y.ToString(format), - this.o.ToString(format) + x.ToString(format), + y.ToString(format), + o.ToString(format) }); } } diff --git a/modules/mono/glue/cs_files/Vector2.cs b/modules/mono/glue/cs_files/Vector2.cs index 6fbe374611..a5da9f97da 100644 --- a/modules/mono/glue/cs_files/Vector2.cs +++ b/modules/mono/glue/cs_files/Vector2.cs @@ -1,13 +1,11 @@ -using System; -using System.Runtime.InteropServices; - // file: core/math/math_2d.h // commit: 7ad14e7a3e6f87ddc450f7e34621eb5200808451 // file: core/math/math_2d.cpp // commit: 7ad14e7a3e6f87ddc450f7e34621eb5200808451 // file: core/variant_call.cpp // commit: 5ad9be4c24e9d7dc5672fdc42cea896622fe5685 - +using System; +using System.Runtime.InteropServices; #if REAL_T_IS_DOUBLE using real_t = System.Double; #else @@ -102,7 +100,7 @@ namespace Godot public Vector2 Clamped(real_t length) { Vector2 v = this; - real_t l = this.Length(); + real_t l = Length(); if (l > 0 && length < l) { @@ -199,8 +197,8 @@ namespace Godot } public void Set(Vector2 v) { - this.x = v.x; - this.y = v.y; + x = v.x; + y = v.y; } public Vector2 Slide(Vector2 n) @@ -244,8 +242,8 @@ namespace Godot } public Vector2(Vector2 v) { - this.x = v.x; - this.y = v.y; + x = v.x; + y = v.y; } public static Vector2 operator +(Vector2 left, Vector2 right) @@ -320,10 +318,8 @@ namespace Godot { return left.y < right.y; } - else - { - return left.x < right.x; - } + + return left.x < right.x; } public static bool operator >(Vector2 left, Vector2 right) @@ -332,10 +328,8 @@ namespace Godot { return left.y > right.y; } - else - { - return left.x > right.x; - } + + return left.x > right.x; } public static bool operator <=(Vector2 left, Vector2 right) @@ -344,10 +338,8 @@ namespace Godot { return left.y <= right.y; } - else - { - return left.x <= right.x; - } + + return left.x <= right.x; } public static bool operator >=(Vector2 left, Vector2 right) @@ -356,10 +348,8 @@ namespace Godot { return left.y >= right.y; } - else - { - return left.x >= right.x; - } + + return left.x >= right.x; } public override bool Equals(object obj) @@ -386,8 +376,8 @@ namespace Godot { return String.Format("({0}, {1})", new object[] { - this.x.ToString(), - this.y.ToString() + x.ToString(), + y.ToString() }); } @@ -395,8 +385,8 @@ namespace Godot { return String.Format("({0}, {1})", new object[] { - this.x.ToString(format), - this.y.ToString(format) + x.ToString(format), + y.ToString(format) }); } } diff --git a/modules/mono/glue/cs_files/Vector3.cs b/modules/mono/glue/cs_files/Vector3.cs index 285736d7b8..af190bfd58 100644 --- a/modules/mono/glue/cs_files/Vector3.cs +++ b/modules/mono/glue/cs_files/Vector3.cs @@ -1,13 +1,11 @@ -using System; -using System.Runtime.InteropServices; - // file: core/math/vector3.h // commit: bd282ff43f23fe845f29a3e25c8efc01bd65ffb0 // file: core/math/vector3.cpp // commit: 7ad14e7a3e6f87ddc450f7e34621eb5200808451 // file: core/variant_call.cpp // commit: 5ad9be4c24e9d7dc5672fdc42cea896622fe5685 - +using System; +using System.Runtime.InteropServices; #if REAL_T_IS_DOUBLE using real_t = System.Double; #else @@ -67,7 +65,7 @@ namespace Godot internal void Normalize() { - real_t length = this.Length(); + real_t length = Length(); if (length == 0f) { @@ -234,9 +232,9 @@ namespace Godot } public void Set(Vector3 v) { - this.x = v.x; - this.y = v.y; - this.z = v.z; + x = v.x; + y = v.y; + z = v.z; } public Vector3 Slide(Vector3 n) @@ -294,9 +292,9 @@ namespace Godot } public Vector3(Vector3 v) { - this.x = v.x; - this.y = v.y; - this.z = v.z; + x = v.x; + y = v.y; + z = v.z; } public static Vector3 operator +(Vector3 left, Vector3 right) @@ -379,8 +377,7 @@ namespace Godot { if (left.y == right.y) return left.z < right.z; - else - return left.y < right.y; + return left.y < right.y; } return left.x < right.x; @@ -392,8 +389,7 @@ namespace Godot { if (left.y == right.y) return left.z > right.z; - else - return left.y > right.y; + return left.y > right.y; } return left.x > right.x; @@ -405,8 +401,7 @@ namespace Godot { if (left.y == right.y) return left.z <= right.z; - else - return left.y < right.y; + return left.y < right.y; } return left.x < right.x; @@ -418,8 +413,7 @@ namespace Godot { if (left.y == right.y) return left.z >= right.z; - else - return left.y > right.y; + return left.y > right.y; } return left.x > right.x; @@ -449,9 +443,9 @@ namespace Godot { return String.Format("({0}, {1}, {2})", new object[] { - this.x.ToString(), - this.y.ToString(), - this.z.ToString() + x.ToString(), + y.ToString(), + z.ToString() }); } @@ -459,9 +453,9 @@ namespace Godot { return String.Format("({0}, {1}, {2})", new object[] { - this.x.ToString(format), - this.y.ToString(format), - this.z.ToString(format) + x.ToString(format), + y.ToString(format), + z.ToString(format) }); } } -- cgit v1.2.3 From fdfc478c888db89c44c748f273ef7fe4466d5c89 Mon Sep 17 00:00:00 2001 From: Xavier Cho Date: Sun, 8 Apr 2018 12:30:43 +0900 Subject: #18051: Use 'var' when applicable --- modules/mono/glue/cs_files/AABB.cs | 32 ++++++++++----------- modules/mono/glue/cs_files/Basis.cs | 22 +++++++------- modules/mono/glue/cs_files/Color.cs | 28 +++++++++--------- modules/mono/glue/cs_files/DebuggingUtils.cs | 6 ++-- modules/mono/glue/cs_files/GD.cs | 20 ++++++------- modules/mono/glue/cs_files/MarshalUtils.cs | 8 +++--- modules/mono/glue/cs_files/Plane.cs | 2 +- modules/mono/glue/cs_files/Quat.cs | 2 +- modules/mono/glue/cs_files/Rect2.cs | 10 +++---- modules/mono/glue/cs_files/StringExtensions.cs | 40 +++++++++++++------------- modules/mono/glue/cs_files/Transform.cs | 2 +- modules/mono/glue/cs_files/Transform2D.cs | 20 ++++++------- modules/mono/glue/cs_files/Vector2.cs | 16 +++++------ modules/mono/glue/cs_files/Vector3.cs | 10 +++---- 14 files changed, 109 insertions(+), 109 deletions(-) diff --git a/modules/mono/glue/cs_files/AABB.cs b/modules/mono/glue/cs_files/AABB.cs index 94f27f38aa..84566d855a 100644 --- a/modules/mono/glue/cs_files/AABB.cs +++ b/modules/mono/glue/cs_files/AABB.cs @@ -111,8 +111,8 @@ namespace Godot public Vector3 GetLongestAxis() { - Vector3 axis = new Vector3(1f, 0f, 0f); - real_t max_size = size.x; + var axis = new Vector3(1f, 0f, 0f); + real_t max_size = size.x; if (size.y > max_size) { @@ -131,7 +131,7 @@ namespace Godot public Vector3.Axis GetLongestAxisIndex() { - Vector3.Axis axis = Vector3.Axis.X; + var axis = Vector3.Axis.X; real_t max_size = size.x; if (size.y > max_size) @@ -151,7 +151,7 @@ namespace Godot public real_t GetLongestAxisSize() { - real_t max_size = size.x; + real_t max_size = size.x; if (size.y > max_size) max_size = size.y; @@ -164,8 +164,8 @@ namespace Godot public Vector3 GetShortestAxis() { - Vector3 axis = new Vector3(1f, 0f, 0f); - real_t max_size = size.x; + var axis = new Vector3(1f, 0f, 0f); + real_t max_size = size.x; if (size.y < max_size) { @@ -184,8 +184,8 @@ namespace Godot public Vector3.Axis GetShortestAxisIndex() { - Vector3.Axis axis = Vector3.Axis.X; - real_t max_size = size.x; + var axis = Vector3.Axis.X; + real_t max_size = size.x; if (size.y < max_size) { @@ -204,7 +204,7 @@ namespace Godot public real_t GetShortestAxisSize() { - real_t max_size = size.x; + real_t max_size = size.x; if (size.y < max_size) max_size = size.y; @@ -228,7 +228,7 @@ namespace Godot public AABB Grow(real_t by) { - AABB res = this; + var res = this; res.position.x -= by; res.position.y -= by; @@ -339,7 +339,7 @@ namespace Godot bool over = false; bool under = false; - for (int i = 0; i < 8; i++) + for (var i = 0; i < 8; i++) { if (plane.DistanceTo(points[i]) > 0) over = true; @@ -355,7 +355,7 @@ namespace Godot real_t min = 0f; real_t max = 1f; - for (int i = 0; i < 3; i++) + for (var i = 0; i < 3; i++) { real_t seg_from = from[i]; real_t seg_to = to[i]; @@ -400,16 +400,16 @@ namespace Godot { Vector3 beg_1 = position; Vector3 beg_2 = with.position; - Vector3 end_1 = new Vector3(size.x, size.y, size.z) + beg_1; - Vector3 end_2 = new Vector3(with.size.x, with.size.y, with.size.z) + beg_2; + var end_1 = new Vector3(size.x, size.y, size.z) + beg_1; + var end_2 = new Vector3(with.size.x, with.size.y, with.size.z) + beg_2; - Vector3 min = new Vector3( + var min = new Vector3( (beg_1.x < beg_2.x) ? beg_1.x : beg_2.x, (beg_1.y < beg_2.y) ? beg_1.y : beg_2.y, (beg_1.z < beg_2.z) ? beg_1.z : beg_2.z ); - Vector3 max = new Vector3( + var max = new Vector3( (end_1.x > end_2.x) ? end_1.x : end_2.x, (end_1.y > end_2.y) ? end_1.y : end_2.y, (end_1.z > end_2.z) ? end_1.z : end_2.z diff --git a/modules/mono/glue/cs_files/Basis.cs b/modules/mono/glue/cs_files/Basis.cs index 660243f77f..d16e40488c 100644 --- a/modules/mono/glue/cs_files/Basis.cs +++ b/modules/mono/glue/cs_files/Basis.cs @@ -220,11 +220,11 @@ namespace Godot public int GetOrthogonalIndex() { - Basis orth = this; + var orth = this; - for (int i = 0; i < 3; i++) + for (var i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) + for (var j = 0; j < 3; j++) { real_t v = orth[i, j]; @@ -239,7 +239,7 @@ namespace Godot } } - for (int i = 0; i < 24; i++) + for (var i = 0; i < 24; i++) { if (orthoBases[i] == orth) return i; @@ -250,9 +250,9 @@ namespace Godot public Basis Inverse() { - Basis inv = this; + var inv = this; - real_t[] co = new real_t[3] + var co = new real_t[3] { inv[1, 1] * inv[2, 2] - inv[1, 2] * inv[2, 1], inv[1, 2] * inv[2, 0] - inv[1, 0] * inv[2, 2], @@ -311,7 +311,7 @@ namespace Godot public Basis Scaled(Vector3 scale) { - Basis m = this; + var m = this; m[0, 0] *= scale.x; m[0, 1] *= scale.x; @@ -343,7 +343,7 @@ namespace Godot public Basis Transposed() { - Basis tr = this; + var tr = this; real_t temp = this[0, 1]; this[0, 1] = this[1, 0]; @@ -415,8 +415,8 @@ namespace Godot (_x[2] - _z[0]) * inv_s ); } else { - real_t s = Mathf.Sqrt(-_x[0] - _y[1] + _z[2] + 1.0f) * 2f; - real_t inv_s = 1f / s; + var s = Mathf.Sqrt(-_x[0] - _y[1] + _z[2] + 1.0f) * 2f; + var inv_s = 1f / s; return new Quat( (_x[2] + _z[0]) * inv_s, (_y[2] + _z[1]) * inv_s, @@ -450,7 +450,7 @@ namespace Godot public Basis(Vector3 axis, real_t phi) { - Vector3 axis_sq = new Vector3(axis.x * axis.x, axis.y * axis.y, axis.z * axis.z); + var axis_sq = new Vector3(axis.x * axis.x, axis.y * axis.y, axis.z * axis.z); real_t cosine = Mathf.Cos( phi); real_t sine = Mathf.Sin( phi); diff --git a/modules/mono/glue/cs_files/Color.cs b/modules/mono/glue/cs_files/Color.cs index 618ae8870e..d15f891e21 100644 --- a/modules/mono/glue/cs_files/Color.cs +++ b/modules/mono/glue/cs_files/Color.cs @@ -45,8 +45,8 @@ namespace Godot { get { - float max = Mathf.Max(r, Mathf.Max(g, b)); - float min = Mathf.Min(r, Mathf.Min(g, b)); + float max = Math.Max(r, Math.Max(g, b)); + float min = Math.Min(r, Math.Min(g, b)); float delta = max - min; @@ -79,8 +79,8 @@ namespace Godot { get { - float max = Mathf.Max(r, Mathf.Max(g, b)); - float min = Mathf.Min(r, Mathf.Min(g, b)); + float max = Math.Max(r, Math.Max(g, b)); + float min = Math.Min(r, Math.Min(g, b)); float delta = max - min; @@ -96,7 +96,7 @@ namespace Godot { get { - return Mathf.Max(r, Mathf.Max(g, b)); + return Math.Max(r, Math.Max(g, b)); } set { @@ -265,7 +265,7 @@ namespace Godot public Color LinearInterpolate(Color b, float t) { - Color res = this; + var res = this; res.r += (t * (b.r - r)); res.g += (t * (b.g - g)); @@ -303,7 +303,7 @@ namespace Godot public string ToHtml(bool include_alpha = true) { - String txt = string.Empty; + var txt = string.Empty; txt += _to_hex(r); txt += _to_hex(g); @@ -339,10 +339,10 @@ namespace Godot { int ig = 0; - for (int i = 0; i < 2; i++) + for (var i = 0; i < 2; i++) { int c = str[i + ofs]; - int v = 0; + var v = 0; if (c >= '0' && c <= '9') { @@ -374,11 +374,11 @@ namespace Godot private String _to_hex(float val) { - int v = (int) Mathf.Clamp(val * 255.0f, 0, 255); + var v = (int) Mathf.Clamp(val * 255.0f, 0, 255); - string ret = string.Empty; + var ret = string.Empty; - for (int i = 0; i < 2; i++) + for (var i = 0; i < 2; i++) { char[] c = { (char)0, (char)0 }; int lv = v & 0xF; @@ -403,7 +403,7 @@ namespace Godot if (color[0] == '#') color = color.Substring(1, color.Length - 1); - bool alpha = false; + var alpha = false; if (color.Length == 8) alpha = true; @@ -449,7 +449,7 @@ namespace Godot if (rgba[0] == '#') rgba = rgba.Substring(1); - bool alpha = false; + var alpha = false; if (rgba.Length == 8) { diff --git a/modules/mono/glue/cs_files/DebuggingUtils.cs b/modules/mono/glue/cs_files/DebuggingUtils.cs index bbedf2fc44..a654c9b268 100644 --- a/modules/mono/glue/cs_files/DebuggingUtils.cs +++ b/modules/mono/glue/cs_files/DebuggingUtils.cs @@ -32,7 +32,7 @@ namespace Godot return; } - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); if (methodBase is MethodInfo) sb.AppendTypeName(((MethodInfo)methodBase).ReturnType); @@ -47,7 +47,7 @@ namespace Godot sb.Append("<"); - for (int j = 0; j < genericParams.Length; j++) + for (var j = 0; j < genericParams.Length; j++) { if (j > 0) sb.Append(", "); @@ -64,7 +64,7 @@ namespace Godot ParameterInfo[] parameter = methodBase.GetParameters(); - for (int i = 0; i < parameter.Length; i++) + for (var i = 0; i < parameter.Length; i++) { if (i > 0) sb.Append(", "); diff --git a/modules/mono/glue/cs_files/GD.cs b/modules/mono/glue/cs_files/GD.cs index 1ee7e7d21c..f0967f2269 100644 --- a/modules/mono/glue/cs_files/GD.cs +++ b/modules/mono/glue/cs_files/GD.cs @@ -91,9 +91,9 @@ namespace Godot public static int[] Range(int length) { - int[] ret = new int[length]; + var ret = new int[length]; - for (int i = 0; i < length; i++) + for (var i = 0; i < length; i++) { ret[i] = i; } @@ -106,9 +106,9 @@ namespace Godot if (to < from) return new int[0]; - int[] ret = new int[to - from]; + var ret = new int[to - from]; - for (int i = from; i < to; i++) + for (var i = from; i < to; i++) { ret[i - from] = i; } @@ -124,27 +124,27 @@ namespace Godot return new int[0]; // Calculate count - int count = 0; + var count = 0; if (increment > 0) count = ((to - from - 1) / increment) + 1; else count = ((from - to - 1) / -increment) + 1; - int[] ret = new int[count]; + var ret = new int[count]; if (increment > 0) { - int idx = 0; - for (int i = from; i < to; i += increment) + int idx = 0; + for (var i = from; i < to; i += increment) { ret[idx++] = i; } } else { - int idx = 0; - for (int i = from; i > to; i += increment) + int idx = 0; + for (var i = from; i > to; i += increment) { ret[idx++] = i; } diff --git a/modules/mono/glue/cs_files/MarshalUtils.cs b/modules/mono/glue/cs_files/MarshalUtils.cs index 2bdfb95c51..661af3f8a2 100644 --- a/modules/mono/glue/cs_files/MarshalUtils.cs +++ b/modules/mono/glue/cs_files/MarshalUtils.cs @@ -7,9 +7,9 @@ namespace Godot { private static Dictionary ArraysToDictionary(object[] keys, object[] values) { - Dictionary ret = new Dictionary(); + var ret = new Dictionary(); - for (int i = 0; i < keys.Length; i++) + for (var i = 0; i < keys.Length; i++) { ret.Add(keys[i], values[i]); } @@ -19,11 +19,11 @@ namespace Godot private static void DictionaryToArrays(Dictionary from, out object[] keysTo, out object[] valuesTo) { - Dictionary.KeyCollection keys = from.Keys; + var keys = from.Keys; keysTo = new object[keys.Count]; keys.CopyTo(keysTo, 0); - Dictionary.ValueCollection values = from.Values; + var values = from.Values; valuesTo = new object[values.Count]; values.CopyTo(valuesTo, 0); } diff --git a/modules/mono/glue/cs_files/Plane.cs b/modules/mono/glue/cs_files/Plane.cs index edbb3545b8..6b19d929c8 100644 --- a/modules/mono/glue/cs_files/Plane.cs +++ b/modules/mono/glue/cs_files/Plane.cs @@ -80,7 +80,7 @@ namespace Godot if (Mathf.Abs(denom) <= Mathf.Epsilon) return new Vector3(); - Vector3 result = (b.normal.Cross(c.normal) * d) + + Vector3 result = (b.normal.Cross(c.normal) * d) + (c.normal.Cross(normal) * b.d) + (normal.Cross(b.normal) * c.d); diff --git a/modules/mono/glue/cs_files/Quat.cs b/modules/mono/glue/cs_files/Quat.cs index cfdb5f21ee..c0bce024cd 100644 --- a/modules/mono/glue/cs_files/Quat.cs +++ b/modules/mono/glue/cs_files/Quat.cs @@ -116,7 +116,7 @@ namespace Godot // Calculate cosine real_t cosom = x * b.x + y * b.y + z * b.z + w * b.w; - real_t[] to1 = new real_t[4]; + var to1 = new real_t[4]; // Adjust signs if necessary if (cosom < 0.0) diff --git a/modules/mono/glue/cs_files/Rect2.cs b/modules/mono/glue/cs_files/Rect2.cs index c7a29b2f0b..027360bb17 100644 --- a/modules/mono/glue/cs_files/Rect2.cs +++ b/modules/mono/glue/cs_files/Rect2.cs @@ -38,7 +38,7 @@ namespace Godot public Rect2 Clip(Rect2 b) { - Rect2 newRect = b; + var newRect = b; if (!Intersects(newRect)) return new Rect2(); @@ -64,7 +64,7 @@ namespace Godot public Rect2 Expand(Vector2 to) { - Rect2 expanded = this; + var expanded = this; Vector2 begin = expanded.position; Vector2 end = expanded.position + expanded.size; @@ -92,7 +92,7 @@ namespace Godot public Rect2 Grow(real_t by) { - Rect2 g = this; + var g = this; g.position.x -= by; g.position.y -= by; @@ -104,7 +104,7 @@ namespace Godot public Rect2 GrowIndividual(real_t left, real_t top, real_t right, real_t bottom) { - Rect2 g = this; + var g = this; g.position.x -= left; g.position.y -= top; @@ -116,7 +116,7 @@ namespace Godot public Rect2 GrowMargin(Margin margin, real_t by) { - Rect2 g = this; + var g = this; g.GrowIndividual((Margin.Left == margin) ? by : 0, (Margin.Top == margin) ? by : 0, diff --git a/modules/mono/glue/cs_files/StringExtensions.cs b/modules/mono/glue/cs_files/StringExtensions.cs index a18c04b274..030d1282f3 100644 --- a/modules/mono/glue/cs_files/StringExtensions.cs +++ b/modules/mono/glue/cs_files/StringExtensions.cs @@ -82,9 +82,9 @@ namespace Godot // public static string[] Bigrams(this string instance) { - string[] b = new string[instance.Length - 1]; + var b = new string[instance.Length - 1]; - for (int i = 0; i < b.Length; i++) + for (var i = 0; i < b.Length; i++) { b[i] = instance.Substring(i, 2); } @@ -97,7 +97,7 @@ namespace Godot // public static string CEscape(this string instance) { - StringBuilder sb = new StringBuilder(string.Copy(instance)); + var sb = new StringBuilder(string.Copy(instance)); sb.Replace("\\", "\\\\"); sb.Replace("\a", "\\a"); @@ -119,7 +119,7 @@ namespace Godot // public static string CUnescape(this string instance) { - StringBuilder sb = new StringBuilder(string.Copy(instance)); + var sb = new StringBuilder(string.Copy(instance)); sb.Replace("\\a", "\a"); sb.Replace("\\b", "\b"); @@ -141,12 +141,12 @@ namespace Godot // public static string Capitalize(this string instance) { - string aux = instance.Replace("_", " ").ToLower(); - string cap = string.Empty; + string aux = instance.Replace("_", " ").ToLower(); + var cap = string.Empty; - for (int i = 0; i < aux.GetSliceCount(" "); i++) + for (var i = 0; i < aux.GetSliceCount(" "); i++) { - string slice = aux.GetSlicec(' ', i); + string slice = aux.GetSlicec(' ', i); if (slice.Length > 0) { slice = char.ToUpper(slice[0]) + slice.Substring(1); @@ -259,12 +259,12 @@ namespace Godot { int basepos = instance.Find("://"); - string rs = string.Empty; - string @base = string.Empty; + var rs = string.Empty; + var @base = string.Empty; if (basepos != -1) { - int end = basepos + 3; + var end = basepos + 3; rs = instance.Substring(end, instance.Length); @base = instance.Substring(0, end); } @@ -378,7 +378,7 @@ namespace Godot while (instance[src] != 0 && text[tgt] != 0) { - bool match = false; + var match = false; if (case_insensitive) { @@ -446,7 +446,7 @@ namespace Godot if (len == 0) return false; - for (int i = 0; i < len; i++) + for (var i = 0; i < len; i++) { if (i == 0) { @@ -482,7 +482,7 @@ namespace Godot if (ip.Length != 4) return false; - for (int i = 0; i < ip.Length; i++) + for (var i = 0; i < ip.Length; i++) { string n = ip[i]; if (!n.IsValidInteger()) @@ -501,7 +501,7 @@ namespace Godot // public static string JsonEscape(this string instance) { - StringBuilder sb = new StringBuilder(string.Copy(instance)); + var sb = new StringBuilder(string.Copy(instance)); sb.Replace("\\", "\\\\"); sb.Replace("\b", "\\b"); @@ -810,9 +810,9 @@ namespace Godot float sum = src_size + tgt_size; float inter = 0; - for (int i = 0; i < src_size; i++) + for (var i = 0; i < src_size; i++) { - for (int j = 0; j < tgt_size; j++) + for (var j = 0; j < tgt_size; j++) { if (srcBigrams[i] == tgtBigrams[j]) { @@ -838,9 +838,9 @@ namespace Godot // public static float[] SplitFloats(this string instance, string divisor, bool allow_empty = true) { - List ret = new List(); - int from = 0; - int len = instance.Length; + var ret = new List(); + int from = 0; + int len = instance.Length; while (true) { diff --git a/modules/mono/glue/cs_files/Transform.cs b/modules/mono/glue/cs_files/Transform.cs index ff6d386994..2e98a4e2e8 100644 --- a/modules/mono/glue/cs_files/Transform.cs +++ b/modules/mono/glue/cs_files/Transform.cs @@ -28,7 +28,7 @@ namespace Godot public Transform LookingAt(Vector3 target, Vector3 up) { - Transform t = this; + var t = this; t.SetLookAt(origin, target, up); return t; } diff --git a/modules/mono/glue/cs_files/Transform2D.cs b/modules/mono/glue/cs_files/Transform2D.cs index 44e5d042b9..cfb6a68b38 100644 --- a/modules/mono/glue/cs_files/Transform2D.cs +++ b/modules/mono/glue/cs_files/Transform2D.cs @@ -110,7 +110,7 @@ namespace Godot public Transform2D AffineInverse() { - Transform2D inv = this; + var inv = this; real_t det = this[0, 0] * this[1, 1] - this[1, 0] * this[0, 1]; @@ -157,15 +157,15 @@ namespace Godot Vector2 s2 = m.Scale; // Slerp rotation - Vector2 v1 = new Vector2(Mathf.Cos(r1), Mathf.Sin(r1)); - Vector2 v2 = new Vector2(Mathf.Cos(r2), Mathf.Sin(r2)); + var v1 = new Vector2(Mathf.Cos(r1), Mathf.Sin(r1)); + var v2 = new Vector2(Mathf.Cos(r2), Mathf.Sin(r2)); real_t dot = v1.Dot(v2); // Clamp dot to [-1, 1] dot = (dot < -1.0f) ? -1.0f : ((dot > 1.0f) ? 1.0f : dot); - Vector2 v = new Vector2(); + var v = new Vector2(); if (dot > 0.9995f) { @@ -184,8 +184,8 @@ namespace Godot Vector2 p2 = m.Origin; // Construct matrix - Transform2D res = new Transform2D(Mathf.Atan2(v.y, v.x), p1.LinearInterpolate(p2, c)); - Vector2 scale = s1.LinearInterpolate(s2, c); + var res = new Transform2D(Mathf.Atan2(v.y, v.x), p1.LinearInterpolate(p2, c)); + Vector2 scale = s1.LinearInterpolate(s2, c); res.x *= scale; res.y *= scale; @@ -194,7 +194,7 @@ namespace Godot public Transform2D Inverse() { - Transform2D inv = this; + var inv = this; // Swap real_t temp = inv.x.y; @@ -208,7 +208,7 @@ namespace Godot public Transform2D Orthonormalized() { - Transform2D on = this; + var on = this; Vector2 onX = on.x; Vector2 onY = on.y; @@ -230,7 +230,7 @@ namespace Godot public Transform2D Scaled(Vector2 scale) { - Transform2D copy = this; + var copy = this; copy.x *= scale; copy.y *= scale; copy.o *= scale; @@ -249,7 +249,7 @@ namespace Godot public Transform2D Translated(Vector2 offset) { - Transform2D copy = this; + var copy = this; copy.o += copy.BasisXform(offset); return copy; } diff --git a/modules/mono/glue/cs_files/Vector2.cs b/modules/mono/glue/cs_files/Vector2.cs index a5da9f97da..aa651abb03 100644 --- a/modules/mono/glue/cs_files/Vector2.cs +++ b/modules/mono/glue/cs_files/Vector2.cs @@ -99,8 +99,8 @@ namespace Godot public Vector2 Clamped(real_t length) { - Vector2 v = this; - real_t l = Length(); + var v = this; + real_t l = Length(); if (l > 0 && length < l) { @@ -113,10 +113,10 @@ namespace Godot public Vector2 CubicInterpolate(Vector2 b, Vector2 preA, Vector2 postB, real_t t) { - Vector2 p0 = preA; - Vector2 p1 = this; - Vector2 p2 = b; - Vector2 p3 = postB; + var p0 = preA; + var p1 = this; + var p2 = b; + var p3 = postB; real_t t2 = t * t; real_t t3 = t2 * t; @@ -164,7 +164,7 @@ namespace Godot public Vector2 LinearInterpolate(Vector2 b, real_t t) { - Vector2 res = this; + var res = this; res.x += (t * (b.x - x)); res.y += (t * (b.y - y)); @@ -174,7 +174,7 @@ namespace Godot public Vector2 Normalized() { - Vector2 result = this; + var result = this; result.Normalize(); return result; } diff --git a/modules/mono/glue/cs_files/Vector3.cs b/modules/mono/glue/cs_files/Vector3.cs index af190bfd58..c9c1bb344c 100644 --- a/modules/mono/glue/cs_files/Vector3.cs +++ b/modules/mono/glue/cs_files/Vector3.cs @@ -111,10 +111,10 @@ namespace Godot public Vector3 CubicInterpolate(Vector3 b, Vector3 preA, Vector3 postB, real_t t) { - Vector3 p0 = preA; - Vector3 p1 = this; - Vector3 p2 = b; - Vector3 p3 = postB; + var p0 = preA; + var p1 = this; + var p2 = b; + var p3 = postB; real_t t2 = t * t; real_t t3 = t2 * t; @@ -196,7 +196,7 @@ namespace Godot public Vector3 Normalized() { - Vector3 v = this; + var v = this; v.Normalize(); return v; } -- cgit v1.2.3 From 93dd59d763146938d59defe270f43091b5579a0a Mon Sep 17 00:00:00 2001 From: Xavier Cho Date: Sun, 8 Apr 2018 12:38:02 +0900 Subject: #18051: Remove unnecessary variable assignments --- modules/mono/glue/cs_files/AABB.cs | 4 ---- modules/mono/glue/cs_files/Color.cs | 6 +++--- modules/mono/glue/cs_files/GD.cs | 2 +- modules/mono/glue/cs_files/StringExtensions.cs | 4 ++-- modules/mono/glue/cs_files/Transform2D.cs | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/modules/mono/glue/cs_files/AABB.cs b/modules/mono/glue/cs_files/AABB.cs index 84566d855a..909f999333 100644 --- a/modules/mono/glue/cs_files/AABB.cs +++ b/modules/mono/glue/cs_files/AABB.cs @@ -123,7 +123,6 @@ namespace Godot if (size.z > max_size) { axis = new Vector3(0f, 0f, 1f); - max_size = size.z; } return axis; @@ -143,7 +142,6 @@ namespace Godot if (size.z > max_size) { axis = Vector3.Axis.Z; - max_size = size.z; } return axis; @@ -176,7 +174,6 @@ namespace Godot if (size.z < max_size) { axis = new Vector3(0f, 0f, 1f); - max_size = size.z; } return axis; @@ -196,7 +193,6 @@ namespace Godot if (size.z < max_size) { axis = Vector3.Axis.Z; - max_size = size.z; } return axis; diff --git a/modules/mono/glue/cs_files/Color.cs b/modules/mono/glue/cs_files/Color.cs index d15f891e21..8e9091cc09 100644 --- a/modules/mono/glue/cs_files/Color.cs +++ b/modules/mono/glue/cs_files/Color.cs @@ -342,7 +342,7 @@ namespace Godot for (var i = 0; i < 2; i++) { int c = str[i + ofs]; - var v = 0; + int v; if (c >= '0' && c <= '9') { @@ -403,7 +403,7 @@ namespace Godot if (color[0] == '#') color = color.Substring(1, color.Length - 1); - var alpha = false; + bool alpha; if (color.Length == 8) alpha = true; @@ -449,7 +449,7 @@ namespace Godot if (rgba[0] == '#') rgba = rgba.Substring(1); - var alpha = false; + bool alpha; if (rgba.Length == 8) { diff --git a/modules/mono/glue/cs_files/GD.cs b/modules/mono/glue/cs_files/GD.cs index f0967f2269..f565d092dd 100644 --- a/modules/mono/glue/cs_files/GD.cs +++ b/modules/mono/glue/cs_files/GD.cs @@ -124,7 +124,7 @@ namespace Godot return new int[0]; // Calculate count - var count = 0; + int count; if (increment > 0) count = ((to - from - 1) / increment) + 1; diff --git a/modules/mono/glue/cs_files/StringExtensions.cs b/modules/mono/glue/cs_files/StringExtensions.cs index 030d1282f3..de85b080df 100644 --- a/modules/mono/glue/cs_files/StringExtensions.cs +++ b/modules/mono/glue/cs_files/StringExtensions.cs @@ -259,7 +259,7 @@ namespace Godot { int basepos = instance.Find("://"); - var rs = string.Empty; + string rs; var @base = string.Empty; if (basepos != -1) @@ -378,7 +378,7 @@ namespace Godot while (instance[src] != 0 && text[tgt] != 0) { - var match = false; + bool match; if (case_insensitive) { diff --git a/modules/mono/glue/cs_files/Transform2D.cs b/modules/mono/glue/cs_files/Transform2D.cs index cfb6a68b38..d3969dfc6e 100644 --- a/modules/mono/glue/cs_files/Transform2D.cs +++ b/modules/mono/glue/cs_files/Transform2D.cs @@ -165,7 +165,7 @@ namespace Godot // Clamp dot to [-1, 1] dot = (dot < -1.0f) ? -1.0f : ((dot > 1.0f) ? 1.0f : dot); - var v = new Vector2(); + Vector2 v; if (dot > 0.9995f) { -- cgit v1.2.3 From 9097c71255c6e8edb0014c043562caffc84ee2cf Mon Sep 17 00:00:00 2001 From: Xavier Cho Date: Sun, 8 Apr 2018 12:39:35 +0900 Subject: #18051: Remove redundant parenthesis --- modules/mono/glue/cs_files/AABB.cs | 54 +++++++++++++------------- modules/mono/glue/cs_files/Basis.cs | 10 ++--- modules/mono/glue/cs_files/Color.cs | 18 ++++----- modules/mono/glue/cs_files/GD.cs | 4 +- modules/mono/glue/cs_files/Mathf.cs | 18 ++++----- modules/mono/glue/cs_files/Plane.cs | 8 ++-- modules/mono/glue/cs_files/Quat.cs | 2 +- modules/mono/glue/cs_files/Rect2.cs | 26 ++++++------- modules/mono/glue/cs_files/StringExtensions.cs | 15 ++++--- modules/mono/glue/cs_files/Transform.cs | 6 +-- modules/mono/glue/cs_files/Transform2D.cs | 4 +- modules/mono/glue/cs_files/Vector2.cs | 6 +-- modules/mono/glue/cs_files/Vector3.cs | 14 +++---- 13 files changed, 94 insertions(+), 91 deletions(-) diff --git a/modules/mono/glue/cs_files/AABB.cs b/modules/mono/glue/cs_files/AABB.cs index 909f999333..3304e418c8 100644 --- a/modules/mono/glue/cs_files/AABB.cs +++ b/modules/mono/glue/cs_files/AABB.cs @@ -49,12 +49,12 @@ namespace Godot Vector3 dst_min = with.position; Vector3 dst_max = with.position + with.size; - return ((src_min.x <= dst_min.x) && - (src_max.x > dst_max.x) && - (src_min.y <= dst_min.y) && - (src_max.y > dst_max.y) && - (src_min.z <= dst_min.z) && - (src_max.z > dst_max.z)); + return src_min.x <= dst_min.x && + src_max.x > dst_max.x && + src_min.y <= dst_min.y && + src_max.y > dst_max.y && + src_min.z <= dst_min.z && + src_max.z > dst_max.z; } public AABB Expand(Vector3 to_point) @@ -217,9 +217,9 @@ namespace Godot Vector3 ofs = position + half_extents; return ofs + new Vector3( - (dir.x > 0f) ? -half_extents.x : half_extents.x, - (dir.y > 0f) ? -half_extents.y : half_extents.y, - (dir.z > 0f) ? -half_extents.z : half_extents.z); + dir.x > 0f ? -half_extents.x : half_extents.x, + dir.y > 0f ? -half_extents.y : half_extents.y, + dir.z > 0f ? -half_extents.z : half_extents.z); } public AABB Grow(real_t by) @@ -278,41 +278,41 @@ namespace Godot return new AABB(); } - min.x = (src_min.x > dst_min.x) ? src_min.x : dst_min.x; - max.x = (src_max.x < dst_max.x) ? src_max.x : dst_max.x; + min.x = src_min.x > dst_min.x ? src_min.x : dst_min.x; + max.x = src_max.x < dst_max.x ? src_max.x : dst_max.x; if (src_min.y > dst_max.y || src_max.y < dst_min.y) { return new AABB(); } - min.y = (src_min.y > dst_min.y) ? src_min.y : dst_min.y; - max.y = (src_max.y < dst_max.y) ? src_max.y : dst_max.y; + min.y = src_min.y > dst_min.y ? src_min.y : dst_min.y; + max.y = src_max.y < dst_max.y ? src_max.y : dst_max.y; if (src_min.z > dst_max.z || src_max.z < dst_min.z) { return new AABB(); } - min.z = (src_min.z > dst_min.z) ? src_min.z : dst_min.z; - max.z = (src_max.z < dst_max.z) ? src_max.z : dst_max.z; + min.z = src_min.z > dst_min.z ? src_min.z : dst_min.z; + max.z = src_max.z < dst_max.z ? src_max.z : dst_max.z; return new AABB(min, max - min); } public bool Intersects(AABB with) { - if (position.x >= (with.position.x + with.size.x)) + if (position.x >= with.position.x + with.size.x) return false; - if ((position.x + size.x) <= with.position.x) + if (position.x + size.x <= with.position.x) return false; - if (position.y >= (with.position.y + with.size.y)) + if (position.y >= with.position.y + with.size.y) return false; - if ((position.y + size.y) <= with.position.y) + if (position.y + size.y <= with.position.y) return false; - if (position.z >= (with.position.z + with.size.z)) + if (position.z >= with.position.z + with.size.z) return false; - if ((position.z + size.z) <= with.position.z) + if (position.z + size.z <= with.position.z) return false; return true; @@ -400,15 +400,15 @@ namespace Godot var end_2 = new Vector3(with.size.x, with.size.y, with.size.z) + beg_2; var min = new Vector3( - (beg_1.x < beg_2.x) ? beg_1.x : beg_2.x, - (beg_1.y < beg_2.y) ? beg_1.y : beg_2.y, - (beg_1.z < beg_2.z) ? beg_1.z : beg_2.z + beg_1.x < beg_2.x ? beg_1.x : beg_2.x, + beg_1.y < beg_2.y ? beg_1.y : beg_2.y, + beg_1.z < beg_2.z ? beg_1.z : beg_2.z ); var max = new Vector3( - (end_1.x > end_2.x) ? end_1.x : end_2.x, - (end_1.y > end_2.y) ? end_1.y : end_2.y, - (end_1.z > end_2.z) ? end_1.z : end_2.z + end_1.x > end_2.x ? end_1.x : end_2.x, + end_1.y > end_2.y ? end_1.y : end_2.y, + end_1.z > end_2.z ? end_1.z : end_2.z ); return new AABB(min, max - min); diff --git a/modules/mono/glue/cs_files/Basis.cs b/modules/mono/glue/cs_files/Basis.cs index d16e40488c..9a4bd7b366 100644 --- a/modules/mono/glue/cs_files/Basis.cs +++ b/modules/mono/glue/cs_files/Basis.cs @@ -296,9 +296,9 @@ namespace Godot Vector3 zAxis = GetAxis(2); xAxis.Normalize(); - yAxis = (yAxis - xAxis * (xAxis.Dot(yAxis))); + yAxis = yAxis - xAxis * xAxis.Dot(yAxis); yAxis.Normalize(); - zAxis = (zAxis - xAxis * (xAxis.Dot(zAxis)) - yAxis * (yAxis.Dot(zAxis))); + zAxis = zAxis - xAxis * xAxis.Dot(zAxis) - yAxis * yAxis.Dot(zAxis); zAxis.Normalize(); return CreateFromAxes(xAxis, yAxis, zAxis); @@ -374,9 +374,9 @@ namespace Godot { return new Vector3 ( - (this[0, 0] * v.x) + (this[1, 0] * v.y) + (this[2, 0] * v.z), - (this[0, 1] * v.x) + (this[1, 1] * v.y) + (this[2, 1] * v.z), - (this[0, 2] * v.x) + (this[1, 2] * v.y) + (this[2, 2] * v.z) + this[0, 0] * v.x + this[1, 0] * v.y + this[2, 0] * v.z, + this[0, 1] * v.x + this[1, 1] * v.y + this[2, 1] * v.z, + this[0, 2] * v.x + this[1, 2] * v.y + this[2, 2] * v.z ); } diff --git a/modules/mono/glue/cs_files/Color.cs b/modules/mono/glue/cs_files/Color.cs index 8e9091cc09..a5160e415a 100644 --- a/modules/mono/glue/cs_files/Color.cs +++ b/modules/mono/glue/cs_files/Color.cs @@ -180,7 +180,7 @@ namespace Godot hue += 1.0f; } - saturation = (max == 0) ? 0 : 1f - (1f * min / max); + saturation = max == 0 ? 0 : 1f - 1f * min / max; value = max / 255f; } @@ -267,10 +267,10 @@ namespace Godot { var res = this; - res.r += (t * (b.r - r)); - res.g += (t * (b.g - g)); - res.b += (t * (b.b - this.b)); - res.a += (t * (b.a - a)); + res.r += t * (b.r - r); + res.g += t * (b.g - g); + res.b += t * (b.b - this.b); + res.a += t * (b.a - a); return res; } @@ -511,8 +511,8 @@ namespace Godot if (left.g == right.g) { if (left.b == right.b) - return (left.a < right.a); - return (left.b < right.b); + return left.a < right.a; + return left.b < right.b; } return left.g < right.g; @@ -528,8 +528,8 @@ namespace Godot if (left.g == right.g) { if (left.b == right.b) - return (left.a > right.a); - return (left.b > right.b); + return left.a > right.a; + return left.b > right.b; } return left.g > right.g; diff --git a/modules/mono/glue/cs_files/GD.cs b/modules/mono/glue/cs_files/GD.cs index f565d092dd..5f9ca2c335 100644 --- a/modules/mono/glue/cs_files/GD.cs +++ b/modules/mono/glue/cs_files/GD.cs @@ -127,9 +127,9 @@ namespace Godot int count; if (increment > 0) - count = ((to - from - 1) / increment) + 1; + count = (to - @from - 1) / increment + 1; else - count = ((from - to - 1) / -increment) + 1; + count = (@from - to - 1) / -increment + 1; var ret = new int[count]; diff --git a/modules/mono/glue/cs_files/Mathf.cs b/modules/mono/glue/cs_files/Mathf.cs index d6655aa1e2..0d20a12563 100644 --- a/modules/mono/glue/cs_files/Mathf.cs +++ b/modules/mono/glue/cs_files/Mathf.cs @@ -145,7 +145,7 @@ namespace Godot return x % y; } - return y - (-x % y); + return y - -x % y; } public static real_t InverseLerp(real_t from, real_t to, real_t weight) @@ -175,22 +175,22 @@ namespace Godot public static int Max(int a, int b) { - return (a > b) ? a : b; + return a > b ? a : b; } public static real_t Max(real_t a, real_t b) { - return (a > b) ? a : b; + return a > b ? a : b; } public static int Min(int a, int b) { - return (a < b) ? a : b; + return a < b ? a : b; } public static real_t Min(real_t a, real_t b) { - return (a < b) ? a : b; + return a < b ? a : b; } public static int NearestPo2(int value) @@ -227,12 +227,12 @@ namespace Godot public static int Sign(int s) { - return (s < 0) ? -1 : 1; + return s < 0 ? -1 : 1; } public static real_t Sign(real_t s) { - return (s < 0f) ? -1f : 1f; + return s < 0f ? -1f : 1f; } public static real_t Sin(real_t s) @@ -273,13 +273,13 @@ namespace Godot public static int Wrap(int value, int min, int max) { int rng = max - min; - return min + ((((value - min) % rng) + rng) % rng); + return min + ((value - min) % rng + rng) % rng; } public static real_t Wrap(real_t value, real_t min, real_t max) { real_t rng = max - min; - return min + ((((value - min) % rng) + rng) % rng); + return min + ((value - min) % rng + rng) % rng; } } } diff --git a/modules/mono/glue/cs_files/Plane.cs b/modules/mono/glue/cs_files/Plane.cs index 6b19d929c8..1043738d7b 100644 --- a/modules/mono/glue/cs_files/Plane.cs +++ b/modules/mono/glue/cs_files/Plane.cs @@ -80,9 +80,9 @@ namespace Godot if (Mathf.Abs(denom) <= Mathf.Epsilon) return new Vector3(); - Vector3 result = (b.normal.Cross(c.normal) * d) + - (c.normal.Cross(normal) * b.d) + - (normal.Cross(b.normal) * c.d); + Vector3 result = b.normal.Cross(c.normal) * d + + c.normal.Cross(normal) * b.d + + normal.Cross(b.normal) * c.d; return result / denom; } @@ -113,7 +113,7 @@ namespace Godot real_t dist = (normal.Dot(begin) - d) / den; - if (dist < -Mathf.Epsilon || dist > (1.0f + Mathf.Epsilon)) + if (dist < -Mathf.Epsilon || dist > 1.0f + Mathf.Epsilon) return new Vector3(); return begin + segment * -dist; diff --git a/modules/mono/glue/cs_files/Quat.cs b/modules/mono/glue/cs_files/Quat.cs index c0bce024cd..c69c55d997 100644 --- a/modules/mono/glue/cs_files/Quat.cs +++ b/modules/mono/glue/cs_files/Quat.cs @@ -137,7 +137,7 @@ namespace Godot real_t sinom, scale0, scale1; // Calculate coefficients - if ((1.0 - cosom) > Mathf.Epsilon) + if (1.0 - cosom > Mathf.Epsilon) { // Standard case (Slerp) real_t omega = Mathf.Acos(cosom); diff --git a/modules/mono/glue/cs_files/Rect2.cs b/modules/mono/glue/cs_files/Rect2.cs index 027360bb17..6f16656573 100644 --- a/modules/mono/glue/cs_files/Rect2.cs +++ b/modules/mono/glue/cs_files/Rect2.cs @@ -57,9 +57,9 @@ namespace Godot public bool Encloses(Rect2 b) { - return (b.position.x >= position.x) && (b.position.y >= position.y) && - ((b.position.x + b.size.x) < (position.x + size.x)) && - ((b.position.y + b.size.y) < (position.y + size.y)); + return b.position.x >= position.x && b.position.y >= position.y && + b.position.x + b.size.x < position.x + size.x && + b.position.y + b.size.y < position.y + size.y; } public Rect2 Expand(Vector2 to) @@ -118,10 +118,10 @@ namespace Godot { var g = this; - g.GrowIndividual((Margin.Left == margin) ? by : 0, - (Margin.Top == margin) ? by : 0, - (Margin.Right == margin) ? by : 0, - (Margin.Bottom == margin) ? by : 0); + g.GrowIndividual(Margin.Left == margin ? by : 0, + Margin.Top == margin ? by : 0, + Margin.Right == margin ? by : 0, + Margin.Bottom == margin ? by : 0); return g; } @@ -138,9 +138,9 @@ namespace Godot if (point.y < position.y) return false; - if (point.x >= (position.x + size.x)) + if (point.x >= position.x + size.x) return false; - if (point.y >= (position.y + size.y)) + if (point.y >= position.y + size.y) return false; return true; @@ -148,13 +148,13 @@ namespace Godot public bool Intersects(Rect2 b) { - if (position.x > (b.position.x + b.size.x)) + if (position.x > b.position.x + b.size.x) return false; - if ((position.x + size.x) < b.position.x) + if (position.x + size.x < b.position.x) return false; - if (position.y > (b.position.y + b.size.y)) + if (position.y > b.position.y + b.size.y) return false; - if ((position.y + size.y) < b.position.y) + if (position.y + size.y < b.position.y) return false; return true; diff --git a/modules/mono/glue/cs_files/StringExtensions.cs b/modules/mono/glue/cs_files/StringExtensions.cs index de85b080df..c86208f9bd 100644 --- a/modules/mono/glue/cs_files/StringExtensions.cs +++ b/modules/mono/glue/cs_files/StringExtensions.cs @@ -312,7 +312,7 @@ namespace Godot int c; while ((c = instance[index++]) != 0) - hashv = ((hashv << 5) + hashv) + c; // hash * 33 + c + hashv = (hashv << 5) + hashv + c; // hash * 33 + c return hashv; } @@ -454,7 +454,10 @@ namespace Godot return false; // Don't start with number plz } - bool valid_char = (instance[i] >= '0' && instance[i] <= '9') || (instance[i] >= 'a' && instance[i] <= 'z') || (instance[i] >= 'A' && instance[i] <= 'Z') || instance[i] == '_'; + bool valid_char = instance[i] >= '0' && + instance[i] <= '9' || instance[i] >= 'a' && + instance[i] <= 'z' || instance[i] >= 'A' && + instance[i] <= 'Z' || instance[i] == '_'; if (!valid_char) return false; @@ -550,7 +553,7 @@ namespace Godot case '\0': return instance[0] == 0; case '*': - return ExprMatch(expr + 1, instance, caseSensitive) || (instance[0] != 0 && ExprMatch(expr, instance + 1, caseSensitive)); + return ExprMatch(expr + 1, instance, caseSensitive) || instance[0] != 0 && ExprMatch(expr, instance + 1, caseSensitive); case '?': return instance[0] != 0 && instance[0] != '.' && ExprMatch(expr + 1, instance + 1, caseSensitive); default: @@ -769,7 +772,7 @@ namespace Godot if (pos < 0) return string.Empty; - return instance.Substring(pos, (instance.Length - pos)); + return instance.Substring(pos, instance.Length - pos); } public static byte[] Sha256Buffer(this string instance) @@ -822,7 +825,7 @@ namespace Godot } } - return (2.0f * inter) / sum; + return 2.0f * inter / sum; } // @@ -847,7 +850,7 @@ namespace Godot int end = instance.Find(divisor, from); if (end < 0) end = len; - if (allow_empty || (end > from)) + if (allow_empty || end > @from) ret.Add(float.Parse(instance.Substring(from))); if (end == len) break; diff --git a/modules/mono/glue/cs_files/Transform.cs b/modules/mono/glue/cs_files/Transform.cs index 2e98a4e2e8..d1b247a552 100644 --- a/modules/mono/glue/cs_files/Transform.cs +++ b/modules/mono/glue/cs_files/Transform.cs @@ -97,9 +97,9 @@ namespace Godot return new Vector3 ( - (basis[0, 0] * vInv.x) + (basis[1, 0] * vInv.y) + (basis[2, 0] * vInv.z), - (basis[0, 1] * vInv.x) + (basis[1, 1] * vInv.y) + (basis[2, 1] * vInv.z), - (basis[0, 2] * vInv.x) + (basis[1, 2] * vInv.y) + (basis[2, 2] * vInv.z) + basis[0, 0] * vInv.x + basis[1, 0] * vInv.y + basis[2, 0] * vInv.z, + basis[0, 1] * vInv.x + basis[1, 1] * vInv.y + basis[2, 1] * vInv.z, + basis[0, 2] * vInv.x + basis[1, 2] * vInv.y + basis[2, 2] * vInv.z ); } diff --git a/modules/mono/glue/cs_files/Transform2D.cs b/modules/mono/glue/cs_files/Transform2D.cs index d3969dfc6e..fad3c86190 100644 --- a/modules/mono/glue/cs_files/Transform2D.cs +++ b/modules/mono/glue/cs_files/Transform2D.cs @@ -163,7 +163,7 @@ namespace Godot real_t dot = v1.Dot(v2); // Clamp dot to [-1, 1] - dot = (dot < -1.0f) ? -1.0f : ((dot > 1.0f) ? 1.0f : dot); + dot = dot < -1.0f ? -1.0f : (dot > 1.0f ? 1.0f : dot); Vector2 v; @@ -214,7 +214,7 @@ namespace Godot Vector2 onY = on.y; onX.Normalize(); - onY = onY - onX * (onX.Dot(onY)); + onY = onY - onX * onX.Dot(onY); onY.Normalize(); on.x = onX; diff --git a/modules/mono/glue/cs_files/Vector2.cs b/modules/mono/glue/cs_files/Vector2.cs index aa651abb03..7f8c342e6f 100644 --- a/modules/mono/glue/cs_files/Vector2.cs +++ b/modules/mono/glue/cs_files/Vector2.cs @@ -121,7 +121,7 @@ namespace Godot real_t t2 = t * t; real_t t3 = t2 * t; - return 0.5f * ((p1 * 2.0f) + + return 0.5f * (p1 * 2.0f + (-p0 + p2) * t + (2.0f * p0 - 5.0f * p1 + 4 * p2 - p3) * t2 + (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3); @@ -166,8 +166,8 @@ namespace Godot { var res = this; - res.x += (t * (b.x - x)); - res.y += (t * (b.y - y)); + res.x += t * (b.x - x); + res.y += t * (b.y - y); return res; } diff --git a/modules/mono/glue/cs_files/Vector3.cs b/modules/mono/glue/cs_files/Vector3.cs index c9c1bb344c..0a71f3fa4d 100644 --- a/modules/mono/glue/cs_files/Vector3.cs +++ b/modules/mono/glue/cs_files/Vector3.cs @@ -103,9 +103,9 @@ namespace Godot { return new Vector3 ( - (y * b.z) - (z * b.y), - (z * b.x) - (x * b.z), - (x * b.y) - (y * b.x) + y * b.z - z * b.y, + z * b.x - x * b.z, + x * b.y - y * b.x ); } @@ -120,7 +120,7 @@ namespace Godot real_t t3 = t2 * t; return 0.5f * ( - (p1 * 2.0f) + (-p0 + p2) * t + + p1 * 2.0f + (-p0 + p2) * t + (2.0f * p0 - 5.0f * p1 + 4f * p2 - p3) * t2 + (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3 ); @@ -178,9 +178,9 @@ namespace Godot { return new Vector3 ( - x + (t * (b.x - x)), - y + (t * (b.y - y)), - z + (t * (b.z - z)) + x + t * (b.x - x), + y + t * (b.y - y), + z + t * (b.z - z) ); } -- cgit v1.2.3 From b765c051cb4e71b377fd5d653e77fc73d390c2b9 Mon Sep 17 00:00:00 2001 From: Xavier Cho Date: Sun, 8 Apr 2018 12:43:11 +0900 Subject: #18051: Use array initializer when applicable --- modules/mono/glue/cs_files/Basis.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/mono/glue/cs_files/Basis.cs b/modules/mono/glue/cs_files/Basis.cs index 9a4bd7b366..f0f1644d46 100644 --- a/modules/mono/glue/cs_files/Basis.cs +++ b/modules/mono/glue/cs_files/Basis.cs @@ -18,8 +18,7 @@ namespace Godot new Vector3(0f, 0f, 1f) ); - private static readonly Basis[] orthoBases = new Basis[24] - { + private static readonly Basis[] orthoBases = { new Basis(1f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 1f), new Basis(0f, -1f, 0f, 1f, 0f, 0f, 0f, 0f, 1f), new Basis(-1f, 0f, 0f, 0f, -1f, 0f, 0f, 0f, 1f), @@ -252,8 +251,7 @@ namespace Godot { var inv = this; - var co = new real_t[3] - { + real_t[] co = { inv[1, 1] * inv[2, 2] - inv[1, 2] * inv[2, 1], inv[1, 2] * inv[2, 0] - inv[1, 0] * inv[2, 2], inv[1, 0] * inv[2, 1] - inv[1, 1] * inv[2, 0] -- cgit v1.2.3 From 85787776a537e2b0ee3b116e0d7dd342e7276a11 Mon Sep 17 00:00:00 2001 From: Xavier Cho Date: Sun, 8 Apr 2018 12:43:31 +0900 Subject: #18051: Use default parameter value --- modules/mono/glue/cs_files/Color.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/mono/glue/cs_files/Color.cs b/modules/mono/glue/cs_files/Color.cs index a5160e415a..2389cbd286 100644 --- a/modules/mono/glue/cs_files/Color.cs +++ b/modules/mono/glue/cs_files/Color.cs @@ -104,7 +104,7 @@ namespace Godot } } - private static readonly Color black = new Color(0f, 0f, 0f, 1.0f); + private static readonly Color black = new Color(0f, 0f, 0f); public Color Black { -- cgit v1.2.3 From f0bf5532fac919fdb4bb6fa0ba088117aa223524 Mon Sep 17 00:00:00 2001 From: Xavier Cho Date: Sun, 8 Apr 2018 12:49:19 +0900 Subject: #18051: Remove redundant verbatim prefixes --- modules/mono/glue/cs_files/GD.cs | 4 ++-- modules/mono/glue/cs_files/StringExtensions.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/mono/glue/cs_files/GD.cs b/modules/mono/glue/cs_files/GD.cs index 5f9ca2c335..8a300fbbd4 100644 --- a/modules/mono/glue/cs_files/GD.cs +++ b/modules/mono/glue/cs_files/GD.cs @@ -127,9 +127,9 @@ namespace Godot int count; if (increment > 0) - count = (to - @from - 1) / increment + 1; + count = (to - from - 1) / increment + 1; else - count = (@from - to - 1) / -increment + 1; + count = (from - to - 1) / -increment + 1; var ret = new int[count]; diff --git a/modules/mono/glue/cs_files/StringExtensions.cs b/modules/mono/glue/cs_files/StringExtensions.cs index c86208f9bd..38f7a0941f 100644 --- a/modules/mono/glue/cs_files/StringExtensions.cs +++ b/modules/mono/glue/cs_files/StringExtensions.cs @@ -850,7 +850,7 @@ namespace Godot int end = instance.Find(divisor, from); if (end < 0) end = len; - if (allow_empty || end > @from) + if (allow_empty || end > from) ret.Add(float.Parse(instance.Substring(from))); if (end == len) break; -- cgit v1.2.3 From 94edd92248b4742e7d7a8e283da44d505957c50e Mon Sep 17 00:00:00 2001 From: Xavier Cho Date: Mon, 9 Apr 2018 14:30:03 +0900 Subject: #18051: Use common name for Color type argument --- modules/mono/glue/cs_files/Color.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/mono/glue/cs_files/Color.cs b/modules/mono/glue/cs_files/Color.cs index 2389cbd286..b527eee0f1 100644 --- a/modules/mono/glue/cs_files/Color.cs +++ b/modules/mono/glue/cs_files/Color.cs @@ -263,14 +263,14 @@ namespace Godot ); } - public Color LinearInterpolate(Color b, float t) + public Color LinearInterpolate(Color c, float t) { var res = this; - res.r += t * (b.r - r); - res.g += t * (b.g - g); - res.b += t * (b.b - this.b); - res.a += t * (b.a - a); + res.r += t * (c.r - r); + res.g += t * (c.g - g); + res.b += t * (c.b - b); + res.a += t * (c.a - a); return res; } -- cgit v1.2.3 From e59fad39245de82cb243da38ba149ccd0ed957e5 Mon Sep 17 00:00:00 2001 From: Xavier Cho Date: Tue, 17 Apr 2018 07:33:42 +0900 Subject: #18051: Do not use `var` in a for-loop, or where type is not obvious --- modules/mono/glue/cs_files/AABB.cs | 4 ++-- modules/mono/glue/cs_files/Basis.cs | 10 +++++----- modules/mono/glue/cs_files/Color.cs | 4 ++-- modules/mono/glue/cs_files/DebuggingUtils.cs | 4 ++-- modules/mono/glue/cs_files/GD.cs | 8 ++++---- modules/mono/glue/cs_files/MarshalUtils.cs | 2 +- modules/mono/glue/cs_files/StringExtensions.cs | 12 ++++++------ 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/modules/mono/glue/cs_files/AABB.cs b/modules/mono/glue/cs_files/AABB.cs index 3304e418c8..f03d6403ef 100644 --- a/modules/mono/glue/cs_files/AABB.cs +++ b/modules/mono/glue/cs_files/AABB.cs @@ -335,7 +335,7 @@ namespace Godot bool over = false; bool under = false; - for (var i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) { if (plane.DistanceTo(points[i]) > 0) over = true; @@ -351,7 +351,7 @@ namespace Godot real_t min = 0f; real_t max = 1f; - for (var i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { real_t seg_from = from[i]; real_t seg_to = to[i]; diff --git a/modules/mono/glue/cs_files/Basis.cs b/modules/mono/glue/cs_files/Basis.cs index f0f1644d46..929b13d70c 100644 --- a/modules/mono/glue/cs_files/Basis.cs +++ b/modules/mono/glue/cs_files/Basis.cs @@ -221,9 +221,9 @@ namespace Godot { var orth = this; - for (var i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { - for (var j = 0; j < 3; j++) + for (int j = 0; j < 3; j++) { real_t v = orth[i, j]; @@ -238,7 +238,7 @@ namespace Godot } } - for (var i = 0; i < 24; i++) + for (int i = 0; i < 24; i++) { if (orthoBases[i] == orth) return i; @@ -413,8 +413,8 @@ namespace Godot (_x[2] - _z[0]) * inv_s ); } else { - var s = Mathf.Sqrt(-_x[0] - _y[1] + _z[2] + 1.0f) * 2f; - var inv_s = 1f / s; + real_t s = Mathf.Sqrt(-_x[0] - _y[1] + _z[2] + 1.0f) * 2f; + real_t inv_s = 1f / s; return new Quat( (_x[2] + _z[0]) * inv_s, (_y[2] + _z[1]) * inv_s, diff --git a/modules/mono/glue/cs_files/Color.cs b/modules/mono/glue/cs_files/Color.cs index b527eee0f1..af94bb616e 100644 --- a/modules/mono/glue/cs_files/Color.cs +++ b/modules/mono/glue/cs_files/Color.cs @@ -339,7 +339,7 @@ namespace Godot { int ig = 0; - for (var i = 0; i < 2; i++) + for (int i = 0; i < 2; i++) { int c = str[i + ofs]; int v; @@ -378,7 +378,7 @@ namespace Godot var ret = string.Empty; - for (var i = 0; i < 2; i++) + for (int i = 0; i < 2; i++) { char[] c = { (char)0, (char)0 }; int lv = v & 0xF; diff --git a/modules/mono/glue/cs_files/DebuggingUtils.cs b/modules/mono/glue/cs_files/DebuggingUtils.cs index a654c9b268..b27816084e 100644 --- a/modules/mono/glue/cs_files/DebuggingUtils.cs +++ b/modules/mono/glue/cs_files/DebuggingUtils.cs @@ -47,7 +47,7 @@ namespace Godot sb.Append("<"); - for (var j = 0; j < genericParams.Length; j++) + for (int j = 0; j < genericParams.Length; j++) { if (j > 0) sb.Append(", "); @@ -64,7 +64,7 @@ namespace Godot ParameterInfo[] parameter = methodBase.GetParameters(); - for (var i = 0; i < parameter.Length; i++) + for (int i = 0; i < parameter.Length; i++) { if (i > 0) sb.Append(", "); diff --git a/modules/mono/glue/cs_files/GD.cs b/modules/mono/glue/cs_files/GD.cs index 8a300fbbd4..2384bc1432 100644 --- a/modules/mono/glue/cs_files/GD.cs +++ b/modules/mono/glue/cs_files/GD.cs @@ -93,7 +93,7 @@ namespace Godot { var ret = new int[length]; - for (var i = 0; i < length; i++) + for (int i = 0; i < length; i++) { ret[i] = i; } @@ -108,7 +108,7 @@ namespace Godot var ret = new int[to - from]; - for (var i = from; i < to; i++) + for (int i = from; i < to; i++) { ret[i - from] = i; } @@ -136,7 +136,7 @@ namespace Godot if (increment > 0) { int idx = 0; - for (var i = from; i < to; i += increment) + for (int i = from; i < to; i += increment) { ret[idx++] = i; } @@ -144,7 +144,7 @@ namespace Godot else { int idx = 0; - for (var i = from; i > to; i += increment) + for (int i = from; i > to; i += increment) { ret[idx++] = i; } diff --git a/modules/mono/glue/cs_files/MarshalUtils.cs b/modules/mono/glue/cs_files/MarshalUtils.cs index 661af3f8a2..ff4477cc6c 100644 --- a/modules/mono/glue/cs_files/MarshalUtils.cs +++ b/modules/mono/glue/cs_files/MarshalUtils.cs @@ -9,7 +9,7 @@ namespace Godot { var ret = new Dictionary(); - for (var i = 0; i < keys.Length; i++) + for (int i = 0; i < keys.Length; i++) { ret.Add(keys[i], values[i]); } diff --git a/modules/mono/glue/cs_files/StringExtensions.cs b/modules/mono/glue/cs_files/StringExtensions.cs index 38f7a0941f..ef81769912 100644 --- a/modules/mono/glue/cs_files/StringExtensions.cs +++ b/modules/mono/glue/cs_files/StringExtensions.cs @@ -84,7 +84,7 @@ namespace Godot { var b = new string[instance.Length - 1]; - for (var i = 0; i < b.Length; i++) + for (int i = 0; i < b.Length; i++) { b[i] = instance.Substring(i, 2); } @@ -144,7 +144,7 @@ namespace Godot string aux = instance.Replace("_", " ").ToLower(); var cap = string.Empty; - for (var i = 0; i < aux.GetSliceCount(" "); i++) + for (int i = 0; i < aux.GetSliceCount(" "); i++) { string slice = aux.GetSlicec(' ', i); if (slice.Length > 0) @@ -446,7 +446,7 @@ namespace Godot if (len == 0) return false; - for (var i = 0; i < len; i++) + for (int i = 0; i < len; i++) { if (i == 0) { @@ -485,7 +485,7 @@ namespace Godot if (ip.Length != 4) return false; - for (var i = 0; i < ip.Length; i++) + for (int i = 0; i < ip.Length; i++) { string n = ip[i]; if (!n.IsValidInteger()) @@ -813,9 +813,9 @@ namespace Godot float sum = src_size + tgt_size; float inter = 0; - for (var i = 0; i < src_size; i++) + for (int i = 0; i < src_size; i++) { - for (var j = 0; j < tgt_size; j++) + for (int j = 0; j < tgt_size; j++) { if (srcBigrams[i] == tgtBigrams[j]) { -- cgit v1.2.3 From 6b611e64316ed91b89822a3b660cdedc087a1da9 Mon Sep 17 00:00:00 2001 From: Xavier Cho Date: Tue, 17 Apr 2018 07:53:27 +0900 Subject: #18051: Fix indentation issues introduced during clean up --- modules/mono/glue/cs_files/AABB.cs | 14 +++++++------- modules/mono/glue/cs_files/GD.cs | 4 ++-- modules/mono/glue/cs_files/Plane.cs | 2 +- modules/mono/glue/cs_files/StringExtensions.cs | 8 ++++---- modules/mono/glue/cs_files/Transform2D.cs | 2 +- modules/mono/glue/cs_files/Vector2.cs | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/mono/glue/cs_files/AABB.cs b/modules/mono/glue/cs_files/AABB.cs index f03d6403ef..39f2d2ed51 100644 --- a/modules/mono/glue/cs_files/AABB.cs +++ b/modules/mono/glue/cs_files/AABB.cs @@ -112,7 +112,7 @@ namespace Godot public Vector3 GetLongestAxis() { var axis = new Vector3(1f, 0f, 0f); - real_t max_size = size.x; + real_t max_size = size.x; if (size.y > max_size) { @@ -149,7 +149,7 @@ namespace Godot public real_t GetLongestAxisSize() { - real_t max_size = size.x; + real_t max_size = size.x; if (size.y > max_size) max_size = size.y; @@ -163,7 +163,7 @@ namespace Godot public Vector3 GetShortestAxis() { var axis = new Vector3(1f, 0f, 0f); - real_t max_size = size.x; + real_t max_size = size.x; if (size.y < max_size) { @@ -182,7 +182,7 @@ namespace Godot public Vector3.Axis GetShortestAxisIndex() { var axis = Vector3.Axis.X; - real_t max_size = size.x; + real_t max_size = size.x; if (size.y < max_size) { @@ -200,7 +200,7 @@ namespace Godot public real_t GetShortestAxisSize() { - real_t max_size = size.x; + real_t max_size = size.x; if (size.y < max_size) max_size = size.y; @@ -396,8 +396,8 @@ namespace Godot { Vector3 beg_1 = position; Vector3 beg_2 = with.position; - var end_1 = new Vector3(size.x, size.y, size.z) + beg_1; - var end_2 = new Vector3(with.size.x, with.size.y, with.size.z) + beg_2; + var end_1 = new Vector3(size.x, size.y, size.z) + beg_1; + var end_2 = new Vector3(with.size.x, with.size.y, with.size.z) + beg_2; var min = new Vector3( beg_1.x < beg_2.x ? beg_1.x : beg_2.x, diff --git a/modules/mono/glue/cs_files/GD.cs b/modules/mono/glue/cs_files/GD.cs index 2384bc1432..ec1534cb9a 100644 --- a/modules/mono/glue/cs_files/GD.cs +++ b/modules/mono/glue/cs_files/GD.cs @@ -135,7 +135,7 @@ namespace Godot if (increment > 0) { - int idx = 0; + int idx = 0; for (int i = from; i < to; i += increment) { ret[idx++] = i; @@ -143,7 +143,7 @@ namespace Godot } else { - int idx = 0; + int idx = 0; for (int i = from; i > to; i += increment) { ret[idx++] = i; diff --git a/modules/mono/glue/cs_files/Plane.cs b/modules/mono/glue/cs_files/Plane.cs index 1043738d7b..8b92522029 100644 --- a/modules/mono/glue/cs_files/Plane.cs +++ b/modules/mono/glue/cs_files/Plane.cs @@ -80,7 +80,7 @@ namespace Godot if (Mathf.Abs(denom) <= Mathf.Epsilon) return new Vector3(); - Vector3 result = b.normal.Cross(c.normal) * d + + Vector3 result = b.normal.Cross(c.normal) * d + c.normal.Cross(normal) * b.d + normal.Cross(b.normal) * c.d; diff --git a/modules/mono/glue/cs_files/StringExtensions.cs b/modules/mono/glue/cs_files/StringExtensions.cs index ef81769912..21090fb68d 100644 --- a/modules/mono/glue/cs_files/StringExtensions.cs +++ b/modules/mono/glue/cs_files/StringExtensions.cs @@ -141,12 +141,12 @@ namespace Godot // public static string Capitalize(this string instance) { - string aux = instance.Replace("_", " ").ToLower(); + string aux = instance.Replace("_", " ").ToLower(); var cap = string.Empty; for (int i = 0; i < aux.GetSliceCount(" "); i++) { - string slice = aux.GetSlicec(' ', i); + string slice = aux.GetSlicec(' ', i); if (slice.Length > 0) { slice = char.ToUpper(slice[0]) + slice.Substring(1); @@ -842,8 +842,8 @@ namespace Godot public static float[] SplitFloats(this string instance, string divisor, bool allow_empty = true) { var ret = new List(); - int from = 0; - int len = instance.Length; + int from = 0; + int len = instance.Length; while (true) { diff --git a/modules/mono/glue/cs_files/Transform2D.cs b/modules/mono/glue/cs_files/Transform2D.cs index fad3c86190..ff5259178b 100644 --- a/modules/mono/glue/cs_files/Transform2D.cs +++ b/modules/mono/glue/cs_files/Transform2D.cs @@ -185,7 +185,7 @@ namespace Godot // Construct matrix var res = new Transform2D(Mathf.Atan2(v.y, v.x), p1.LinearInterpolate(p2, c)); - Vector2 scale = s1.LinearInterpolate(s2, c); + Vector2 scale = s1.LinearInterpolate(s2, c); res.x *= scale; res.y *= scale; diff --git a/modules/mono/glue/cs_files/Vector2.cs b/modules/mono/glue/cs_files/Vector2.cs index 7f8c342e6f..cc2cda82fb 100644 --- a/modules/mono/glue/cs_files/Vector2.cs +++ b/modules/mono/glue/cs_files/Vector2.cs @@ -100,7 +100,7 @@ namespace Godot public Vector2 Clamped(real_t length) { var v = this; - real_t l = Length(); + real_t l = Length(); if (l > 0 && length < l) { -- cgit v1.2.3