Implement IComparable on WRange.

This commit is contained in:
Paul Chote
2013-12-25 08:59:46 +13:00
parent c49b06fdde
commit aca897fa76

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System;
using System.Linq; using System.Linq;
namespace OpenRA namespace OpenRA
@@ -15,7 +16,7 @@ namespace OpenRA
/// <summary> /// <summary>
/// 1d world distance - 1024 units = 1 cell. /// 1d world distance - 1024 units = 1 cell.
/// </summary> /// </summary>
public struct WRange public struct WRange : IComparable
{ {
public readonly int Range; public readonly int Range;
@@ -82,6 +83,15 @@ namespace OpenRA
return o != null && o == this; return o != null && o == this;
} }
public int CompareTo(object obj)
{
var o = obj as WRange?;
if (o == null)
return 1;
return Range.CompareTo(o.Value.Range);
}
public override string ToString() { return "{0}".F(Range); } public override string ToString() { return "{0}".F(Range); }
} }
} }