feat: safe delegate invocation helper added
This commit is contained in:
@@ -50,7 +50,7 @@ public class BehaviourCollector<T> : IBehaviourCollector<T> where T : class
|
||||
|
||||
behaviours.Add(tBehaviour);
|
||||
OnBehaviourAdd(behaviour);
|
||||
OnCollected?.Invoke(this, tBehaviour);
|
||||
OnCollected?.InvokeSafe(this, tBehaviour);
|
||||
}
|
||||
|
||||
protected virtual void OnBehaviourRemove(IBehaviour behaviour) { }
|
||||
@@ -63,7 +63,7 @@ public class BehaviourCollector<T> : IBehaviourCollector<T> where T : class
|
||||
return;
|
||||
|
||||
OnBehaviourRemove(behaviour);
|
||||
OnRemoved?.Invoke(this, tBehaviour);
|
||||
OnRemoved?.InvokeSafe(this, tBehaviour);
|
||||
}
|
||||
|
||||
protected virtual void OnAssign(IGameManager gameManager) { }
|
||||
@@ -80,7 +80,7 @@ public class BehaviourCollector<T> : IBehaviourCollector<T> where T : class
|
||||
|
||||
GameManager = gameManager;
|
||||
OnAssign(gameManager);
|
||||
OnGameManagerAssigned?.Invoke(this);
|
||||
OnGameManagerAssigned?.InvokeSafe(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class BehaviourCollector<T> : IBehaviourCollector<T> where T : class
|
||||
GameManager.OnHierarchyObjectUnRegistered -= OnHierarchyObjectUnregistered;
|
||||
|
||||
GameManager = null!;
|
||||
OnUnassigned?.Invoke(this);
|
||||
OnUnassigned?.InvokeSafe(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user