feat: GetOrAddBehaviour Extension for IBehaviourController
This commit is contained in:
parent
c0c48c7d51
commit
981db0190f
|
@ -6,6 +6,9 @@ namespace Syntriax.Engine.Core;
|
||||||
|
|
||||||
public static class BehaviourControllerExtensions
|
public static class BehaviourControllerExtensions
|
||||||
{
|
{
|
||||||
|
public static T GetOrAddBehaviour<T>(this IBehaviourController behaviourController, params object?[]? args) where T : class, IBehaviour
|
||||||
|
=> behaviourController.GetBehaviour<T>() ?? behaviourController.AddBehaviour<T>(args);
|
||||||
|
|
||||||
public static bool TryGetBehaviourInParent<T>(this IBehaviourController behaviourController, [NotNullWhen(returnValue: true)] out T? behaviour) where T : class
|
public static bool TryGetBehaviourInParent<T>(this IBehaviourController behaviourController, [NotNullWhen(returnValue: true)] out T? behaviour) where T : class
|
||||||
{
|
{
|
||||||
behaviour = GetBehaviourInParent<T>(behaviourController);
|
behaviour = GetBehaviourInParent<T>(behaviourController);
|
||||||
|
|
Loading…
Reference in New Issue