Decompiled source of NoUnderwaterCamera v1.0.0

NoUnderwaterCamera.dll

Decompiled 3 days ago
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace BakaNoUnderwaterCamera;

[BepInPlugin("baka.NoUnderwaterCamera", "Baka NoUnderwaterCamera", "1.0.0")]
public class NoUnderwaterCameraPlugin : BaseUnityPlugin
{
	public const string PluginGuid = "baka.NoUnderwaterCamera";

	public const string PluginName = "Baka NoUnderwaterCamera";

	public const string PluginVersion = "1.0.0";

	internal static ConfigEntry<bool> Enabled;

	internal static ConfigEntry<float> Clearance;

	private void Awake()
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Keep the camera above the water surface (restores vanilla behaviour). Disable to allow the Wind Chasers underwater camera again.");
		Clearance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Water Clearance", 0.4f, "How far (metres) above the water surface the camera is held when it would otherwise dip below. Vanilla keeps a small clearance; raise this if the waterline still creeps into view.");
		new Harmony("baka.NoUnderwaterCamera").PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Baka NoUnderwaterCamera 1.0.0 loaded (Enabled=" + Enabled.Value + ")."));
	}
}
[HarmonyPriority(0)]
[HarmonyPatch(typeof(GameCamera), "UpdateCamera")]
[HarmonyAfter(new string[] { "balrond.astafaraios.BalrondWindChasers" })]
internal static class Patch_GameCamera_UpdateCamera
{
	private static void Postfix(GameCamera __instance)
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		if (NoUnderwaterCameraPlugin.Enabled == null || !NoUnderwaterCameraPlugin.Enabled.Value)
		{
			return;
		}
		ZoneSystem instance = ZoneSystem.instance;
		if (!((Object)(object)instance == (Object)null))
		{
			float num = instance.m_waterLevel + NoUnderwaterCameraPlugin.Clearance.Value;
			Transform transform = ((Component)__instance).transform;
			Vector3 position = transform.position;
			if (position.y < num)
			{
				position.y = num;
				transform.position = position;
			}
		}
	}
}