Decompiled source of MotionSickness v1.0.0

BepInEx/plugins/MotionSickness/MotionSickness.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace MotionSickness;

[BepInPlugin("com.ex3124.MotionSickness", "MotionSickness", "1.0")]
public class Plugin : BaseUnityPlugin
{
	internal static ConfigEntry<bool> DisableShake;

	internal static ConfigEntry<bool> DisableBob;

	internal static ConfigEntry<bool> DisableTilt;

	internal static ConfigEntry<float> MaxFOV;

	internal static ConfigEntry<bool> DisableMask;

	internal static ConfigEntry<bool> HideSeamoth;

	internal static ConfigEntry<float> WaveHeight;

	public void Awake()
	{
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Expected O, but got Unknown
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Expected O, but got Unknown
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		DisableShake = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera", "Disable Shake", true, "Camera shake effect in certain scenes\nFor example, the shake after executing 'camshake' on the console");
		DisableBob = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera", "Disable Bobbing", true, "Bobbing up and down when moving");
		DisableTilt = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera", "Disable Tilt", true, "Camera tilt when moving left and right");
		MaxFOV = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "Max FOV", 120f, new ConfigDescription("Customize maximum FOV value", (AcceptableValueBase)(object)new AcceptableValueRange<float>(90f, 180f), Array.Empty<object>()));
		DisableMask = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera", "Disable Mask", true, "Mask on the edge of the screen");
		HideSeamoth = ((BaseUnityPlugin)this).Config.Bind<bool>("Renderer", "Hide Seamoth When Entered", false, "Better visibility when driving Seamoth");
		WaveHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Renderer", "Wave Height", 300f, new ConfigDescription("When surfacing, looking down at the waves may make you feel dizzy\nLowering the wave height may improve this\nOnly works when the 'Water quality' is 'Medium'", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 300f), Array.Empty<object>()));
		new Harmony("com.ex3124.MotionSickness").PatchAll(Assembly.GetExecutingAssembly());
	}
}
[HarmonyPatch(typeof(MainCameraControl))]
[HarmonyPatch("ShakeCamera")]
public static class CameraShake
{
	[HarmonyPrefix]
	public static bool Prefix()
	{
		return !Plugin.DisableShake.Value;
	}
}
[HarmonyPatch(typeof(MainCameraControl))]
[HarmonyPatch("GetCameraBob")]
public static class CameraBob
{
	[HarmonyPrefix]
	public static bool Prefix(ref bool __result)
	{
		if (Plugin.DisableBob.Value)
		{
			__result = false;
			return false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(MainCameraControl))]
[HarmonyPatch("UpdateStrafeTilt")]
public static class CameraTilt
{
	[HarmonyPrefix]
	public static bool Prefix()
	{
		return !Plugin.DisableTilt.Value;
	}
}
[HarmonyPatch(typeof(uGUI_TabbedControlsPanel))]
[HarmonyPatch("AddSliderOption", new Type[]
{
	typeof(int),
	typeof(string),
	typeof(float),
	typeof(float),
	typeof(float),
	typeof(float),
	typeof(float),
	typeof(UnityAction<float>),
	typeof(SliderLabelMode),
	typeof(string),
	typeof(string)
})]
public static class FOVSlider
{
	[HarmonyPrefix]
	public static bool Prefix(string label, ref float maxValue)
	{
		if (label == "FieldOfView")
		{
			maxValue = Plugin.MaxFOV.Value;
		}
		return true;
	}
}
[HarmonyPatch(typeof(Player))]
[HarmonyPatch("SetScubaMaskActive")]
public static class Mask
{
	[HarmonyPrefix]
	public static bool Prefix(ref bool state)
	{
		if (Plugin.DisableMask.Value)
		{
			state = false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(SeaMoth))]
[HarmonyPatch("Update")]
public static class RendererUpdate
{
	[HarmonyPrefix]
	public static bool Prefix(SeaMoth __instance)
	{
		Renderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Renderer>();
		if (Plugin.HideSeamoth.Value && componentsInChildren != null)
		{
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				if ((Object)(object)val != (Object)null && ((Object)val).name.ToLower().Contains("seamoth"))
				{
					val.enabled = !((Vehicle)__instance).playerFullyEntered;
				}
			}
		}
		return true;
	}
}
[HarmonyPatch(typeof(WaterSurface))]
[HarmonyPatch("DoUpdate")]
public static class WaterWave
{
	[HarmonyPrefix]
	public static bool Prefix(WaterSurface __instance)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		typeof(WaterSurface).GetField("maxDisplacement", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, (object)new Vector3(100f, Plugin.WaveHeight.Value, 100f));
		return true;
	}
}