Decompiled source of Quiet Chat v0.0.1

QuietChat.dll

Decompiled 2 months ago
using 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 CG.Ship.LogEvents;
using Gameplay.Chat;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UI.Chat;
using UnityEngine.UIElements;
using VoidManager;
using VoidManager.CustomGUI;
using VoidManager.MPModChecks;
using VoidManager.Utilities;

[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.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("QuietChat")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Template")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1+e8595b089ffca1f26f4a4292795d876a24206961")]
[assembly: AssemblyProduct("QuietChat")]
[assembly: AssemblyTitle("Removes chat messages produced by the game. Player messages are still displayed. Client Side.")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.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 QuietChat
{
	[BepInPlugin("18107.QuietChat", "QuietChat", "0.0.1")]
	[BepInProcess("Void Crew.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BepinPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "18107.QuietChat");
			Configs.Load(this);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin 18107.QuietChat is loaded!");
		}
	}
	internal class Configs
	{
		internal static ConfigEntry<bool> TemporaryChatConfig;

		internal static void Load(BepinPlugin plugin)
		{
			TemporaryChatConfig = ((BaseUnityPlugin)plugin).Config.Bind<bool>("QuietChat", "TemporaryGameMessages", true, (ConfigDescription)null);
		}
	}
	internal class GUI : ModSettingsMenu
	{
		public override string Name()
		{
			return "Quiet Chat";
		}

		public override void Draw()
		{
			bool value = Configs.TemporaryChatConfig.Value;
			if (GUITools.DrawCheckbox("Temporary game messages", ref value))
			{
				Configs.TemporaryChatConfig.Value = value;
			}
			bool flag = !Configs.TemporaryChatConfig.Value;
			if (GUITools.DrawCheckbox("No game messages", ref flag))
			{
				Configs.TemporaryChatConfig.Value = !flag;
			}
		}
	}
	public class MyPluginInfo
	{
		public const string PLUGIN_GUID = "18107.QuietChat";

		public const string PLUGIN_NAME = "QuietChat";

		public const string USERS_PLUGIN_NAME = "Quiet Chat";

		public const string PLUGIN_VERSION = "0.0.1";

		public const string PLUGIN_DESCRIPTION = "Removes chat messages produced by the game. Player messages are still displayed. Client Side.";

		public const string PLUGIN_ORIGINAL_AUTHOR = "18107";

		public const string PLUGIN_AUTHORS = "18107";

		public const string PLUGIN_THUNDERSTORE_ID = "VoidCrewModdingTeam/QuietChat";
	}
	[HarmonyPatch(typeof(TextChat), "OnLogEventSent")]
	internal class TextChatPatch
	{
		private static readonly FieldInfo chatUIField = AccessTools.Field(typeof(TextChat), "_chatUI");

		private static readonly FieldInfo logViewField = AccessTools.Field(typeof(TextChatVE), "logView");

		private static bool Prefix(TextChat __instance, LogEvent obj)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if (Configs.TemporaryChatConfig.Value)
			{
				TextChatVE val = (TextChatVE)chatUIField.GetValue(__instance);
				ScrollView logView = (ScrollView)logViewField.GetValue(val);
				__instance.AddLog(new Log("", obj.Message));
				VisualElement log = ((VisualElement)logView).ElementAt(((VisualElement)logView).childCount - 1);
				((VisualElement)val).schedule.Execute((Action)delegate
				{
					((VisualElement)logView).Remove(log);
				}).ExecuteLater(8000L);
			}
			return false;
		}
	}
	public class VoidManagerPlugin : VoidPlugin
	{
		public override MultiplayerType MPType => (MultiplayerType)8;

		public override string Author => "18107";

		public override string Description => "Removes chat messages produced by the game. Player messages are still displayed. Client Side.";

		public override string ThunderstoreID => "VoidCrewModdingTeam/QuietChat";
	}
}