feat: safe delegate invocation helper added
This commit is contained in:
@@ -41,9 +41,9 @@ public class BehaviourController : IBehaviourController
|
||||
|
||||
_initialized = value;
|
||||
if (value)
|
||||
OnInitialized?.Invoke(this);
|
||||
OnInitialized?.InvokeSafe(this);
|
||||
else
|
||||
OnFinalized?.Invoke(this);
|
||||
OnFinalized?.InvokeSafe(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class BehaviourController : IBehaviourController
|
||||
|
||||
behaviour.Initialize();
|
||||
behaviour.OnPriorityChanged += OnPriorityChange;
|
||||
OnBehaviourAdded?.Invoke(this, behaviour);
|
||||
OnBehaviourAdded?.InvokeSafe(this, behaviour);
|
||||
return behaviour;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class BehaviourController : IBehaviourController
|
||||
behaviour.OnPriorityChanged -= OnPriorityChange;
|
||||
behaviour.Finalize();
|
||||
behaviours.Remove(behaviour);
|
||||
OnBehaviourRemoved?.Invoke(this, behaviour);
|
||||
OnBehaviourRemoved?.InvokeSafe(this, behaviour);
|
||||
}
|
||||
|
||||
protected virtual void OnAssign(IHierarchyObject hierarchyObject) { }
|
||||
@@ -132,7 +132,7 @@ public class BehaviourController : IBehaviourController
|
||||
|
||||
_hierarchyObject = hierarchyObject;
|
||||
OnAssign(hierarchyObject);
|
||||
OnHierarchyObjectAssigned?.Invoke(this);
|
||||
OnHierarchyObjectAssigned?.InvokeSafe(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ public class BehaviourController : IBehaviourController
|
||||
return false;
|
||||
|
||||
_hierarchyObject = null!;
|
||||
OnUnassigned?.Invoke(this);
|
||||
OnUnassigned?.InvokeSafe(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -177,8 +177,8 @@ public class BehaviourController : IBehaviourController
|
||||
if (!HierarchyObject.StateEnable.Enabled)
|
||||
return;
|
||||
|
||||
OnPreUpdate?.Invoke(this);
|
||||
OnUpdate?.Invoke(this);
|
||||
OnPreUpdate?.InvokeSafe(this);
|
||||
OnUpdate?.InvokeSafe(this);
|
||||
}
|
||||
|
||||
public void UpdatePreDraw()
|
||||
@@ -186,7 +186,7 @@ public class BehaviourController : IBehaviourController
|
||||
if (!HierarchyObject.StateEnable.Enabled)
|
||||
return;
|
||||
|
||||
OnPreDraw?.Invoke(this);
|
||||
OnPreDraw?.InvokeSafe(this);
|
||||
}
|
||||
|
||||
public BehaviourController() { }
|
||||
|
Reference in New Issue
Block a user