Decompiled source of Auto Dice Cleanup v1.0.0

AutoDiceCleanup.dll

Decompiled 7 months ago
using System.CodeDom.Compiler;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using ModdingTales;
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("Auto Dice Cleanup")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HolloFox")]
[assembly: AssemblyProduct("MFC")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4e4deb5e-97f9-4901-bf67-6748a9c1229a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AutoDiceCleanup
{
	[BepInPlugin("org.hollofox.plugins.AutoDiceCleanup", "Auto Dice Cleanup Plugin", "1.0.0.0")]
	public class AutoDiceCleanupPlugin : BaseUnityPlugin
	{
		public const string Guid = "org.hollofox.plugins.AutoDiceCleanup";

		internal const string Version = "1.0.0.0";

		public static AutoDiceCleanupPlugin Instance;

		private static ConfigEntry<bool> _cleanupAfterSelf { get; set; }

		internal static bool CleanUpAfterSelf
		{
			get
			{
				return _cleanupAfterSelf.Value;
			}
			set
			{
				_cleanupAfterSelf.Value = value;
			}
		}

		private static ConfigEntry<bool> _cleanupAsGm { get; set; }

		internal static bool CleanupAsGm
		{
			get
			{
				return _cleanupAsGm.Value;
			}
			set
			{
				_cleanupAsGm.Value = value;
			}
		}

		private static ConfigEntry<float> _cleanupAfterSelfInSeconds { get; set; }

		internal static float CleanupAfterSelfInSeconds
		{
			get
			{
				return _cleanupAfterSelfInSeconds.Value;
			}
			set
			{
				_cleanupAfterSelfInSeconds.Value = value;
			}
		}

		private static ConfigEntry<float> _cleanupAsGmInSeconds { get; set; }

		internal static float CleanupAsGmInSeconds
		{
			get
			{
				return _cleanupAsGmInSeconds.Value;
			}
			set
			{
				_cleanupAsGmInSeconds.Value = value;
			}
		}

		internal void ClearDiceRoll(float delayInSeconds, RollId rollId)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			((MonoBehaviour)this).StartCoroutine(ClearDiceRollIEnum(delayInSeconds, rollId));
		}

		internal IEnumerator ClearDiceRollIEnum(float delayInSeconds, RollId rollId)
		{
			//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 (object)new WaitForSeconds(Mathf.Max(1f, delayInSeconds));
			PhotonSimpleSingletonBehaviour<DiceManager>.Instance.ClearDiceRoll(rollId);
		}

		private void Awake()
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			Instance = this;
			Debug.Log((object)"Auto Dice Cleanup loaded");
			_cleanupAfterSelf = ((BaseUnityPlugin)this).Config.Bind<bool>("Cleanup", "Self", true, (ConfigDescription)null);
			_cleanupAsGm = ((BaseUnityPlugin)this).Config.Bind<bool>("Cleanup", "All as GM", true, (ConfigDescription)null);
			_cleanupAfterSelfInSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Cleanup", "Self Delay in Seconds", 5f, (ConfigDescription)null);
			_cleanupAsGmInSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Cleanup", "GM Delay in Seconds", 5f, (ConfigDescription)null);
			ModdingUtils.Initialize((BaseUnityPlugin)(object)this, ((BaseUnityPlugin)this).Logger, "HolloFoxes'", false);
			Harmony val = new Harmony("org.hollofox.plugins.AutoDiceCleanup");
			val.PatchAll();
		}
	}
}
namespace AutoDiceCleanup.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("AutoDiceCleanup.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace AutoDiceCleanup.Patches
{
	[HarmonyPatch(typeof(DiceManager), "SendDiceResult")]
	public class SendDiceRolledPatch
	{
		private static void Postfix(bool isGmOnly, RollResults rollResultData)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (AutoDiceCleanupPlugin.CleanUpAfterSelf)
			{
				AutoDiceCleanupPlugin.Instance.ClearDiceRoll(AutoDiceCleanupPlugin.CleanupAfterSelfInSeconds, rollResultData.RollId);
			}
		}
	}
	[HarmonyPatch(typeof(DiceManager), "RPC_DiceResult")]
	public class ReceiveDiceRolledPatch
	{
		private static void Postfix(bool isGmOnly, byte[] diceListData, PhotonMessageInfo msgInfo, Reader ____reader)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (LocalClient.IsInGmMode && AutoDiceCleanupPlugin.CleanupAsGm)
			{
				RollResults val = default(RollResults);
				BrSerializeHelpers.DeserializeFromByteArray<RollResults>(____reader, diceListData, (BrDeserializer<RollResults>)RollResults.Deserialize, ref val);
				AutoDiceCleanupPlugin.Instance.ClearDiceRoll(AutoDiceCleanupPlugin.CleanupAsGmInSeconds, val.RollId);
			}
		}
	}
}