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.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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Tomatobird.RandomizedTexts")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+cd9334fa4bff9cc997965530d8b76ba5adf55f82")]
[assembly: AssemblyProduct("RandomizedTexts")]
[assembly: AssemblyTitle("Tomatobird.RandomizedTexts")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.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.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 RandomizedTexts
{
[BepInPlugin("Tomatobird.RandomizedTexts", "RandomizedTexts", "0.1.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 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;
Patch();
Logger.LogInfo((object)"Tomatobird.RandomizedTexts v0.1.0 has loaded!");
}
internal static void Patch()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("Tomatobird.RandomizedTexts");
}
if (aliveMessages.Count > 0)
{
Logger.LogDebug((object)"Patching.... AliveMessagePatch");
Harmony.PatchAll(typeof(AliveMessagePatch));
}
if (handsFullMessages.Count > 0)
{
Logger.LogDebug((object)"Patching.... HandsFullMessagePatch");
Harmony.PatchAll(typeof(HandsFullMessagePatch));
}
if (criticalInjuryMessages.Count > 0)
{
Logger.LogDebug((object)"Patching.... CriticalInjuryPatch");
Harmony.PatchAll(typeof(CriticalInjuryPatch));
}
if (deathMessages.Count > 0)
{
Logger.LogDebug((object)"Patching.... DeathMessagePatch");
Harmony.PatchAll(typeof(DeathMessagePatch));
}
if (gameOverMessages.Count > 0 || gameOverSubtitles.Count > 0)
{
Logger.LogDebug((object)"Patching.... GameOverMessagePatch");
Harmony.PatchAll(typeof(GameOverMessagePatch));
}
Logger.LogDebug((object)"Finished patching!");
}
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.1.0";
}
}
namespace RandomizedTexts.Patches
{
internal class AliveMessagePatch
{
[HarmonyPatch(typeof(StartOfRound), "Start")]
[HarmonyPostfix]
private static void StartPatch(StartOfRound __instance)
{
string text = "";
GameObject val = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/SystemsOnline/TipLeft1");
if ((Object)(object)val != (Object)null)
{
TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
if (RandomizedTexts.seedBasedRandom)
{
Random random = new Random(StartOfRound.Instance.randomMapSeed + 29);
text = random.NextItem(RandomizedTexts.aliveMessages);
}
else
{
Random random2 = new Random();
text = random2.NextItem(RandomizedTexts.aliveMessages);
}
((TMP_Text)component).text = text;
((TMP_Text)component).fontSize = RandomizedTexts.aliveFontSize;
}
}
[HarmonyPatch(typeof(HUDManager), "RemoveSpectateUI")]
[HarmonyPostfix]
private static void RemoveSpectateUIPatch(HUDManager __instance)
{
string text = "";
GameObject val = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/SystemsOnline/TipLeft1");
if ((Object)(object)val != (Object)null)
{
TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
if (RandomizedTexts.seedBasedRandom)
{
Random random = new Random(StartOfRound.Instance.randomMapSeed + 39);
text = random.NextItem(RandomizedTexts.aliveMessages);
}
else
{
Random random2 = new Random();
text = random2.NextItem(RandomizedTexts.aliveMessages);
}
((TMP_Text)component).text = text;
((TMP_Text)component).fontSize = RandomizedTexts.aliveFontSize;
}
}
}
internal class CriticalInjuryPatch
{
[HarmonyPatch(typeof(HUDManager), "UpdateHealthUI")]
[HarmonyPostfix]
private static void UpdateHealthUIPostFix(HUDManager __instance, ref int health, ref bool hurtPlayer)
{
if (!hurtPlayer || health >= 20)
{
return;
}
string text = "";
GameObject val = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/SpecialHUDGraphics/CriticalInjury/TipLeft1");
if ((Object)(object)val != (Object)null)
{
TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
if (RandomizedTexts.seedBasedRandom)
{
Random random = new Random(StartOfRound.Instance.randomMapSeed + 75);
text = random.NextItem(RandomizedTexts.criticalInjuryMessages);
}
else
{
Random random2 = new Random();
text = random2.NextItem(RandomizedTexts.criticalInjuryMessages);
}
((TMP_Text)component).text = text;
((TMP_Text)component).fontSize = RandomizedTexts.criticalInjuryFontSize;
}
}
}
internal class DeathMessagePatch
{
[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
[HarmonyPrefix]
private static void KillPlayerPrefix(PlayerControllerB __instance)
{
string text = "";
GameObject val = GameObject.Find("Systems/UI/Canvas/DeathScreen/GameOverText");
if ((Object)(object)val != (Object)null)
{
TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
if (RandomizedTexts.seedBasedRandom)
{
Random random = new Random(StartOfRound.Instance.randomMapSeed + 420);
text = random.NextItem(RandomizedTexts.deathMessages);
}
else
{
Random random2 = new Random();
text = random2.NextItem(RandomizedTexts.deathMessages);
}
((TMP_Text)component).text = text;
((TMP_Text)component).fontSize = RandomizedTexts.deathFontSize;
}
}
}
internal class GameOverMessagePatch
{
[HarmonyPatch(typeof(HUDManager), "ShowPlayersFiredScreen")]
[HarmonyPrefix]
private static void ShowPlayersFiredScreenPreFix(StartOfRound __instance)
{
if (RandomizedTexts.gameOverMessages.Count > 0)
{
string text = "";
GameObject val = GameObject.Find("Systems/UI/Canvas/GameOverScreen/MaskImage/HeaderText");
if ((Object)(object)val != (Object)null)
{
TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
if (RandomizedTexts.seedBasedRandom)
{
Random random = new Random(StartOfRound.Instance.randomMapSeed + 169);
text = random.NextItem(RandomizedTexts.gameOverMessages);
}
else
{
Random random2 = new Random();
text = random2.NextItem(RandomizedTexts.gameOverMessages);
}
((TMP_Text)component).text = text;
((TMP_Text)component).fontSize = RandomizedTexts.gameOverFontSize;
}
}
if (RandomizedTexts.gameOverSubtitles.Count <= 0)
{
return;
}
string text2 = "";
GameObject val2 = GameObject.Find("Systems/UI/Canvas/GameOverScreen/MaskImage/HeaderText (1)");
if ((Object)(object)val2 != (Object)null)
{
TextMeshProUGUI component2 = val2.GetComponent<TextMeshProUGUI>();
if (RandomizedTexts.seedBasedRandom)
{
Random random3 = new Random(StartOfRound.Instance.randomMapSeed + 160);
text2 = random3.NextItem(RandomizedTexts.gameOverSubtitles);
}
else
{
Random random4 = new Random();
text2 = random4.NextItem(RandomizedTexts.gameOverSubtitles);
}
((TMP_Text)component2).text = text2;
((TMP_Text)component2).fontSize = RandomizedTexts.gameOverSubtitleFontSize;
}
}
}
internal class HandsFullMessagePatch
{
[HarmonyPatch(typeof(PlayerControllerB), "SwitchToItemSlot")]
[HarmonyPostfix]
private static void SwitchToItemSlotPostFix(PlayerControllerB __instance)
{
if (!((NetworkBehaviour)__instance).IsOwner || !((Behaviour)HUDManager.Instance.holdingTwoHandedItem).enabled)
{
return;
}
string text = "";
GameObject val = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/HandsFullText");
if ((Object)(object)val != (Object)null)
{
TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
if (RandomizedTexts.seedBasedRandom)
{
Random random = new Random(StartOfRound.Instance.randomMapSeed + 38);
text = random.NextItem(RandomizedTexts.handsFullMessages);
}
else
{
Random random2 = new Random();
text = random2.NextItem(RandomizedTexts.handsFullMessages);
}
((TMP_Text)component).text = text;
((TMP_Text)component).fontSize = RandomizedTexts.handsFullFontSize;
}
}
}
}
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)
{
return random.NextBool() ? 1 : (-1);
}
public static Quaternion NextQuaternion(this Random random)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: 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));
}
}
}