refactor: MonoGameCamera

This commit is contained in:
Syntriax 2024-01-30 12:15:26 +03:00
parent 3717701171
commit 958a75552f
1 changed files with 6 additions and 8 deletions

View File

@ -1,5 +1,3 @@
using System;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
@ -10,11 +8,11 @@ namespace Pong.Behaviours;
public class MonoGameCameraBehaviour : BehaviourOverride public class MonoGameCameraBehaviour : BehaviourOverride
{ {
public Action<MonoGameCameraBehaviour>? OnPositionChanged { get; set; } = null; public System.Action<MonoGameCameraBehaviour>? OnPositionChanged { get; set; } = null;
public Action<MonoGameCameraBehaviour>? OnMatrixTransformChanged { get; set; } = null; public System.Action<MonoGameCameraBehaviour>? OnMatrixTransformChanged { get; set; } = null;
public Action<MonoGameCameraBehaviour>? OnViewportChanged { get; set; } = null; public System.Action<MonoGameCameraBehaviour>? OnViewportChanged { get; set; } = null;
public Action<MonoGameCameraBehaviour>? OnRotationChanged { get; set; } = null; public System.Action<MonoGameCameraBehaviour>? OnRotationChanged { get; set; } = null;
public Action<MonoGameCameraBehaviour>? OnZoomChanged { get; set; } = null; public System.Action<MonoGameCameraBehaviour>? OnZoomChanged { get; set; } = null;
private Matrix _matrixTransform = Matrix.Identity; private Matrix _matrixTransform = Matrix.Identity;
@ -59,7 +57,7 @@ public class MonoGameCameraBehaviour : BehaviourOverride
get => _zoom; get => _zoom;
set set
{ {
float newValue = value >= .1f ? value : .1f; float newValue = Math.Max(0.1f, value);
if (_zoom == newValue) if (_zoom == newValue)
return; return;