refactor: Engine.Core ICamera Removal

This commit is contained in:
Syntriax 2024-01-30 12:14:49 +03:00
parent 4e95a3a420
commit 3717701171
3 changed files with 8 additions and 15 deletions

2
Engine

@ -1 +1 @@
Subproject commit d7d53e467a9fe118c8ec9e93ee97a3bd64b1208e Subproject commit 4000e761a7827bb76d657b10a3341248b90b0aa5

View File

@ -8,13 +8,13 @@ using Syntriax.Engine.Core.Abstract;
namespace Pong.Behaviours; namespace Pong.Behaviours;
public class MonoGameCameraBehaviour : BehaviourOverride, ICamera public class MonoGameCameraBehaviour : BehaviourOverride
{ {
public Action<ICamera>? OnPositionChanged { get; set; } = null; public Action<MonoGameCameraBehaviour>? OnPositionChanged { get; set; } = null;
public Action<ICamera>? OnMatrixTransformChanged { get; set; } = null; public Action<MonoGameCameraBehaviour>? OnMatrixTransformChanged { get; set; } = null;
public Action<ICamera>? OnViewportChanged { get; set; } = null; public Action<MonoGameCameraBehaviour>? OnViewportChanged { get; set; } = null;
public Action<ICamera>? OnRotationChanged { get; set; } = null; public Action<MonoGameCameraBehaviour>? OnRotationChanged { get; set; } = null;
public Action<ICamera>? OnZoomChanged { get; set; } = null; public Action<MonoGameCameraBehaviour>? OnZoomChanged { get; set; } = null;
private Matrix _matrixTransform = Matrix.Identity; private Matrix _matrixTransform = Matrix.Identity;
@ -74,11 +74,8 @@ public class MonoGameCameraBehaviour : BehaviourOverride, ICamera
get => Transform.Rotation; get => Transform.Rotation;
set => Transform.Rotation = value; set => Transform.Rotation = value;
} }
public Action<IAssignableTransform>? OnTransformAssigned { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
ITransform IAssignableTransform.Transform => throw new NotImplementedException(); protected override void OnPreDraw()
public void Update()
{ {
MatrixTransform = MatrixTransform =
Matrix.CreateTranslation(new Vector3(-Position.X, Position.Y, 0f)) * Matrix.CreateTranslation(new Vector3(-Position.X, Position.Y, 0f)) *
@ -101,6 +98,4 @@ public class MonoGameCameraBehaviour : BehaviourOverride, ICamera
private void OnTransformRotationChanged(ITransform _) => OnRotationChanged?.Invoke(this); private void OnTransformRotationChanged(ITransform _) => OnRotationChanged?.Invoke(this);
private void OnTransformPositionChanged(ITransform _) => OnPositionChanged?.Invoke(this); private void OnTransformPositionChanged(ITransform _) => OnPositionChanged?.Invoke(this);
public bool Assign(ITransform transform) => GameObject.Assign(transform);
} }

View File

@ -68,7 +68,6 @@ public class Game1 : Game
cameraBehaviour = gameObjectCamera.BehaviourController.AddBehaviour<MonoGameCameraBehaviour>(); cameraBehaviour = gameObjectCamera.BehaviourController.AddBehaviour<MonoGameCameraBehaviour>();
cameraBehaviour.Viewport = GraphicsDevice.Viewport; cameraBehaviour.Viewport = GraphicsDevice.Viewport;
gameManager.Camera = cameraBehaviour;
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
@ -243,7 +242,6 @@ public class Game1 : Game
// TODO: Add your drawing code here // TODO: Add your drawing code here
gameManager.PreDraw(); gameManager.PreDraw();
gameManager.Camera.Update();
_spriteBatch.Begin(SpriteSortMode.Deferred, transformMatrix: cameraBehaviour.MatrixTransform); _spriteBatch.Begin(SpriteSortMode.Deferred, transformMatrix: cameraBehaviour.MatrixTransform);
foreach (IGameObject gameObject in gameManager) foreach (IGameObject gameObject in gameManager)