BREAKING CHANGE: Removed MonoGame Package
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
using Syntriax.Engine.Core.Abstract;
|
||||
using Syntriax.Engine.Core.Exceptions;
|
||||
using Syntriax.Engine.Core.Factory;
|
||||
@@ -20,7 +17,6 @@ public class GameManager : IEntity
|
||||
|
||||
|
||||
private IList<IGameObject> _gameObjects = new List<IGameObject>(Constants.GAME_OBJECTS_SIZE_INITIAL);
|
||||
private IList<IDisplayable> _drawables = new List<IDisplayable>(Constants.DRAWABLE_OBJECTS_SIZE_INITIAL);
|
||||
|
||||
private IStateEnable _stateEnable = null!;
|
||||
private GameObjectFactory _gameObjectFactory = null!;
|
||||
@@ -137,51 +133,31 @@ public class GameManager : IEntity
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Update(GameTime time)
|
||||
public void Update()
|
||||
{
|
||||
foreach (var gameObject in GameObjects)
|
||||
gameObject.BehaviourController.Update(time);
|
||||
gameObject.BehaviourController.Update();
|
||||
}
|
||||
|
||||
public void PreDraw(GameTime time)
|
||||
public void PreDraw()
|
||||
{
|
||||
foreach (var gameObject in GameObjects)
|
||||
gameObject.BehaviourController.UpdatePreDraw(time);
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, transformMatrix: Camera.MatrixTransform);
|
||||
|
||||
foreach (var drawable in _drawables)
|
||||
drawable.Draw(spriteBatch);
|
||||
|
||||
spriteBatch.End();
|
||||
gameObject.BehaviourController.UpdatePreDraw();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
private void Unregister(IGameObject gameObject)
|
||||
{
|
||||
gameObject.BehaviourController.OnBehaviourAdded -= OnBehaviourAdd;
|
||||
gameObject.BehaviourController.OnBehaviourRemoved -= OnBehaviourRemove;
|
||||
gameObject.OnFinalized -= OnGameObjectFinalize;
|
||||
|
||||
if (gameObject.BehaviourController.TryGetBehaviour<IDisplayable>(out var drawable))
|
||||
_drawables.Remove(drawable);
|
||||
|
||||
_gameObjects.Remove(gameObject);
|
||||
}
|
||||
|
||||
private void Register(IGameObject gameObject)
|
||||
{
|
||||
gameObject.BehaviourController.OnBehaviourAdded += OnBehaviourAdd;
|
||||
gameObject.BehaviourController.OnBehaviourRemoved += OnBehaviourRemove;
|
||||
gameObject.OnFinalized += OnGameObjectFinalize;
|
||||
|
||||
if (gameObject.BehaviourController.TryGetBehaviour<IDisplayable>(out var drawable))
|
||||
_drawables.Add(drawable);
|
||||
|
||||
_gameObjects.Add(gameObject);
|
||||
}
|
||||
|
||||
@@ -190,16 +166,4 @@ public class GameManager : IEntity
|
||||
if (initialize is IGameObject gameObject)
|
||||
Unregister(gameObject);
|
||||
}
|
||||
|
||||
private void OnBehaviourAdd(IBehaviourController controller, IBehaviour behaviour)
|
||||
{
|
||||
if (behaviour is IDisplayable drawable)
|
||||
_drawables.Add(drawable);
|
||||
}
|
||||
|
||||
private void OnBehaviourRemove(IBehaviourController controller, IBehaviour behaviour)
|
||||
{
|
||||
if (behaviour is IDisplayable drawable)
|
||||
_drawables.Remove(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user