refactor: Actions to Delegates
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
using System;
|
||||
|
||||
using Syntriax.Engine.Core.Abstract;
|
||||
using Syntriax.Engine.Core.Exceptions;
|
||||
|
||||
@@ -8,15 +6,16 @@ namespace Syntriax.Engine.Core;
|
||||
[System.Diagnostics.DebuggerDisplay("{GetType().Name, nq}, Priority: {Priority}, Initialized: {Initialized}")]
|
||||
public abstract class Behaviour : BaseEntity, IBehaviour
|
||||
{
|
||||
public Action<IAssignableBehaviourController>? OnBehaviourControllerAssigned { get; set; } = null;
|
||||
public event IAssignableBehaviourController.OnBehaviourControllerAssignedDelegate? OnBehaviourControllerAssigned = null;
|
||||
|
||||
public Action<IBehaviour>? OnPriorityChanged { get; set; } = null;
|
||||
public event IBehaviour.OnPriorityChangedDelegate? OnPriorityChanged = null;
|
||||
|
||||
|
||||
private IBehaviourController _behaviourController = null!;
|
||||
|
||||
private int _priority = 0;
|
||||
|
||||
|
||||
public IBehaviourController BehaviourController => _behaviourController;
|
||||
|
||||
public override bool IsActive => base.IsActive && BehaviourController.GameObject.StateEnable.Enabled;
|
||||
@@ -29,8 +28,9 @@ public abstract class Behaviour : BaseEntity, IBehaviour
|
||||
if (value == _priority)
|
||||
return;
|
||||
|
||||
int previousPriority = _priority;
|
||||
_priority = value;
|
||||
OnPriorityChanged?.Invoke(this);
|
||||
OnPriorityChanged?.Invoke(this, previousPriority);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user