feat: Added Basic Camera
This commit is contained in:
@@ -12,6 +12,7 @@ namespace Syntriax.Engine.Core;
|
||||
|
||||
public class GameManager : IEntity
|
||||
{
|
||||
public Action<GameManager>? OnCameraChanged { get; set; } = null;
|
||||
public Action<IInitialize>? OnInitialized { get; set; } = null;
|
||||
public Action<IInitialize>? OnFinalized { get; set; } = null;
|
||||
public Action<IAssignable>? OnUnassigned { get; set; } = null;
|
||||
@@ -24,6 +25,7 @@ public class GameManager : IEntity
|
||||
private IStateEnable _stateEnable = null!;
|
||||
private GameObjectFactory _gameObjectFactory = null!;
|
||||
private bool _initialized = false;
|
||||
private ICamera _camera = null!;
|
||||
|
||||
private GameObjectFactory GameObjectFactory
|
||||
{
|
||||
@@ -52,6 +54,19 @@ public class GameManager : IEntity
|
||||
}
|
||||
}
|
||||
|
||||
public ICamera Camera
|
||||
{
|
||||
get => _camera;
|
||||
set
|
||||
{
|
||||
if (_camera == value)
|
||||
return;
|
||||
|
||||
_camera = value;
|
||||
OnCameraChanged?.Invoke(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterGameObject(IGameObject gameObject)
|
||||
{
|
||||
if (_gameObjects.Contains(gameObject))
|
||||
@@ -136,7 +151,7 @@ public class GameManager : IEntity
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
spriteBatch.Begin();
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, transformMatrix: Camera.MatrixTransform);
|
||||
|
||||
foreach (var drawable in _drawables)
|
||||
drawable.Draw(spriteBatch);
|
||||
|
||||
Reference in New Issue
Block a user