Files
Dec2017-Script-Dump/Assembly-CSharp/RecRoom/ActionEvent.2.cs
T
2026-06-04 11:42:34 +02:00

83 lines
1.9 KiB
C#

using System;
using UnityEngine;
namespace RecRoom
{
// Token: 0x0200113B RID: 4411
public sealed class ActionEvent<T> : ListEvent<Action<T>>
{
// Token: 0x06025BC2 RID: 154562 RVA: 0x00A7877C File Offset: 0x00A7697C
public ActionEvent(int capacity = 32, bool useTryCatch = false)
: base(capacity, useTryCatch)
{
}
// Token: 0x06025BC3 RID: 154563 RVA: 0x00A78788 File Offset: 0x00A76988
public void Invoke(T t)
{
object actionList = this.actionList;
lock (actionList)
{
try
{
this.isIterating = true;
if (this.useTryCatch)
{
for (int i = 0; i < this.actionList.Count; i++)
{
try
{
this.actionList[i](t);
}
catch (Exception ex)
{
Debug.LogException(ex);
}
}
}
else
{
for (int j = 0; j < this.actionList.Count; j++)
{
this.actionList[j](t);
}
}
}
finally
{
base.ProcessQueuedModifications();
this.isIterating = false;
}
}
}
// Token: 0x06025BC4 RID: 154564 RVA: 0x00A78870 File Offset: 0x00A76A70
public override void DynamicInvoke(object[] args)
{
if (args == null)
{
throw new ArgumentException("Null arguments passed to ActionEvent.Invoke()");
}
if (args.Length != 1)
{
throw new ArgumentException("Invalid number of arguments passed to ActionEvent.Invoke()");
}
this.Invoke((T)((object)args[0]));
}
// Token: 0x06025BC5 RID: 154565 RVA: 0x00A788A8 File Offset: 0x00A76AA8
public static ActionEvent<T>operator +(ActionEvent<T> actionEvent, Action<T> action)
{
actionEvent.Add(action);
return actionEvent;
}
// Token: 0x06025BC6 RID: 154566 RVA: 0x00A788B4 File Offset: 0x00A76AB4
public static ActionEvent<T>operator -(ActionEvent<T> actionEvent, Action<T> action)
{
actionEvent.Remove(action);
return actionEvent;
}
}
}