refactor: Actions to Delegates
This commit is contained in:
parent
a35e25eb31
commit
73ae55e1d4
2
Engine
2
Engine
|
@ -1 +1 @@
|
||||||
Subproject commit 2cf6135063b12dfff4d2c8391ad8edde806183f0
|
Subproject commit ef21cdf2138a2f5107a628c0fe970b88bc03dcfd
|
|
@ -8,9 +8,9 @@ namespace Pong.Behaviours;
|
||||||
|
|
||||||
public class MonoGameCamera2DBehaviour(GraphicsDeviceManager Graphics) : BehaviourOverride, ICamera2D
|
public class MonoGameCamera2DBehaviour(GraphicsDeviceManager Graphics) : BehaviourOverride, ICamera2D
|
||||||
{
|
{
|
||||||
public System.Action<MonoGameCamera2DBehaviour>? OnMatrixTransformChanged { get; set; } = null;
|
public event OnMatrixTransformChangedDelegate? OnMatrixTransformChanged = null;
|
||||||
public System.Action<MonoGameCamera2DBehaviour>? OnViewportChanged { get; set; } = null;
|
public event OnViewportChangedDelegate? OnViewportChanged = null;
|
||||||
public System.Action<MonoGameCamera2DBehaviour>? OnZoomChanged { get; set; } = null;
|
public event OnZoomChangedDelegate? OnZoomChanged = null;
|
||||||
|
|
||||||
private Matrix _matrixTransform = Matrix.Identity;
|
private Matrix _matrixTransform = Matrix.Identity;
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class MonoGameCamera2DBehaviour(GraphicsDeviceManager Graphics) : Behavio
|
||||||
set => Transform.Rotation = value;
|
set => Transform.Rotation = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.Action<IAssignableTransform>? IAssignableTransform.OnTransformAssigned { get => GameObject.OnTransformAssigned; set => GameObject.OnTransformAssigned = value; }
|
public event IAssignableTransform.OnTransformAssignedDelegate? OnTransformAssigned { add => GameObject.OnTransformAssigned += value; remove => GameObject.OnTransformAssigned -= value; }
|
||||||
ITransform IAssignableTransform.Transform => GameObject.Transform;
|
ITransform IAssignableTransform.Transform => GameObject.Transform;
|
||||||
bool IAssignableTransform.Assign(ITransform transform) => GameObject.Assign(transform);
|
bool IAssignableTransform.Assign(ITransform transform) => GameObject.Assign(transform);
|
||||||
|
|
||||||
|
@ -99,4 +99,8 @@ public class MonoGameCamera2DBehaviour(GraphicsDeviceManager Graphics) : Behavio
|
||||||
Matrix.CreateScale(Zoom) *
|
Matrix.CreateScale(Zoom) *
|
||||||
Matrix.CreateTranslation(new Vector3(_viewport.Width * .5f, _viewport.Height * .5f, 0f));
|
Matrix.CreateTranslation(new Vector3(_viewport.Width * .5f, _viewport.Height * .5f, 0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public delegate void OnMatrixTransformChangedDelegate(MonoGameCamera2DBehaviour sender);
|
||||||
|
public delegate void OnViewportChangedDelegate(MonoGameCamera2DBehaviour sender);
|
||||||
|
public delegate void OnZoomChangedDelegate(MonoGameCamera2DBehaviour sender);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue