using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Bounce.Singletons;
using Dice;
using GameChat.UI;
using HarmonyLib;
using ModdingTales;
using Unity.Mathematics;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DiceOpsPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Nth Dimension")]
[assembly: AssemblyProduct("DiceOpsPlugin")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("TemplatePlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.1.0.0")]
namespace LordAshes;
[BepInPlugin("org.lordashes.plugins.diceops", "Dice Operations Plugin", "1.1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class DiceOpsPlugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(UIDiceTray), "SetDiceUrl")]
public static class Patch_UIDiceTray_SetDiceUrl
{
public static bool Prefix(ref DiceRollDescriptor rollDescriptor, ref bool showResult)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
foreach (LoadDiceInTrayCallback value in notificationsLoadDiceInTray.Values)
{
value(DiceEvent.beforeLoadDiceInTray, default(RollId), ref rollDescriptor, ref showResult);
}
return true;
}
public static void Postfix(ref DiceRollDescriptor rollDescriptor, ref bool showResult)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
foreach (LoadDiceInTrayCallback value in notificationsLoadDiceInTray.Values)
{
value(DiceEvent.afterLoadDiceInTray, default(RollId), ref rollDescriptor, ref showResult);
}
}
}
[HarmonyPatch(typeof(DiceRollManager), "SpawnNewRoll")]
public static class Patche_DiceRollManager_SpawnNewRoll
{
public static bool Prefix(RollId rollId, in DiceRollDescriptor diceRollDescriptor, ref float3 pos, ref bool isGmRoll, ref bool showResult)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
foreach (SpawnDiceFromTrayCallback value in notificationsSpawnDiceFromTray.Values)
{
value(DiceEvent.beforeSpawnDiceFromTray, rollId, diceRollDescriptor, ref pos, ref isGmRoll, ref showResult);
}
return true;
}
public static void Postfix(RollId rollId, in DiceRollDescriptor diceRollDescriptor, ref float3 pos, ref bool isGmRoll, ref bool showResult)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
foreach (SpawnDiceFromTrayCallback value in notificationsSpawnDiceFromTray.Values)
{
value(DiceEvent.afterSpawnDiceFromTray, rollId, diceRollDescriptor, ref pos, ref isGmRoll, ref showResult);
}
}
}
[HarmonyPatch(typeof(DiceRollManager), "GatherDice")]
public static class Patche_DiceRollManager_GatherDice
{
public static bool Prefix(ref Vector3 position, RollId rollId)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
foreach (GatherDiceCallback value in notificationsGatherDice.Values)
{
value(DiceEvent.beforeGatherDice, rollId, ref position);
}
return true;
}
public static void Postfix(ref Vector3 position, RollId rollId)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
foreach (GatherDiceCallback value in notificationsGatherDice.Values)
{
value(DiceEvent.afterGatherDice, rollId, ref position);
}
}
}
[HarmonyPatch(typeof(DiceRollManager), "ThrowDice")]
public static class Patche_DiceRollManager_ThrowDice
{
public static bool Prefix(RollId rollId, ref float3 velocity)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
foreach (RollDiceCallback value in notificationsRollDice.Values)
{
value(DiceEvent.beforeRollDice, rollId, ref velocity);
}
return true;
}
public static void Postfix(RollId rollId, ref float3 velocity)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
foreach (RollDiceCallback value in notificationsRollDice.Values)
{
value(DiceEvent.afterRollDice, rollId, ref velocity);
}
}
}
[HarmonyPatch(typeof(DiceRollManager), "RemoveRoll")]
public static class Patche_DiceRollManager_RemoveRoll
{
public static bool Prefix(RollId rollId)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
foreach (ClearDiceCallback value in notificationsClearDice.Values)
{
value(DiceEvent.beforeClearDice, rollId);
}
return true;
}
public static void Postfix(RollId rollId)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
foreach (ClearDiceCallback value in notificationsClearDice.Values)
{
value(DiceEvent.afterClearDice, rollId);
}
}
}
[HarmonyPatch(typeof(UIDiceRollResult), "DisplayResult")]
public static class Patche_UIDiceRollResult_DisplayResult
{
public static bool Prefix(ref RollResults rollResultData, ref ClientGuid sender)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
foreach (DiceRollResultCallback value in notificationsDiceRollResult.Values)
{
value(DiceEvent.beforeDiceRollResult, rollResultData.RollId, ref rollResultData, ref sender);
}
return true;
}
public static void Postfix(ref RollResults rollResultData, ref ClientGuid sender)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
foreach (DiceRollResultCallback value in notificationsDiceRollResult.Values)
{
value(DiceEvent.afterDiceRollResult, rollResultData.RollId, ref rollResultData, ref sender);
}
}
}
[HarmonyPatch(typeof(UIChatMessageManager), "AddDiceResultMessage")]
public static class Patche_UIChatMessageManager_AddDiceResultMessage
{
public static bool Prefix(ref RollResults diceResult, ref ResultsOrigin origin, ref ClientGuid sender, ref bool hidden, IChatFocusable focus = null)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
foreach (DiceRollChatResultCallback value in notificationsDiceRollChatResult.Values)
{
value(DiceEvent.beforeDiceRollChatResult, diceResult.RollId, ref diceResult, ref origin, ref sender, ref hidden, focus);
}
return true;
}
public static void Postfix(ref RollResults diceResult, ref ResultsOrigin origin, ref ClientGuid sender, ref bool hidden, IChatFocusable focus = null)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
foreach (DiceRollChatResultCallback value in notificationsDiceRollChatResult.Values)
{
value(DiceEvent.afterDiceRollChatResult, diceResult.RollId, ref diceResult, ref origin, ref sender, ref hidden, focus);
}
}
}
public static class PatchAssistant
{
public static object GetProperty(object instance, string propertyName)
{
Type type = instance.GetType();
foreach (PropertyInfo runtimeProperty in type.GetRuntimeProperties())
{
if (runtimeProperty.Name.Contains(propertyName))
{
return runtimeProperty.GetValue(instance);
}
}
PropertyInfo[] properties = type.GetProperties();
foreach (PropertyInfo propertyInfo in properties)
{
if (propertyInfo.Name.Contains(propertyName))
{
return propertyInfo.GetValue(instance);
}
}
return null;
}
public static void SetProperty(object instance, string propertyName, object value)
{
Type type = instance.GetType();
foreach (PropertyInfo runtimeProperty in type.GetRuntimeProperties())
{
if (runtimeProperty.Name.Contains(propertyName))
{
runtimeProperty.SetValue(instance, value);
return;
}
}
PropertyInfo[] properties = type.GetProperties();
foreach (PropertyInfo propertyInfo in properties)
{
if (propertyInfo.Name.Contains(propertyName))
{
propertyInfo.SetValue(instance, value);
break;
}
}
}
public static object GetField(object instance, string fieldName)
{
Type type = instance.GetType();
foreach (FieldInfo runtimeField in type.GetRuntimeFields())
{
if (runtimeField.Name.Contains(fieldName))
{
return runtimeField.GetValue(instance);
}
}
FieldInfo[] fields = type.GetFields();
foreach (FieldInfo fieldInfo in fields)
{
if (fieldInfo.Name.Contains(fieldName))
{
return fieldInfo.GetValue(instance);
}
}
return null;
}
public static void SetField(object instance, string fieldName, object value)
{
Type type = instance.GetType();
foreach (FieldInfo runtimeField in type.GetRuntimeFields())
{
if (runtimeField.Name.Contains(fieldName))
{
runtimeField.SetValue(instance, value);
return;
}
}
FieldInfo[] fields = type.GetFields();
foreach (FieldInfo fieldInfo in fields)
{
if (fieldInfo.Name.Contains(fieldName))
{
fieldInfo.SetValue(instance, value);
break;
}
}
}
public static object UseMethod(object instance, string methodName, object[] parameters)
{
Type type = instance.GetType();
foreach (MethodInfo runtimeMethod in type.GetRuntimeMethods())
{
if (runtimeMethod.Name.Contains(methodName))
{
return runtimeMethod.Invoke(instance, parameters);
}
}
MethodInfo[] methods = type.GetMethods();
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.Name.Contains(methodName))
{
return methodInfo.Invoke(instance, parameters);
}
}
return null;
}
}
public static class RollSimplifier
{
public class RollParseResult
{
public string RollString { get; set; }
public List<short> AllDiceValues { get; set; }
public List<int> Totals { get; set; }
}
public static RollParseResult ParseRollResults(RollResults rollResults)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
List<short> allDiceValues = new List<short>();
List<string> list = new List<string>();
List<int> list2 = new List<int>();
RollGroup[] array = rollResults.ResultsGroups.ToArray();
foreach (RollGroup val in array)
{
var (item, item2) = ProcessOperand(val.Result, allDiceValues);
list.Add(item);
list2.Add(item2);
}
return new RollParseResult
{
RollString = string.Join(" / ", list),
AllDiceValues = allDiceValues,
Totals = list2
};
}
private static (string str, int total) ProcessOperand(RollOperand operand, List<short> allDiceValues)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Invalid comparison between Unknown and I8
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
RollOperation val = default(RollOperation);
RollResult val2 = default(RollResult);
RollValue val3 = default(RollValue);
Which val4 = ((RollOperand)(ref operand)).Get(ref val, ref val2, ref val3);
Which val5 = val4;
Which val6 = val5;
if ((long)val6 <= 2L)
{
switch ((uint)val6)
{
case 0u:
{
RollOperand[] array2 = val.Operands.ToArray();
if (array2.Length != 2)
{
throw new InvalidOperationException("Unexpected number of operands in RollOperation (expected 2).");
}
(string, int) tuple = ProcessOperand(array2[0], allDiceValues);
(string, int) tuple2 = ProcessOperand(array2[1], allDiceValues);
int item2 = (((int)val.Operator == 0) ? (tuple.Item2 + tuple2.Item2) : (tuple.Item2 - tuple2.Item2));
string text = (((int)val.Operator == 0) ? "+" : "-");
return (tuple.Item1 + text + tuple2.Item1, item2);
}
case 1u:
{
int num = ((IEnumerable<short>)val2.Results).Count();
string registeredName = ((DieKind)(ref val2.Kind)).RegisteredName;
short[] array = val2.Results.ToArray();
allDiceValues.AddRange(array);
int item = array.Sum((short r) => r);
return ($"{num}{registeredName}", item);
}
case 2u:
{
short value = val3.Value;
return (value.ToString(), val3.Value);
}
}
}
throw new InvalidOperationException("Unknown RollOperand type encountered.");
}
}
public static class Utility
{
public static bool isBoardLoaded()
{
return SimpleSingletonBehaviour<CameraController>.HasInstance && SingletonStateMBehaviour<BoardSessionManager, State<BoardSessionManager>>.HasInstance && !BoardSessionManager.IsLoading;
}
public static float ParseFloat(string value)
{
return float.Parse(value, CultureInfo.InvariantCulture);
}
public static GameObject FindInHierarchy(GameObject start, string seekName)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, seekName, null, single: true, ref results, ref done);
return (results.Count > 0) ? results.ElementAt(0) : null;
}
public static GameObject FindInHierarchyViaPartialName(GameObject start, string seekName)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, seekName, null, single: true, ref results, ref done, partial: true);
return (results.Count > 0) ? results.ElementAt(0) : null;
}
public static GameObject[] FindAllInHierarchy(GameObject start, string seekName)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, seekName, null, single: false, ref results, ref done);
return results.ToArray();
}
public static GameObject[] FindAllInHierarchyViaPartialName(GameObject start, string seekName)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, seekName, null, single: false, ref results, ref done, partial: true);
return results.ToArray();
}
public static GameObject FindWithComponentInHierarchy(GameObject start, string seekType)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, null, seekType, single: true, ref results, ref done);
return (results.Count > 0) ? results.ElementAt(0) : null;
}
public static GameObject[] FindAllWithComponentInHierarchy<T>(GameObject start, string seekType)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, null, seekType, single: false, ref results, ref done);
return results.ToArray();
}
public static void Traverse(Transform root, string seekName, string seekType, bool single, ref List<GameObject> results, ref bool done, bool partial = false)
{
try
{
if ((seekName == null || seekName == ((Object)((Component)root).gameObject).name || (partial && ((Object)((Component)root).gameObject).name.Contains(seekName))) && (seekType == null || (Object)(object)((Component)root).GetComponent(seekType) != (Object)null))
{
LoggingPlugin.LogTrace("Matched '" + ((Object)((Component)root).gameObject).name + "'");
results.Add(((Component)root).gameObject);
if (single)
{
done = true;
return;
}
}
foreach (Transform item in ExtensionMethods.Children(root))
{
if (!done)
{
Traverse(item, seekName, seekType, single, ref results, ref done, partial);
}
}
}
catch
{
}
}
public static object LookUp(in Dictionary<string, object> dictionary, string key)
{
foreach (KeyValuePair<string, object> item in dictionary)
{
if (item.Key.ToUpper() == key.ToUpper())
{
return item.Value;
}
}
return null;
}
public static void PostOnMainPage(BaseUnityPlugin plugin)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
string text = "Lord Ashes" + ("Lord Ashes".ToUpper().EndsWith("S") ? "'" : "'s");
ModdingUtils.Initialize(plugin, new ManualLogSource("Dice Operations Plugin"), text, false);
}
}
public enum DiceEvent
{
none,
beforeLoadDiceInTray,
afterLoadDiceInTray,
beforeSpawnDiceFromTray,
afterSpawnDiceFromTray,
beforeGatherDice,
afterGatherDice,
beforeRollDice,
afterRollDice,
beforeDiceRollResult,
afterDiceRollResult,
beforeDiceRollChatResult,
afterDiceRollChatResult,
beforeClearDice,
afterClearDice
}
public delegate void LoadDiceInTrayCallback(DiceEvent diceEvent, RollId rollId, ref DiceRollDescriptor rollDescriptor, ref bool showResult);
public delegate void SpawnDiceFromTrayCallback(DiceEvent diceEvent, RollId rollId, DiceRollDescriptor diceRollDescriptor, ref float3 pos, ref bool isGmRoll, ref bool showResult);
public delegate void GatherDiceCallback(DiceEvent diceEvent, RollId rollId, ref Vector3 position);
public delegate void RollDiceCallback(DiceEvent diceEvent, RollId rollId, ref float3 velocity);
public delegate void ClearDiceCallback(DiceEvent diceEvent, RollId rollId);
public delegate void DiceRollResultCallback(DiceEvent diceEvent, RollId rollId, ref RollResults rollResultData, ref ClientGuid sender);
public delegate void DiceRollChatResultCallback(DiceEvent diceEvent, RollId rollId, ref RollResults diceResult, ref ResultsOrigin origin, ref ClientGuid sender, ref bool hidden, IChatFocusable focus = null);
[CompilerGenerated]
private sealed class <ClearDice>d__42 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public RollId rollId;
public float delay;
public DiceOpsPlugin <>4__this;
private DiceRollManager <drm>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ClearDice>d__42(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<drm>5__1 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
{
<>1__state = -1;
long asLong = rollId.AsLong;
LoggingPlugin.LogDebug("Dice Operations Plugin: Delayed Clear Dice Roll " + asLong);
<>2__current = (object)new WaitForSeconds(delay);
<>1__state = 1;
return true;
}
case 1:
{
<>1__state = -1;
long asLong = rollId.AsLong;
LoggingPlugin.LogDebug("Dice Operations Plugin: Clearing Dice Roll " + asLong);
<drm>5__1 = Object.FindObjectOfType<DiceRollManager>();
if ((Object)(object)<drm>5__1 != (Object)null)
{
<drm>5__1.RemoveRoll(rollId);
}
return false;
}
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <GatherDice>d__40 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public RollId rollId;
public Vector3 pos;
public float delay;
public DiceOpsPlugin <>4__this;
private DiceRollManager <dm>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <GatherDice>d__40(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<dm>5__1 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
{
<>1__state = -1;
long asLong = rollId.AsLong;
LoggingPlugin.LogDebug("Dice Operations Plugin: Delayed Gather Dice Roll " + asLong);
if (rollId.AsLong != -1)
{
<>2__current = (object)new WaitForSeconds(delay);
<>1__state = 1;
return true;
}
break;
}
case 1:
{
<>1__state = -1;
long asLong = rollId.AsLong;
LoggingPlugin.LogInfo("Dice Operations Plugin: Gather Dice Roll " + asLong + " At " + ((object)(Vector3)(ref pos)).ToString());
<dm>5__1 = Object.FindObjectOfType<DiceRollManager>();
<dm>5__1.GatherDice(pos, rollId);
<dm>5__1 = null;
break;
}
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <RollDice>d__41 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public RollId rollId;
public float delay;
public DiceOpsPlugin <>4__this;
private DiceRollManager <dm>5__1;
private float <extraBounceHeight>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RollDice>d__41(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<dm>5__1 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
{
<>1__state = -1;
long asLong = rollId.AsLong;
LoggingPlugin.LogDebug("Dice Operations Plugin: Delayed Roll Dice Roll " + asLong);
if (rollId.AsLong != -1)
{
<>2__current = (object)new WaitForSeconds(delay);
<>1__state = 1;
return true;
}
break;
}
case 1:
{
<>1__state = -1;
long asLong = rollId.AsLong;
LoggingPlugin.LogInfo("Dice Operations Plugin: Rolling Dice Roll " + asLong);
<dm>5__1 = Object.FindObjectOfType<DiceRollManager>();
LoggingPlugin.LogTrace("Dice Operations Plugin: Rolling Dice (Roll Id: " + ((object)(RollId)(ref rollId)).ToString() + ")");
<extraBounceHeight>5__2 = ((BaseUnityPlugin)<>4__this).Config.Bind<float>("Setting", "Extra Bounce Height", 0f, (ConfigDescription)null).Value;
if (<extraBounceHeight>5__2 > 0f)
{
<dm>5__1.GatherDice(((Component)SimpleSingletonBehaviour<CameraController>.Instance).transform.position + <extraBounceHeight>5__2 * Vector3.up, rollId);
}
<dm>5__1.ThrowDice(rollId, new float3(0f, 1f, 0f));
<dm>5__1 = null;
break;
}
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <SpawnTrayDice>d__39 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public float delay;
public DiceOpsPlugin <>4__this;
private UIDiceTray <uidiceTray>5__1;
private bool <flag>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SpawnTrayDice>d__39(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<uidiceTray>5__1 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
LoggingPlugin.LogDebug("Dice Operations Plugin: Delayed Spawn Dice Tray Dice");
<>2__current = (object)new WaitForSeconds(delay);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
LoggingPlugin.LogDebug("Dice Operations Plugin: Spawning Dice Tray Dice");
<uidiceTray>5__1 = Object.FindObjectOfType<UIDiceTray>();
<flag>5__2 = (bool)PatchAssistant.GetField(<uidiceTray>5__1, "_leftMouseButtonHeld");
PatchAssistant.SetField(<uidiceTray>5__1, "_leftMouseButtonHeld", true);
<uidiceTray>5__1.SpawnDice();
PatchAssistant.SetField(<uidiceTray>5__1, "_leftMouseButtonHeld", <flag>5__2);
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WarnAboutLogLevel>d__43 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public DiceOpsPlugin <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WarnAboutLogLevel>d__43(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
try
{
DiagnosticLevel logLevel = LoggingPlugin.GetLogLevel();
SystemMessage.DisplayInfoText("Dice Operations Plugin: Using '" + ((object)(DiagnosticLevel)(ref logLevel)).ToString() + "' diagnostics.\r\nUse 'Info' for better performance", 10f, 0f);
SystemMessage.DisplayInfoText("Dice Operations Plugin: Use 'Debug' or 'Trace' for\r\ntroubleshooting only.", 10f, 0f);
}
catch
{
goto IL_0072;
}
return false;
IL_0072:
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public const string Name = "Dice Operations Plugin";
public const string Guid = "org.lordashes.plugins.diceops";
public const string Version = "1.1.0.0";
public const string Author = "Lord Ashes";
public static DiceOpsPlugin _self = null;
private static Dictionary<Guid, LoadDiceInTrayCallback> notificationsLoadDiceInTray = new Dictionary<Guid, LoadDiceInTrayCallback>();
private static Dictionary<Guid, SpawnDiceFromTrayCallback> notificationsSpawnDiceFromTray = new Dictionary<Guid, SpawnDiceFromTrayCallback>();
private static Dictionary<Guid, GatherDiceCallback> notificationsGatherDice = new Dictionary<Guid, GatherDiceCallback>();
private static Dictionary<Guid, RollDiceCallback> notificationsRollDice = new Dictionary<Guid, RollDiceCallback>();
private static Dictionary<Guid, ClearDiceCallback> notificationsClearDice = new Dictionary<Guid, ClearDiceCallback>();
private static Dictionary<Guid, DiceRollResultCallback> notificationsDiceRollResult = new Dictionary<Guid, DiceRollResultCallback>();
private static Dictionary<Guid, DiceRollChatResultCallback> notificationsDiceRollChatResult = new Dictionary<Guid, DiceRollChatResultCallback>();
private void Awake()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Invalid comparison between Unknown and I4
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
_self = this;
LoggingPlugin.SetLogLevel(((BaseUnityPlugin)this).Config.Bind<DiagnosticLevel>("Settings", "Diagnostic Level", (DiagnosticLevel)3, (ConfigDescription)null).Value);
string? assemblyQualifiedName = ((object)this).GetType().AssemblyQualifiedName;
DiagnosticLevel logLevel = LoggingPlugin.GetLogLevel();
Debug.Log((object)(assemblyQualifiedName + ": Active. (Diagnostic Mode = " + ((object)(DiagnosticLevel)(ref logLevel)).ToString() + ")"));
if ((int)LoggingPlugin.GetLogLevel() >= 4)
{
((MonoBehaviour)this).StartCoroutine(WarnAboutLogLevel());
}
Harmony val = new Harmony("org.lordashes.plugins.diceops");
val.PatchAll();
Utility.PostOnMainPage((BaseUnityPlugin)(object)this);
}
public static Guid AddNotification(LoadDiceInTrayCallback callback)
{
Guid guid = System.Guid.NewGuid();
notificationsLoadDiceInTray.Add(guid, callback);
return guid;
}
public static Guid AddNotification(SpawnDiceFromTrayCallback callback)
{
Guid guid = System.Guid.NewGuid();
notificationsSpawnDiceFromTray.Add(guid, callback);
return guid;
}
public static Guid AddNotification(GatherDiceCallback callback)
{
Guid guid = System.Guid.NewGuid();
notificationsGatherDice.Add(guid, callback);
return guid;
}
public static Guid AddNotification(RollDiceCallback callback)
{
Guid guid = System.Guid.NewGuid();
notificationsRollDice.Add(guid, callback);
return guid;
}
public static Guid AddNotification(ClearDiceCallback callback)
{
Guid guid = System.Guid.NewGuid();
notificationsClearDice.Add(guid, callback);
return guid;
}
public static Guid AddNotification(DiceRollResultCallback callback)
{
Guid guid = System.Guid.NewGuid();
notificationsDiceRollResult.Add(guid, callback);
return guid;
}
public static Guid AddNotification(DiceRollChatResultCallback callback)
{
Guid guid = System.Guid.NewGuid();
notificationsDiceRollChatResult.Add(guid, callback);
return guid;
}
public static void RemoveNotification(Guid removeSubscription)
{
for (int i = 0; i < notificationsLoadDiceInTray.Keys.Count; i++)
{
if (notificationsLoadDiceInTray.Keys.ElementAt(i) == removeSubscription)
{
notificationsLoadDiceInTray.Remove(notificationsLoadDiceInTray.Keys.ElementAt(i));
i--;
}
}
for (int j = 0; j < notificationsSpawnDiceFromTray.Keys.Count; j++)
{
if (notificationsSpawnDiceFromTray.Keys.ElementAt(j) == removeSubscription)
{
notificationsSpawnDiceFromTray.Remove(notificationsSpawnDiceFromTray.Keys.ElementAt(j));
j--;
}
}
for (int k = 0; k < notificationsGatherDice.Keys.Count; k++)
{
if (notificationsGatherDice.Keys.ElementAt(k) == removeSubscription)
{
notificationsGatherDice.Remove(notificationsGatherDice.Keys.ElementAt(k));
k--;
}
}
for (int l = 0; l < notificationsRollDice.Keys.Count; l++)
{
if (notificationsRollDice.Keys.ElementAt(l) == removeSubscription)
{
notificationsRollDice.Remove(notificationsRollDice.Keys.ElementAt(l));
l--;
}
}
for (int m = 0; m < notificationsClearDice.Keys.Count; m++)
{
if (notificationsClearDice.Keys.ElementAt(m) == removeSubscription)
{
notificationsClearDice.Remove(notificationsClearDice.Keys.ElementAt(m));
m--;
}
}
for (int n = 0; n < notificationsDiceRollResult.Keys.Count; n++)
{
if (notificationsDiceRollResult.Keys.ElementAt(n) == removeSubscription)
{
notificationsDiceRollResult.Remove(notificationsDiceRollResult.Keys.ElementAt(n));
n--;
}
}
for (int num = 0; num < notificationsDiceRollChatResult.Keys.Count; num++)
{
if (notificationsDiceRollChatResult.Keys.ElementAt(num) == removeSubscription)
{
notificationsDiceRollChatResult.Remove(notificationsDiceRollChatResult.Keys.ElementAt(num));
num--;
}
}
}
[IteratorStateMachine(typeof(<SpawnTrayDice>d__39))]
public IEnumerator SpawnTrayDice(float delay)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SpawnTrayDice>d__39(0)
{
<>4__this = this,
delay = delay
};
}
[IteratorStateMachine(typeof(<GatherDice>d__40))]
public IEnumerator GatherDice(RollId rollId, Vector3 pos, float delay)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <GatherDice>d__40(0)
{
<>4__this = this,
rollId = rollId,
pos = pos,
delay = delay
};
}
[IteratorStateMachine(typeof(<RollDice>d__41))]
public IEnumerator RollDice(RollId rollId, float delay)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RollDice>d__41(0)
{
<>4__this = this,
rollId = rollId,
delay = delay
};
}
[IteratorStateMachine(typeof(<ClearDice>d__42))]
public IEnumerator ClearDice(RollId rollId, float delay)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ClearDice>d__42(0)
{
<>4__this = this,
rollId = rollId,
delay = delay
};
}
[IteratorStateMachine(typeof(<WarnAboutLogLevel>d__43))]
private IEnumerator WarnAboutLogLevel()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WarnAboutLogLevel>d__43(0)
{
<>4__this = this
};
}
}