sneak/Shared/ExtensionMethods.cs
Colin McMillen 6802b3f162 Make separate ExtensionMethods file.
Add Point-deconstruction as an extension method.

GitOrigin-RevId: a804ba797a9b939b65652df67987628b1742dad6
2020-02-24 20:46:24 -05:00

21 lines
576 B
C#

using Microsoft.Xna.Framework;
// All extension methods on built-in types (of C# or MonoGame) go in this file.
namespace SemiColinGames {
static class ExtensionMethods {
// Vector2
public static Vector2 Rotate(this Vector2 point, float angle) {
float cos = FMath.Cos(angle);
float sin = FMath.Sin(angle);
return new Vector2(
point.X * cos - point.Y * sin,
point.Y * cos + point.X * sin);
}
// Point
public static void Deconstruct(this Point point, out int x, out int y) =>
(x, y) = (point.X, point.Y);
}
}