Decompiled source of MissingDialogueFix v1.0.0

SoDDialogueFix.dll

Decompiled 9 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SoDDialogueFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SoDDialogueFix")]
[assembly: AssemblyTitle("SoDDialogueFix")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 SoDDialogueFix
{
	[BepInPlugin("sm3gm.sod.dialoguefix", "Missing Dialogue Fix", "1.0.0")]
	public sealed class Plugin : BasePlugin
	{
		public const string VER = "1.0.0";

		internal static ManualLogSource L;

		internal static ConfigEntry<bool> FixBlank;

		public override void Load()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			L = ((BasePlugin)this).Log;
			FixBlank = ((BasePlugin)this).Config.Bind<bool>("Dialogue", "ShowInvisibleText", true, "Shows the words in speech bubbles that would otherwise be an empty box.");
			new Harmony("sm3gm.sod.dialoguefix").PatchAll(typeof(Patches));
			ManualLogSource l = L;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Missing Dialogue Fix ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded");
			}
			l.LogInfo(val);
		}
	}
	[HarmonyPatch]
	internal static class Patches
	{
		private static int fixedCount;

		private static int told;

		private static int colours;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(SpeechBubbleController), "Update")]
		private static void Update(SpeechBubbleController __instance)
		{
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Expected O, but got Unknown
			//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)
			//IL_003d: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!Plugin.FixBlank.Value)
				{
					return;
				}
				TextMeshProUGUI text = __instance.text;
				Image backgroundImg = __instance.backgroundImg;
				if ((Object)(object)text == (Object)null || (Object)(object)backgroundImg == (Object)null)
				{
					return;
				}
				Color color = ((Graphic)text).color;
				if (color.a >= 0.05f)
				{
					return;
				}
				float a = ((((Graphic)backgroundImg).color.a >= 0.05f) ? ((Graphic)backgroundImg).color.a : 1f);
				if (color.r < 0.01f && color.g < 0.01f && color.b < 0.01f)
				{
					color.r = 1f;
					color.g = 1f;
					color.b = 1f;
				}
				color.a = a;
				((Graphic)text).color = color;
				fixedCount++;
				if (told >= 20)
				{
					return;
				}
				told++;
				string text2 = "-";
				try
				{
					SpeechController speechController = __instance.speechController;
					object obj;
					if (speechController == null)
					{
						obj = null;
					}
					else
					{
						Actor actor = speechController.actor;
						obj = ((actor != null) ? ((Object)actor).name : null);
					}
					if (obj == null)
					{
						obj = "-";
					}
					text2 = (string)obj;
				}
				catch
				{
				}
				ManualLogSource l = Plugin.L;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(49, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DIALOGUE] text made visible (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(fixedCount);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" so far) for '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(__instance.actualString);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
				}
				l.LogInfo(val);
			}
			catch
			{
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(SpeechController), "Speak", new Type[]
		{
			typeof(string),
			typeof(string),
			typeof(bool),
			typeof(bool),
			typeof(bool),
			typeof(float),
			typeof(bool),
			typeof(Color),
			typeof(Human),
			typeof(bool),
			typeof(bool),
			typeof(SideJob),
			typeof(DialogPreset),
			typeof(AISpeechPreset),
			typeof(Interactable),
			typeof(InteractionDialogInstance)
		})]
		private static void Speak(string dictionary, string speechEntryRef, Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!(color.a >= 0.05f) && colours < 15)
				{
					colours++;
					ManualLogSource l = Plugin.L;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(53, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DIALOGUE] line asked for with see-through colour ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Color>(color);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(dictionary);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(speechEntryRef);
					}
					l.LogInfo(val);
				}
			}
			catch
			{
			}
		}
	}
}