using System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Pigeon.Movement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("coruscnium")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Completely removes all screenshake (weapons, explosions, effects).")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0.0")] [assembly: AssemblyProduct("NoScreenshake")] [assembly: AssemblyTitle("NoScreenshakeMod")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace NoScreenshakeMod { [MycoMod(/*Could not decode attribute arguments.*/)] [BepInPlugin("coruscnium.noscreenshake", "NoScreenshake", "1.0.0.0")] [BepInProcess("Mycopunk.exe")] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "coruscnium.noscreenshake"; public const string PluginName = "NoScreenshake"; public const string PluginVersion = "1.0.0.0"; internal static ManualLogSource Logger; private static ConfigEntry _shakePercentConfig; private static float _shakePercent; private static FileSystemWatcher _configWatcher; private static volatile bool _pendingConfigReload; private void Awake() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"NoScreenshake loading..."); _shakePercentConfig = ((BaseUnityPlugin)this).Config.Bind("General", "ShakePercent", 0f, new ConfigDescription("Screenshake percentage.\n 0 = no shake (default)\n 100 = default shake\n 200 = double shake", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 200f), Array.Empty())); _shakePercent = _shakePercentConfig.Value; _shakePercentConfig.SettingChanged += delegate { _shakePercent = _shakePercentConfig.Value; Logger.LogInfo((object)$"ShakePercent set to {_shakePercent}%"); }; ((BaseUnityPlugin)this).Config.Save(); try { _configWatcher = new FileSystemWatcher(Paths.ConfigPath, "coruscnium.noscreenshake.cfg") { NotifyFilter = (NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite), EnableRaisingEvents = true }; _configWatcher.Changed += OnConfigFileChanged; _configWatcher.Created += OnConfigFileChanged; _configWatcher.Renamed += OnConfigFileChanged; } catch (Exception ex) { Logger.LogWarning((object)("Could not start config file watcher: " + ex.Message)); } Harmony.CreateAndPatchAll(typeof(Plugin), (string)null); Logger.LogInfo((object)$"NoScreenshake loaded. Shake: {_shakePercent}%"); } private void OnConfigFileChanged(object sender, FileSystemEventArgs e) { _pendingConfigReload = true; } private void OnDestroy() { if (_configWatcher != null) { _configWatcher.EnableRaisingEvents = false; _configWatcher.Changed -= OnConfigFileChanged; _configWatcher.Created -= OnConfigFileChanged; _configWatcher.Renamed -= OnConfigFileChanged; _configWatcher.Dispose(); _configWatcher = null; } } private void Update() { if (_pendingConfigReload) { _pendingConfigReload = false; try { ((BaseUnityPlugin)this).Config.Reload(); Logger.LogInfo((object)"Config reloaded from disk."); } catch (Exception ex) { Logger.LogError((object)("Error reloading config: " + ex.Message)); } } } [HarmonyPatch(typeof(PlayerLook), "ShakeTranslate")] [HarmonyPrefix] private static void ShakeTranslate_Prefix(ref float intensity) { if (_shakePercent != 100f) { intensity *= _shakePercent / 100f; } } [HarmonyPatch(typeof(PlayerLook), "ShakeRotation")] [HarmonyPrefix] private static void ShakeRotation_Prefix(ref float intensity) { if (_shakePercent != 100f) { intensity *= _shakePercent / 100f; } } [HarmonyPatch(typeof(PlayerLook), "ShakeTranslateMin")] [HarmonyPrefix] private static void ShakeTranslateMin_Prefix(ref float intensity) { if (_shakePercent != 100f) { intensity *= _shakePercent / 100f; } } [HarmonyPatch(typeof(PlayerLook), "ShakeRotationMin")] [HarmonyPrefix] private static void ShakeRotationMin_Prefix(ref float intensity) { if (_shakePercent != 100f) { intensity *= _shakePercent / 100f; } } } }