diff --git a/src/DotRecast.Core/Numerics/RcVec2f.cs b/src/DotRecast.Core/Numerics/RcVec2f.cs index 111f1e8..8d0e4a9 100644 --- a/src/DotRecast.Core/Numerics/RcVec2f.cs +++ b/src/DotRecast.Core/Numerics/RcVec2f.cs @@ -16,18 +16,6 @@ namespace DotRecast.Core.Numerics Y = y; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public float Get(int idx) - { - if (0 == idx) - return X; - - if (1 == idx) - return Y; - - throw new IndexOutOfRangeException("vector2f index out of range"); - } - public override bool Equals(object obj) { if (!(obj is RcVec2f)) diff --git a/src/DotRecast.Core/Numerics/RcVecExtensions.cs b/src/DotRecast.Core/Numerics/RcVecExtensions.cs new file mode 100644 index 0000000..22e1483 --- /dev/null +++ b/src/DotRecast.Core/Numerics/RcVecExtensions.cs @@ -0,0 +1,20 @@ +using System; +using System.Runtime.CompilerServices; +using DotRecast.Core.Numerics; + +namespace DotRecast.Core.Numerics +{ + public static class RcVecExtensions + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static float Get(this RcVec2f v, int i) + { + switch (i) + { + case 0: return v.X; + case 1: return v.Y; + default: throw new IndexOutOfRangeException("vector2f index out of range"); + } + } + } +} \ No newline at end of file