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 MessageStay v0.0.3
MessageStay.dll
Decompiled 9 months agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; 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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Autodesk.Fbx")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")] [assembly: IgnoresAccessChecksTo("Klattersynth")] [assembly: IgnoresAccessChecksTo("Photon3Unity3D")] [assembly: IgnoresAccessChecksTo("PhotonChat")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")] [assembly: IgnoresAccessChecksTo("PhotonVoice.API")] [assembly: IgnoresAccessChecksTo("PhotonVoice")] [assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization")] [assembly: IgnoresAccessChecksTo("Sirenix.Utilities")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("websocket-sharp")] [assembly: AssemblyCompany("LeonYew")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.0.3.0")] [assembly: AssemblyInformationalVersion("0.0.3+3b61bda0c7ee9a1db06c26422d8752515825a4ce")] [assembly: AssemblyProduct("MessageStay")] [assembly: AssemblyTitle("MessageStay")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.3.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 MessageStay { [HarmonyPatch(typeof(LobbyChatUI))] internal static class LobbyChatUIPatch { private static readonly ConditionalWeakTable<LobbyChatUI, TimerData> timers = new ConditionalWeakTable<LobbyChatUI, TimerData>(); private static readonly FieldInfo ttsVoiceField = AccessTools.Field(typeof(LobbyChatUI), "ttsVoice"); [HarmonyPostfix] [HarmonyPatch("Update")] private static void DisplayTimePatch(LobbyChatUI __instance) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown TimerData orCreateValue = timers.GetOrCreateValue(__instance); TTSVoice val = (TTSVoice)ttsVoiceField.GetValue(__instance); if ((Object)(object)val == (Object)null) { return; } if (val.isSpeaking) { orCreateValue.reset(); orCreateValue.lastText = val.voiceText; } else if (orCreateValue.extraTime > 0f) { orCreateValue.extraTime -= Time.deltaTime; if (string.IsNullOrEmpty(((TMP_Text)((SemiUI)__instance).uiText).text)) { ((TMP_Text)((SemiUI)__instance).uiText).text = orCreateValue.lastText; } } } } [BepInPlugin("LeonYew.MessageStay", "MessageStay", "0.0.3")] public class MessageStay : BaseUnityPlugin { public const float DEFAULT_EXTRA_TIME = 5f; internal static MessageStay Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } public static ConfigEntry<float> ExtraTimeConfig { get; private set; } public static ConfigEntry<bool> EnablePluginConfig { get; private set; } public static ConfigEntry<bool> DebugModeConfig { get; private set; } private void Awake() { Instance = this; InitializeConfig(); if (!EnablePluginConfig.Value) { Logger.LogInfo((object)(((BaseUnityPlugin)this).Info.Metadata.GUID + " is disabled")); return; } ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); Logger.LogInfo((object)$"Extra chat time configured to: {ExtraTimeConfig.Value} seconds"); } private void InitializeConfig() { ExtraTimeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ExtraTime", 5f, "Additional time in seconds to extend chat display duration (default: 5)"); EnablePluginConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnablePlugin", true, "Enable or disable the MessageStay functionality"); DebugModeConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "DebugMode", false, "Enable debug mode for additional logging information"); ExtraTimeConfig.SettingChanged += delegate { Logger.LogInfo((object)$"Extra time changed to: {ExtraTimeConfig.Value} seconds"); }; EnablePluginConfig.SettingChanged += delegate { Logger.LogInfo((object)$"Plugin enabled: {EnablePluginConfig.Value}"); }; DebugModeConfig.SettingChanged += delegate { Logger.LogInfo((object)$"Debug mode: {DebugModeConfig.Value}"); }; } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { } } public class TimerData { public float extraTime = 5f; public bool isInit = false; public string lastText = ""; public TimerData() { extraTime = MessageStay.ExtraTimeConfig?.Value ?? 5f; } public void reset() { extraTime = MessageStay.ExtraTimeConfig?.Value ?? 5f; isInit = false; } public float GetExtraTime() { return MessageStay.ExtraTimeConfig?.Value ?? extraTime; } public bool IsPluginEnabled() { return MessageStay.EnablePluginConfig?.Value ?? true; } public bool IsDebugMode() { return MessageStay.DebugModeConfig?.Value ?? false; } } [HarmonyPatch(typeof(WorldSpaceUITTS))] internal static class WorldSpaceUITTSPatch { private static readonly ConditionalWeakTable<WorldSpaceUITTS, TimerData> timers = new ConditionalWeakTable<WorldSpaceUITTS, TimerData>(); public static bool isExtend(WorldSpaceUITTS instance) { if ((Object)(object)instance.ttsVoice != (Object)null && instance.ttsVoice.isSpeaking) { timers.GetOrCreateValue(instance).reset(); return true; } if (timers.TryGetValue(instance, out TimerData value) && value.extraTime > 0f) { value.extraTime -= Time.deltaTime; return true; } return false; } [HarmonyPostfix] [HarmonyPatch("Update")] private static void PostfixUpdate(WorldSpaceUITTS __instance) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if (isExtend(__instance)) { FieldInfo fieldInfo = AccessTools.Field(typeof(WorldSpaceUITTS), "textAlphaTarget"); FieldInfo fieldInfo2 = AccessTools.Field(typeof(WorldSpaceUITTS), "textAlpha"); FieldInfo fieldInfo3 = AccessTools.Field(typeof(WorldSpaceUITTS), "textColor"); fieldInfo.SetValue(__instance, 1f); float num = (float)fieldInfo2.GetValue(__instance); float num2 = Mathf.Lerp(num, 1f, 30f * Time.deltaTime); fieldInfo2.SetValue(__instance, num2); Color val = (Color)fieldInfo3.GetValue(__instance); ((Graphic)__instance.text).color = new Color(val.r, val.g, val.b, num2); } } } [HarmonyPatch(typeof(Object), "Destroy", new Type[] { typeof(Object) })] internal static class ObjectDestroyPatch { private static bool Prefix(Object obj) { GameObject val = (GameObject)(object)((obj is GameObject) ? obj : null); if (val != null) { WorldSpaceUITTS component = val.GetComponent<WorldSpaceUITTS>(); if ((Object)(object)component != (Object)null && WorldSpaceUITTSPatch.isExtend(component)) { return false; } } return true; } } }