perf!: events refactored throughout all the project to use Event<> class
All delegate events are refactored to use the Event<TSender> and Event<TSender, TArgument> for performance issues regarding delegate events creating garbage, also this gives us better control on event invocation since C# Delegates did also create unnecessary garbage during Delegate.DynamicInvoke
This commit is contained in:
@@ -2,9 +2,9 @@ namespace Syntriax.Engine.Core;
|
||||
|
||||
public class StateEnable : IStateEnable
|
||||
{
|
||||
public event IAssignable.UnassignEventHandler? OnUnassigned = null;
|
||||
public event IHasEntity.EntityAssignedEventHandler? OnEntityAssigned = null;
|
||||
public event IStateEnable.EnabledChangedEventHandler? OnEnabledChanged = null;
|
||||
public Event<IStateEnable, IStateEnable.EnabledChangedArguments> OnEnabledChanged { get; } = new();
|
||||
public Event<IHasEntity> OnEntityAssigned { get; } = new();
|
||||
public Event<IAssignable>? OnUnassigned { get; } = new();
|
||||
|
||||
private bool _enabled = true;
|
||||
private IEntity _entity = null!;
|
||||
@@ -21,7 +21,7 @@ public class StateEnable : IStateEnable
|
||||
|
||||
bool previousState = _enabled;
|
||||
_enabled = value;
|
||||
OnEnabledChanged?.Invoke(this, previousState);
|
||||
OnEnabledChanged?.Invoke(this, new(previousState));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user