problème : Il y avait plusieurs manières de faire planter le loading screen en appuyant sur des boutons changements: - turn off buttons when loading screen is active - turn on buttons when loading screen is not active - add event aggregator class to project and migrate every event to it - fix bugs and regressions
34 lines
1.0 KiB
C#
34 lines
1.0 KiB
C#
|
|
namespace GatherAndDefend.Events
|
|
{
|
|
/// <summary>
|
|
/// lets you create custom events for the event aggregator
|
|
/// </summary>
|
|
public abstract class EventBase
|
|
{
|
|
private event System.Action innerEvent;
|
|
public void Invoke()
|
|
{
|
|
innerEvent?.Invoke();
|
|
}
|
|
public void Attach(System.Action handler)
|
|
{
|
|
innerEvent += handler;
|
|
}
|
|
public void Detach(System.Action handler)
|
|
{
|
|
innerEvent -= handler;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// lets you create custom event with given parameter for the event aggregator
|
|
/// </summary>
|
|
/// <typeparam name="T"></typeparam>
|
|
public abstract class EventBase<T> : EventBase
|
|
{
|
|
private event System.Action<T> innerEvent;
|
|
public void Invoke(T value) => innerEvent?.Invoke(value);
|
|
public void Attach(System.Action<T> handler) => innerEvent += handler;
|
|
public void Detach(System.Action<T> handler) => innerEvent -= handler;
|
|
}
|
|
} |