From 9b45bfa4fd217afebeacf1441d820bb770ef736b Mon Sep 17 00:00:00 2001 From: Syntriax Date: Mon, 27 Nov 2023 11:11:58 +0300 Subject: [PATCH] refactor: Fixed Compiler Warning On Possible Null --- Engine.Core/GameManager.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Engine.Core/GameManager.cs b/Engine.Core/GameManager.cs index d83d95d..dbc7394 100644 --- a/Engine.Core/GameManager.cs +++ b/Engine.Core/GameManager.cs @@ -37,7 +37,20 @@ public class GameManager : IEntity public bool Initialized => _initialized; public IList GameObjects => _gameObjects; - public IStateEnable StateEnable { get { if (_stateEnable is null) Assign(new StateEnableFactory().Instantiate(this)); return _stateEnable; } } + public IStateEnable StateEnable + { + get + { + if (_stateEnable is null) + { + Assign(new StateEnableFactory().Instantiate(this)); + if (_stateEnable is null) + throw NotAssignedException.From(this, _stateEnable); + } + + return _stateEnable; + } + } public void RegisterGameObject(IGameObject gameObject) {