using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;
[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("OxygenDisplay")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OxygenDisplay")]
[assembly: AssemblyTitle("OxygenDisplay")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 OxygenDisplay
{
[BepInPlugin("OxygenDisplay", "Oxygen Display", "1.0.0")]
public class OxygenDisplay : BaseUnityPlugin
{
public const string PluginName = "Oxygen Display";
public const string PluginVersion = "1.0.0";
public const string PluginGUID = "OxygenDisplay";
public static OxygenDisplay? Instance;
public static ManualLogSource? Logger;
public static Harmony? harmony;
private ConfigEntry<bool>? showOnlyInWater;
private ConfigEntry<bool>? showLowOxygen;
public bool ShowOnlyInWater;
public bool ShowLowOxygen;
public void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
harmony = new Harmony("OxygenDisplay");
harmony.PatchAll(Assembly.GetExecutingAssembly());
showOnlyInWater = ((BaseUnityPlugin)this).Config.Bind<bool>("Oxygen Display", "Show Only In Water", false, "Only shows the oxygen meter while in water");
showLowOxygen = ((BaseUnityPlugin)this).Config.Bind<bool>("Oxygen Display", "Show Low Oxygen", true, "Changes the oxygen meter to blue when oxygen is low");
ShowOnlyInWater = showOnlyInWater.Value;
ShowLowOxygen = showLowOxygen.Value;
showOnlyInWater.SettingChanged += delegate
{
ShowOnlyInWater = showOnlyInWater.Value;
};
showLowOxygen.SettingChanged += delegate
{
ShowLowOxygen = showLowOxygen.Value;
};
Logger.LogInfo((object)"Oxygen Display 1.0.0 is loaded!");
}
}
}
namespace OxygenDisplay.Patches
{
[HarmonyPatch(typeof(StartOfRound))]
public class StartOfRoundPatches
{
public static GameObject? OxygenMeterObject;
public static Image? OxygenMeterImage;
[HarmonyPatch("LateUpdate")]
[HarmonyPostfix]
public static void LateUpdatePostfix(StartOfRound __instance)
{
//IL_00b7: 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)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance == (Object)null)
{
return;
}
PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
if ((Object)(object)val == (Object)null)
{
return;
}
if ((Object)(object)OxygenMeterObject == (Object)null)
{
GameObject gameObject = ((Component)val.sprintMeterUI).gameObject;
OxygenMeterObject = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent);
((Object)OxygenMeterObject).name = "OxygenMeter";
OxygenMeterImage = OxygenMeterObject.GetComponentInChildren<Image>(true);
RectTransform component = gameObject.GetComponent<RectTransform>();
RectTransform component2 = OxygenMeterObject.GetComponent<RectTransform>();
((Transform)component2).SetSiblingIndex(((Transform)component).GetSiblingIndex() + 1);
component2.anchoredPosition = new Vector2(component.anchoredPosition.x + 3f, component.anchoredPosition.y - 4f);
((Transform)component2).localScale = ((Transform)component).localScale * 1.2f;
}
else if (!((Object)(object)OxygenMeterImage == (Object)null))
{
float num = Mathf.Clamp01(__instance.drowningTimer);
Image? oxygenMeterImage = OxygenMeterImage;
OxygenDisplay? instance = OxygenDisplay.Instance;
((Graphic)oxygenMeterImage).color = ((instance != null && instance.ShowLowOxygen) ? Color.Lerp(Color.white, new Color(0f, 0.384f, 1f), 1f - Mathf.Clamp01(num / 0.3f)) : Color.white);
OxygenMeterImage.fillAmount = Mathf.Lerp(0.2976f, 0.9101f, num);
OxygenDisplay? instance2 = OxygenDisplay.Instance;
if (instance2 != null && instance2.ShowOnlyInWater)
{
OxygenMeterObject.SetActive(HUDManager.Instance?.setUnderwaterFilter ?? false);
}
else
{
OxygenMeterObject.SetActive(true);
}
}
}
}
}