refactor: IHierarchyObject Nullable IGameManager to Non-Nullable

Since in a typical use case of these classes they are already in the
hierarchy and it bloats the behaviour code with lots of null checks
This commit is contained in:
2024-11-17 21:57:00 +03:00
parent cc4068fa2e
commit c0c48c7d51
4 changed files with 10 additions and 9 deletions

View File

@@ -6,6 +6,7 @@ public abstract class Behaviour : BehaviourBase
{
private bool isInitializedThisFrame = false;
protected IGameManager GameManager => BehaviourController.GameObject.GameManager;
protected IGameObject GameObject => BehaviourController.GameObject;
protected ITransform Transform => BehaviourController.GameObject.Transform;
@@ -33,7 +34,7 @@ public abstract class Behaviour : BehaviourBase
OnInitialize();
if (GameObject.IsInHierarchy)
EnteredHierarchy(GameObject, GameObject.GameManager ?? throw new System.Exception("Unexpected Error"));
EnteredHierarchy(GameObject, GameManager);
}
protected virtual void OnFinalize() { }
@@ -48,7 +49,7 @@ public abstract class Behaviour : BehaviourBase
OnFinalize();
if (GameObject.IsInHierarchy)
ExitedHierarchy(GameObject, GameObject.GameManager ?? throw new System.Exception("Unexpected Error"));
ExitedHierarchy(GameObject, GameManager);
}
protected virtual void OnPreUpdatePreActiveCheck() { }