You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.1 KiB
33 lines
1.1 KiB
3 weeks ago
|
public static class GodotExtensions
|
||
2 months ago
|
{
|
||
3 weeks ago
|
public static Vector2I RoundToVector2I(this Vector2 vector)
|
||
|
=> new(RoundToInt(vector.X), RoundToInt(vector.Y));
|
||
|
|
||
2 months ago
|
public static (Corner, Corner) GetCorners(this Side side)
|
||
|
=> side switch {
|
||
|
Side.Left => (Corner.TopLeft, Corner.BottomLeft),
|
||
|
Side.Top => (Corner.TopLeft, Corner.TopRight),
|
||
|
Side.Right => (Corner.TopRight, Corner.BottomRight),
|
||
|
Side.Bottom => (Corner.BottomLeft, Corner.BottomRight),
|
||
|
_ => throw new ArgumentException($"Invalid Side value '{side}'", nameof(side)),
|
||
|
};
|
||
|
|
||
|
public static Side GetOpposite(this Side side)
|
||
|
=> side switch {
|
||
|
Side.Left => Side.Right,
|
||
|
Side.Top => Side.Bottom,
|
||
|
Side.Right => Side.Left,
|
||
|
Side.Bottom => Side.Top,
|
||
|
_ => throw new ArgumentException($"Invalid Side value '{side}'", nameof(side)),
|
||
|
};
|
||
|
|
||
|
public static Corner GetOpposite(this Corner corner)
|
||
|
=> corner switch {
|
||
|
Corner.TopLeft => Corner.BottomRight,
|
||
|
Corner.TopRight => Corner.BottomLeft,
|
||
|
Corner.BottomRight => Corner.TopLeft,
|
||
|
Corner.BottomLeft => Corner.TopRight,
|
||
|
_ => throw new ArgumentException($"Invalid Corner value '{corner}'", nameof(corner)),
|
||
|
};
|
||
|
}
|