Decompiled source of CustomTitleCards v0.1.1

CustomTitleCards.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using CustomTitleCards.Settings;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TeamCherry.Localization;
using UnityEngine;

[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("CustomTitleCards")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1+89eff3e95647c97529bcf6df8a142152a27fd397")]
[assembly: AssemblyProduct("CustomTitleCards")]
[assembly: AssemblyTitle("CustomTitleCards")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/danielstegink/Silksong.SilkAndSong")]
[assembly: NeutralResourcesLanguage("EN")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace CustomTitleCards
{
	[BepInPlugin("io.github.danielstegink.customtitlecards", "CustomTitleCards", "0.1.1")]
	public class CustomTitleCards : BaseUnityPlugin
	{
		internal static CustomTitleCards instance;

		public const string Id = "io.github.danielstegink.customtitlecards";

		public static string Name => "CustomTitleCards";

		public static string Version => "0.1.1";

		private void Awake()
		{
			instance = this;
			Log("Plugin " + Name + " (io.github.danielstegink.customtitlecards) has loaded!");
		}

		private void Start()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			ConfigSettings.Initialize(((BaseUnityPlugin)this).Config);
			new Harmony("io.github.danielstegink.customtitlecards").PatchAll();
		}

		internal void Log(string message)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)message);
		}
	}
}
namespace CustomTitleCards.Settings
{
	internal class ConfigSection
	{
		internal string[] Keys = new string[3];

		internal string[] Texts = new string[3];

		internal string CompleteString()
		{
			return string.Join(" ", Texts).Replace("  ", " ").Trim();
		}
	}
	public static class ConfigSettings
	{
		public static Dictionary<string, ConfigEntry<string>> Presets = new Dictionary<string, ConfigEntry<string>>();

		public static void Initialize(ConfigFile config)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			foreach (string key2 in Language.GetKeys("Titles"))
			{
				dictionary.Add(key2, Language.Get(key2, "Titles"));
			}
			Dictionary<string, ConfigSection> dictionary2 = new Dictionary<string, ConfigSection>();
			foreach (string key3 in dictionary.Keys)
			{
				string text = key3.Replace("_MAIN", "").Replace("_SUPER", "").Replace("_SUB", "");
				if (!dictionary2.Keys.Contains(text))
				{
					dictionary2.Add(text, new ConfigSection());
				}
				ConfigSection configSection = dictionary2[text];
				int num = -1;
				if (key3.EndsWith("_SUPER"))
				{
					num = 0;
				}
				else if (key3.EndsWith("_MAIN"))
				{
					num = 1;
				}
				else if (key3.EndsWith("_SUB"))
				{
					num = 2;
				}
				if (num >= 0)
				{
					configSection.Keys[num] = key3;
					configSection.Texts[num] = dictionary[key3];
				}
			}
			foreach (string key4 in dictionary2.Keys)
			{
				ConfigSection configSection2 = dictionary2[key4];
				string text2 = configSection2.CompleteString();
				for (int i = 0; i < 3; i++)
				{
					string key = dictionary2[key4].Keys[i];
					string text3 = $"{key4}_{i + 1}";
					string text4 = configSection2.Texts[i];
					Presets.Add(key, config.Bind<string>(text2, text3, text4, ""));
				}
			}
		}
	}
}
namespace CustomTitleCards.HarmonyPatches
{
	[HarmonyPatch(typeof(HeroController), "Update")]
	public static class HeroController_Update
	{
		private static GameObject? gmsImage;

		private static GameObject? gmsText;

		[HarmonyPostfix]
		public static void Postfix(HeroController __instance)
		{
			GrandMotherSilk();
		}

		private static void GrandMotherSilk()
		{
			if (!GameManager.instance.sceneName.Equals("Cradle_03"))
			{
				gmsImage = null;
				gmsText = null;
				return;
			}
			if ((Object)(object)gmsImage == (Object)null && (Object)(object)gmsText == (Object)null)
			{
				Transform obj = (from x in Object.FindObjectsByType<GameObject>((FindObjectsSortMode)1).ToArray()
					where ((Object)x).name.Equals("Boss Title")
					select x).First().transform.Find("Title Text");
				gmsImage = ((Component)obj.Find("Silk_Title_Image")).gameObject;
				gmsText = ((Component)obj.Find("Silk_Title_Text")).gameObject;
			}
			gmsImage.SetActive(false);
			gmsText.SetActive(true);
		}
	}
	[HarmonyPatch(typeof(Language), "Get", new Type[]
	{
		typeof(string),
		typeof(string)
	})]
	public static class Language_Get
	{
		[HarmonyPostfix]
		public static void Postfix(ref string key, ref string sheetTitle, ref string __result)
		{
			if (sheetTitle.Equals("Titles"))
			{
				string value = ConfigSettings.Presets[key].Value;
				__result = value;
			}
		}
	}
}