using System;
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 BepInEx.Logging;
using HarmonyLib;
using ModdingTales;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[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.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.1.0")]
namespace AutoDiceCleanup
{
[BepInPlugin("org.hollofox.plugins.AutoDiceCleanup", "Auto Dice Cleanup Plugin", "1.0.1.0")]
public class AutoDiceCleanupPlugin : BaseUnityPlugin
{
public const string Guid = "org.hollofox.plugins.AutoDiceCleanup";
internal const string Version = "1.0.1.0";
public static AutoDiceCleanupPlugin Instance;
internal static ManualLogSource logger;
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_0003: 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_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 (object)new WaitForSeconds(Mathf.Max(1f, delayInSeconds));
try
{
logger.LogDebug((object)$"Clearing dice roll {rollId}");
PhotonSimpleSingletonBehaviour<DiceManager>.Instance.ClearDiceRoll(rollId);
}
catch (Exception ex)
{
logger.LogDebug((object)ex.Message);
}
}
private void Awake()
{
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
logger = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Logger.LogDebug((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);
try
{
new Harmony("org.hollofox.plugins.AutoDiceCleanup").PatchAll();
ModdingUtils.AddPluginToMenuList((BaseUnityPlugin)(object)this, "HolloFoxes'");
}
catch (Exception ex)
{
logger.LogError((object)ex.Message);
}
}
}
}
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)
{
resourceMan = new ResourceManager("AutoDiceCleanup.Properties.Resources", typeof(Resources).Assembly);
}
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_0012: 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_002e: 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);
}
}
}
}