From 75d00916f3121ebfd205d0b6037514c0e4a81234 Mon Sep 17 00:00:00 2001 From: ikpil Date: Tue, 17 Oct 2023 23:40:07 +0900 Subject: [PATCH] feature: cleaning up the API to accommodate .net 8 Numerics compatibility. --- src/DotRecast.Core/Numerics/RcVec2f.cs | 12 ----------- .../Numerics/RcVecExtensions.cs | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 src/DotRecast.Core/Numerics/RcVecExtensions.cs 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