feat: safe delegate invocation helper added

This commit is contained in:
2025-04-13 19:08:47 +03:00
parent 00f7b1aaab
commit 58eb373c79
21 changed files with 116 additions and 91 deletions

View File

@@ -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;
}