Decompiled source of Diving Bell Tweaks v1.1.1

DivingBellTweaks.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using CWDivingBellTweaks.Config;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
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("DivingBellTweaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyProduct("DivingBellTweaks")]
[assembly: AssemblyTitle("DivingBellTweaks")]
[assembly: AssemblyVersion("1.1.1.0")]
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;
		}
	}
}
namespace CWDivingBellTweaks
{
	[BepInPlugin("froj.contentwarning.divingbelltweaks", "Diving Bell Tweaks", "1.0.0")]
	public class DivingBellTweaks : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(PlayerInput), "SampeInput")]
		public static class Player_SampeInput_Patch
		{
			public static void Postfix(Player player)
			{
				if (ModConfig.DEBUG_MODE.Value == "true")
				{
					if (GlobalInputHandler.GetKeyDown((KeyCode)273))
					{
						player.data.remainingOxygen = player.data.maxOxygen;
						player.data.health = 100f;
					}
					if (GlobalInputHandler.GetKeyDown((KeyCode)274))
					{
						player.data.remainingOxygen = 10f;
						player.data.health = 10f;
					}
				}
			}
		}

		[HarmonyPatch(typeof(DivingBell), "Update")]
		public static class DivingBell_Update_Patch
		{
			public static void Postfix(DivingBell __instance)
			{
				if ((ModConfig.OXYGEN_REGEN_ENABLED.Value == "false" && ModConfig.HEALTH_REGEN_ENABLED.Value == "false") || __instance.onSurface || !__instance.door.IsFullyClosed())
				{
					return;
				}
				ICollection<Player> collection = __instance.playerDetector.CheckForPlayers();
				foreach (Player item in collection)
				{
					if (ModConfig.OXYGEN_REGEN_ENABLED.Value == "true" && item.data.remainingOxygen < item.data.maxOxygen)
					{
						PlayerData data = item.data;
						data.remainingOxygen += ModConfig.OXYGEN_REGEN_SPEED.Value * Time.deltaTime;
					}
					if (ModConfig.HEALTH_REGEN_ENABLED.Value == "true" && item.data.health < 100f)
					{
						PlayerData data2 = item.data;
						data2.health += ModConfig.HEALTH_REGEN_SPEED.Value * Time.deltaTime;
					}
				}
			}
		}

		private const string pluginGuid = "froj.contentwarning.divingbelltweaks";

		private const string pluginName = "Diving Bell Tweaks";

		private const string pluginVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("froj.contentwarning.divingbelltweaks");

		internal static DivingBellTweaksConfig ModConfig { get; private set; }

		public void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Initing config");
			ModConfig = new DivingBellTweaksConfig(((BaseUnityPlugin)this).Config);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Applying Harmony patches");
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"froj.contentwarning.divingbelltweaks is loaded!");
		}
	}
}
namespace CWDivingBellTweaks.Items
{
	internal class Bell : ItemInstanceBehaviour
	{
		public override void ConfigItem(ItemInstanceData data, PhotonView playerView)
		{
			((Component)this).gameObject.SetActive(true);
		}

		private void Update()
		{
		}
	}
}
namespace CWDivingBellTweaks.Config
{
	internal class DivingBellTweaksConfig
	{
		internal ConfigEntry<string> DEBUG_MODE;

		internal ConfigEntry<string> OXYGEN_REGEN_ENABLED;

		internal ConfigEntry<float> OXYGEN_REGEN_SPEED;

		internal ConfigEntry<string> HEALTH_REGEN_ENABLED;

		internal ConfigEntry<float> HEALTH_REGEN_SPEED;

		internal DivingBellTweaksConfig(ConfigFile cfgFile)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			DEBUG_MODE = cfgFile.Bind<string>("Debug", "DebugEnabled", "false", new ConfigDescription("Should debug mode be enabled? (UpArrow = max oxygen, DownArrow = low oxygen)", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "true", "false" }), Array.Empty<object>()));
			OXYGEN_REGEN_ENABLED = cfgFile.Bind<string>("OxygenRegen", "OxygenRegenEnabled", "true", new ConfigDescription("Allow oxygen to regen when inside the diving bell with the door shut?", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "true", "false" }), Array.Empty<object>()));
			OXYGEN_REGEN_SPEED = cfgFile.Bind<float>("OxygenRegen", "OxygenRegenSpeed", 5f, "How much oxygen is regenerated per second");
			HEALTH_REGEN_ENABLED = cfgFile.Bind<string>("HealthRegen", "HealthRegenEnabled", "true", new ConfigDescription("Allow health to regen when inside the diving bell with the door shut?", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "true", "false" }), Array.Empty<object>()));
			HEALTH_REGEN_SPEED = cfgFile.Bind<float>("HealthRegen", "HealthRegenSpeed", 2f, "How much health is regenerated per second");
		}
	}
}