Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of EggChat v0.3.2
EggChat.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using EggChat.Patches; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; 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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("EggChat")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("(WIP) Quality-of-life additions to text chat.")] [assembly: AssemblyFileVersion("0.3.2.0")] [assembly: AssemblyInformationalVersion("0.3.2")] [assembly: AssemblyProduct("EggChat")] [assembly: AssemblyTitle("EggChat")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.3.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 EggChat { [BepInPlugin("EggChat", "EggChat", "0.3.2")] public class Plugin : BaseUnityPlugin { public static Plugin Instance; public static int maxCharLimit = 127; private static ConfigEntry<int> chatBgOpacity; private static ConfigEntry<bool> wideChat; private void Awake() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown ((BaseUnityPlugin)this).Logger.LogInfo((object)"Initializing EggChat"); SetUpConfigs(); Instance = this; Harmony val = new Harmony("EggChat"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Initialized EggChat"); } public static bool isLocalPlayerDead() { return GameNetworkManager.Instance.localPlayerController.isPlayerDead; } private void SetUpConfigs() { chatBgOpacity = ((BaseUnityPlugin)this).Config.Bind<int>("UI", "Chat Background Opacity", 0, "The opacity of the chat background. Set values 0-100."); HUDManagerPatch.chatBgOpacity = chatBgOpacity.Value; chatBgOpacity.SettingChanged += delegate { HUDManagerPatch.chatBgOpacity = chatBgOpacity.Value; HUDManagerPatch.SetBgOpacity(); }; wideChat = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "Wide Chat", false, "Make the chat wider."); HUDManagerPatch.wideChat = wideChat.Value; wideChat.SettingChanged += delegate { HUDManagerPatch.wideChat = wideChat.Value; HUDManagerPatch.SetWidthType(); }; } } public static class PluginInfo { public const string PLUGIN_GUID = "EggChat"; public const string PLUGIN_NAME = "EggChat"; public const string PLUGIN_VERSION = "0.3.2"; } } namespace EggChat.Patches { [HarmonyPatch(typeof(HUDManager))] internal class HUDManagerPatch { public class Attributes { public class Text { public class Default { public static float anchorMinX; public static float anchorMaxX = DefaultAnchorMaxX; public static float sizeDeltaX; } public class Wide { public static float anchorMinX = 0.6f; public static float anchorMaxX = WideAnchorMaxX; public static float sizeDeltaX = WideSizeDeltaX; } } public class Input { public class Default { public static float anchorMinX; public static float anchorMaxX = DefaultAnchorMaxX; public static float sizeDeltaX; } public class Wide { public static float anchorMinX = 0.4f; public static float anchorMaxX = WideAnchorMaxX; public static float sizeDeltaX = WideSizeDeltaX; } } public class Image { public class Default { public static float anchorMinX; public static float sizeDeltaX = WideSizeDeltaX; } public class Wide { public static float anchorMinX = 1f; public static float sizeDeltaX = WideSizeDeltaX + 100f; } } public class Background { public class Default { public static float anchorMaxX = DefaultAnchorMaxX; public static float sizeDeltaX = DefaultSizeDeltaX; } public class Wide { public static float anchorMaxX = WideAnchorMaxX; public static float sizeDeltaX = WideSizeDeltaX; } } public static float DefaultSizeDeltaX; private static readonly float DefaultAnchorMaxX = 0.5f; private static readonly float WideAnchorMaxX = 1f; private static readonly float WideSizeDeltaX = 141f; } internal static int chatBgOpacity; internal static bool wideChat; private static Transform bottomLeftCorner; private static Transform input; private static Transform text; private static Transform image; private static GameObject background; [HarmonyPatch("Awake")] [HarmonyPostfix] private static void HUDManager_awake(HUDManager __instance) { __instance.chatTextField.characterLimit = Plugin.maxCharLimit - 1; bottomLeftCorner = __instance.HUDContainer.transform.Find("BottomLeftCorner"); text = bottomLeftCorner.Find("ChatText"); input = bottomLeftCorner.Find("InputField (TMP)"); image = bottomLeftCorner.Find("Image"); SetDefaultAttributes(); AddChatBg(); SetBgOpacity(); if (wideChat) { SetWidthType(); } } private static void AddChatBg() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)background)) { background = new GameObject("ChatBG"); Transform transform = background.transform; transform.SetParent(bottomLeftCorner); transform.SetSiblingIndex(0); transform.SetPositionAndRotation(image.position, image.rotation); transform.localScale = image.localScale; RectTransform t = background.AddComponent<RectTransform>(); CopyAttributes(t, ((Component)image).GetComponent<RectTransform>()); CanvasGroup val = background.AddComponent<CanvasGroup>(); val.alpha = (float)chatBgOpacity / 100f; val.ignoreParentGroups = true; Sprite sprite = Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 4f, 4f), new Vector2(0f, 0f)); Image val2 = background.AddComponent<Image>(); val2.sprite = sprite; ((Graphic)val2).color = Color.black; } } private static void SetDefaultAttributes() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) Attributes.DefaultSizeDeltaX = ((Component)image).GetComponent<RectTransform>().sizeDelta.x; Attributes.Text.Default.anchorMinX = ((Component)text).GetComponent<RectTransform>().anchorMin.x; Attributes.Text.Default.sizeDeltaX = ((Component)text).GetComponent<RectTransform>().sizeDelta.x; Attributes.Input.Default.anchorMinX = ((Component)input).GetComponent<RectTransform>().anchorMin.x; Attributes.Input.Default.sizeDeltaX = ((Component)input).GetComponent<RectTransform>().sizeDelta.x; Attributes.Image.Default.anchorMinX = ((Component)input).GetComponent<RectTransform>().anchorMin.x; } public static void SetBgOpacity() { CanvasGroup component = background.GetComponent<CanvasGroup>(); component.alpha = (float)chatBgOpacity / 100f; } private static void SetWidthAttributes(RectTransform rt, float? anchorMin, float? anchorMax, float sizeDelta) { //IL_0017: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (anchorMin.HasValue) { rt.anchorMin = new Vector2(anchorMin.Value, rt.anchorMin.y); } if (anchorMax.HasValue) { rt.anchorMax = new Vector2(anchorMax.Value, rt.anchorMax.y); } rt.sizeDelta = new Vector2(sizeDelta, rt.sizeDelta.y); } public static void SetWidthType() { if (wideChat) { SetWidthAttributes(((Component)input).GetComponent<RectTransform>(), Attributes.Input.Wide.anchorMinX, Attributes.Input.Wide.anchorMaxX, Attributes.Input.Wide.sizeDeltaX); SetWidthAttributes(((Component)text).GetComponent<RectTransform>(), Attributes.Text.Wide.anchorMinX, Attributes.Text.Wide.anchorMaxX, Attributes.Text.Wide.sizeDeltaX); SetWidthAttributes(((Component)image).GetComponent<RectTransform>(), Attributes.Image.Wide.anchorMinX, null, Attributes.Image.Wide.sizeDeltaX); SetWidthAttributes(background.GetComponent<RectTransform>(), null, Attributes.Background.Wide.anchorMaxX, Attributes.Background.Wide.sizeDeltaX); } else { SetWidthAttributes(((Component)input).GetComponent<RectTransform>(), Attributes.Input.Default.anchorMinX, Attributes.Input.Default.anchorMaxX, Attributes.Input.Default.sizeDeltaX); SetWidthAttributes(((Component)text).GetComponent<RectTransform>(), Attributes.Text.Default.anchorMinX, Attributes.Text.Default.anchorMaxX, Attributes.Text.Default.sizeDeltaX); SetWidthAttributes(((Component)image).GetComponent<RectTransform>(), Attributes.Image.Default.anchorMinX, null, Attributes.Image.Default.sizeDeltaX); SetWidthAttributes(background.GetComponent<RectTransform>(), null, Attributes.Background.Default.anchorMaxX, Attributes.Background.Default.sizeDeltaX); } } private static void CopyAttributes(RectTransform t1, RectTransform t2) { //IL_0003: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) t1.anchoredPosition = t2.anchoredPosition; t1.anchoredPosition3D = t2.anchoredPosition3D; t1.offsetMax = t2.offsetMax; t1.offsetMin = t2.offsetMin; ((Transform)t1).eulerAngles = ((Transform)t2).eulerAngles; ((Transform)t1).forward = ((Transform)t2).forward; } [HarmonyPatch("Update")] [HarmonyPostfix] private static void HUDManager_update(HUDManager __instance) { if (GameNetworkManager.Instance.localPlayerController.isPlayerDead) { __instance.Inventory.canvasGroup.alpha = 0f; __instance.PlayerInfo.canvasGroup.alpha = 0f; __instance.Clock.canvasGroup.alpha = 0f; } } [HarmonyPatch("EnableChat_performed")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> EnableChat_performed_transpiler(IEnumerable<CodeInstruction> instructions) { FieldInfo isPlayerDead = typeof(PlayerControllerB).GetField("isPlayerDead"); bool referenceToIsPlayerDead = false; foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.LoadsField(instruction, isPlayerDead, false)) { referenceToIsPlayerDead = true; } if (referenceToIsPlayerDead && instruction.opcode == OpCodes.Ret) { referenceToIsPlayerDead = false; yield return new CodeInstruction(OpCodes.Nop, (object)null); } else { yield return instruction; } } } [HarmonyPatch("SubmitChat_performed")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> SubmitChat_performed_transpiler(IEnumerable<CodeInstruction> instructions) { FieldInfo isPlayerDead = typeof(PlayerControllerB).GetField("isPlayerDead"); bool referenceToIsPlayerDead = false; foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.LoadsField(instruction, isPlayerDead, false)) { referenceToIsPlayerDead = true; } if (referenceToIsPlayerDead && instruction.opcode == OpCodes.Ret) { referenceToIsPlayerDead = false; yield return new CodeInstruction(OpCodes.Nop, (object)null); } else if (instruction.opcode == OpCodes.Ldc_I4_S && (sbyte)instruction.operand == 50) { yield return new CodeInstruction(OpCodes.Ldc_I4_S, (object)Plugin.maxCharLimit); } else { yield return instruction; } } } [HarmonyPatch("AddPlayerChatMessageServerRpc")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> AddPlayerChatMessageServerRpc_transpiler(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldc_I4_S && (sbyte)instruction.operand == 50) { yield return new CodeInstruction(OpCodes.Ldc_I4_S, (object)Plugin.maxCharLimit); } else { yield return instruction; } } } [HarmonyPatch("AddPlayerChatMessageClientRpc")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> AddPlayerChatMessageClientRpc_transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator iL) { FieldInfo isPlayerDead = typeof(PlayerControllerB).GetField("isPlayerDead"); bool referenceToIsPlayerDead = false; Label addChatMessageLabel = default(Label); foreach (CodeInstruction instruction2 in instructions) { if (instruction2.opcode == OpCodes.Brtrue) { addChatMessageLabel = (Label)instruction2.operand; } } foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.LoadsField(instruction, isPlayerDead, false)) { referenceToIsPlayerDead = true; } if (referenceToIsPlayerDead && instruction.opcode == OpCodes.Ret) { referenceToIsPlayerDead = false; yield return new CodeInstruction(OpCodes.Call, (object)typeof(Plugin).GetMethod("isLocalPlayerDead")); yield return new CodeInstruction(OpCodes.Brtrue, (object)addChatMessageLabel); yield return instruction; } else { yield return instruction; } } } } [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatch { [HarmonyPatch("KillPlayer")] [HarmonyPostfix] private static void KillPlayer_postfix() { HUDManager.Instance.HideHUD(false); } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> EndOfGame_transpiler(IEnumerable<CodeInstruction> instructions) { MethodInfo hideHUD = typeof(HUDManager).GetMethod("HideHUD"); foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.Calls(instruction, hideHUD)) { yield return new CodeInstruction(OpCodes.Pop, (object)null); yield return new CodeInstruction(OpCodes.Ldc_I4_0, (object)null); yield return instruction; } else { yield return instruction; } } } } }