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,14 +1,12 @@
using System;
using Syntriax.Engine.Core.Abstract;
namespace Syntriax.Engine.Core;
public class StateEnable : IStateEnable
{
public Action<IAssignable>? OnUnassigned { get; set; } = null;
public Action<IAssignableEntity>? OnEntityAssigned { get; set; } = null;
public Action<IStateEnable>? OnEnabledChanged { get; set; } = null;
public event IAssignable.OnUnassignedDelegate? OnUnassigned = null;
public event IAssignableEntity.OnEntityAssignedDelegate? OnEntityAssigned = null;
public event IStateEnable.OnNameChangedDelegate? OnEnabledChanged = null;
private bool _enabled = true;
private IEntity _entity = null!;
@@ -23,8 +21,9 @@ public class StateEnable : IStateEnable
if (value == _enabled)
return;
bool previousState = _enabled;
_enabled = value;
OnEnabledChanged?.Invoke(this);
OnEnabledChanged?.Invoke(this, previousState);
}
}