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:
@@ -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() { }
|
||||
|
Reference in New Issue
Block a user