refactor: Actions to Delegates

This commit is contained in:
2024-07-15 01:13:39 +03:00
parent 2cf6135063
commit ef21cdf213
30 changed files with 157 additions and 134 deletions

View File

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