Skip to content

Commit

Permalink
another one
Browse files Browse the repository at this point in the history
  • Loading branch information
VALERA771 committed Nov 29, 2023
1 parent bb1125b commit 0bae3ad
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
49 changes: 49 additions & 0 deletions Exiled.Events/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
// </copyright>
// -----------------------------------------------------------------------

using System.Collections.Generic;
using Exiled.Events.EventArgs.Interfaces;
using Exiled.Events.EventArgs.Map;
using Exiled.Events.EventArgs.Player;
using MEC;

namespace Exiled.Events
{
using System;
Expand Down Expand Up @@ -69,6 +75,13 @@ public override void OnEnabled()
Handlers.Player.Verified += Handlers.Internal.Round.OnVerified;
Handlers.Map.ChangedIntoGrenade += Handlers.Internal.ExplodingGrenade.OnChangedIntoGrenade;

Handlers.Player.ChangingMoveState += UwU;
Handlers.Player.ChangingRole += UwU;
Handlers.Map.FillingLocker += UwU;

Handlers.Server.RoundStarted += UwU;
Handlers.Server.WaitingForPlayers += UwU;

CharacterClassManager.OnRoundStarted += Handlers.Server.OnRoundStarted;

InventorySystem.InventoryExtensions.OnItemAdded += Handlers.Player.OnItemAdded;
Expand All @@ -82,6 +95,42 @@ public override void OnEnabled()
EventManager.RegisterEvents<Handlers.Player>(this);
}

private IEnumerator<float> UwU(ChangingRoleEventArgs ev)
{
Log.Info("ChangingRole");

yield return Timing.WaitForSeconds(2);

Log.Info("UwU");
}

private IEnumerator<float> UwU(ChangingMoveStateEventArgs ev)
{
Log.Info("ChangingMovingState");

yield return Timing.WaitForSeconds(2);

Log.Info("UwU");
}

private IEnumerator<float> UwU(FillingLockerEventArgs ev)
{
Log.Info("FillingLocker");

yield return Timing.WaitForSeconds(2);

Log.Info("UwU");
}

private IEnumerator<float> UwU()
{
Log.Info("Non-event arg ev");

yield return Timing.WaitForSeconds(2);

Log.Info("UwU");
}

/// <inheritdoc/>
public override void OnDisabled()
{
Expand Down
9 changes: 9 additions & 0 deletions Exiled.Events/Features/Event{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ public void Unsubscribe(CustomAsyncEventHandler<T> handler)
/// <param name="arg">The event argument.</param>
/// <exception cref="ArgumentNullException">Event or its arg is <see langword="null"/>.</exception>
public void InvokeSafely(T arg)
{
InvokeNormal(arg);
InvokeAsync(arg);
}

internal void InvokeNormal(T arg)
{
if (InnerEvent is null)
return;
Expand All @@ -178,7 +184,10 @@ public void InvokeSafely(T arg)
Log.Error($"Method \"{handler.Method.Name}\" of the class \"{handler.Method.ReflectedType.FullName}\" caused an exception when handling the event \"{GetType().FullName}\"\n{ex}");
}
}
}

internal void InvokeAsync(T arg)
{
if (InnerAsyncEvent is null)
return;

Expand Down

0 comments on commit 0bae3ad

Please sign in to comment.