1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-23 05:08:34 +01:00

expose the viewport of a camera

This commit is contained in:
Ell 2021-03-09 02:29:06 +01:00
parent 0b39928334
commit b594c271ac

View file

@ -23,7 +23,6 @@ namespace MLEM.Cameras {
get => this.scale; get => this.scale;
set => this.scale = MathHelper.Clamp(value, this.MinScale, this.MaxScale); set => this.scale = MathHelper.Clamp(value, this.MinScale, this.MaxScale);
} }
private float scale = 1;
/// <summary> /// <summary>
/// The minimum <see cref="Scale"/> that the camera can have /// The minimum <see cref="Scale"/> that the camera can have
/// </summary> /// </summary>
@ -79,11 +78,15 @@ namespace MLEM.Cameras {
get => this.Position + this.ScaledViewport / 2; get => this.Position + this.ScaledViewport / 2;
set => this.Position = value - this.ScaledViewport / 2; set => this.Position = value - this.ScaledViewport / 2;
} }
private Rectangle Viewport => this.graphicsDevice.Viewport.Bounds; /// <summary>
private Vector2 ScaledViewport => new Vector2(this.Viewport.Width, this.Viewport.Height) / this.ActualScale; /// The viewport of this camera, based on the game's <see cref="GraphicsDevice.Viewport"/> and this camera's <see cref="ActualScale"/>
/// </summary>
public Vector2 ScaledViewport => new Vector2(this.Viewport.Width, this.Viewport.Height) / this.ActualScale;
private Rectangle Viewport => this.graphicsDevice.Viewport.Bounds;
private readonly bool roundPosition; private readonly bool roundPosition;
private readonly GraphicsDevice graphicsDevice; private readonly GraphicsDevice graphicsDevice;
private float scale = 1;
/// <summary> /// <summary>
/// Creates a new camera. /// Creates a new camera.