Decompiled source of officerballs ChatTweaks v1.0.2

BepInEx/plugins/officerballs/officerballs.ChatTweaks.dll

Decompiled 18 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ChatTweaks.patches;
using DG.Tweening;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PurrNet;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("officerballs.ChatTweaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("officerballs.ChatTweaks")]
[assembly: AssemblyTitle("officerballs.ChatTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ChatTweaks
{
	[BepInPlugin("officerballs.chatTweaks", "Chat Tweaks", "1.0.2.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string modGUID = "officerballs.chatTweaks";

		public const string modName = "Chat Tweaks";

		public const string modVersion = "1.0.2.0";

		private Harmony harmony = new Harmony("officerballs.chatTweaks");

		public ManualLogSource mls = Logger.CreateLogSource("officerballs.chatTweaks");

		public static ConfigEntry<bool> configMsgNoises { get; private set; }

		public static ConfigEntry<bool> configJoinLeaveNoises { get; private set; }

		private void Awake()
		{
			harmony.PatchAll(typeof(UIManagerPatch));
			harmony.PatchAll(typeof(TimeStampsPatch));
			harmony.PatchAll(typeof(PlayerLeftPatch));
			harmony.PatchAll(typeof(joinSoundPatch));
			configMsgNoises = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Toggles", "PlayMessageNoises", true, "Enable or disable on-message noises (takes effect after restart)");
			configJoinLeaveNoises = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Toggles", "PlayJoinLeaveNoises", true, "Enable or disable on-leave/join noises (takes effect after restart)");
			mls.LogInfo((object)"Chat tweaked");
		}
	}
}
namespace ChatTweaks.patches
{
	[HarmonyPatch(typeof(UIManager))]
	internal class UIManagerPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void patchReset(ref float ____messageTimer)
		{
			____messageTimer = 0f;
		}

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void outlineChanger(ref TextMeshProUGUI ____messageTextForFont)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			Material fontSharedMaterial = ((TMP_Text)____messageTextForFont).fontSharedMaterial;
			fontSharedMaterial.EnableKeyword("OUTLINE_ON");
			fontSharedMaterial.SetFloat("_OutlineWidth", 0.25f);
			fontSharedMaterial.SetColor("_OutlineColor", Color32.op_Implicit(new Color32((byte)20, (byte)20, (byte)20, (byte)205)));
			((TMP_Text)____messageTextForFont).UpdateMeshPadding();
		}

		[HarmonyPatch("SetMessagePanelActiveness")]
		[HarmonyPrefix]
		public static bool ActivenessTweaker(ref TextMeshProUGUI ____messagePlaceholderText, ref Color ____messagePlaceholderActiveColor, ref float ____uiFadeDuration, ref GameObject ____messagePanel, ref List<Image> ____messagePanelImages, ref List<TextMeshProUGUI> ____messagePanelTexts, ref Image ____globalScrollImage, ref Image ____localScrollImage, UIManager __instance)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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)
			((Graphic)____globalScrollImage).raycastTarget = true;
			((Graphic)____localScrollImage).raycastTarget = true;
			__instance.IsMessagePanelActivated = true;
			DOTweenModuleUI.DOColor((Graphic)(object)____messagePlaceholderText, ____messagePlaceholderActiveColor, ____uiFadeDuration);
			____messagePanel.gameObject.SetActive(true);
			float a = 1f;
			for (int i = 0; i < ____messagePanelImages.Count; i++)
			{
				Color color = ((Graphic)____messagePanelImages[i]).color;
				color.a = a;
				DOTweenModuleUI.DOColor(____messagePanelImages[i], color, ____uiFadeDuration);
			}
			for (int j = 0; j < ____messagePanelTexts.Count; j++)
			{
				Color color2 = ((Graphic)____messagePanelTexts[j]).color;
				color2.a = a;
				DOTweenModuleUI.DOColor((Graphic)(object)____messagePanelTexts[j], color2, ____uiFadeDuration);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerCustomizationController))]
	internal class joinSoundPatch
	{
		[HarmonyPatch("NotifyOtherClients_Original_5")]
		[HarmonyPrefix]
		public static void joinSoundPatcher()
		{
			if (Plugin.configJoinLeaveNoises.Value)
			{
				NetworkSingleton<TextChannelManager>.I.MainSFXController.PlayPetSound((PetType)4);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerPanelController))]
	internal class PlayerLeftPatch
	{
		[HarmonyPatch("DespawnHandle")]
		[HarmonyPrefix]
		public static void PlayerLeftNoti(NetworkTransform netTransform, PlayerPanelController __instance)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < __instance.PlayerSteamIDs.Count; i++)
			{
				if ((Object)(object)__instance.PlayerTransforms[i] == (Object)(object)netTransform)
				{
					byte[] name = __instance.IDInfos[i].Name;
					NetworkSingleton<TextChannelManager>.I.AddNotification(Encoding.Unicode.GetString(name) + " has left the server.");
					if (Plugin.configJoinLeaveNoises.Value)
					{
						NetworkSingleton<TextChannelManager>.I.MainSFXController.PlayPetSound((PetType)6);
					}
					break;
				}
			}
		}
	}
	[HarmonyPatch(typeof(TextChannelManager))]
	public class TimeStampsPatch
	{
		[HarmonyPatch("AddMessageUI")]
		[HarmonyPrefix]
		public static bool MsgUIFix(string userName, string text, bool isLocal, int senderIndex, ref List<GameObject> ____messageObjectsLocal, ref List<GameObject> ____messageObjectsGlobal, ref TMP_Text ____textPrefab)
		{
			TMP_Text val = UnityProxy.Instantiate<TMP_Text>(____textPrefab, isLocal ? MonoSingleton<UIManager>.I.TextContentLocalTransform : MonoSingleton<UIManager>.I.TextContentGlobalTransform);
			string text2 = DateTime.Now.ToString("h:mm tt");
			if (Plugin.configJoinLeaveNoises.Value)
			{
				MonoSingleton<SFXManager>.I.PlayRodAppear();
			}
			val.text = "[" + text2 + "] <color=#" + ScriptableSingleton<GameSettings>.I.MessageOthersColors[senderIndex] + "ff>" + userName + ":</color> " + text;
			if (isLocal)
			{
				____messageObjectsLocal.Add(((Component)val).gameObject);
				if (____messageObjectsLocal.Count > ScriptableSingleton<GameSettings>.I.LocalMessageLimitCount)
				{
					GameObject val2 = ____messageObjectsLocal[0];
					____messageObjectsLocal.RemoveAt(0);
					UnityProxy.Destroy((Object)(object)val2);
				}
			}
			else
			{
				____messageObjectsGlobal.Add(((Component)val).gameObject);
				if (____messageObjectsGlobal.Count > ScriptableSingleton<GameSettings>.I.GlobalMessageLimitCount)
				{
					GameObject val3 = ____messageObjectsGlobal[0];
					____messageObjectsGlobal.RemoveAt(0);
					UnityProxy.Destroy((Object)(object)val3);
				}
			}
			return false;
		}
	}
}