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

@@ -63,12 +63,12 @@ public class ActiveBehaviourCollector<T> : IBehaviourCollector<T> where T : clas
{
activeBehaviours.Add(behaviour);
OnBehaviourAdd(behaviour);
OnCollected?.Invoke(this, behaviour);
OnCollected?.InvokeSafe(this, behaviour);
}
else if (activeBehaviours.Remove(behaviour))
{
OnBehaviourRemove(behaviour);
OnRemoved?.Invoke(this, behaviour);
OnRemoved?.InvokeSafe(this, behaviour);
}
}
@@ -85,7 +85,7 @@ public class ActiveBehaviourCollector<T> : IBehaviourCollector<T> where T : clas
if (activeBehaviours.Remove(tBehaviour))
{
OnBehaviourRemove(tBehaviour);
OnRemoved?.Invoke(this, tBehaviour);
OnRemoved?.InvokeSafe(this, tBehaviour);
}
}
@@ -101,7 +101,7 @@ public class ActiveBehaviourCollector<T> : IBehaviourCollector<T> where T : clas
gameManager.OnHierarchyObjectUnRegistered += OnHierarchyObjectUnregistered;
GameManager = gameManager;
OnGameManagerAssigned?.Invoke(this);
OnGameManagerAssigned?.InvokeSafe(this);
return true;
}
@@ -118,7 +118,7 @@ public class ActiveBehaviourCollector<T> : IBehaviourCollector<T> where T : clas
GameManager.OnHierarchyObjectUnRegistered -= OnHierarchyObjectUnregistered;
GameManager = null!;
OnUnassigned?.Invoke(this);
OnUnassigned?.InvokeSafe(this);
return true;
}