Pong/Scripts/Data/GameCoordinate.cs

26 lines
939 B
C#
Raw Normal View History

namespace Pong.Scripts.Data;
/// <summary>
/// simple wrapper structure to a double that makes it easy to get commonly used calculations of the number.
/// </summary>
/// <param name="Coordinate">the coordinate you want to wrap.</param>
public readonly record struct GameCoordinate(double Coordinate)
{
/// <summary>
/// the original coordinate. you don't really need to use this as the struct has an implicit operator, but
/// its here if you need it.
/// </summary>
public readonly double Coordinate = Coordinate;
/// <summary>
/// get the coordinate but calculated by the extents of the wall size.
/// </summary>
public double ByWallSizeExtents => Coordinate - Constants.WallSizeExtents;
/// <summary>
/// get the coordinate but calculated by the wall size.
/// </summary>
public double ByWallSize => Coordinate - Constants.WallSize;
public static implicit operator double(GameCoordinate coord) => coord.Coordinate;
}