Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of FourPlayer Local Fixes v1.6.2
plugins/KeybindCompat.dll
Decompiled 3 days agousing System; using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] [BepInPlugin("local.profile.keybindcompat", "4P Keybind Compatibility", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class KeybindCompat : BaseUnityPlugin { private static KeybindCompat self; private static BaseUnityPlugin riding; private Harmony harmony; private void Awake() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00da: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown self = this; if (!Chainloader.PluginInfos.TryGetValue("Ygg.BetterRiding", out var value)) { return; } if (value.Metadata.Version != new Version(1, 0, 3)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Better Riding key correction skipped: only version 1.0.3 is verified."); return; } riding = value.Instance; harmony = new Harmony("local.profile.keybindcompat"); try { Assembly assembly = ((object)value.Instance).GetType().Assembly; MethodInfo methodInfo = AccessTools.Method(assembly.GetType("BetterRiding.Patches.CallOwnedPetPatch+Player_Update_Patch", throwOnError: true), "Postfix", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(KeybindCompat), "AllowCompanionCommands", (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(KeybindCompat), "RemapRecall", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); Type type = assembly.GetType("BetterRiding.Compendium.BetterRidingCompendium", throwOnError: true); harmony.Patch((MethodBase)AccessTools.Method(type, "Unlock", (Type[])null, (Type[])null), new HarmonyMethod(typeof(KeybindCompat), "FixHelpText", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(type, "RefreshKnownText", (Type[])null, (Type[])null), new HarmonyMethod(typeof(KeybindCompat), "FixHelpText", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Key correction ready: ground recall Shift+Q; existing Shift+F/Shift+V kept; inventory/build/chat contexts excluded; help text reflects configured controls."); } catch (Exception ex) { harmony.UnpatchSelf(); ((BaseUnityPlugin)this).Logger.LogError((object)("Key correction could not be applied; original mod left intact: " + ex)); } } public static bool AllowCompanionCommands() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || ((Character)localPlayer).InPlaceMode() || ((Character)localPlayer).IsRiding()) { return false; } if (InventoryGui.IsVisible() || Minimap.IsOpen() || Menu.IsVisible() || Console.IsVisible() || StoreGui.IsVisible() || TextInput.IsVisible()) { return false; } if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) { return false; } if ((Object)(object)TextViewer.instance != (Object)null && TextViewer.instance.IsVisible()) { return false; } if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.InPasswordDialog()) { return false; } return !Input.GetKey((KeyCode)306) && !Input.GetKey((KeyCode)305) && !Input.GetKey((KeyCode)308) && !Input.GetKey((KeyCode)307); } public static IEnumerable<CodeInstruction> RemapRecall(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = 0; int index = -1; for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.LoadsConstant(list[i], 98L) && i + 2 < list.Count) { MethodInfo methodInfo = list[i + 2].operand as MethodInfo; if (methodInfo != null && methodInfo.DeclaringType == typeof(ZInput) && methodInfo.Name == "GetKeyDown") { num++; index = i; } } } if (num != 1) { throw new InvalidOperationException("Expected exactly one hardcoded B recall input; found " + num); } list[index].opcode = OpCodes.Ldc_I4; list[index].operand = 113; return list; } private static string KeyLabel(string section, string key, string fallback) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0061: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)riding == (Object)null) { return fallback; } ConfigDefinition val = new ConfigDefinition(section, key); if (!riding.Config.ContainsKey(val)) { return fallback; } object boxedValue = riding.Config[val].BoxedValue; if (boxedValue is KeyCode) { return ((object)(KeyCode)boxedValue).ToString(); } if (boxedValue is KeyboardShortcut val2) { return ((object)((KeyboardShortcut)(ref val2)).MainKey).ToString(); } return fallback; } public static void FixHelpText(ref string body) { if (!string.IsNullOrEmpty(body)) { body = body.Replace("Shift + B", "Shift + Q").Replace("<color=#7CFC00>F</color>", "<color=#7CFC00>" + KeyLabel("5 - Mount Controls", "Flight Toggle Key (Keyboard)", "U") + "</color>").Replace("<color=#7CFC00>Z</color>", "<color=#7CFC00>" + KeyLabel("09 - Aiming", "01 - Aim Toggle Key", "K") + "</color>") .Replace("<color=#7CFC00>X</color>", "<color=#7CFC00>" + KeyLabel("09 - Aiming", "02 - Aim Mode Key", "L") + "</color>") .Replace("V - Third Attack", KeyLabel("7 - Mount Attacks", "Third Attack Key", "N") + " - Third Attack") .Replace("Middle Click - Secondary Attack", "Your Valheim Secondary Attack key - Secondary Attack"); } } private void OnDestroy() { if (harmony != null) { harmony.UnpatchSelf(); } } }
plugins/MapSaveFix.dll
Decompiled 3 days agousing System; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Logging; using HarmonyLib; using ServerSideMapReborn; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] [BepInPlugin("local.profile.mapsavefix", "Profile Map Save Compatibility", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class MapSaveFix : BaseUnityPlugin { private static ManualLogSource log; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown log = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("local.profile.mapsavefix"); val.Patch((MethodBase)AccessTools.Method("ServerSideMapReborn.SaveWorld+ZnetPatchLoadMap:Postfix", (Type[])null, (Type[])null), new HarmonyMethod(typeof(MapSaveFix), "Load", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method("ServerSideMapReborn.SaveWorld+ZnetPatchSaveWorldThread:Postfix", (Type[])null, (Type[])null), new HarmonyMethod(typeof(MapSaveFix), "Save", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Cloud-safe exploration sidecar path fix active"); } private static World WorldNow() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown return (World)AccessTools.Field(typeof(ZNet), "m_world").GetValue(null); } private static string SavePath() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 World val = WorldNow(); string text = SaveSystem.GetWorldsSaveRootPath((FileSource)2); if ((int)val.m_fileSource == 4) { text = Path.Combine(text, "ServerSideMapCloud"); } Directory.CreateDirectory(text); return Path.Combine(text, ((int)val.m_fileSource == 4) ? (val.m_uid + ".mod.serversidemap.explored") : (val.m_worldName + ".mod.serversidemap.explored")); } private static bool Load() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown try { string text = SavePath(); byte[] array = (File.Exists(text) ? File.ReadAllBytes(text) : null); if (array != null && array.Length > 0) { ExplorationDatabase.SetMapData(new ZPackage(array)); } else { ExplorationDatabase.SetMapData(ExplorationDatabase.Default()); } log.LogInfo((object)("Exploration sidecar loaded: " + text)); } catch (Exception ex) { log.LogError((object)ex); ExplorationDatabase.SetMapData(ExplorationDatabase.Default()); } return false; } private static bool Save() { try { byte[] array = ExplorationDatabase.GetMapData().GetArray(); if (array.Length > 0) { AtomicFile.Write(SavePath(), array); } } catch (Exception ex) { log.LogError((object)("Exploration save failed (world save retained): " + ex)); } return false; } }
plugins/PeriodicStutterFix.dll
Decompiled 3 days agousing System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("local.profile.periodicstutterfix", "Periodic Stutter Fix", "1.7.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class PeriodicStutterFix : BaseUnityPlugin { private static readonly object gate = new object(); private static readonly HashSet<string> missing = new HashSet<string>(); private static ConfigEntry<bool> cacheEnabled; private static ConfigEntry<bool> ridingEnabled; private static ConfigEntry<bool> containerCleanup; private static ConfigEntry<bool> keyboardVibration; private static ConfigEntry<bool> blueprintPolling; private static ConfigEntry<bool> optionalBridge; private static FieldInfo blueprintWatcher; private static FieldInfo blueprintFault; private static float nextBlueprintEnsure; private static volatile bool dataForgePresent; private static ConfigEntry<bool> skipIdleSummonScans; private static ConfigEntry<bool> skipZeroRainWork; private static ConfigEntry<bool> quietRecipeMisses; private static ConfigEntry<bool> skipUnusedFoodEnumeration; private static ConfigEntry<bool> guardKinematicFloaters; private static ConfigEntry<KeyboardShortcut> unsummonKey; private static ConfigEntry<float> maxRainDamage; private static readonly List<Character> emptyCharacters = new List<Character>(); private static readonly List<IList> containerRegistries = new List<IList>(); private static PeriodicStutterFix self; private FileSystemWatcher watcher; private Harmony harmony; private static ConfigEntry<bool> fixWizardryEffects; private static bool wizardrySupported; private static readonly HashSet<string> WizardrySounds = new HashSet<string>(StringComparer.Ordinal) { "sfx_summonsurtling_cast_TW", "sfx_summonsurtling_prespawn_TW", "sfx_surtling_pet_TW", "sfx_summonsurtling_spawn_TW" }; private static readonly FieldInfo timedView = AccessTools.Field(typeof(TimedDestruction), "m_nview"); public static int SkippedFoodEnumerations { get; private set; } public static int SkippedKinematicWrites { get; private set; } public static int SkippedSummonScans { get; private set; } public static int SkippedRainChecks { get; private set; } public static int SuppressedRecipeMessages { get; private set; } public static bool BlueprintPollingApplied { get; private set; } public static bool OptionalBridgeApplied { get; private set; } public static int SkippedBlueprintPolls { get; private set; } public static int SkippedMissingBridgeLookups { get; private set; } public static int ReleasedContainerReferences { get; private set; } public static int SkippedKeyboardVibrations { get; private set; } public static int RegistryCount => containerRegistries.Count; public static int RepairedMaterialBlocks { get; private set; } public static bool RidingPatchApplied { get; private set; } public static int RepairedSoundNetworkViews { get; private set; } public static int PreventedNestedSoundViews { get; private set; } private void Awake() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown //IL_01c0: Expected O, but got Unknown //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Expected O, but got Unknown //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Expected O, but got Unknown self = this; cacheEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Optimizations", "Enable DataForge Cache", true, "Cache unsuccessful optional DataForge assembly lookups. Installing or loading an assembly invalidates the cache."); ridingEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Optimizations", "Enable Better Riding Optimization", true, "Use Valheim's live character registry for Better Riding 1.0.3 dragon tracking. Keeps bonding rules and map pins."); harmony = new Harmony("local.profile.periodicstutterfix"); containerCleanup = ((BaseUnityPlugin)this).Config.Bind<bool>("Optimizations", "Enable Container Registry Cleanup", true, "Remove only unloaded Container references from AutomaticFuel registry. Keeps inventories and access checks unchanged."); keyboardVibration = ((BaseUnityPlugin)this).Config.Bind<bool>("Optimizations", "Skip Keyboard UI Vibration Objects", true, "Do not instantiate controller-only UI vibration sound objects for mouse/keyboard input. Normal UI/world sound and active controller/touch feedback remain unchanged."); RegisterContainerList("TastyChickenLegs.AutomaticFuel", "AutomaticFuel.AutomaticFuelPlugin", "ContainerList"); RegisterContainerList("TastyChickenLegs.AutomaticFuel", "AutomaticFuel.Configs", "ContainerList"); harmony.Patch((MethodBase)AccessTools.Method(typeof(Container), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(PeriodicStutterFix), "TrackContainerLifetime", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(GamepadRumble), "PlayGlobalSelectVibration", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PeriodicStutterFix), "AllowGlobalSelectVibration", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo method = typeof(Utility).GetMethod("TryResolveDllAssembly", new Type[3] { typeof(AssemblyName), typeof(string), typeof(Assembly).MakeByRefType() }); harmony.Patch((MethodBase)method, new HarmonyMethod(typeof(PeriodicStutterFix), "Before", (Type[])null), new HarmonyMethod(typeof(PeriodicStutterFix), "After", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); AppDomain.CurrentDomain.AssemblyLoad += Loaded; InstallMeasuredOptimizations(); InstallCombatRainOptimizations(); InstallAdditionalOptimizations(); InstallNetworkEffectFix(); try { watcher = new FileSystemWatcher(Paths.PluginPath, "DataForge.dll"); watcher.IncludeSubdirectories = true; watcher.Created += Changed; watcher.Changed += Changed; watcher.Deleted += Changed; watcher.Renamed += Renamed; watcher.EnableRaisingEvents = true; } catch (Exception ex) { cacheEnabled.Value = false; ((BaseUnityPlugin)this).Logger.LogWarning((object)("DataForge cache disabled because file monitoring failed: " + ex.Message)); } if (Chainloader.PluginInfos.TryGetValue("Ygg.BetterRiding", out var value)) { if (value.Metadata.Version == new Version(1, 0, 3)) { try { Type type = ((object)value.Instance).GetType().Assembly.GetType("BetterRiding.Behaviour.BondedDragonMapTracker", throwOnError: true); harmony.Patch((MethodBase)AccessTools.Method(type, "UpdateLoadedDragons", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(PeriodicStutterFix), "OptimizeCharacterLookup", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Better Riding optimization was not applied: " + ex.Message)); } } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Better Riding optimization skipped for untested version " + value.Metadata.Version)); } } Type nestedType = typeof(MaterialMan).GetNestedType("PropertyContainer", BindingFlags.NonPublic); MethodInfo methodInfo = ((nestedType == null) ? null : AccessTools.Method(nestedType, "UpdateBlock", (Type[])null, (Type[])null)); FieldInfo fieldInfo = ((nestedType == null) ? null : AccessTools.Field(nestedType, "m_propertyBlock")); if (methodInfo != null && fieldInfo != null && fieldInfo.FieldType == typeof(MaterialPropertyBlock)) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(PeriodicStutterFix), "EnsureMaterialBlock", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"MaterialMan missing property-block initialization guard ready."); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"MaterialMan guard skipped: unsupported layout."); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("DataForge lookup cache ready; Better Riding registry optimization applied=" + RidingPatchApplied + ". Gameplay rules unchanged.")); } private void InstallMeasuredOptimizations() { //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Expected O, but got Unknown //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Expected O, but got Unknown blueprintPolling = ((BaseUnityPlugin)this).Config.Bind<bool>("Optimizations", "Throttle Blueprint Directory Checks", true, "Check Homestead's healthy blueprint directory once per second instead of every rendered frame. File change callbacks still run every frame. Reconnect errors and initial setup keep their original behavior."); optionalBridge = ((BaseUnityPlugin)this).Config.Bind<bool>("Optimizations", "Skip Missing DataForge Bridge Lookups", true, "Skip BossRules optional DataForge API discovery only while DataForge is absent. Assembly loads or a DataForge.dll filesystem event re-enable original discovery. Does not change boss rules."); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetName().Name == "DataForge") { dataForgePresent = true; } } try { using IEnumerator<string> enumerator = Directory.EnumerateFiles(Paths.PluginPath, "DataForge.dll", SearchOption.AllDirectories).GetEnumerator(); if (enumerator.MoveNext()) { string current = enumerator.Current; dataForgePresent = true; } } catch { dataForgePresent = true; } if (Chainloader.PluginInfos.TryGetValue("sighsorry.Homestead", out var value) && (value.Metadata.Version == new Version(1, 3, 5) || value.Metadata.Version == new Version(1, 3, 7))) { Type type = ((object)value.Instance).GetType().Assembly.GetType("Homestead.ZoneBlueprintDirectoryWatcher"); blueprintWatcher = AccessTools.Field(type, "_watcher"); blueprintFault = AccessTools.Field(type, "_watcherFaulted"); if (blueprintWatcher != null && blueprintFault != null) { harmony.Patch((MethodBase)AccessTools.Method(type, "Ensure", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PeriodicStutterFix), "AllowBlueprintEnsure", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(type, "Reset", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(PeriodicStutterFix), "ResetBlueprintSchedule", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); BlueprintPollingApplied = true; } } if (Chainloader.PluginInfos.TryGetValue("sighsorry.BossRules", out value) && value.Metadata.Version == new Version(1, 1, 8)) { Type type = ((object)value.Instance).GetType().Assembly.GetType("BossRules.DataForgeStatusEffectBridge"); harmony.Patch((MethodBase)AccessTools.Method(type, "TryResolveAndSubscribe", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PeriodicStutterFix), "AllowOptionalBridgeLookup", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); OptionalBridgeApplied = true; } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Measured optimizations ready: blueprint polling=" + BlueprintPollingApplied + ", optional bridge=" + OptionalBridgeApplied)); } private void InstallCombatRainOptimizations() { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Expected O, but got Unknown //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected O, but got Unknown skipIdleSummonScans = ((BaseUnityPlugin)this).Config.Bind<bool>("Optimizations", "Skip Idle Summon Dismiss Scans", true, "MagicRevamp 1.5.1: scan characters for dismissing summons only when the existing unsummon shortcut is pressed. Spell cycling is unchanged."); skipZeroRainWork = ((BaseUnityPlugin)this).Config.Bind<bool>("Optimizations", "Skip Disabled Rain Decay Work", true, "No Rain Damage 1.3.1: skip rain-decay-only checks when Max Damage is zero. Rain visuals, structural support, snow, fire and other damage remain unchanged."); quietRecipeMisses = ((BaseUnityPlugin)this).Config.Bind<bool>("Optimizations", "Suppress Repeated Recipe Miss Debug Logs", true, "Suppress only Recycle N Reclaim's repeated missing-recipe debug messages. Recipe analysis, UI explanations, warnings and errors remain active."); if (Chainloader.PluginInfos.TryGetValue("blacks7ar.MagicRevamp", out var value) && value.Metadata.Version == new Version(1, 5, 1)) { Type type = ((object)value.Instance).GetType(); unsummonKey = (ConfigEntry<KeyboardShortcut>)AccessTools.Field(type, "_unSummonKey").GetValue(null); harmony.Patch((MethodBase)AccessTools.Method(type, "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(PeriodicStutterFix), "GateSummonEnumeration", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } if (Chainloader.PluginInfos.TryGetValue("uk.co.oliapps.valheim.noraindamage", out value) && value.Metadata.Version == new Version(1, 3, 1)) { Type type = ((object)value.Instance).GetType(); maxRainDamage = (ConfigEntry<float>)AccessTools.Field(type, "maxRainDamagePercentage").GetValue(null); harmony.Patch((MethodBase)AccessTools.Method(type, "Prefix", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(PeriodicStutterFix), "GateRainDecay", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } if (Chainloader.PluginInfos.TryGetValue("Azumatt.Recycle_N_Reclaim", out value) && value.Metadata.Version == new Version(1, 4, 5)) { Type type = ((object)value.Instance).GetType().Assembly.GetType("Recycle_N_Reclaim.GamePatches.Recycling.Reclaimer", throwOnError: true); harmony.Patch((MethodBase)AccessTools.Method(type, "TryFindRecipeForItem", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(PeriodicStutterFix), "QuietMissingRecipeLog", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } } private void InstallAdditionalOptimizations() { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Expected O, but got Unknown //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Expected O, but got Unknown skipUnusedFoodEnumeration = ((BaseUnityPlugin)this).Config.Bind<bool>("Optimizations", "Skip Unused Renegade Food Enumeration", true, "RenegadeVikings 1.4.2: skip the unused food filter inside nearby-container discovery. Actual food selection, feeding, container search order, range and frequency remain unchanged."); guardKinematicFloaters = ((BaseUnityPlugin)this).Config.Bind<bool>("Optimizations", "Guard Kinematic Magic Item Physics", true, "MagicRevamp 1.5.1: avoid unsupported velocity writes and forces on kinematic floating items. Dynamic item physics, visual bobbing and terrain/height positioning remain unchanged."); if (Chainloader.PluginInfos.TryGetValue("blacks7ar.RenegadeVikings", out var value) && value.Metadata.Version == new Version(1, 4, 2)) { try { Type type = ((object)value.Instance).GetType().Assembly.GetType("RenegadeVikings.Utilities.Helper", throwOnError: true); harmony.Patch((MethodBase)AccessTools.Method(type, "GetNearbyContainers", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(PeriodicStutterFix), "RemoveUnusedFoodFilter", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"RenegadeVikings unused container-food enumeration optimization ready."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("RenegadeVikings optimization skipped: " + ex.Message)); } } if (Chainloader.PluginInfos.TryGetValue("blacks7ar.MagicRevamp", out value) && value.Metadata.Version == new Version(1, 5, 1)) { try { Type type = ((object)value.Instance).GetType().Assembly.GetType("MagicRevamp.Functions.CustomFloater", throwOnError: true); harmony.Patch((MethodBase)AccessTools.Method(type, "FixedUpdate", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(PeriodicStutterFix), "GuardFloaterPhysics", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(type, "TerrainCheck", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(PeriodicStutterFix), "GuardFloaterTerrainVelocity", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"MagicRevamp kinematic item physics guards ready."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("MagicRevamp floater guards skipped: " + ex.Message)); } } } public static IEnumerable<CodeInstruction> RemoveUnusedFoodFilter(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = 0; foreach (CodeInstruction item in list) { MethodInfo methodInfo = item.operand as MethodInfo; if (item.opcode == OpCodes.Call && methodInfo != null && methodInfo.DeclaringType == typeof(Enumerable) && methodInfo.Name == "Where" && methodInfo.IsGenericMethod && methodInfo.GetGenericArguments()[0] == typeof(ItemData) && methodInfo.GetParameters().Length == 2 && methodInfo.GetParameters()[1].ParameterType == typeof(Func<ItemData, bool>)) { item.operand = AccessTools.Method(typeof(PeriodicStutterFix), "UnusedFoodFilter", (Type[])null, (Type[])null); num++; } } if (num != 1) { throw new InvalidOperationException("Expected exactly one unused food Where filter, found " + num); } return list; } public static IEnumerable<ItemData> UnusedFoodFilter(IEnumerable<ItemData> source, Func<ItemData, bool> predicate) { if (!skipUnusedFoodEnumeration.Value) { return source.Where(predicate); } SkippedFoodEnumerations++; return Enumerable.Empty<ItemData>(); } public static IEnumerable<CodeInstruction> GuardFloaterPhysics(IEnumerable<CodeInstruction> instructions) { return ReplaceFloaterPhysics(instructions, 2, 1, 1); } public static IEnumerable<CodeInstruction> GuardFloaterTerrainVelocity(IEnumerable<CodeInstruction> instructions) { return ReplaceFloaterPhysics(instructions, 1, 0, 0); } private static IEnumerable<CodeInstruction> ReplaceFloaterPhysics(IEnumerable<CodeInstruction> instructions, int expectedLinear, int expectedAngular, int expectedForce) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = 0; int num2 = 0; int num3 = 0; MethodInfo objB = AccessTools.PropertySetter(typeof(Rigidbody), "linearVelocity"); MethodInfo objB2 = AccessTools.PropertySetter(typeof(Rigidbody), "angularVelocity"); MethodInfo objB3 = AccessTools.Method(typeof(Rigidbody), "AddForce", new Type[2] { typeof(Vector3), typeof(ForceMode) }, (Type[])null); foreach (CodeInstruction item in list) { if (!(item.opcode != OpCodes.Call) || !(item.opcode != OpCodes.Callvirt)) { string text = null; if (object.Equals(item.operand, objB)) { text = "SetFloaterLinearVelocity"; num++; } else if (object.Equals(item.operand, objB2)) { text = "SetFloaterAngularVelocity"; num2++; } else if (object.Equals(item.operand, objB3)) { text = "AddFloaterForce"; num3++; } if (text != null) { item.opcode = OpCodes.Call; item.operand = AccessTools.Method(typeof(PeriodicStutterFix), text, (Type[])null, (Type[])null); } } } if (num != expectedLinear || num2 != expectedAngular || num3 != expectedForce) { throw new InvalidOperationException("Floater call layout changed: " + num + "," + num2 + "," + num3); } return list; } private static bool UnsupportedKinematicWrite(Rigidbody body) { if (!guardKinematicFloaters.Value || (Object)(object)body == (Object)null || !body.isKinematic) { return false; } SkippedKinematicWrites++; return true; } public static void SetFloaterLinearVelocity(Rigidbody body, Vector3 velocity) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (!UnsupportedKinematicWrite(body)) { body.linearVelocity = velocity; } } public static void SetFloaterAngularVelocity(Rigidbody body, Vector3 velocity) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (!UnsupportedKinematicWrite(body)) { body.angularVelocity = velocity; } } public static void AddFloaterForce(Rigidbody body, Vector3 force, ForceMode mode) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (!UnsupportedKinematicWrite(body)) { body.AddForce(force, mode); } } private static IEnumerable<CodeInstruction> ReplaceOne(IEnumerable<CodeInstruction> code, MethodInfo from, MethodInfo to) { List<CodeInstruction> list = new List<CodeInstruction>(code); int num = 0; foreach (CodeInstruction item in list) { if ((item.opcode == OpCodes.Call || item.opcode == OpCodes.Callvirt) && object.Equals(item.operand, from)) { item.opcode = OpCodes.Call; item.operand = to; num++; } } if (num != 1) { throw new InvalidOperationException(string.Concat("Scoped optimization expected one call to ", from, ", found ", num)); } return list; } public static IEnumerable<CodeInstruction> GateSummonEnumeration(IEnumerable<CodeInstruction> code) { return ReplaceOne(code, AccessTools.Method(typeof(Character), "GetAllCharacters", (Type[])null, (Type[])null), AccessTools.Method(typeof(PeriodicStutterFix), "CharactersForDismiss", (Type[])null, (Type[])null)); } public static List<Character> CharactersForDismiss() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (skipIdleSummonScans.Value) { KeyboardShortcut value = unsummonKey.Value; if (!((KeyboardShortcut)(ref value)).IsDown()) { SkippedSummonScans++; return emptyCharacters; } } return Character.GetAllCharacters(); } public static IEnumerable<CodeInstruction> GateRainDecay(IEnumerable<CodeInstruction> code) { return ReplaceOne(code, AccessTools.Method(typeof(WearNTear), "IsWet", (Type[])null, (Type[])null), AccessTools.Method(typeof(PeriodicStutterFix), "RainDecayNeedsWetCheck", (Type[])null, (Type[])null)); } public static bool RainDecayNeedsWetCheck(WearNTear piece) { if (skipZeroRainWork.Value && maxRainDamage.Value <= 0f) { SkippedRainChecks++; return false; } return piece.IsWet(); } public static IEnumerable<CodeInstruction> QuietMissingRecipeLog(IEnumerable<CodeInstruction> code) { return ReplaceOne(code, AccessTools.Method(typeof(ManualLogSource), "LogDebug", new Type[1] { typeof(object) }, (Type[])null), AccessTools.Method(typeof(PeriodicStutterFix), "RecipeMissLog", (Type[])null, (Type[])null)); } public static void RecipeMissLog(ManualLogSource source, object message) { if (quietRecipeMisses.Value) { SuppressedRecipeMessages++; } else { source.LogDebug(message); } } public static bool AllowBlueprintEnsure() { if (!blueprintPolling.Value || blueprintWatcher.GetValue(null) == null || (bool)blueprintFault.GetValue(null)) { return true; } float realtimeSinceStartup = Time.realtimeSinceStartup; if (realtimeSinceStartup >= nextBlueprintEnsure) { nextBlueprintEnsure = realtimeSinceStartup + 1f; return true; } SkippedBlueprintPolls++; return false; } public static void ResetBlueprintSchedule() { nextBlueprintEnsure = 0f; } public static bool AllowOptionalBridgeLookup() { if (!optionalBridge.Value || dataForgePresent) { return true; } SkippedMissingBridgeLookups++; return false; } public static void EnsureMaterialBlock(ref MaterialPropertyBlock ___m_propertyBlock) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown if (___m_propertyBlock == null) { ___m_propertyBlock = new MaterialPropertyBlock(); RepairedMaterialBlocks++; if (RepairedMaterialBlocks == 1) { ((BaseUnityPlugin)self).Logger.LogInfo((object)"Initialized a missing MaterialMan property block; original rendering update will continue."); } } } private void RegisterContainerList(string guid, string type, string field) { if (Chainloader.PluginInfos.TryGetValue(guid, out var value)) { Type type2 = ((object)value.Instance).GetType().Assembly.GetType(type); FieldInfo fieldInfo = ((type2 == null) ? null : AccessTools.Field(type2, field)); IList list = ((fieldInfo == null) ? null : (fieldInfo.GetValue(null) as IList)); if (list != null) { containerRegistries.Add(list); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Container lifetime cleanup unavailable: " + guid)); } } } public static void TrackContainerLifetime(Container __instance) { if (containerCleanup.Value && !((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).GetComponent<LocalContainerRegistryLifetime>() != (Object)null)) { ((Component)__instance).gameObject.AddComponent<LocalContainerRegistryLifetime>().Target = __instance; } } public static void ReleaseContainer(Container container) { if (!containerCleanup.Value || object.ReferenceEquals(container, null)) { return; } foreach (IList containerRegistry in containerRegistries) { for (int num = containerRegistry.Count - 1; num >= 0; num--) { if (object.ReferenceEquals(containerRegistry[num], container)) { containerRegistry.RemoveAt(num); ReleasedContainerReferences++; } } } } public static bool AllowGlobalSelectVibration() { if (!keyboardVibration.Value || ZInput.IsGamepadActive() || ZInput.IsTouchActive()) { return true; } SkippedKeyboardVibrations++; return false; } private static void Clear() { lock (gate) { missing.Clear(); } } private static void Loaded(object s, AssemblyLoadEventArgs e) { if (e.LoadedAssembly.GetName().Name == "DataForge") { dataForgePresent = true; } Clear(); } private static void Changed(object s, FileSystemEventArgs e) { dataForgePresent = true; Clear(); } private static void Renamed(object s, RenamedEventArgs e) { dataForgePresent = true; Clear(); } private static bool Before(AssemblyName assemblyName, string directory, ref Assembly assembly, ref bool __result) { if (!cacheEnabled.Value || assemblyName.Name != "DataForge") { return true; } lock (gate) { if (missing.Contains(assemblyName.FullName + "|" + directory)) { assembly = null; __result = false; return false; } } return true; } private static void After(AssemblyName assemblyName, string directory, bool __result) { if (cacheEnabled.Value && assemblyName.Name == "DataForge" && !__result) { lock (gate) { missing.Add(assemblyName.FullName + "|" + directory); } } } private static IEnumerable<CodeInstruction> OptimizeCharacterLookup(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = 0; int index = -1; for (int i = 0; i < list.Count; i++) { MethodInfo methodInfo = list[i].operand as MethodInfo; if (list[i].opcode == OpCodes.Call && methodInfo != null && methodInfo.DeclaringType == typeof(Object) && methodInfo.Name == "FindObjectsOfType" && methodInfo.IsGenericMethod && methodInfo.GetGenericArguments()[0] == typeof(Character) && methodInfo.GetParameters().Length == 0) { num++; index = i; } } if (num != 1) { ((BaseUnityPlugin)self).Logger.LogWarning((object)"Better Riding lookup signature changed; optimization skipped."); return list; } list[index].operand = AccessTools.Method(typeof(PeriodicStutterFix), "GetActiveCharacters", (Type[])null, (Type[])null); RidingPatchApplied = true; return list; } public static Character[] GetActiveCharacters() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Invalid comparison between Unknown and I4 if (!ridingEnabled.Value) { return Object.FindObjectsOfType<Character>(); } List<Character> list = new List<Character>(); foreach (Character allCharacter in Character.GetAllCharacters()) { if ((Object)(object)allCharacter != (Object)null && ((Component)allCharacter).gameObject.activeInHierarchy && (((Object)allCharacter).hideFlags & 0x34) == 0 && (((Object)((Component)allCharacter).gameObject).hideFlags & 0x34) == 0) { list.Add(allCharacter); } } list.Sort((Character a, Character b) => ((Object)a).GetInstanceID().CompareTo(((Object)b).GetInstanceID())); return list.ToArray(); } private void InstallNetworkEffectFix() { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown fixWizardryEffects = ((BaseUnityPlugin)this).Config.Bind<bool>("Optimizations", "Repair Wizardry Summon Sound Networking", true, "Wizardry 1.2.3: materialize the two Surtling sound prefabs whose incoming ZDOs have no root ZNetView. Skip only nested network views of the four audited temporary Surtling sounds. Sound, timeout and summon statistics remain unchanged. Install on every peer."); wizardrySupported = Chainloader.PluginInfos.TryGetValue("Therzie.Wizardry", out var value) && value.Metadata.Version == new Version(1, 2, 3); if (wizardrySupported && timedView != null) { harmony.Patch((MethodBase)AccessTools.Method(typeof(ZNetScene), "CreateObject", new Type[1] { typeof(ZDO) }, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(PeriodicStutterFix), "RepairIncomingSoundClone", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(ZNetView), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PeriodicStutterFix), "AllowSoundNetworkView", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Wizardry 1.2.3 Surtling sound network-object repair ready."); } } public static IEnumerable<CodeInstruction> RepairIncomingSoundClone(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = 0; foreach (CodeInstruction item in list) { MethodInfo methodInfo = item.operand as MethodInfo; if (item.opcode == OpCodes.Call && methodInfo != null && methodInfo.DeclaringType == typeof(Object) && methodInfo.Name == "Instantiate" && methodInfo.IsGenericMethod && methodInfo.GetGenericArguments()[0] == typeof(GameObject) && methodInfo.GetParameters().Length == 3 && methodInfo.GetParameters()[1].ParameterType == typeof(Vector3) && methodInfo.GetParameters()[2].ParameterType == typeof(Quaternion)) { item.operand = AccessTools.Method(typeof(PeriodicStutterFix), "InstantiateNetworkSound", (Type[])null, (Type[])null); num++; } } if (num != 1) { throw new InvalidOperationException("Expected one network Instantiate<GameObject>, found " + num); } return list; } public static GameObject InstantiateNetworkSound(GameObject prefab, Vector3 position, Quaternion rotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(prefab, position, rotation); if (!fixWizardryEffects.Value || !wizardrySupported || (Object)(object)val == (Object)null || ZNetView.m_initZDO == null || (((Object)prefab).name != "sfx_summonsurtling_cast_TW" && ((Object)prefab).name != "sfx_summonsurtling_prespawn_TW") || (Object)(object)val.GetComponent<ZNetView>() != (Object)null) { return val; } ZNetView value = val.AddComponent<ZNetView>(); TimedDestruction component = val.GetComponent<TimedDestruction>(); if ((Object)(object)component != (Object)null) { timedView.SetValue(component, value); } RepairedSoundNetworkViews++; return val; } public static bool AllowSoundNetworkView(ZNetView __instance) { if (!wizardrySupported || !fixWizardryEffects.Value || (Object)(object)__instance == (Object)null) { return true; } string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject); if (!WizardrySounds.Contains(prefabName) || (Object)(object)((Component)__instance).transform.parent == (Object)null) { return true; } ZNetView componentInParent = ((Component)((Component)__instance).transform.parent).GetComponentInParent<ZNetView>(); if ((Object)(object)componentInParent == (Object)null) { return true; } Object.Destroy((Object)(object)__instance); PreventedNestedSoundViews++; return false; } private void OnDestroy() { AppDomain.CurrentDomain.AssemblyLoad -= Loaded; if (watcher != null) { watcher.Dispose(); } if (harmony != null) { harmony.UnpatchSelf(); } Clear(); containerRegistries.Clear(); } } public sealed class LocalContainerRegistryLifetime : MonoBehaviour { public Container Target; private void OnDestroy() { PeriodicStutterFix.ReleaseContainer(Target); } }
plugins/ProfileCompatibilityFix.dll
Decompiled 3 days agousing System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("local.profile.compatibilityfix", "Profile Compatibility Fix", "1.6.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ProfileCompatibilityFix : BaseUnityPlugin { private static ProfileCompatibilityFix self; private Harmony harmony; private static ConfigEntry<int> fruitMinutes; private static ConfigEntry<bool> dragonOnly; private static ConfigEntry<bool> zeroMagicWeight; private static ConfigEntry<bool> keepSummonColors; private static FieldInfo farmView; private static ConfigEntry<bool> protectFriendlyBuildings; private static ConfigEntry<bool> recoverOwnChestLease; private static ConfigEntry<bool> extendChestWait; private static FieldInfo chestSession; private static PropertyInfo chestReplay; private static float nextDragonPinPosition; private static readonly HashSet<string> WildDragons = new HashSet<string>(StringComparer.Ordinal) { "Dragon_Fire_Wild", "Dragon_Frost_Wild", "Dragon_Lightning_Wild", "Dragon_Poison_Wild" }; private static readonly HashSet<string> additionalHarvests = new HashSet<string>(StringComparer.Ordinal); public static readonly HashSet<string> Fruits = new HashSet<string>(StringComparer.Ordinal) { "RaspberryBush", "BlueberryBush", "BlueberriesVegvisirAsmodeus", "CloudberryBush", "LingonberryBush", "VineAsh", "VineGreen", "FH_RedAppleTree", "FH_PearTree", "FH_PeachTree", "FH_PomegranateTree", "BCA_TomatoPlant", "BCA_ChiliPepperPlant", "BCA_Wild_Tomato", "BCA_Wild_ChiliPepper" }; private static Func<ZDO, bool, bool> nativeCheatRead; private static readonly FieldInfo craftRecipe = AccessTools.Field(typeof(InventoryGui), "m_craftRecipe"); private static readonly FieldInfo craftItem = AccessTools.Field(typeof(InventoryGui), "m_craftUpgradeItem"); private static readonly string[] BbMethods = new string[4] { "ApplyAmmoRecipeBatchTweaks", "UpdateBearHeaddressRecipe", "ApplyMuckshakeFoodTweaks", "ApplyWeaponKnockbackTweaks" }; private static readonly HashSet<string> ZeroWeightPrefabsAllowed = new HashSet<string>(StringComparer.Ordinal) { "BMR_FireEssence", "BMR_IceEssence", "BMR_LightningEssence", "BMR_PoisonEssence", "BMR_FireScroll1", "BMR_FireScroll2", "BMR_FireScroll3", "BMR_FireScroll4", "BMR_FireScroll5", "BMR_FireScroll6", "BMR_HealScroll1", "BMR_HealScroll2", "BMR_HealScroll3", "BMR_HealScroll4", "BMR_HealScroll5", "BMR_HealScroll6", "BMR_IceScroll1", "BMR_IceScroll2", "BMR_IceScroll3", "BMR_IceScroll4", "BMR_IceScroll5", "BMR_IceScroll6", "BMR_LightningScroll1", "BMR_LightningScroll2", "BMR_LightningScroll3", "BMR_LightningScroll4", "BMR_LightningScroll5", "BMR_LightningScroll6", "BMR_PoisonScroll1", "BMR_PoisonScroll2", "BMR_PoisonScroll3", "BMR_PoisonScroll4", "BMR_PoisonScroll5", "BMR_PoisonScroll6", "BMR_BoarScroll", "BMR_NeckScroll", "BMR_GreydwarfScroll", "BMR_GreydwarfEliteScroll", "BMR_SkeletonScroll", "BMR_TrollScroll", "BMR_DraugrScroll", "BMR_DraugrRangeScroll", "BMR_AbominationScroll", "BMR_WolfScroll", "BMR_HatchlingScroll", "BMR_UlvScroll", "BMR_StoneGolem", "BMR_FenringCultistScroll", "BMR_BatScroll", "BMR_LoxScroll", "BMR_GoblinScroll", "BMR_GoblinArcherScroll", "BMR_GoblinBruteScroll", "BMR_DeathsquitoScroll", "BMR_SeekerScroll", "BMR_SeekerBruteScroll", "BMR_AsksvinScroll", "BMR_CharredMeleeScroll", "BMR_BlobLavaScroll", "BMR_BlobScroll", "BMR_BlobTarScroll", "BMR_FallenValkyrieScroll", "BMR_SurtlingScroll", "BMR_WraithScroll", "BMR_MeteorScroll", "BMR_FrostSpikeScroll", "BMR_LightningStormScroll", "BMR_PoisonMistScroll", "BMR_FireWispScroll", "BMR_PortalScroll", "BMR_ClusterBombScroll", "BMR_FrostBombScroll", "BMR_ShieldScroll", "BMR_DemisterScroll", "BMR_RepairScroll", "BMR_SailingScroll", "BMR_WoodCuttingScroll1", "BMR_WoodCuttingScroll2", "BMR_WoodCuttingScroll3", "BMR_WoodCuttingScroll4", "BMR_WoodCuttingScroll5", "BMR_WoodCuttingScroll6", "BMR_ComfortScroll1", "BMR_ComfortScroll2", "BMR_ComfortScroll3", "BMR_ComfortScroll4", "BMR_ComfortScroll5", "BMR_ComfortScroll6", "BMR_CleanseScroll1", "BMR_CleanseScroll2", "BMR_CleanseScroll3", "BMR_CleanseScroll4", "BMR_CleanseScroll5", "BMR_CleanseScroll6", "FreyjaEssence_TW", "ArcaneScroll_BlackForest_TW", "ArcaneScroll_Swamp_TW", "ArcaneScroll_Mountain_TW", "ArcaneScroll_Plains_TW", "ArcaneScroll_Mistlands_TW", "ArcaneScroll_DamageBuff_TW", "ArcaneScroll_SpeedBuff_TW", "ArcaneScroll_JumpBuff_TW", "ArcaneScroll_SlowfallBuff_TW", "Essence_Fire", "Essence_Frost", "Essence_Lightning", "Essence_Poison", "EssenceMagic", "EssenceRare", "EssenceEpic", "EssenceLegendary", "EssenceMythic", "EssenceAncient" }; private static readonly HashSet<string> ZeroWeightTokens = new HashSet<string>(StringComparer.Ordinal) { "$bmr_essence_fire", "$bmr_essence_ice", "$bmr_essence_lightning", "$bmr_essence_poison", "$bmr_scroll_fire1", "$bmr_scroll_fire2", "$bmr_scroll_fire3", "$bmr_scroll_fire4", "$bmr_scroll_fire5", "$bmr_scroll_fire6", "$bmr_scroll_heal1", "$bmr_scroll_heal2", "$bmr_scroll_heal3", "$bmr_scroll_heal4", "$bmr_scroll_heal5", "$bmr_scroll_heal6", "$bmr_scroll_ice1", "$bmr_scroll_ice2", "$bmr_scroll_ice3", "$bmr_scroll_ice4", "$bmr_scroll_ice5", "$bmr_scroll_ice6", "$bmr_scroll_lightning1", "$bmr_scroll_lightning2", "$bmr_scroll_lightning3", "$bmr_scroll_lightning4", "$bmr_scroll_lightning5", "$bmr_scroll_lightning6", "$bmr_scroll_poison1", "$bmr_scroll_poison2", "$bmr_scroll_poison3", "$bmr_scroll_poison4", "$bmr_scroll_poison5", "$bmr_scroll_poison6", "$bmr_scroll_boar", "$bmr_scroll_neck", "$bmr_scroll_greydwarf", "$bmr_scroll_greydwarfelite", "$bmr_scroll_skeleton", "$bmr_scroll_troll", "$bmr_scroll_draugr", "$bmr_scroll_draugrrange", "$bmr_scroll_abomination", "$bmr_scroll_wolf", "$bmr_scroll_hatchling", "$bmr_scroll_ulv", "$bmr_scroll_stonegolem", "$bmr_scroll_fenringcultist", "$bmr_scroll_bat", "$bmr_scroll_lox", "$bmr_scroll_goblin", "$bmr_scroll_goblinarcher", "$bmr_scroll_goblinbrute", "$bmr_scroll_deathsquito", "$bmr_scroll_seeker", "$bmr_scroll_seekerbrute", "$bmr_scroll_asksvin", "$bmr_scroll_charredmelee", "$bmr_scroll_bloblava", "$bmr_scroll_blob", "$bmr_scroll_blobtar", "$bmr_scroll_fallenvalkyrie", "$bmr_scroll_surtling", "$bmr_scroll_wraith", "$bmr_scroll_meteor", "$bmr_scroll_frostspike", "$bmr_scroll_lightningstorm", "$bmr_scroll_poisonmist", "$bmr_scroll_firewisp", "$bmr_scroll_portal", "$bmr_scroll_clusterbomb", "$bmr_scroll_frostbomb", "$bmr_scroll_shield", "$bmr_scroll_demister", "$bmr_scroll_repair", "$bmr_scroll_sailing", "$bmr_scroll_woodcutting1", "$bmr_scroll_woodcutting2", "$bmr_scroll_woodcutting3", "$bmr_scroll_woodcutting4", "$bmr_scroll_woodcutting5", "$bmr_scroll_woodcutting6", "$bmr_scroll_comfort1", "$bmr_scroll_comfort2", "$bmr_scroll_comfort3", "$bmr_scroll_comfort4", "$bmr_scroll_comfort5", "$bmr_scroll_comfort6", "$bmr_scroll_cleanse1", "$bmr_scroll_cleanse2", "$bmr_scroll_cleanse3", "$bmr_scroll_cleanse4", "$bmr_scroll_cleanse5", "$bmr_scroll_cleanse6", "$mat_freyjaessence_TW", "$arcanescroll_blackforest_TW", "$arcanescroll_swamp_TW", "$arcanescroll_mountain_TW", "$arcanescroll_plains_TW", "$arcanescroll_mistlands_TW", "$arcanescroll_damagebuff_TW", "$arcanescroll_speedbuff_TW", "$arcanescroll_jumpbuff_TW", "$arcanescroll_slowfallbuff_TW", "$item_Essence_Fire", "$item_Essence_Frost", "$item_Essence_Lightning", "$item_Essence_Poison", "$mod_epicloot_Magic $mod_epicloot_assets_essence", "$mod_epicloot_Rare $mod_epicloot_assets_essence", "$mod_epicloot_Epic $mod_epicloot_assets_essence", "$mod_epicloot_Legendary $mod_epicloot_assets_essence", "$mod_epicloot_Mythic $mod_epicloot_assets_essence", "$mod_epicloot_Ancient $mod_epicloot_assets_essence" }; private static readonly HashSet<string> patched = new HashSet<string>(); private static ConfigEntry<bool> restoreFuelKeys; private static ConfigEntry<bool> matchWorkbenchRange; private static ConfigEntry<float> workbenchMultiplier; private static ConfigEntry<float> stackRange; private static ConfigEntry<float> craftRange; private static ConfigEntry<KeyCode> fuelStationKey; private static ConfigEntry<KeyCode> fuelGlobalKey; private static readonly FieldInfo acceptableMax = AccessTools.Field(typeof(AcceptableValueRange<float>), "<MaxValue>k__BackingField"); private static ConfigEntry<bool> fixShardVariant; public static bool FarmTimingHookApplied { get; private set; } public static int BlockedFriendlyStructureHits { get; private set; } public static int RecoveredOrphanChestLeases { get; private set; } public static int ZeroWeightPrefabs { get; private set; } public static int PreventedDarkSummons { get; private set; } public static bool SummonColorHookApplied { get; private set; } public static bool DragonFilterApplied { get; private set; } public static int RepairedRespawnSchedules { get; private set; } public static int ConfiguredPlantPrefabs { get; private set; } public static int GuardedContainers { get; private set; } public static int ConfiguredFruitPrefabs { get; private set; } public static int TerrainDescriptionsFixed { get; private set; } public static int MissingEffectsRemoved { get; private set; } public static int PuzzleDefinitionsFixed { get; private set; } public static int CreatureMaterialsFixed { get; private set; } public static int RejectedUnsafeUpgrades { get; private set; } public static int LegacyCheatTargets { get; private set; } public static int NormalizedShardVariants { get; private set; } private void Awake() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Expected O, but got Unknown //IL_0245: Expected O, but got Unknown //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Expected O, but got Unknown //IL_02a0: Expected O, but got Unknown //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Expected O, but got Unknown self = this; fruitMinutes = ((BaseUnityPlugin)this).Config.Bind<int>("Farming", "Fruit Regrowth Minutes", 45, new ConfigDescription("Unified growth and regrowth minutes for plantable crops, saplings and renewable harvests. Keep PlantEverything and CookingAdditions timers consistent. All players need the same bundle/config.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 1440), new object[0])); harmony = new Harmony("local.profile.compatibilityfix"); InstallBuildingAndChestRules(); InstallProfileControlsAndRanges(); InstallShardVariantFix(); RepairBagInputCompatibility(); dragonOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "Show Only Wild Dragons", true, "Restrict BetterMap creature pins to the four Elemental Dragons wild species. Does not change resource pins or BetterRiding pet tracking. All players must install this bundle."); zeroMagicWeight = ((BaseUnityPlugin)this).Config.Bind<bool>("Inventory", "Zero Essence And Spell Weight", true, "Zero weight for the audited 15 essences and 99 spell/arcane scroll items. Excludes equipment and Ancient Scroll crafting material. All players need this bundle. Restart required when disabling."); keepSummonColors = ((BaseUnityPlugin)this).Config.Bind<bool>("Appearance", "Keep Original Summon Colors", true, "Keep original creature material colors instead of MagicRevamp's random dark grey tint on summons. Stats, textures, lighting and wild creatures stay unchanged. Restart required."); harmony.Patch((MethodBase)AccessTools.Method(typeof(ItemData), "GetWeight", new Type[1] { typeof(int) }, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ProfileCompatibilityFix), "OverrideMagicWeight", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Harmony obj = harmony; MethodInfo methodInfo = AccessTools.Method(typeof(ObjectDB), "Awake", (Type[])null, (Type[])null); HarmonyMethod val = new HarmonyMethod(typeof(ProfileCompatibilityFix), "ApplyMagicWeightPrefabs", (Type[])null); val.priority = 0; obj.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); InstallMapAndStack(); Type type = typeof(ZDO).Assembly.GetType("CheatUtils"); MethodInfo methodInfo2 = ((type == null) ? null : AccessTools.Method(type, "IsCheated", new Type[2] { typeof(ZDO), typeof(bool) }, (Type[])null)); if (methodInfo2 != null) { nativeCheatRead = (Func<ZDO, bool, bool>)Delegate.CreateDelegate(typeof(Func<ZDO, bool, bool>), methodInfo2); } Harmony obj2 = harmony; MethodInfo methodInfo3 = AccessTools.Method(typeof(Pickable), "Awake", (Type[])null, (Type[])null); HarmonyMethod val2 = new HarmonyMethod(typeof(ProfileCompatibilityFix), "FruitAwake", (Type[])null); HarmonyMethod val3 = new HarmonyMethod(typeof(ProfileCompatibilityFix), "FruitReady", (Type[])null); val3.priority = 0; obj2.Patch((MethodBase)methodInfo3, val2, val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Harmony obj3 = harmony; MethodInfo methodInfo4 = AccessTools.Method(typeof(Plant), "Awake", (Type[])null, (Type[])null); HarmonyMethod val4 = new HarmonyMethod(typeof(ProfileCompatibilityFix), "PlantReady", (Type[])null); HarmonyMethod val5 = new HarmonyMethod(typeof(ProfileCompatibilityFix), "PlantReady", (Type[])null); val5.priority = 0; obj3.Patch((MethodBase)methodInfo4, val4, val5, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Harmony obj4 = harmony; MethodInfo methodInfo5 = AccessTools.Method(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null); HarmonyMethod val6 = new HarmonyMethod(typeof(ProfileCompatibilityFix), "SceneReady", (Type[])null); val6.priority = 0; obj4.Patch((MethodBase)methodInfo5, (HarmonyMethod)null, val6, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); AppDomain.CurrentDomain.AssemblyLoad += OnAssembly; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly a in assemblies) { InstallCompat(a); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Fruit timing and scoped compatibility fixes ready."); } private void RepairBagInputCompatibility() { //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown if (!Chainloader.PluginInfos.TryGetValue("randyknapp.mods.epicloot", out var value) || value.Metadata.Version != new Version(0, 15, 1)) { return; } string[][] array = new string[2][] { new string[3] { "sighsorry.TrollingFishing", "1.1.5", "TrollingFishing.EpicLootBagCompatibility" }, new string[3] { "sighsorry.UsefulTankards", "1.0.9", "UsefulTankards.EpicLootStorageCompatibility" } }; foreach (string[] array2 in array) { if (!Chainloader.PluginInfos.TryGetValue(array2[0], out var value2) || value2.Metadata.Version != new Version(array2[1])) { continue; } try { Type type = ((object)value2.Instance).GetType().Assembly.GetType(array2[2], throwOnError: true); MethodInfo methodInfo = AccessTools.Method(type, "Initialize", Type.EmptyTypes, (Type[])null); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(ProfileCompatibilityFix), "CurrentEpicLootOverlayField", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); methodInfo.Invoke(null, null); FieldInfo fieldInfo = AccessTools.Field(type, "_unavailable"); if (fieldInfo == null || (bool)fieldInfo.GetValue(null)) { throw new InvalidOperationException("Bag input bridge remained unavailable"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Recovered " + array2[0] + " bag input bridge with Epic Loot SocketOverlayKey. Earlier startup warning is superseded.")); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Bag input recovery skipped for " + array2[0] + ": " + ex.Message)); } } } public static IEnumerable<CodeInstruction> CurrentEpicLootOverlayField(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = 0; foreach (CodeInstruction item in list) { if (item.opcode == OpCodes.Ldstr && (string)item.operand == "SocketOverlayModifier") { item.operand = "SocketOverlayKey"; num++; } } if (num != 2) { throw new InvalidOperationException("Expected two old Epic Loot setting-name references, found " + num); } return list; } private void InstallShardVariantFix() { //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown fixShardVariant = ((BaseUnityPlugin)this).Config.Bind<bool>("Compatibility", "Fix Epic Loot Shard Visual Variants", true, "Epic Loot 0.15.1: use the sole available visual variant for shard stones when rarity initialization assigns an out-of-range index. Preserves rarity, custom data, powers, item counts and valid variants."); if (Chainloader.PluginInfos.TryGetValue("randyknapp.mods.epicloot", out var value) && !(value.Metadata.Version != new Version(0, 15, 1))) { Assembly assembly = ((object)value.Instance).GetType().Assembly; string[][] array = new string[3][] { new string[2] { "EpicLoot.Crafting.ItemDrop_Awake_Patch", "InitializeItemData" }, new string[2] { "EpicLoot.Crafting.Inventory_Load_Patch", "Postfix" }, new string[2] { "EpicLoot.Crafting.Player_AddKnownItem_Patch", "Prefix" } }; foreach (string[] array2 in array) { Type type = assembly.GetType(array2[0], throwOnError: true); harmony.Patch((MethodBase)AccessTools.Method(type, array2[1], (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(ProfileCompatibilityFix), "CorrectShardVariantAssignment", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Epic Loot 0.15.1 shard visual-variant assignment fix ready."); } } public static IEnumerable<CodeInstruction> CorrectShardVariantAssignment(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); FieldInfo objB = AccessTools.Field(typeof(ItemData), "m_variant"); int num = 0; foreach (CodeInstruction item in list) { if (item.opcode == OpCodes.Stfld && object.Equals(item.operand, objB)) { item.opcode = OpCodes.Call; item.operand = AccessTools.Method(typeof(ProfileCompatibilityFix), "SetCraftingMaterialVariant", (Type[])null, (Type[])null); num++; } } if (num != 1) { throw new InvalidOperationException("Expected one Epic Loot variant assignment, found " + num); } return list; } public static void SetCraftingMaterialVariant(ItemData item, int variant) { if (fixShardVariant.Value && item != null && item.m_shared != null && item.m_shared.m_name != null && item.m_shared.m_name.Contains("$mod_epicloot_assets_shardstone") && item.m_shared.m_variants == 1 && item.m_shared.m_icons != null && item.m_shared.m_icons.Length == 1 && variant != 0) { variant = 0; NormalizedShardVariants++; } item.m_variant = variant; } private void InstallProfileControlsAndRanges() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Expected O, but got Unknown //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Expected O, but got Unknown //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Expected O, but got Unknown restoreFuelKeys = ((BaseUnityPlugin)this).Config.Bind<bool>("Controls", "Restore Automatic Fuel Hotkeys", true, "Keep AutomaticFuel 1.5.9 station toggle F9 and global toggle F10 on startup and config reload. Disable this guard before intentionally changing these two keys."); matchWorkbenchRange = ((BaseUnityPlugin)this).Config.Bind<bool>("Containers", "Match Maximum Workbench Range", true, "Set InventorySlots area quick-stack and AzuCraftyBoxes container range to the registered workbench maximum build radius multiplied by Workbench Range Multiplier. Counts unique workbench extensions. Requires same bundle on all peers."); workbenchMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Containers", "Workbench Range Multiplier", 2f, new ConfigDescription("Multiplier of the maximum registered workbench radius.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 3f), new object[0])); if (Chainloader.PluginInfos.TryGetValue("TastyChickenLegs.AutomaticFuel", out var value) && value.Metadata.Version == new Version(1, 5, 9)) { fuelStationKey = value.Instance.Config[new ConfigDefinition("Base Settings", "StationToggleKey")] as ConfigEntry<KeyCode>; fuelGlobalKey = value.Instance.Config[new ConfigDefinition("Base Settings", "Mod ToggleKey")] as ConfigEntry<KeyCode>; RestoreFuelControls(); harmony.Patch((MethodBase)AccessTools.Method(((object)value.Instance).GetType(), "ReadConfigValues", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ProfileCompatibilityFix), "RestoreFuelControls", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (Chainloader.PluginInfos.TryGetValue("sighsorry.InventorySlots", out value) && value.Metadata.Version == new Version(1, 6, 23)) { stackRange = value.Instance.Config[new ConfigDefinition("1 - General", "Area Quick Stack Range")] as ConfigEntry<float>; } if (Chainloader.PluginInfos.TryGetValue("Azumatt.AzuCraftyBoxes", out value) && value.Metadata.Version == new Version(1, 8, 28)) { craftRange = value.Instance.Config[new ConfigDefinition("2 - CraftyBoxes", "Container Range")] as ConfigEntry<float>; } if (Chainloader.PluginInfos.TryGetValue("com.ljindustries.valheim.collectionchest", out value) && value.Metadata.Version == new Version(1, 0, 0)) { Type type = ((object)value.Instance).GetType().Assembly.GetType("CollectionChest.Collector"); harmony.Patch((MethodBase)AccessTools.Method(type, "Collect", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ProfileCompatibilityFix), "AllowChestCollection", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } SetProfileRange(36f * workbenchMultiplier.Value); Harmony obj = harmony; MethodInfo methodInfo = AccessTools.Method(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null); HarmonyMethod val = new HarmonyMethod(typeof(ProfileCompatibilityFix), "ApplyWorkbenchRanges", (Type[])null); val.priority = 0; obj.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static bool AllowChestCollection(Component __instance) { if ((Object)(object)__instance == (Object)null) { return false; } Container component = __instance.GetComponent<Container>(); ZNetView component2 = __instance.GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || !component2.IsValid() || !component2.IsOwner() || component.IsInUse()) { return false; } ZDO zDO = component2.GetZDO(); long num = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetTime().Ticks : DateTime.UtcNow.Ticks); return zDO.GetLong("InventorySlots_AreaLeaseTokenV1", 0L) == 0 || zDO.GetLong("InventorySlots_AreaLeaseExpiryV1", 0L) <= num; } public static void RestoreFuelControls() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Invalid comparison between Unknown and I4 if (restoreFuelKeys.Value) { if (fuelStationKey != null && (int)fuelStationKey.Value != 290) { fuelStationKey.Value = (KeyCode)290; } if (fuelGlobalKey != null && (int)fuelGlobalKey.Value != 291) { fuelGlobalKey.Value = (KeyCode)291; } } } private static void SetProfileRange(float radius) { if (!matchWorkbenchRange.Value) { return; } ConfigEntry<float>[] array = new ConfigEntry<float>[2] { stackRange, craftRange }; foreach (ConfigEntry<float> val in array) { if (val == null) { continue; } if (((ConfigEntryBase)val).Description.AcceptableValues is AcceptableValueRange<float> val2 && val2.MaxValue < radius) { if (acceptableMax == null) { ((BaseUnityPlugin)self).Logger.LogWarning((object)("Range extension unavailable for " + ((ConfigEntryBase)val).Definition)); continue; } acceptableMax.SetValue(val2, Math.Max(200f, radius)); } if (val.Value != radius) { val.Value = radius; } } } public static void ApplyWorkbenchRanges(ZNetScene __instance) { if (!matchWorkbenchRange.Value || (Object)(object)__instance == (Object)null) { return; } GameObject prefab = __instance.GetPrefab("piece_workbench"); CraftingStation val = (((Object)(object)prefab == (Object)null) ? null : prefab.GetComponent<CraftingStation>()); if ((Object)(object)val == (Object)null) { return; } HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal); foreach (GameObject prefab2 in __instance.m_prefabs) { if (!((Object)(object)prefab2 == (Object)null)) { StationExtension component = prefab2.GetComponent<StationExtension>(); Piece component2 = prefab2.GetComponent<Piece>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component2 == (Object)null) && !((Object)(object)component.m_craftingStation == (Object)null) && !(component.m_craftingStation.m_name != val.m_name)) { hashSet.Add(component2.m_name); } } } float num = (val.m_rangeBuild + (float)hashSet.Count * val.m_extraRangePerLevel) * workbenchMultiplier.Value; SetProfileRange(num); ((BaseUnityPlugin)self).Logger.LogInfo((object)("Area stack/craft radius=" + num + "m; base=" + val.m_rangeBuild + ", extension kinds=" + hashSet.Count + ", per level=" + val.m_extraRangePerLevel)); } private void InstallBuildingAndChestRules() { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Expected O, but got Unknown //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Expected O, but got Unknown //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Expected O, but got Unknown //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Expected O, but got Unknown protectFriendlyBuildings = ((BaseUnityPlugin)this).Config.Bind<bool>("Combat", "Protect Player Buildings From Allied Creatures", true, "Prevent summoned/allied tamed creatures from damaging player-built pieces. Hostile creatures, player attacks and natural objects are unchanged. All peers need this bundle."); recoverOwnChestLease = ((BaseUnityPlugin)this).Config.Bind<bool>("Containers", "Recover Abandoned Local Transfer Locks", true, "InventorySlots 1.6.18: clear only a local-owned chest lease issued to this client when no local transfer or replay is active. Never clears another player's lease or edits chest contents."); extendChestWait = ((BaseUnityPlugin)this).Config.Bind<bool>("Containers", "Allow More Time For Chest Synchronization", true, "InventorySlots 1.6.18: allow 4 seconds for approval and 4 seconds for fresh ownership state. Original authorization, data revision and 8-second lease expiry remain enforced."); Type[] array = new Type[2] { typeof(WearNTear), typeof(Destructible) }; foreach (Type type in array) { harmony.Patch((MethodBase)AccessTools.Method(type, "Damage", new Type[1] { typeof(HitData) }, (Type[])null), new HarmonyMethod(typeof(ProfileCompatibilityFix), "ProtectBuiltPiece", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(type, "RPC_Damage", new Type[2] { typeof(long), typeof(HitData) }, (Type[])null), new HarmonyMethod(typeof(ProfileCompatibilityFix), "ProtectBuiltPiece", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (Chainloader.PluginInfos.TryGetValue("sighsorry.InventorySlots", out var value) && value.Metadata.Version == new Version(1, 6, 18)) { Type type = ((object)value.Instance).GetType(); chestSession = AccessTools.Field(type, "_containerAreaSession"); chestReplay = AccessTools.Property(type, "IsReplayingSharedContainerInteraction"); if (chestSession == null || chestReplay == null) { throw new MissingMemberException("InventorySlots transfer state changed"); } harmony.Patch((MethodBase)AccessTools.Method(type, "HasContainerAreaLease", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ProfileCompatibilityFix), "RecoverAbandonedLease", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(type, "TryRequestContainerAreaTarget", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(ProfileCompatibilityFix), "ExtendChestResponse", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(type, "RPC_ContainerAreaOwnershipResponse", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(ProfileCompatibilityFix), "ExtendChestState", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } } public static bool ProtectBuiltPiece(Component __instance, HitData hit) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (!protectFriendlyBuildings.Value || (Object)(object)__instance == (Object)null || hit == null) { return true; } Piece component = __instance.GetComponent<Piece>(); if ((Object)(object)component == (Object)null || component.GetCreator() == 0) { return true; } Character attacker = hit.GetAttacker(); if ((Object)(object)attacker == (Object)null || attacker.IsPlayer()) { return true; } if ((int)attacker.GetFaction() != 0 && !attacker.IsTamed()) { return true; } BlockedFriendlyStructureHits++; return false; } public static void RecoverAbandonedLease(ZDO zdo, ref bool __result) { if (__result && recoverOwnChestLease.Value && zdo != null && !((Object)(object)ZNet.instance == (Object)null) && chestSession.GetValue(null) == null && !(bool)chestReplay.GetValue(null, null)) { long uID = ZNet.GetUID(); if (uID != 0 && zdo.GetOwner() == uID && zdo.GetLong("InventorySlots_AreaLeaseRequesterV1", 0L) == uID) { zdo.Set("InventorySlots_AreaLeaseTokenV1", 0L); __result = false; RecoveredOrphanChestLeases++; } } } private static IEnumerable<CodeInstruction> ExtendChestConstant(IEnumerable<CodeInstruction> code, float old, string helper) { List<CodeInstruction> list = code.ToList(); int num = 0; foreach (CodeInstruction item in list) { if (item.opcode == OpCodes.Ldc_R4 && (float)item.operand == old) { item.opcode = OpCodes.Call; item.operand = AccessTools.Method(typeof(ProfileCompatibilityFix), helper, (Type[])null, (Type[])null); num++; } } if (num != 1) { throw new InvalidOperationException("InventorySlots deadline layout changed: " + helper + " matches=" + num); } return list; } public static IEnumerable<CodeInstruction> ExtendChestResponse(IEnumerable<CodeInstruction> code) { return ExtendChestConstant(code, 2.5f, "ChestResponseSeconds"); } public static IEnumerable<CodeInstruction> ExtendChestState(IEnumerable<CodeInstruction> code) { return ExtendChestConstant(code, 3f, "ChestStateSeconds"); } public static float ChestResponseSeconds() { return extendChestWait.Value ? 4f : 2.5f; } public static float ChestStateSeconds() { return extendChestWait.Value ? 4f : 3f; } private void InstallMapAndStack() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown if (Chainloader.PluginInfos.TryGetValue("xtav1m.BetterMap", out var value)) { if (value.Metadata.Version == new Version(1, 1, 0)) { Type type = ((object)value.Instance).GetType().Assembly.GetType("BetterMap.Scripts.Creatures.CreatureTracker", throwOnError: true); harmony.Patch((MethodBase)AccessTools.Method(type, "ShouldTrack", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ProfileCompatibilityFix), "FilterDragonPin", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(type, "UpdatePositions", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ProfileCompatibilityFix), "LimitDragonPinRefresh", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(type, "Tick", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(ProfileCompatibilityFix), "DragonTrackerGate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); DragonFilterApplied = true; } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Dragon-only map filter skipped for untested BetterMap version " + value.Metadata.Version)); } } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Dragon-only map filter=" + DragonFilterApplied)); } public static bool DragonPinsEnabled(ConfigEntry<bool> original) { return dragonOnly.Value || original.Value; } public static IEnumerable<CodeInstruction> DragonTrackerGate(IEnumerable<CodeInstruction> code) { List<CodeInstruction> list = code.ToList(); MethodInfo objB = AccessTools.PropertyGetter(typeof(ConfigEntry<bool>), "Value"); int num = 0; foreach (CodeInstruction item in list) { if ((item.opcode == OpCodes.Callvirt || item.opcode == OpCodes.Call) && object.Equals(item.operand, objB)) { item.opcode = OpCodes.Call; item.operand = AccessTools.Method(typeof(ProfileCompatibilityFix), "DragonPinsEnabled", (Type[])null, (Type[])null); num++; } } if (num != 1) { throw new InvalidOperationException("BetterMap creature gate changed; expected one boolean read."); } return list; } public static bool IsZeroWeightItem(ItemData item) { return item != null && item.m_shared != null && ZeroWeightTokens.Contains(item.m_shared.m_name); } public static void OverrideMagicWeight(ItemData __instance, ref float __result) { if (zeroMagicWeight.Value && IsZeroWeightItem(__instance)) { __result = 0f; } } public static void ApplyMagicWeightPrefabs() { if (!zeroMagicWeight.Value || (Object)(object)ObjectDB.instance == (Object)null) { return; } int num = 0; foreach (GameObject item in ObjectDB.instance.m_items) { if (!((Object)(object)item == (Object)null) && ZeroWeightPrefabsAllowed.Contains(((Object)item).name)) { ItemDrop component = item.GetComponent<ItemDrop>(); if (!((Object)(object)component == (Object)null)) { component.m_itemData.m_shared.m_weight = 0f; num++; } } } ZeroWeightPrefabs = num; } public static bool KeepSummonColor(GameObject __0) { if (keepSummonColors.Value && (Object)(object)__0 != (Object)null && ((Object)__0).name.StartsWith("BMR_Summon", StringComparison.Ordinal)) { PreventedDarkSummons++; return false; } return true; } public static bool IsWildDragonName(string name) { return name != null && WildDragons.Contains(name.Replace("(Clone)", "").Trim()); } public static bool FilterDragonPin(Character __0, ref bool __result) { if (!dragonOnly.Value) { return true; } if ((Object)(object)__0 == (Object)null || !IsWildDragonName(((Object)((Component)__0).gameObject).name)) { __result = false; return false; } return true; } public static bool LimitDragonPinRefresh() { if (!dragonOnly.Value) { return true; } if (Time.unscaledTime < nextDragonPinPosition) { return false; } nextDragonPinPosition = Time.unscaledTime + 0.2f; return true; } private static void OnAssembly(object sender, AssemblyLoadEventArgs e) { self.InstallCompat(e.LoadedAssembly); } private void Patch(Type t, string method, string prefix) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown if (!(t == null)) { MethodInfo method2 = t.GetMethod(method, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (method2 != null) { harmony.Patch((MethodBase)method2, new HarmonyMethod(typeof(ProfileCompatibilityFix), prefix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } private void InstallCompat(Assembly a) { //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Expected O, but got Unknown //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Expected O, but got Unknown string name = a.GetName().Name; if ((name != "CraftyCartsRemake" && name != "ValheimBB" && name != "DowngradeableIdols" && name != "TerrainTools" && name != "NoBuildDust" && name != "More_World_Locations_AIO" && name != "ReforgedPotential" && name != "EpicLoot" && name != "MagicRevamp" && name != "FarmHeim") || !patched.Add(name)) { return; } try { PluginInfo value; if (name == "FarmHeim") { if (Chainloader.PluginInfos.TryGetValue("marlthon.FarmHeim", out value) && value.Metadata.Version == new Version(0, 4, 0)) { Type type = a.GetType("FarmHeim.FarmPlantSystem", throwOnError: true); farmView = AccessTools.Field(type, "m_nview"); if (farmView == null) { throw new MissingFieldException("FarmPlantSystem.m_nview"); } harmony.Patch((MethodBase)AccessTools.Method(type, "SortearDuracaoDoCiclo", new Type[1] { typeof(bool) }, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ProfileCompatibilityFix), "FarmNewCycle", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(type, "ObterDuracaoAtualDoCiclo", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ProfileCompatibilityFix), "FarmCurrentCycle", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); FarmTimingHookApplied = true; } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"FarmHeim timing fix skipped for untested version."); } } if (name == "CraftyCartsRemake") { Patch(a.GetType("CraftyCartsRemake.CCR_ChangeContainerInventorySize"), "Postfix", "CartGuard"); } if (name == "ValheimBB") { Type[] types = a.GetTypes(); foreach (Type type in types) { string[] bbMethods = BbMethods; foreach (string method in bbMethods) { Patch(type, method, "ReadyDatabase"); } MethodInfo method2 = type.GetMethod("EnsureValheimBBCompendiumEntries", BindingFlags.Static | BindingFlags.NonPublic); if (method2 != null) { harmony.Patch((MethodBase)method2, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(ProfileCompatibilityFix), "OptionalTutorialField", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } } } if (name == "DowngradeableIdols") { Patch(a.GetType("DowngradeableIdols.Plugin"), "Apply", "ReadyIdols"); } if (name == "TerrainTools") { Type[] types = a.GetTypes(); foreach (Type type in types) { Patch(type, "SetDescription", "SetTerrainDescription"); } } if (name == "NoBuildDust") { Patch(a.GetType("NoBuildDust.ZNetSceneAwakePatch"), "Postfix", "CleanMissingEffects"); } if (name == "More_World_Locations_AIO") { Patch(a.GetType("More_World_Locations_AIO.Dungeons.Packs.DungeonPackRegistrar"), "Register", "RepairPuzzleDefinition"); } if (name == "ReforgedPotential") { Type type = a.GetType("ReforgedPotential.ReforgedPotential+InventoryGuiPatch"); Patch(type, "DoCraftingPrefix", "ReforgedRequirements"); PatchLegacyCheat(type, "DoCraftingPrefix"); } if (name == "MagicRevamp") { if (Chainloader.PluginInfos.TryGetValue("blacks7ar.MagicRevamp", out value) && value.Metadata.Version == new Version(1, 5, 1)) { Type type = a.GetType("MagicRevamp.Functions.SummonHelper", throwOnError: true); MethodInfo method2 = AccessTools.Method(type, "ChangeColor", new Type[2] { typeof(GameObject), typeof(Color) }, (Type[])null); if (method2 == null) { throw new MissingMethodException("MagicRevamp SummonHelper.ChangeColor"); } harmony.Patch((MethodBase)method2, new HarmonyMethod(typeof(ProfileCompatibilityFix), "KeepSummonColor", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); SummonColorHookApplied = true; } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Summon color fix skipped for untested MagicRevamp version."); } } if (name == "EpicLoot") { PatchLegacyCheat(a.GetType("EpicLoot.CraftingV2.Piece_DropResources_Patch"), "Postfix"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Installed scoped compatibility for " + name)); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Compatibility initialization failed for " + name + ": " + ex)); } } private void PatchLegacyCheat(Type t, string name) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown if (!(t == null) && nativeCheatRead != null) { MethodInfo methodInfo = AccessTools.Method(t, name, (Type[])null, (Type[])null); if (!(methodInfo == null)) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(ProfileCompatibilityFix), "ModernCheatRead", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); LegacyCheatTargets++; } } } private static IEnumerable<CodeInstruction> ModernCheatRead(IEnumerable<CodeInstruction> code) { MethodInfo old = AccessTools.Method(typeof(ZDO), "GetBool", new Type[2] { typeof(int), typeof(bool) }, (Type[])null); foreach (CodeInstruction c in code) { if ((c.opcode == OpCodes.Call || c.opcode == OpCodes.Callvirt) && object.Equals(c.operand, old)) { c.opcode = OpCodes.Call; c.operand = AccessTools.Method(typeof(ProfileCompatibilityFix), "ReadCheatRevision", (Type[])null, (Type[])null); } yield return c; } } public static bool ReadCheatRevision(ZDO zdo, int key, bool fallback) { return (key == ZDOVars.s_cheated && nativeCheatRead != null) ? nativeCheatRead(zdo, fallback) : zdo.GetBool(key, fallback); } public static bool ReforgedRequirements(InventoryGui __0, Player __1, ref bool __result) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown if ((Object)(object)__1 == (Object)null || (Object)(object)__0 == (Object)null) { __result = false; RejectedUnsafeUpgrades++; return false; } CraftingStation currentCraftingStation = __1.GetCurrentCraftingStation(); if ((Object)(object)currentCraftingStation == (Object)null || !currentCraftingStation.m_upgrader) { return true; } Recipe val = (Recipe)craftRecipe.GetValue(__0); ItemData val2 = (ItemData)craftItem.GetValue(__0); bool flag = (Object)(object)val != (Object)null && (Object)(object)val.m_item != (Object)null && val2 != null && ((Humanoid)__1).GetInventory().ContainsItem(val2) && val.m_resources != null && val.m_resources.Any((Requirement r) => r != null && r.m_upgraderResource && (Object)(object)r.m_resItem != (Object)null); if (flag) { int num = val2.m_quality + 1; int num2 = default(int); ItemData val3 = default(ItemData); val.GetAmount(num, ref num2, ref val3, 1); flag = (__1.NoCostCheat() || ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGlobalKey((GlobalKeys)25)) || __1.HaveRequirements(val, false, num, 1)) && (!val.m_requireOnlyOneIngredient || val3 != null); } if (flag) { return true; } __result = false; RejectedUnsafeUpgrades++; return false; } public static bool CartGuard(Container __0) { if ((Object)(object)__0 == (Object)null || AccessTools.Field(typeof(Container), "m_nview").GetValue(__0) == null || __0.GetInventory() == null) { GuardedContainers++; return false; } return true; } public static bool ReadyDatabase(ObjectDB __0) { return (Object)(object)__0 != (Object)null && __0.m_recipes != null && __0.m_recipes.Count > 100 && (Object)(object)__0.GetItemPrefab("Wood") != (Object)null; } public static bool ReadyIdols(ObjectDB __0) { return ReadyDatabase(__0) && (Object)(object)ZNetScene.instance != (Object)null && (Object)(object)ZNetScene.instance.GetPrefab("piece_workbench") != (Object)null; } public static void RepairPuzzleDefinition(object __0) { if (__0 == null) { return; } Type type = __0.GetType(); PropertyInfo property = type.GetProperty("Name"); if (property == null || (string)property.GetValue(__0, null) != "UndergroundRuins") { return; } PropertyInfo property2 = type.GetProperty("CustomPrefabs"); Array array = ((property2 == null) ? null : (property2.GetValue(__0, null) as Array)); if (array == null) { return; } object obj = null; foreach (object item in array) { if (item != null) { string text = (string)item.GetType().GetProperty("Name").GetValue(item, null); if (text == "8_PuzzleStand") { return; } if (text == "0_PuzzleStand") { obj = item; } } } if (obj == null) { ((BaseUnityPlugin)self).Logger.LogWarning((object)"Puzzle repair skipped: original stand definition unavailable."); return; } object obj2 = Activator.CreateInstance(obj.GetType()); PropertyInfo[] properties = obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo propertyInfo in properties) { if (propertyInfo.CanRead && propertyInfo.CanWrite && propertyInfo.GetIndexParameters().Length == 0) { propertyInfo.SetValue(obj2, propertyInfo.GetValue(obj, null), null); } } obj2.GetType().GetProperty("Name").SetValue(obj2, "8_PuzzleStand", null); Array array2 = Array.CreateInstance(array.GetType().GetElementType(), array.Length + 1); Array.Copy(array, array2, array.Length); array2.SetValue(obj2, array.Length); property2.SetValue(__0, array2, null); PuzzleDefinitionsFixed++; } public static void RepairCreatureShaders() { Shader val = null; ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { return; } GameObject prefab = instance.GetPrefab("Boar"); Material[] sharedMaterials; if ((Object)(object)prefab != (Object)null) { Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren) { sharedMaterials = val2.sharedMaterials; foreach (Material val3 in sharedMaterials) { if ((Object)(object)val3 != (Object)null && (Object)(object)val3.shader != (Object)null && ((Object)val3.shader).name == "Custom/Creature" && val3.shader.isSupported) { val = val3.shader; break; } } } } if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)self).Logger.LogWarning((object)"Creature shader repair skipped: supported vanilla shader unavailable."); return; } sharedMaterials = Resources.FindObjectsOfTypeAll<Material>(); foreach (Material val3 in sharedMaterials) { if ((Object)(object)val3 != (Object)null && (Object)(object)val3.shader != (Object)null && ((Object)val3.shader).name == "Custom/Creature" && !val3.shader.isSupported) { val3.shader = val; CreatureMaterialsFixed++; } } } public static bool SetTerrainDescription(string __0, string __1) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown Type type = Type.GetType("Jotunn.Managers.PrefabManager, Jotunn"); object value = type.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy).GetValue(null, null); MethodInfo method = type.GetMethod("GetPrefab", new Type[1] { typeof(string) }); GameObject val = (GameObject)method.Invoke(value, new object[1] { __0 }); Piece val2 = (((Object)(object)val == (Object)null) ? null : val.GetComponent<Piece>()); if ((Object)(object)val2 != (Object)null) { val2.m_description = __1; TerrainDescriptionsFixed++; } else { ((BaseUnityPlugin)self).Logger.LogWarning((object)("Terrain description target genuinely absent: " + __0)); } return false; } public static void CleanMissingEffects(ZNetScene __0) { foreach (GameObject prefab in __0.m_prefabs) { if (!((Object)(object)prefab == (Object)null)) { Piece component = prefab.GetComponent<Piece>(); if ((Object)(object)component != (Object)null) { CleanEffects(component.m_placeEffect); } WearNTear component2 = prefab.GetComponent<WearNTear>(); if ((Object)(object)component2 != (Object)null) { CleanEffects(component2.m_destroyedEffect); } } } } private static void CleanEffects(EffectList effects) { if (effects == null) { return; } if (effects.m_effectPrefabs == null) { effects.m_effectPrefabs = (EffectData[])(object)new EffectData[0]; return; } int num = effects.m_effectPrefabs.Length; effects.m_effectPrefabs = effects.m_effectPrefabs.Where((EffectData x) => x != null && (Object)(object)x.m_prefab != (Object)null).ToArray(); MissingEffectsRemoved += num - effects.m_effectPrefabs.Length; } private static IEnumerable<CodeInstruction> OptionalTutorialField(IEnumerable<CodeInstruction> code) { MethodInfo original = AccessTools.Method(typeof(AccessTools), "Field", new Type[2] { typeof(Type), typeof(string) }, (Type[])null); foreach (CodeInstruction c in code) { if (c.opcode == OpCodes.Call && object.Equals(c.operand, original)) { c.operand = AccessTools.Method(typeof(ProfileCompatibilityFix), "FindOptionalField", (Type[])null, (Type[])null); } yield return c; } } public static FieldInfo FindOptionalField(Type t, string name) { while (t != null) { FieldInfo field = t.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return field; } t = t.BaseType; } return null; } public static void FruitAwake(Pickable __instance) { SetFruit(__instance); } private static string PrefabName(GameObject go) { return ((Object)go).name.Replace("(Clone)", "").Trim(); } private static bool SetFruit(Pickable p) { if ((Object)(object)p == (Object)null) { return false; } string item = PrefabName(((Component)p).gameObject); if (!Fruits.Contains(item) && !additionalHarvests.Contains(item)) { return false; } p.m_respawnTimeMinutes = fruitMinutes.Value; return true; } public static void FruitReady(Pickable __instance) { if (SetFruit(__instance)) { ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if ((Object)(object)component != (Object)null && component.IsValid() && ((Component)__instance).gameObject.activeInHierarchy && !((MonoBehaviour)__instance).IsInvoking("UpdateRespawn")) { ((MonoBehaviour)__instance).InvokeRepeating("UpdateRespawn", 2f, 60f); RepairedRespawnSchedules++; } } } public static void PlantReady(Plant __instance) { if ((Object)(object)__instance != (Object)null && (Object)(object)((Component)__instance).GetComponent<Piece>() != (Object)null && __instance.m_grownPrefabs != null && __instance.m_grownPrefabs.Length > 0) { __instance.m_growTime = fruitMinutes.Value * 60; __instance.m_growTimeMax = fruitMinutes.Value * 60; } } public static void FarmNewCycle(ref float __result) { __result = (float)fruitMinutes.Value * 60f; } public static void FarmCurrentCycle(object __instance, ref double __result) { object? value = farmView.GetValue(__instance); ZNetView val = (ZNetView)((value is ZNetView) ? value : null); if ((Object)(object)val != (Object)null && val.IsValid() && val.GetZDO() != null) { __result = (double)fruitMinutes.Value * 60.0; } } private static void RegisterHarvests() { if ((Object)(object)ObjectDB.instance == (Object)null || (Object)(object)ZNetScene.instance == (Object)null) { return; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Cultivator"); ItemDrop val = (((Object)(object)itemPrefab == (Object)null) ? null : itemPrefab.GetComponent<ItemDrop>()); PieceTable val2 = (((Object)(object)val == (Object)null) ? null : val.m_itemData.m_shared.m_buildPieces); if ((Object)(object)val2 != (Object)null) { foreach (GameObject piece in val2.m_pieces) { if (!((Object)(object)piece == (Object)null)) { Pickable component = piece.GetComponent<Pickable>(); if ((Object)(object)component != (Object)null && component.m_respawnTimeMinutes > 0f && (Object)(object)component.m_itemPrefab != (Object)null && ((Object)component.m_itemPrefab).name != "Wood" && ((Object)component.m_itemPrefab).name != "Stone" && ((Object)component.m_itemPrefab).name != "Flint") { additionalHarvests.Add(((Object)piece).name); } } } } int num = 0; foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if (!((Object)(object)prefab == (Object)null)) { Plant component2 = prefab.GetComponent<Plant>(); if ((Object)(object)component2 != (Object)null && (Object)(object)((Component)component2).GetComponent<Piece>() != (Object)null && component2.m_grownPrefabs.Length > 0) { PlantReady(component2); num++; } } } ConfiguredPlantPrefabs = num; } private static void SceneReady(ZNetScene __instance) { int num = 0; foreach (GameObject prefab in __instance.m_prefabs) { if ((Object)(object)prefab != (Object)null && SetFruit(prefab.GetComponent<Pickable>())) { num++; } } ConfiguredFruitPrefabs = num; ((MonoBehaviour)self).StartCoroutine(self.DelayedReady()); } private IEnumerator DelayedReady() { yield return null; yield return null; ApplyMagicWeightPrefabs(); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetName().Name == "DowngradeableIdols") { Type type = assembly.GetType("DowngradeableIdols.Plugin"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "Apply", (Type[])null, (Type[])null)); if (methodInfo != null) { methodInfo.Invoke(null, new object[1] { ObjectDB.instance }); } } } if (!((Object)(object)ZNetScene.instance != (Object)null)) { yield break; } RegisterHarvests(); int num = 0; foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if ((Object)(object)prefab != (Object)null && SetFruit(prefab.GetComponent<Pickable>())) { num++; } } ConfiguredFruitPrefabs = num; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Harvest intervals set to " + fruitMinutes.Value + " minutes: " + num + " renewable harvest prefabs, " + ConfiguredPlantPrefabs + " plants.")); RepairCreatureShaders(); } private void OnDestroy() { AppDomain.CurrentDomain.AssemblyLoad -= OnAssembly; if (harmony != null) { harmony.UnpatchSelf(); } } }