using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; 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 TMProOld; 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("AllNeedolin")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+799526e5150cc29ddecfef538304e8d59bf1192d")] [assembly: AssemblyProduct("AllNeedolin")] [assembly: AssemblyTitle("AllNeedolin")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/CarrieForle/AllNeedolinSilksong")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [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")] [Embedded] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Microsoft.CodeAnalysis { [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace AllNeedolin { [BepInPlugin("io.github.carrieforle.allneedolin", "AllNeedolin", "1.0.1")] public class AllNeedolinPlugin : BaseUnityPlugin { private static ConfigEntry configEnableMod; private static string currentText = ""; private static ManualLogSource logger; private Harmony harmony; public const string Id = "io.github.carrieforle.allneedolin"; public static string Name => "AllNeedolin"; public static string Version => "1.0.1"; private void Start() { harmony = Harmony.CreateAndPatchAll(typeof(AllNeedolinPlugin), (string)null); logger = ((BaseUnityPlugin)this).Logger; configEnableMod = ((BaseUnityPlugin)this).Config.Bind("General", "EnableMod", true, (ConfigDescription)null); configEnableMod.SettingChanged += delegate { if (configEnableMod.Value) { harmony.PatchAll(typeof(AllNeedolinPlugin)); } else { harmony.UnpatchSelf(); } }; } [HarmonyPostfix] [HarmonyPatch(typeof(LocalisedTextCollectionData), "GetRandom")] private static void PatchRandom(LocalisedTextCollectionData __instance, ref LocalisedString __result) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(currentText)) { __result = new LocalisedString("io.github.carrieforle.allneedolin", currentText); return; } LocalisedTextCollectionData data = __instance; while (true) { LocalisedTextCollectionData val = data.ResolveAlternatives(); if (val == data) { break; } data = val; } IEnumerable source = Enumerable.Range(0, data.currentTexts.Length); source = ((data.currentProbabilities == null) ? source.OrderBy((int i) => Math.Pow(Random.value, 1.0 / (double)((ProbabilityBase)(object)data.currentTexts[i]).Probability)) : source.OrderBy((int i) => Math.Pow(Random.value, 1.0 / (double)data.currentProbabilities[i]))); IEnumerable values = source.Select((int i) => ((object)Unsafe.As(ref data.currentTexts[i].text)/*cast due to .constrained prefix*/).ToString()); currentText = string.Join("\n", values); __result = new LocalisedString("io.github.carrieforle.allneedolin", currentText); } [HarmonyPrefix] [HarmonyPatch(typeof(LocalisedString), "ToString", new Type[] { typeof(bool) })] private static bool BypassLocalisedStringCheck(ref LocalisedString __instance, ref string __result) { if (__instance.Sheet == "io.github.carrieforle.allneedolin" && __instance.Key == currentText) { __result = currentText; return false; } return true; } [HarmonyPostfix] [HarmonyPatch(typeof(NeedolinMsgBox), "CycleTexts")] private static void ResetCurrentText() { currentText = ""; } [HarmonyPostfix] [HarmonyPatch(typeof(NeedolinMsgBox), "Awake")] private static void OverflowNeedolin(NeedolinMsgBox __instance) { TextMeshPro[] componentsInChildren = ((Component)__instance).GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { ((TMP_Text)componentsInChildren[i]).OverflowMode = (TextOverflowModes)0; } } } }