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:
2025-05-31 00:14:43 +03:00
parent 996e61d0ad
commit 61e2761580
58 changed files with 637 additions and 485 deletions

View File

@@ -1,18 +1,19 @@
using Syntriax.Engine.Core;
namespace Syntriax.Engine.Systems.Time;
public interface IReadOnlyStopwatch
{
event StopwatchEventHandler? OnStarted;
event StopwatchDeltaEventHandler? OnDelta;
event StopwatchEventHandler? OnStopped;
Event<IReadOnlyStopwatch> OnStarted { get; }
Event<IReadOnlyStopwatch, StopwatchDeltaArguments> OnDelta { get; }
Event<IReadOnlyStopwatch> OnStopped { get; }
double Time { get; }
TimerState State { get; }
event StopwatchEventHandler? OnPaused;
event StopwatchEventHandler? OnResumed;
Event<IReadOnlyStopwatch> OnPaused { get; }
Event<IReadOnlyStopwatch> OnResumed { get; }
delegate void StopwatchEventHandler(IReadOnlyStopwatch sender);
delegate void StopwatchDeltaEventHandler(IReadOnlyStopwatch sender, double delta);
readonly record struct StopwatchDeltaArguments(double Delta);
}