using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using InfectionHUD.Patches; 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("Freedom.InfectionHUD")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+62a3d7f29958af769b4fb66c8689dc455eb8877f")] [assembly: AssemblyProduct("InfectionHUD")] [assembly: AssemblyTitle("Freedom.InfectionHUD")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.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 InfectionHUD { [BepInPlugin("Freedom.InfectionHUD", "InfectionHUD", "1.0.0")] public class InfectionHUD : BaseUnityPlugin { private readonly Harmony _harmony; public static InfectionHUD Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } private bool IsDevHotReload => ((Object)((Component)this).gameObject).name.Contains("ScriptEngine"); public InfectionHUD() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; Logger.LogInfo((object)"Freedom.InfectionHUD v1.0.0 has loaded!"); Logger.LogDebug((object)"Patching..."); _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); Logger.LogDebug((object)"Finished patching!"); } private void Awake() { if ((Object)(object)HUDManager.Instance != (Object)null && ((Component)HUDManager.Instance).gameObject.activeInHierarchy) { global::InfectionHUD.Patches.Patches.HUDManager_Start(HUDManager.Instance); } } private void OnDestroy() { Logger.LogDebug((object)"OnDestroy called"); if (IsDevHotReload) { Logger.LogDebug((object)"Unpatching..."); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } TextMeshProUGUI infectionText = global::InfectionHUD.Patches.Patches.InfectionText; Object.Destroy((Object)(object)((infectionText != null) ? ((Component)infectionText).gameObject : null)); Logger.LogDebug((object)"Finished unpatching!"); } } } internal static class PluginInfo { public const string PLUGIN_GUID = "Freedom.InfectionHUD"; public const string PLUGIN_NAME = "InfectionHUD"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace InfectionHUD.Patches { [HarmonyPatch] public static class Patches { private static readonly ManualLogSource Logger = InfectionHUD.Logger; private static readonly Stopwatch _stopwatch = Stopwatch.StartNew(); private static readonly Stopwatch _stopwatch2 = Stopwatch.StartNew(); public static TextMeshProUGUI InfectionText = null; private static PlayerInfection LocalPlayerInfection { set { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) Logger.LogDebug((object)$"UpdatingPercentValue called with infection={value.infectionMeter}"); if (!((Object)(object)InfectionText == (Object)null)) { if (value.burstMeter > 0f) { float burstMeter = value.burstMeter; ((TMP_Text)InfectionText).text = $"{MathF.Floor(burstMeter * 100f)}% burst"; } else { float num = Math.Clamp(value.infectionMeter, 0f, 1f); ((Graphic)InfectionText).color = Color.Lerp(Color.green, Color.red, num); ((TMP_Text)InfectionText).text = ((num == 0f) ? "" : $"{MathF.Floor(num * 100f)}% infected"); } } } } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "Awake")] public static void StartOfRound_Awake() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown Logger.LogDebug((object)$"StartOfRound_Awake CALLED! {DateTime.Now}"); LocalPlayerInfection = new PlayerInfection(); } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "EndOfGame")] public static void StartOfRound_EndOfGame() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown Logger.LogDebug((object)$"StartOfRound_EndOfGame CALLED! {DateTime.Now}"); LocalPlayerInfection = new PlayerInfection(); } [HarmonyPostfix] [HarmonyPatch(typeof(CadaverGrowthAI), "ProgressPlayerInfections")] public static void CadaverGrowthAI_ProgressPlayerInfections(CadaverGrowthAI __instance) { if (_stopwatch.ElapsedMilliseconds >= 1000) { LocalPlayerInfection = __instance.playerInfections[StartOfRound.Instance.thisClientPlayerId]; _stopwatch.Restart(); } } [HarmonyPostfix] [HarmonyPatch(typeof(HUDManager), "Start")] public static void HUDManager_Start(HUDManager __instance) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("MyCustomHUDText"); val.transform.SetParent(((TMP_Text)__instance.weightCounter).transform.parent, false); InfectionText = val.AddComponent(); ((TMP_Text)InfectionText).font = ((TMP_Text)__instance.weightCounter).font; ((TMP_Text)InfectionText).fontSize = 14f; ((Graphic)InfectionText).color = Color.green; ((TMP_Text)InfectionText).alignment = (TextAlignmentOptions)513; ((TMP_Text)InfectionText).text = ""; ((Transform)((TMP_Text)InfectionText).rectTransform).localPosition = new Vector3(-20f, -30f, 0f); } } }