using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;
[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("BetterOxygen")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c97d1b4622294248f44b1d38140e8d928e65ca38")]
[assembly: AssemblyProduct("BetterOxygen")]
[assembly: AssemblyTitle("BetterOxygen")]
[assembly: AssemblyVersion("1.0.0.0")]
public class Config
{
public static ConfigEntry<float> maximumOxygen;
public static ConfigEntry<bool> infiniteOxygen;
public static ConfigEntry<bool> refillOxygen;
public static ConfigEntry<float> oxygenRefillRate;
public Config(ConfigFile cfg)
{
maximumOxygen = cfg.Bind<float>("Oxygen Levels", "Maximum Oxygen (Minutes):", 12f, "Sets the amount of oxygen you have in minutes, restart required to take effect. Unmodded game is 8 minutes and 20 seconds or 8.33");
infiniteOxygen = cfg.Bind<bool>("Extra Options", "Do you want infinite oxygen?", false, "Enabling this makes your oxygen last forever");
refillOxygen = cfg.Bind<bool>("Extra Options", "Refill oxygen inside the diving bell?", false, "Enabling this makes your oxygen refill over time when standing in the diving bell. (A bit more fair than infinite O2)");
oxygenRefillRate = cfg.Bind<float>("Extra Options", "Oxygen Refill Rate (seconds/second):", 4f, "Controls the rate at which oxygen refills while standing inside the diving bell, in seconds of O2 gained per second inside the bell");
}
}
namespace BetterOxygen
{
[BepInPlugin("Symphony.BetterOxygen", "Better Oxygen", "1.3.1")]
public class BetterO2 : BaseUnityPlugin
{
private const string modGUID = "Symphony.BetterOxygen";
private const string modName = "Better Oxygen";
private const string modVersion = "1.3.1";
private readonly Harmony harmony = new Harmony("Symphony.BetterOxygen");
private static BetterO2 Instance;
internal ManualLogSource mls;
public static Config BsConfig { get; internal set; }
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("Symphony.BetterOxygen");
BsConfig = new Config(((BaseUnityPlugin)this).Config);
mls.LogInfo((object)"Better breathing starts here");
harmony.PatchAll();
}
}
}
namespace BetterOxygen.Patches
{
[HarmonyPatch(typeof(PlayerData))]
internal class PLayerDataPatch
{
public static float max02 = Config.maximumOxygen.Value;
public static float btsMax = max02 * 60f;
public static bool infiniteO2 = Config.infiniteOxygen.Value;
public static bool diveRefill = Config.refillOxygen.Value;
public static float refillRate = Config.oxygenRefillRate.Value;
public static bool sceneSwitch = false;
public static int higher = 0;
[HarmonyPatch("UpdateValues")]
[HarmonyPrefix]
private static void betterOxygenPatch(ref float ___maxOxygen, ref float ___remainingOxygen, ref bool ___usingOxygen, ref bool ___isInDiveBell)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (sceneSwitch = ((Scene)(ref activeScene)).name == "SurfaceScene")
{
___maxOxygen = btsMax;
___remainingOxygen = btsMax;
higher = 0;
}
activeScene = SceneManager.GetActiveScene();
if (sceneSwitch = ((((Scene)(ref activeScene)).name != "SurfaceScene") & ___isInDiveBell) && !infiniteO2)
{
___maxOxygen = btsMax;
if (___maxOxygen > 500f)
{
while (___remainingOxygen < ___maxOxygen && higher == 0)
{
___remainingOxygen += ___maxOxygen - 500f;
higher = 1;
}
}
else
{
while (___remainingOxygen > ___maxOxygen && higher == 0)
{
___remainingOxygen -= 500f - ___maxOxygen;
higher = 1;
}
}
if (diveRefill && higher == 1 && ___remainingOxygen <= ___maxOxygen)
{
___remainingOxygen += refillRate * Time.deltaTime;
}
}
else if (infiniteO2)
{
___remainingOxygen = btsMax;
}
}
}
}