Decompiled source of Dice Color Sync v1.1.1

DiceColorSync.dll

Decompiled a week ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
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 DataModel;
using Dice;
using HarmonyLib;
using PluginUtilities;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("DiceColorSyncPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HolloFox")]
[assembly: AssemblyProduct("DiceColorSyncPlugin")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4e4deb5e-97f9-4901-bf67-6748a9c1229a")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.1.1.0")]
namespace DiceColorSyncPlugin
{
	[BepInPlugin("org.hollofox.plugins.DiceColorSyncPlugin", "Dice Color Sync Plug-In", "1.1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class DiceColorSyncPlugin : DependencyUnityPlugin
	{
		public const string Name = "Dice Color Sync Plug-In";

		public const string Guid = "org.hollofox.plugins.DiceColorSyncPlugin";

		internal const string Version = "1.1.1.0";

		private Harmony harmony;

		protected override void OnAwake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			Debug.Log((object)"DiceColorSync Plug-in loaded");
			harmony = new Harmony("org.hollofox.plugins.DiceColorSyncPlugin");
			harmony.PatchAll();
		}

		protected override void OnDestroyed()
		{
			harmony.UnpatchSelf();
		}
	}
}
namespace DiceColorSyncPlugin.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.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("DiceColorSyncPlugin.Properties.Resources", typeof(Resources).Assembly);
				}
				return resourceMan;
			}
		}

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

		internal Resources()
		{
		}
	}
}
namespace DiceColorSyncPlugin.Patches
{
	[HarmonyPatch(typeof(DiceRollManager), "OnOp", new Type[]
	{
		typeof(RegisterRollOp),
		typeof(MessageInfo)
	})]
	public class DiceRollManagerPatch
	{
		internal static Dictionary<RollId, ClientGuid> registeredDice = new Dictionary<RollId, ClientGuid>();

		private static void Prefix(RegisterRollOp op, MessageInfo msgInfo)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			registeredDice[op.RollId] = op.InitialDriveId.ClientId;
		}
	}
	[HarmonyPatch(typeof(Die), "Init")]
	public class DicePatch2
	{
		internal static BindingFlags flag = BindingFlags.Instance | BindingFlags.NonPublic;

		private static void Postfix(Die __instance, RollId rollId, Mode mode, bool isGmOnly, MaterialPropertyBlock iconMpb, int faceIndexBase, ref Renderer ____dieRenderer)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			Color val = default(Color);
			if (DiceRollManagerPatch.registeredDice.ContainsKey(rollId) && TempClientColorManager.TryGetColor(DiceRollManagerPatch.registeredDice[rollId], ref val))
			{
				____dieRenderer.material.SetColor("_Color", val);
			}
		}
	}
	[HarmonyPatch(typeof(Die), "SetMaterial")]
	public class SetMaterialPatch
	{
		private static bool Prefix(ref Renderer ____dieRenderer, ref bool gmDie, Material ____normalMaterial, Material ____gmMaterial)
		{
			//IL_0060: 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_007a: 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)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			if (gmDie)
			{
				if (!((Object)(object)____dieRenderer.sharedMaterial != (Object)(object)____gmMaterial))
				{
					return false;
				}
				Color color = ____dieRenderer.material.GetColor("_Color");
				____dieRenderer.sharedMaterial = ____gmMaterial;
				____dieRenderer.material.SetColor("_Color", color);
			}
			else
			{
				if (!((Object)(object)____dieRenderer.sharedMaterial != (Object)(object)____normalMaterial))
				{
					return false;
				}
				Color color2 = ____dieRenderer.material.GetColor("_Color");
				____dieRenderer.sharedMaterial = ____normalMaterial;
				____dieRenderer.material.SetColor("_Color", color2);
			}
			return false;
		}
	}
}