chore: Code Typos Fixed

This commit is contained in:
Syntriax 2023-11-27 11:06:02 +03:00
parent 12bbfdceaf
commit 6dec7dd720
1 changed files with 9 additions and 10 deletions

View File

@ -19,7 +19,7 @@ public class GameManager : IEntity
private IList<IGameObject> _gameObjects = new List<IGameObject>(Constants.GAME_OBJECTS_SIZE_INITIAL);
private IList<IDrawable> _drawables = new List<IDrawable>(Constants.DRAWABLE_OBJECTS_SIZE_INITIAL);
private IList<IDisplayable> _drawables = new List<IDisplayable>(Constants.DRAWABLE_OBJECTS_SIZE_INITIAL);
private IStateEnable _stateEnable = null!;
private GameObjectFactory _gameObjectFactory = null!;
@ -42,7 +42,7 @@ public class GameManager : IEntity
public void RegisterGameObject(IGameObject gameObject)
{
if (_gameObjects.Contains(gameObject))
throw new Exception($"{nameof(IGameComponent)} named {gameObject.Name} is already registered to the {nameof(GameManager)}.");
throw new Exception($"{nameof(IGameObject)} named {gameObject.Name} is already registered to the {nameof(GameManager)}.");
Register(gameObject);
}
@ -57,7 +57,7 @@ public class GameManager : IEntity
public IGameObject RemoveGameObject(IGameObject gameObject)
{
if (!_gameObjects.Contains(gameObject))
throw new Exception($"{nameof(IGameComponent)} named {gameObject.Name} is not registered to the {nameof(GameManager)}.");
throw new Exception($"{nameof(IGameObject)} named {gameObject.Name} is not registered to the {nameof(GameManager)}.");
Unregister(gameObject);
return gameObject;
@ -125,9 +125,8 @@ public class GameManager : IEntity
{
spriteBatch.Begin();
foreach (var gameObject in GameObjects)
if (gameObject.BehaviourController.TryGetBehaviour<IDisplayable>(out var drawable))
drawable.Draw(spriteBatch);
foreach (var drawable in _drawables)
drawable.Draw(spriteBatch);
spriteBatch.End();
}
@ -140,7 +139,7 @@ public class GameManager : IEntity
gameObject.BehaviourController.OnBehaviourRemoved -= OnBehaviourRemove;
gameObject.OnFinalized -= OnGameObjectFinalize;
if (gameObject.BehaviourController.TryGetBehaviour<IDrawable>(out var drawable))
if (gameObject.BehaviourController.TryGetBehaviour<IDisplayable>(out var drawable))
_drawables.Remove(drawable);
_gameObjects.Remove(gameObject);
@ -152,7 +151,7 @@ public class GameManager : IEntity
gameObject.BehaviourController.OnBehaviourRemoved += OnBehaviourRemove;
gameObject.OnFinalized += OnGameObjectFinalize;
if (gameObject.BehaviourController.TryGetBehaviour<IDrawable>(out var drawable))
if (gameObject.BehaviourController.TryGetBehaviour<IDisplayable>(out var drawable))
_drawables.Add(drawable);
_gameObjects.Add(gameObject);
@ -166,13 +165,13 @@ public class GameManager : IEntity
private void OnBehaviourAdd(IBehaviourController controller, IBehaviour behaviour)
{
if (behaviour is IDrawable drawable)
if (behaviour is IDisplayable drawable)
_drawables.Add(drawable);
}
private void OnBehaviourRemove(IBehaviourController controller, IBehaviour behaviour)
{
if (behaviour is IDrawable drawable)
if (behaviour is IDisplayable drawable)
_drawables.Remove(drawable);
}
}