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; [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("Adjust weapon recoil intensity from 0% (no recoil) to 200% (double recoil)")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0.0")] [assembly: AssemblyProduct("RecoilAdjustMod")] [assembly: AssemblyTitle("RecoilAdjustMod")] [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 RecoilAdjustMod { [MycoMod(/*Could not decode attribute arguments.*/)] [BepInPlugin("coruscnium.recoiladjust", "RecoilAdjust", "1.0.1.0")] [BepInProcess("Mycopunk.exe")] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "coruscnium.recoiladjust"; public const string PluginName = "RecoilAdjust"; public const string PluginVersion = "1.0.1.0"; internal static ManualLogSource Logger; private static ConfigEntry _recoilPercentConfig; private static float _recoilPercent = 100f; 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)"RecoilAdjust loading..."); _recoilPercentConfig = ((BaseUnityPlugin)this).Config.Bind("General", "RecoilPercent", 100f, new ConfigDescription("Recoil percentage.\n 100 = default recoil\n 50 = half recoil\n 0 = no recoil\n 200 = double recoil", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 200f), Array.Empty())); _recoilPercent = _recoilPercentConfig.Value; _recoilPercentConfig.SettingChanged += delegate { _recoilPercent = _recoilPercentConfig.Value; Logger.LogInfo((object)$"RecoilPercent set to {_recoilPercent}%"); }; ((BaseUnityPlugin)this).Config.Save(); try { _configWatcher = new FileSystemWatcher(Paths.ConfigPath, "coruscnium.recoiladjust.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)$"RecoilAdjust loaded. Recoil: {_recoilPercent}%"); } 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(Gun), "AddRecoil")] [HarmonyPrefix] private static void AddRecoil_Prefix(ref float multiplier) { if (_recoilPercent != 100f) { multiplier *= _recoilPercent / 100f; } } } }