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 RandomizedTexts v0.3.0
Tomatobird.RandomizedTexts.dll
Decompiled 3 days agousing 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.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using RandomizedTexts.Extensions; using RandomizedTexts.Patches; using TMPro; using Unity.Netcode; 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("Tomatobird.RandomizedTexts")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.3.0.0")] [assembly: AssemblyInformationalVersion("0.3.0+f4666693d6766262abb0858011e30ac002b8f193")] [assembly: AssemblyProduct("RandomizedTexts")] [assembly: AssemblyTitle("Tomatobird.RandomizedTexts")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.3.0.0")] [module: UnverifiableCode] [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 RandomizedTexts { [BepInPlugin("Tomatobird.RandomizedTexts", "RandomizedTexts", "0.3.0")] public class RandomizedTexts : BaseUnityPlugin { public static bool seedBasedRandom = false; public static List<string> aliveMessages = new List<string>(); public static float aliveFontSize = 30f; public static List<string> handsFullMessages = new List<string>(); public static float handsFullFontSize = 16f; public static List<string> criticalInjuryMessages = new List<string>(); public static float criticalInjuryFontSize = 35f; public static List<string> deathMessages = new List<string>(); public static float deathFontSize = 45f; public static List<string> gameOverMessages = new List<string>(); public static float gameOverFontSize = 80f; public static List<string> gameOverSubtitles = new List<string>(); public static float gameOverSubtitleFontSize = 23f; public static List<string> landingToMoonMessages = new List<string>(); public static float landingToMoonFontSize = 35f; public static List<string> loadingMessages = new List<string>(); public static float loadingFontSize = 19.6f; public static RandomizedTexts Instance { get; private set; } = null; internal static ManualLogSource Logger { get; private set; } = null; internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; seedBasedRandom = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SeedBasedRandom", false, "Should the random texts be based on the current seed?").Value; aliveMessages = StringToList(((BaseUnityPlugin)this).Config.Bind<string>("General", "AliveMessages", "", "Add texts to display here. Separate messages using the | symbol.").Value); aliveFontSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "AliveFontSize", 30f, "Set text font size here.").Value; handsFullMessages = StringToList(((BaseUnityPlugin)this).Config.Bind<string>("General", "HandsFullMessages", "", "Add texts to display here. Separate messages using the | symbol.").Value); handsFullFontSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "HandsFullFontSize", 16f, "Set text font size here.").Value; criticalInjuryMessages = StringToList(((BaseUnityPlugin)this).Config.Bind<string>("General", "CriticalInjuryMessages", "", "Add texts to display here. Separate messages using the | symbol.").Value); criticalInjuryFontSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CriticalInjuryFontSize", 35f, "Set text font size here.").Value; deathMessages = StringToList(((BaseUnityPlugin)this).Config.Bind<string>("General", "DeathMessages", "", "Add texts to display here. Separate messages using the | symbol.").Value); deathFontSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DeathFontSize", 45f, "Set text font size here.").Value; gameOverMessages = StringToList(((BaseUnityPlugin)this).Config.Bind<string>("General", "GameOverMessages", "", "Add texts to display here. Separate messages using the | symbol.").Value); gameOverFontSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "GameOverFontSize", 80f, "Set text font size here.").Value; gameOverSubtitles = StringToList(((BaseUnityPlugin)this).Config.Bind<string>("General", "GameOverSubtitleMessages", "", "Add texts to display here. Separate messages using the | symbol.").Value); gameOverSubtitleFontSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "GameOverSubtitleFontSize", 23f, "Set text font size here.").Value; landingToMoonMessages = StringToList(((BaseUnityPlugin)this).Config.Bind<string>("General", "EnteringAtmosphereMessages", "", "Add texts to display here. Separate messages using the | symbol.").Value); landingToMoonFontSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "EnteringAtmosphereFontSize", 35f, "Set text font size here.").Value; loadingMessages = StringToList(((BaseUnityPlugin)this).Config.Bind<string>("General", "LoadingMessages", "", "Add texts to display here. Separate messages using the | symbol.").Value); loadingFontSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "LoadingFontSize", 19.6f, "Set text font size here.").Value; Patch(); Logger.LogInfo((object)"Tomatobird.RandomizedTexts v0.3.0 has loaded!"); } internal static void Patch() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("Tomatobird.RandomizedTexts"); } TryPatchSingle(aliveMessages.Count > 0, typeof(AliveMessagePatch)); TryPatchSingle(handsFullMessages.Count > 0, typeof(HandsFullMessagePatch)); TryPatchSingle(criticalInjuryMessages.Count > 0, typeof(CriticalInjuryPatch)); TryPatchSingle(deathMessages.Count > 0, typeof(DeathMessagePatch)); TryPatchSingle(gameOverMessages.Count > 0 || gameOverSubtitles.Count > 0, typeof(GameOverMessagePatch)); TryPatchSingle(landingToMoonMessages.Count > 0, typeof(LoadingLevelPatch)); TryPatchSingle(loadingMessages.Count > 0, typeof(LoadingGamePatch)); Logger.LogDebug((object)"Finished patching!"); static void TryPatchSingle(bool cond, Type patchType) { if (cond) { Logger.LogDebug((object)("Patching... " + patchType.Name)); Harmony? harmony = Harmony; if (harmony != null) { harmony.PatchAll(patchType); } } } } internal static void ChangeText(string path, string name, List<string> stringList, float fontSize, int seed) { GameObject val = GameObject.Find(path); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)("Couldn't find the " + name + " text game object.")); return; } TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>(); if ((Object)(object)component == (Object)null) { Logger.LogWarning((object)("Couldn't find the " + name + " text component, even though gameobject was found.")); return; } string text; if (seedBasedRandom && (Object)(object)StartOfRound.Instance != (Object)null) { Random random = new Random(StartOfRound.Instance.randomMapSeed + seed); text = random.NextItem(stringList); } else { Random random2 = new Random(); text = random2.NextItem(stringList); } ((TMP_Text)component).text = text; ((TMP_Text)component).fontSize = fontSize; } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } internal static List<string> StringToList(string s) { string[] array = s.Trim().Split('|'); if (array.Length == 1 && array[0] == "") { return new List<string>(); } return array.ToList(); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Tomatobird.RandomizedTexts"; public const string PLUGIN_NAME = "RandomizedTexts"; public const string PLUGIN_VERSION = "0.3.0"; } } namespace RandomizedTexts.Patches { internal class AliveMessagePatch { [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPatch(typeof(HUDManager), "RemoveSpectateUI")] [HarmonyPostfix] private static void StartPatch(StartOfRound __instance) { RandomizedTexts.ChangeText("Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/SystemsOnline/TipLeft1", "Systems Online", RandomizedTexts.aliveMessages, RandomizedTexts.aliveFontSize, 29); } } internal class CriticalInjuryPatch { [HarmonyPatch(typeof(HUDManager), "UpdateHealthUI")] [HarmonyPostfix] private static void UpdateHealthUIPostFix(HUDManager __instance, ref int health, ref bool hurtPlayer) { if (hurtPlayer && health < 20) { RandomizedTexts.ChangeText("Systems/UI/Canvas/IngamePlayerHUD/SpecialHUDGraphics/CriticalInjury/TipLeft1", "Critical Injury", RandomizedTexts.criticalInjuryMessages, RandomizedTexts.criticalInjuryFontSize, 75); } } } internal class DeathMessagePatch { [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] [HarmonyPrefix] private static void KillPlayerPrefix(PlayerControllerB __instance) { RandomizedTexts.ChangeText("Systems/UI/Canvas/DeathScreen/GameOverText", "Life Support: Offline", RandomizedTexts.deathMessages, RandomizedTexts.deathFontSize, 420); } } internal class GameOverMessagePatch { [HarmonyPatch(typeof(HUDManager), "ShowPlayersFiredScreen")] [HarmonyPrefix] private static void ShowPlayersFiredScreenPreFix(StartOfRound __instance) { if (RandomizedTexts.gameOverMessages.Count > 0) { RandomizedTexts.ChangeText("Systems/UI/Canvas/GameOverScreen/MaskImage/HeaderText", "You Are Fired", RandomizedTexts.gameOverMessages, RandomizedTexts.gameOverFontSize, 169); } if (RandomizedTexts.gameOverSubtitles.Count > 0) { RandomizedTexts.ChangeText("Systems/UI/Canvas/GameOverScreen/MaskImage/HeaderText (1)", "You Are Fired Subtitle", RandomizedTexts.gameOverSubtitles, RandomizedTexts.gameOverSubtitleFontSize, 160); } } } internal class HandsFullMessagePatch { [HarmonyPatch(typeof(PlayerControllerB), "SwitchToItemSlot")] [HarmonyPostfix] private static void SwitchToItemSlotPostFix(PlayerControllerB __instance) { if (((NetworkBehaviour)__instance).IsOwner && ((Behaviour)HUDManager.Instance.holdingTwoHandedItem).enabled) { RandomizedTexts.ChangeText("Systems/UI/Canvas/IngamePlayerHUD/HandsFullText", "Hands Full", RandomizedTexts.handsFullMessages, RandomizedTexts.handsFullFontSize, 38); } } } internal class LoadingGamePatch { [HarmonyPatch(typeof(MenuManager), "SetLoadingScreen")] [HarmonyPrefix] internal static void SetLoadingScreen_Prefix() { RandomizedTexts.ChangeText("Canvas/MenuContainer/LoadingScreen/LoadingTextContainer/LoadingText", "Loading (Game/Lobby)", RandomizedTexts.loadingMessages, RandomizedTexts.loadingFontSize, 518); } } internal class LoadingLevelPatch { [HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")] [HarmonyPatch(typeof(RoundManager), "Start")] [HarmonyPostfix] private static void GenerateNewLevelClientRpc_Postfix() { RandomizedTexts.ChangeText("Systems/UI/Canvas/LoadingText/LoadText", "Entering The Atmosphere", RandomizedTexts.landingToMoonMessages, RandomizedTexts.landingToMoonFontSize, 114); } } } namespace RandomizedTexts.Extensions { public static class RandomExtensions { public static T NextEnum<T>(this Random random) where T : struct, Enum { Array values = Enum.GetValues(typeof(T)); return (T)values.GetValue(random.Next(values.Length)); } public static T NextItem<T>(this Random random, List<T> collection) { int index = random.Next(collection.Count); return collection[index]; } public static T NextItem<T>(this Random random, T[] collection) { int num = random.Next(collection.Length); return collection[num]; } public static double NextDouble(this Random random, double min, double max) { return random.NextDouble() * (max - min) + min; } public static float NextFloat(this Random random, float min, float max) { return (float)random.NextDouble(min, max); } public static bool NextBool(this Random random) { return random.Next(2) == 0; } public static int NextSign(this Random random) { if (!random.NextBool()) { return -1; } return 1; } public static Quaternion NextQuaternion(this Random random) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) return Quaternion.Euler(random.NextFloat(0f, 360f), random.NextFloat(0f, 360f), random.NextFloat(0f, 360f)); } } }