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.
32 lines
1.2 KiB
32 lines
1.2 KiB
public static class GodotExtensions |
|
{ |
|
public static Vector2I RoundToVector2I(this Vector2 vector) |
|
=> new(RoundToInt(vector.X), RoundToInt(vector.Y)); |
|
|
|
public static (Corner, Corner) GetCorners(this Side side) |
|
=> side switch { |
|
Side.Left => (Corner.BottomLeft , Corner.TopLeft ), |
|
Side.Top => (Corner.TopLeft , Corner.TopRight ), |
|
Side.Right => (Corner.TopRight , Corner.BottomRight), |
|
Side.Bottom => (Corner.BottomRight, Corner.BottomLeft ), |
|
_ => 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)), |
|
}; |
|
}
|
|
|