using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;
using j_red.Patches;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("j-red-lethal")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("j-red-lethal")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c9dfa95d-75b1-4796-9f58-e9aa57cedc41")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace j_red
{
public class ModConfig
{
public ConfigEntry<bool> lockFOV;
[Range(0f, 132f)]
public ConfigEntry<float> FOV;
public ConfigEntry<float> terminalFOV;
public ConfigEntry<bool> disableMotionSway;
[Range(0f, 10f)]
public ConfigEntry<float> motionSwayIntensity;
public ConfigEntry<bool> disableHUDHelmetVisor;
}
[BepInPlugin("jred.RemoveMotionSway", "Remove Motion Sway", "1.3.0")]
public class ModBase : BaseUnityPlugin
{
private const string GUID = "jred.RemoveMotionSway";
private const string ModName = "Remove Motion Sway";
private const string ModVersion = "1.3.0";
private readonly Harmony harmony = new Harmony("jred.RemoveMotionSway");
private static ModBase Instance;
public static ModConfig config;
internal ManualLogSource logger;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
config = new ModConfig();
config.disableMotionSway = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Disable Motion Sway", true, "If motion sway/head bobbing should be disabled.");
config.motionSwayIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Motion Sway Intensity", 1f, "If enabled, how strong the motion sway effect will be. Range [0.0, 10.0]. Recommended max 3.0.");
config.lockFOV = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Lock FOV", true, "Determines if the player field of view should remain locked. Disable for mod compatibility.");
config.FOV = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Field of View", 66f, "FOV to use when locked. Has no effect if LockFOV is false.");
config.terminalFOV = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Terminal Field of View", 66f, "FOV to use in terminal window.");
config.disableHUDHelmetVisor = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Disable HUD helmet visor effect", true, "If enabled, will remove the helmet visor effect from the HUD.");
}
logger = Logger.CreateLogSource("jred.RemoveMotionSway");
logger.LogInfo((object)"Remove Motion Sway v1.3.0 initialized.");
harmony.PatchAll(typeof(ModBase));
harmony.PatchAll(typeof(PlayerControllerBPatch));
}
}
}
namespace j_red.Patches
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerBPatch
{
public static Camera playerCam = null;
private static Vector3 cameraRotation = new Vector3(90f, 0f, 0f);
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void CacheCameraContainer(ref PlayerControllerB __instance)
{
Transform transform = ((Component)__instance).transform;
playerCam = ((Component)transform.Find("ScavengerModel/metarig/CameraContainer/MainCamera")).GetComponent<Camera>();
if (ModBase.config.disableHUDHelmetVisor.Value)
{
GameObject val = GameObject.Find("Systems/Rendering/PlayerHUDHelmetModel/ScavengerHelmet");
MeshRenderer component = val.GetComponent<MeshRenderer>();
((Renderer)component).enabled = false;
}
}
[HarmonyPatch("LateUpdate")]
[HarmonyPrefix]
private static void LateUpdatePatch(ref PlayerControllerB __instance)
{
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
if (!__instance.inTerminalMenu)
{
if (!__instance.inSpecialInteractAnimation && !__instance.playingQuickSpecialAnimation)
{
if (ModBase.config.disableMotionSway.Value)
{
__instance.cameraContainerTransform.position = new Vector3(__instance.cameraContainerTransform.position.x, ((Component)__instance.playerModelArmsMetarig).transform.position.y, __instance.cameraContainerTransform.position.z);
__instance.cameraContainerTransform.localRotation = Quaternion.Euler(cameraRotation);
}
else
{
float num = __instance.cameraContainerTransform.position.y - ((Component)__instance.playerModelArmsMetarig).transform.position.y;
__instance.cameraContainerTransform.position = new Vector3(__instance.cameraContainerTransform.position.x, ((Component)__instance.playerModelArmsMetarig).transform.position.y + num * ModBase.config.motionSwayIntensity.Value, __instance.cameraContainerTransform.position.z);
}
}
if (ModBase.config.lockFOV.Value && Object.op_Implicit((Object)(object)playerCam))
{
playerCam.fieldOfView = ModBase.config.FOV.Value;
}
return;
}
try
{
if (ModBase.config.lockFOV.Value && Object.op_Implicit((Object)(object)playerCam))
{
playerCam.fieldOfView = ModBase.config.terminalFOV.Value;
}
}
catch
{
}
}
}
}