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 Lethargique Company Fixes v1.3.0
LethargiqueFixes.dll
Decompiled 4 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using DunGen; using DunGen.Graph; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using Unity.Collections; using Unity.Netcode; using Unity.Netcode.Transports.UTP; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Utilities; using UnityEngine.Profiling; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was partially or fully created with the assistance of Generative AI (code, refactoring and documentation), reviewed and tested by its author.")] [assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic (Claude)")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LethargiqueFixes { [BepInPlugin("0.LethargiqueCompany.LethargiqueFixes.Avance", "Lethargique Fixes (avant les autres mods)", "1.3.0")] public class PluginAvance : BaseUnityPlugin { public const string Guid = "0.LethargiqueCompany.LethargiqueFixes.Avance"; private void Awake() { if (Plugin.Log == null) { Plugin.Log = ((BaseUnityPlugin)this).Logger; } Avance.Demarrer(((BaseUnityPlugin)this).Logger); } } internal static class Avance { private static ManualLogSource _log; private static Harmony _h; private static bool _scrap; private static bool _tulip; private static bool _turbo; internal static bool ScrapPose; internal static bool TulipPose; internal static bool TurboPose; internal static void Demarrer(ManualLogSource log) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown _log = log; try { string fichier = Path.Combine(Paths.ConfigPath, "LethargiqueCompany.LethargiqueFixes.cfg"); _scrap = Actif(fichier, "ButteRyBalance", "FixScrapCountWithLategameUpgrades"); _tulip = Actif(fichier, "EnemySoundFixes", "FixTulipSnakeChuckle"); _turbo = Actif(fichier, "LategameUpgrades", "FixTurboTankWithButteRyBalance"); _h = new Harmony("0.LethargiqueCompany.LethargiqueFixes.Avance"); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Essayer(assemblies[i]); } if (!Fini()) { AppDomain.CurrentDomain.AssemblyLoad += SurChargement; } log.LogInfo((object)("Avant les autres mods : recherches corrigées posées pour" + Etat() + (Fini() ? "." : " ; le reste à l'arrivée de ces mods."))); } catch (Exception ex) { log.LogWarning((object)("Avant les autres mods : démarrage impossible (" + ex.Message + ") ; le plugin principal s'en chargera.")); } } private static void SurChargement(object sender, AssemblyLoadEventArgs e) { try { bool scrapPose = ScrapPose; bool tulipPose = TulipPose; bool turboPose = TurboPose; Essayer(e.LoadedAssembly); if ((ScrapPose && !scrapPose) || (TulipPose && !tulipPose) || (TurboPose && !turboPose)) { _log.LogInfo((object)("Avant les autres mods : " + e.LoadedAssembly.GetName().Name + " chargé, recherche corrigée posée avant ses patchs.")); } if (Fini()) { AppDomain.CurrentDomain.AssemblyLoad -= SurChargement; } } catch (Exception ex) { _log.LogWarning((object)("Avant les autres mods : " + ex.Message)); } } private static void Essayer(Assembly a) { if (!(a == null) && !a.IsDynamic) { string name = a.GetName().Name; if (_scrap && !ScrapPose && name == "ButteRyBalance") { ScrapPose = ButteRyBalanceScrapFix.ApplyEarly(_h, a); } if (_tulip && !TulipPose && name == "EnemySoundFixes") { TulipPose = TulipSnakeChuckleFix.ApplyEarly(_h, a); } if (_turbo && !TurboPose && name == "LategameCompanyCruiserUpgrades") { TurboPose = TurboTankFix.ApplyEarly(_h, a); } } } private static bool Fini() { if ((!_scrap || ScrapPose) && (!_tulip || TulipPose)) { if (_turbo) { return TurboPose; } return true; } return false; } private static string Etat() { return (ScrapPose ? " scrap (ButteRyBalance)" : "") + (TulipPose ? " serpent (EnemySoundFixes)" : "") + (TurboPose ? " turbo (Cruiser Upgrades)" : "") + ((!ScrapPose && !TulipPose && !TurboPose) ? " rien encore" : ""); } private static bool Actif(string fichier, string section, string cle) { if (!File.Exists(fichier)) { return true; } string text = null; string[] array = File.ReadAllLines(fichier); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); if (text2.StartsWith("[") && text2.EndsWith("]")) { text = text2.Substring(1, text2.Length - 2); } else if (text == section && text2.StartsWith(cle + " ") && text2.Contains("=")) { return !text2.Substring(text2.IndexOf('=') + 1).Trim().Equals("false", StringComparison.OrdinalIgnoreCase); } } return true; } internal static Type Trouver(string nomComplet) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (!assembly.IsDynamic) { Type type = assembly.GetType(nomComplet, throwOnError: false); if (type != null) { return type; } } } return null; } } internal static class BetterSavesFix { private const string FilesPanel = "Canvas/MenuContainer/LobbyHostSettings/FilesPanel"; internal static bool Apply(Harmony h) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown Type type = TypeIndex.Find("LCBetterSaves.Plugin"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "Postfix", new Type[1] { typeof(MenuManager) }, (Type[])null)); if (methodInfo == null) { return false; } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(BetterSavesFix), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool Prefix() { return (Object)(object)GameObject.Find("Canvas/MenuContainer/LobbyHostSettings/FilesPanel") != (Object)null; } } internal static class ButteRyBalanceScrapFix { private static FieldInfo _maxScrap; private static FieldInfo _maxValue; private static MethodInfo _next; private static bool _logged; internal static bool ApplyEarly(Harmony h, Assembly a) { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown Type type = a.GetType("ButteRyBalance.Patches.RoundManagerPatches", throwOnError: false); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "RoundManager_Trans_SpawnScrapInLevel", (Type[])null, (Type[])null)); _maxScrap = AccessTools.Field(typeof(SelectableLevel), "maxScrap"); _maxValue = AccessTools.Field(typeof(Item), "maxValue"); _next = AccessTools.Method(typeof(Random), "Next", new Type[2] { typeof(int), typeof(int) }, (Type[])null); if (methodInfo == null || _maxScrap == null || _maxValue == null || _next == null) { return false; } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(ButteRyBalanceScrapFix), "TheirTranspilerPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } internal static bool Apply(Harmony h) { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown Type type = TypeIndex.Find("ButteRyBalance.Patches.RoundManagerPatches"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "RoundManager_Trans_SpawnScrapInLevel", (Type[])null, (Type[])null)); MethodInfo methodInfo2 = AccessTools.Method(typeof(RoundManager), "SpawnScrapInLevel", Type.EmptyTypes, (Type[])null); _maxScrap = AccessTools.Field(typeof(SelectableLevel), "maxScrap"); _maxValue = AccessTools.Field(typeof(Item), "maxValue"); _next = AccessTools.Method(typeof(Random), "Next", new Type[2] { typeof(int), typeof(int) }, (Type[])null); if (methodInfo == null || methodInfo2 == null || _maxScrap == null || _maxValue == null || _next == null) { return false; } if (!Avance.ScrapPose) { h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(ButteRyBalanceScrapFix), "TheirTranspilerPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } h.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(ButteRyBalanceScrapFix), "Check", (Type[])null) { priority = 0 }, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool TheirTranspilerPrefix(IEnumerable<CodeInstruction> instructions, ref IEnumerable<CodeInstruction> __result) { try { List<CodeInstruction> list = new List<CodeInstruction>(instructions); int done; List<int> list2 = FindBounds(list, out done); if (list2.Count + done < 3) { return true; } AddPlusOne(list, list2); __result = list; return false; } catch (Exception ex) { Plugin.Log.LogWarning((object)("ButteRyBalance : remplacement du transpiler des objets impossible (" + ex.Message + ").")); return true; } } private static IEnumerable<CodeInstruction> Check(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); try { int done; List<int> list2 = FindBounds(list, out done); int count = list2.Count; AddPlusOne(list, list2); if (!_logged) { _logged = true; if (done + count >= 3) { Plugin.Log.LogInfo((object)("ButteRyBalance : nombre d'objets maximum de nouveau atteignable (conflit avec Lategame Upgrades réglé, " + (done + count) + " tirages corrigés" + ((count > 0) ? (", dont " + count + " par le correctif") : "") + ").")); } else { Plugin.Log.LogWarning((object)("ButteRyBalance : forme inattendue de SpawnScrapInLevel, seulement " + (done + count) + " tirage(s) sur 3 corrigé(s).")); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("ButteRyBalance : vérification du tirage des objets impossible (" + ex.Message + ").")); return instructions; } return list; } private static List<int> FindBounds(List<CodeInstruction> codes, out int done) { List<int> list = new List<int>(); done = 0; for (int i = 1; i < codes.Count; i++) { if (codes[i].opcode != OpCodes.Callvirt || !object.Equals(codes[i].operand, _next)) { continue; } int num = i - 1; bool flag = num >= 1 && codes[num].opcode == OpCodes.Add && codes[num - 1].opcode == OpCodes.Ldc_I4_1; if (flag) { num -= 2; } if (num >= 0 && IsIntToIntStaticCall(codes[num])) { num--; } if (num < 0 || codes[num].opcode != OpCodes.Ldfld) { continue; } FieldInfo objA = codes[num].operand as FieldInfo; if (object.Equals(objA, _maxScrap) || object.Equals(objA, _maxValue)) { if (flag) { done++; } else { list.Add(i); } } } return list; } private static bool IsIntToIntStaticCall(CodeInstruction ci) { if (ci.opcode != OpCodes.Call || !(ci.operand is MethodInfo { IsStatic: not false } methodInfo) || methodInfo.ReturnType != typeof(int)) { return false; } ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 1) { return parameters[0].ParameterType == typeof(int); } return false; } private static void AddPlusOne(List<CodeInstruction> codes, List<int> positions) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown for (int num = positions.Count - 1; num >= 0; num--) { int index = positions[num]; CodeInstruction val = new CodeInstruction(OpCodes.Ldc_I4_1, (object)null); val.labels.AddRange(codes[index].labels); codes[index].labels.Clear(); codes.InsertRange(index, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[2] { val, new CodeInstruction(OpCodes.Add, (object)null) }); } } } internal static class CasinoDoubleDownFix { private static MethodInfo _onActivate; private static MemberInfo _inputActions; private static bool _logged; internal static bool Apply(Harmony h) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown Type type = TypeIndex.Find("LethalCasinoTweaks.Components.BlackjackDoubleDownFeature"); _onActivate = ((type == null) ? null : AccessTools.Method(type, "OnActivateDoubleDown", (Type[])null, (Type[])null)); if (_onActivate == null) { return false; } Type type2 = TypeIndex.Find("LethalCasinoTweaks.LethalCasinoTweaks"); if (type2 != null) { _inputActions = (MemberInfo)(((object)AccessTools.Property(type2, "InputActions")) ?? ((object)AccessTools.Field(type2, "InputActions"))); } h.Patch((MethodBase)_onActivate, new HarmonyMethod(typeof(CasinoDoubleDownFix), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool Prefix(MonoBehaviour __instance) { if (__instance == null || (Object)(object)__instance != (Object)null) { return true; } try { Unsubscribe(__instance); } catch (Exception) { } return false; } private static void Unsubscribe(MonoBehaviour dead) { if (_inputActions == null) { return; } object obj = ((_inputActions is PropertyInfo propertyInfo) ? propertyInfo.GetValue(null, null) : ((FieldInfo)_inputActions).GetValue(null)); if (obj == null) { return; } Type type = obj.GetType(); MemberInfo memberInfo = (MemberInfo)(((object)AccessTools.Property(type, "DoubleDownKey")) ?? ((object)AccessTools.Field(type, "DoubleDownKey"))); object obj2 = ((memberInfo is PropertyInfo propertyInfo2) ? propertyInfo2.GetValue(obj, null) : ((memberInfo is FieldInfo fieldInfo) ? fieldInfo.GetValue(obj) : null)); if (obj2 == null) { return; } EventInfo eventInfo = obj2.GetType().GetEvent("performed"); if (eventInfo == null) { return; } Delegate obj3 = Delegate.CreateDelegate(eventInfo.EventHandlerType, dead, _onActivate, throwOnBindFailure: false); if ((object)obj3 != null) { eventInfo.RemoveEventHandler(obj2, obj3); if (!_logged) { _logged = true; Plugin.Log.LogInfo((object)"LethalCasinoTweaks : touche « double down » détachée d'une table de blackjack disparue."); } } } } internal static class ClientSaveGuard { private static readonly Regex SaveFile = new Regex("LCSaveFile\\d+", RegexOptions.IgnoreCase); private static FieldInfo _cachedFiles; private static readonly HashSet<string> Reported = new HashSet<string>(); private static int _blocked; private static bool IsJoinedClient { get { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.IsClient) { return !singleton.IsServer; } return false; } } internal static bool Apply(Harmony h) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown Type type = TypeIndex.Find("LethalPerformance.Utilities.ES3SaverTask"); Type type2 = TypeIndex.Find("ES3File"); MethodInfo methodInfo = ((type == null || type2 == null) ? null : AccessTools.Method(type, "ScheduleSaveFor", new Type[1] { type2 }, (Type[])null)); _cachedFiles = ((type2 == null) ? null : AccessTools.Field(type2, "cachedFiles")); if (methodInfo == null || _cachedFiles == null || !_cachedFiles.IsStatic) { return false; } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(ClientSaveGuard), "SchedulePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool SchedulePrefix(object __0) { try { if (__0 == null || !IsJoinedClient) { return true; } if (!(_cachedFiles.GetValue(null) is IDictionary dictionary)) { return true; } string text = null; foreach (DictionaryEntry item in dictionary) { if (item.Value == __0) { text = item.Key as string; break; } } if (text == null || !SaveFile.IsMatch(text)) { return true; } dictionary.Remove(text); _blocked++; string stack; string text2 = FindOrigin(out stack); if (Reported.Add(text2)) { Plugin.Log.LogWarning((object)("Sauvegarde : un mod a voulu écrire dans « " + text + " » chez un joueur (pas l'hôte) : écriture bloquée, le fichier n'est pas modifié. Origine : " + text2 + ".\n" + stack)); } else { Plugin.Log.LogInfo((object)("Sauvegarde : écriture dans « " + text + " » chez un joueur bloquée (" + _blocked + " en tout).")); } return false; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Sauvegarde : vérification d'une écriture côté joueur impossible (" + ex.Message + ").")); return true; } } private static string FindOrigin(out string stack) { StackFrame[] obj = new StackTrace(2, fNeedFileInfo: false).GetFrames() ?? new StackFrame[0]; StringBuilder stringBuilder = new StringBuilder(); string text = null; int num = 0; StackFrame[] array = obj; for (int i = 0; i < array.Length; i++) { MethodBase method = array[i].GetMethod(); if (!(method == null)) { string text2 = ((method.DeclaringType != null) ? method.DeclaringType.FullName : "?"); string text3 = text2 + "." + method.Name; if (num < 12) { stringBuilder.Append(" ").Append(text3).Append('\n'); num++; } if (text == null && !text2.StartsWith("ES3") && !text2.StartsWith("LethalPerformance") && !text2.StartsWith("HarmonyLib") && !text2.StartsWith("LethargiqueFixes") && !text2.StartsWith("System") && !text3.Contains("Trampoline")) { text = text3; } } } stack = stringBuilder.ToString().TrimEnd(); return text ?? "inconnue"; } } internal static class CodeRebirthCrateFix { private static FieldInfo _shopList; private static bool _logged; internal static bool Apply(Harmony h) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown Type type = TypeIndex.Find("CodeRebirth.src.Content.Maps.ItemCrate"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "GetRandomShopItem", Type.EmptyTypes, (Type[])null)); _shopList = ((type == null) ? null : AccessTools.Field(type, "ShopItemList")); if (methodInfo == null || _shopList == null || !_shopList.IsStatic || _shopList.FieldType != typeof(List<Item>)) { return false; } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(CodeRebirthCrateFix), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static void Prefix() { try { if (!(_shopList.GetValue(null) is List<Item> { Count: <=0 } list)) { return; } Terminal val = Object.FindObjectOfType<Terminal>(); if ((Object)(object)val == (Object)null || val.buyableItemsList == null) { return; } Item[] buyableItemsList = val.buyableItemsList; foreach (Item val2 in buyableItemsList) { if ((Object)(object)val2 != (Object)null && !val2.isScrap && (Object)(object)val2.spawnPrefab != (Object)null && !list.Contains(val2)) { list.Add(val2); } } if (!_logged && list.Count > 0) { _logged = true; Plugin.Log.LogInfo((object)("CodeRebirth : liste des objets de la caisse en bois vide, remplie avec les " + list.Count + " objets vendus par le terminal.")); } } catch (Exception ex) { if (!_logged) { _logged = true; Plugin.Log.LogWarning((object)("CodeRebirth : liste de la caisse en bois non remplie (" + ex.Message + ").")); } } } } internal static class CodeRebirthHologramFix { private static PropertyInfo _hologramObject; private static Type _proBuilderMesh; internal static bool Apply(Harmony h) { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown Type type = TypeIndex.Find("CodeRebirth.src.Content.DevTools.HologramCopy"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "SetUpHologram", new Type[1] { typeof(GameObject) }, (Type[])null)); _hologramObject = ((type == null) ? null : AccessTools.Property(type, "HologramObject")); if (methodInfo == null || _hologramObject == null || _hologramObject.PropertyType != typeof(GameObject) || _hologramObject.GetSetMethod(nonPublic: true) == null) { return false; } _proBuilderMesh = TypeIndex.Find("UnityEngine.ProBuilder.ProBuilderMesh"); h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(CodeRebirthHologramFix), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool Keep(Component c) { if (!(c is Transform) && !(c is MeshFilter) && !(c is Renderer)) { if (_proBuilderMesh != null) { return _proBuilderMesh.IsInstanceOfType(c); } return false; } return true; } private static bool Prefix(object __instance, GameObject __0) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__0 == (Object)null) { return true; } GameObject val; try { val = Object.Instantiate<GameObject>(__0, Vector3.zero, Quaternion.identity); } catch { return true; } try { _hologramObject.SetValue(__instance, val, null); ((Object)val).name = ((Object)val).name + " - HologramCopy"; List<Component> list = new List<Component>(); Component[] componentsInChildren = val.GetComponentsInChildren<Component>(); foreach (Component val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null && !Keep(val2)) { list.Add(val2); } } RemoveInOrder(list); val.SetActive(false); } catch (Exception ex) { Plugin.Log.LogWarning((object)("CodeRebirth : hologramme de « " + ((Object)__0).name + " » préparé partiellement (" + ex.Message + ").")); try { val.SetActive(false); } catch { } } return false; } private static void RemoveInOrder(List<Component> list) { bool flag = true; while (list.Count > 0 && flag) { flag = false; for (int num = list.Count - 1; num >= 0; num--) { Component val = list[num]; if ((Object)(object)val == (Object)null) { list.RemoveAt(num); flag = true; } else if (!IsRequiredByOther(val)) { Object.DestroyImmediate((Object)(object)val); list.RemoveAt(num); flag = true; } } } foreach (Component item in list) { if ((Object)(object)item != (Object)null) { Object.Destroy((Object)(object)item); } } } private static bool IsRequiredByOther(Component target) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown Type type = ((object)target).GetType(); Component[] components = target.GetComponents<Component>(); foreach (Component val in components) { if ((Object)(object)val == (Object)null || val == target) { continue; } object[] customAttributes = ((object)val).GetType().GetCustomAttributes(typeof(RequireComponent), inherit: true); for (int j = 0; j < customAttributes.Length; j++) { RequireComponent val2 = (RequireComponent)customAttributes[j]; if ((val2.m_Type0 != null && val2.m_Type0.IsAssignableFrom(type)) || (val2.m_Type1 != null && val2.m_Type1.IsAssignableFrom(type)) || (val2.m_Type2 != null && val2.m_Type2.IsAssignableFrom(type))) { return true; } } } return false; } } internal static class CruiserUpgradesSyncFix { private static PropertyInfo _storeInstance; private static int _skipped; internal static bool Apply(Harmony h) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown Type type = TypeIndex.Find("LategameCompanyCruiserUpgrades.Misc.PluginConfig"); Type type2 = TypeIndex.Find("MoreShipUpgrades.Managers.LguStore"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "PluginConfig_InitialSyncCompleted", (Type[])null, (Type[])null)); _storeInstance = ((type2 == null) ? null : AccessTools.Property(type2, "Instance")); MethodInfo methodInfo2 = ((_storeInstance == null) ? null : _storeInstance.GetGetMethod(nonPublic: true)); if (methodInfo == null || methodInfo2 == null || !methodInfo2.IsStatic || !typeof(NetworkBehaviour).IsAssignableFrom(type2)) { return false; } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(CruiserUpgradesSyncFix), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool Prefix() { try { object? value = _storeInstance.GetValue(null, null); NetworkBehaviour val = (NetworkBehaviour)((value is NetworkBehaviour) ? value : null); if ((Object)(object)val != (Object)null && val.IsSpawned) { return true; } _skipped++; if (_skipped == 1 || _skipped % 20 == 0) { Plugin.Log.LogInfo((object)("Lategame Cruiser Upgrades : reconstruction de Lategame Upgrades reportée (son LguStore n'est pas encore arrivé ; Lategame Upgrades la refait dès qu'il apparaît). " + _skipped + " fois depuis le lancement.")); } return false; } catch (Exception) { return true; } } } internal static class CultureFixes { private static readonly HashSet<string> Logged = new HashSet<string>(); internal static bool ApplyScopophobia(Harmony h) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown Type type = TypeIndex.Find("Scopophobia.Utils"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "ToFloatsArray", new Type[1] { typeof(string) }, (Type[])null)); if (methodInfo == null || methodInfo.ReturnType != typeof(float[])) { return false; } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(CultureFixes), "ToFloatsPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool ToFloatsPrefix(string __0, ref float[] __result) { try { List<float> list = new List<float>(); if (!string.IsNullOrWhiteSpace(__0)) { string[] array = __0.Split(','); for (int i = 0; i < array.Length; i++) { if (float.TryParse(array[i].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { list.Add(result); } } } __result = list.ToArray(); if (Logged.Add(__0 ?? "")) { Plugin.Log.LogInfo((object)("Scopophobia : courbe d'apparition du Shy Guy lue au format des configs (« " + __0 + " » → " + list.Count + " valeur(s)).")); } return false; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Scopophobia : lecture de la courbe impossible, lecture d'origine utilisée. " + ex.Message)); return true; } } } internal static class ScopophobiaMoonsFix { internal static bool Apply(Harmony h) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown Type type = TypeIndex.Find("Scopophobia.EnemyDataManager"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "SetEnemyDataForCurrentLevel", Type.EmptyTypes, (Type[])null)); if (methodInfo == null) { return false; } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(ScopophobiaMoonsFix), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool Prefix() { try { SelectableLevel val = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.currentLevel : null); return (Object)(object)val == (Object)null || val.spawnEnemiesAndScrap; } catch { return true; } } } internal static class CustomStoryLogsFix { private static FieldInfo _registered; private static FieldInfo _unlockedVar; private static PropertyInfo _value; private static readonly HashSet<int> Logged = new HashSet<int>(); internal static bool Apply(Harmony h) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown Type type = TypeIndex.Find("CustomStoryLogs.CustomStoryLogs"); if (type == null) { return false; } MethodInfo methodInfo = AccessTools.Method(type, "ReceiveUnlockFromClient", new Type[2] { typeof(int), typeof(ulong) }, (Type[])null); _registered = AccessTools.Field(type, "RegisteredLogs"); _unlockedVar = AccessTools.Field(type, "UnlockedNetwork"); if (methodInfo == null || _registered == null || !typeof(IDictionary).IsAssignableFrom(_registered.FieldType)) { return false; } if (_unlockedVar != null) { _value = AccessTools.Property(_unlockedVar.FieldType, "Value"); } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(CustomStoryLogsFix), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool Prefix(int logID) { try { if (!(_registered.GetValue(null) is IDictionary dictionary)) { return true; } if (!dictionary.Contains(logID)) { if (Logged.Count < 100 && Logged.Add(logID)) { Plugin.Log.LogInfo((object)("CustomStoryLogs : un document demande le journal " + logID + ", qui n'existe dans aucun fichier de journaux installé (documents de Musema) : ignoré.")); } return false; } if (_value != null) { object value = _unlockedVar.GetValue(null); List<int> list = ((value != null) ? (_value.GetValue(value, null) as List<int>) : null); if (list != null && list.Contains(logID)) { return false; } } } catch (Exception) { } return true; } } internal static class DawnClientSaveGuard { private static readonly Regex SaveFile = new Regex("^(Contract|Save)LCSaveFile\\d+$", RegexOptions.IgnoreCase); private static PropertyInfo _fileName; private static readonly HashSet<string> Reported = new HashSet<string>(); internal static bool Apply(Harmony h) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown Type type = TypeIndex.Find("Dawn.PersistentDataContainer"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "SaveAsync", Type.EmptyTypes, (Type[])null)); _fileName = ((type == null) ? null : AccessTools.Property(type, "FileName")); if (methodInfo == null || _fileName == null || methodInfo.ReturnType != typeof(Task)) { return false; } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(DawnClientSaveGuard), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool Prefix(object __instance, ref Task __result) { try { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null || !singleton.IsClient || singleton.IsServer) { return true; } if (!(_fileName.GetValue(__instance, null) is string text) || !SaveFile.IsMatch(text)) { return true; } lock (Reported) { if (Reported.Add(text)) { Plugin.Log.LogInfo((object)("DawnLib : écriture de « " + text + " » évitée chez ce joueur (partie de l'hôte) : sa propre sauvegarde reste intacte. Message affiché une fois par fichier.")); } } __result = Task.CompletedTask; return false; } catch (Exception) { return true; } } } internal static class DawnNameplateFix { private static FieldInfo _usernameText; private static bool _logged; internal static bool Apply(Harmony h) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown Type type = TypeIndex.Find("Dawn.Internal.PlayerNameplateUI"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "Setup", new Type[1] { typeof(PlayerControllerB) }, (Type[])null)); _usernameText = ((type == null) ? null : AccessTools.Field(type, "_usernameText")); if (methodInfo == null || _usernameText == null) { return false; } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(DawnNameplateFix), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool Prefix(object __instance, PlayerControllerB __0) { try { GameNetworkManager instance = GameNetworkManager.Instance; bool flag = (Object)(object)instance != (Object)null && !instance.disableSteam; if ((Object)(object)__0 != (Object)null && flag && __0.playerSteamId != 0L) { return true; } object value = _usernameText.GetValue(__instance); PropertyInfo propertyInfo = ((value != null) ? AccessTools.Property(value.GetType(), "text") : null); if (propertyInfo == null) { return true; } propertyInfo.SetValue(value, ((Object)(object)__0 != (Object)null) ? __0.playerUsername : string.Empty, null); if (!_logged) { _logged = true; Plugin.Log.LogInfo((object)("DawnLib : étiquette de joueur de l'écran de trajet sans avatar (" + (flag ? "joueur pas encore identifié par Steam" : "partie en LAN") + ") : nom seul, sans l'erreur cachée. Message affiché une seule fois.")); } return false; } catch (Exception) { return true; } } } internal static class DawnPlayerRefFix { private static FieldRef<object, int> _playerId; private static int _count; private static bool _logged; internal static bool Apply(Harmony h) { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown Type type = TypeIndex.Find("Dawn.Utils.PlayerControllerReference"); if (type == null) { return false; } MethodInfo methodInfo = null; MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public); foreach (MethodInfo methodInfo2 in methods) { if (!(methodInfo2.Name != "op_Implicit") && !(methodInfo2.ReturnType != typeof(PlayerControllerB))) { ParameterInfo[] parameters = methodInfo2.GetParameters(); if (parameters.Length == 1 && parameters[0].ParameterType == type) { methodInfo = methodInfo2; } } } FieldInfo fieldInfo = AccessTools.Field(type, "_playerID"); if (methodInfo == null || fieldInfo == null || fieldInfo.IsStatic || fieldInfo.FieldType != typeof(int)) { return false; } _playerId = AccessTools.FieldRefAccess<int>(type, "_playerID"); h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(DawnPlayerRefFix), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool Prefix(object __0, ref PlayerControllerB __result) { try { if (__0 == null || _playerId.Invoke(__0) != -1) { return true; } } catch (Exception) { return true; } __result = null; _count++; if (!_logged) { _logged = true; Plugin.Log.LogInfo((object)"DawnLib : référence « aucun joueur » convertie en null au lieu d'une erreur (SnailCat de CodeRebirth). Message affiché une seule fois."); } return false; } } internal static class DawnVehicleItemSaveFix { private static MethodInfo _find; private static bool _logged; internal static bool Apply(Harmony h) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown Type type = TypeIndex.Find("Dawn.Internal.ItemSaveDataHandler"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "SaveAllItems", (Type[])null, (Type[])null)); MethodInfo methodInfo2 = AccessTools.FirstMethod(typeof(Object), (Func<MethodInfo, bool>)((MethodInfo m) => m.Name == "FindObjectsOfType" && m.IsGenericMethodDefinition && m.GetParameters().Length == 0)); _find = ((methodInfo2 == null) ? null : methodInfo2.MakeGenericMethod(typeof(GrabbableObject))); if (methodInfo == null || _find == null) { return false; } h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(DawnVehicleItemSaveFix), "Transpiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { int n = 0; foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Call && object.Equals(instruction.operand, _find)) { instruction.operand = AccessTools.Method(typeof(DawnVehicleItemSaveFix), "ObjetsASauver", (Type[])null, (Type[])null); n++; } yield return instruction; } if (n == 0) { Plugin.Log.LogWarning((object)"DawnLib : liste des objets à sauvegarder introuvable, rien n'a été changé (manuel du Cruiser)."); } } private static GrabbableObject[] ObjetsASauver() { GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>(); try { HashSet<Item> hashSet = Secondaires(); if (hashSet.Count == 0) { return array; } List<GrabbableObject> list = new List<GrabbableObject>(array.Length); int num = 0; string text = null; GrabbableObject[] array2 = array; foreach (GrabbableObject val in array2) { bool flag = (Object)(object)val != (Object)null && (Object)(object)((NetworkBehaviour)val).NetworkObject != (Object)null && ((NetworkBehaviour)val).NetworkObject.IsSceneObject == true; if ((Object)(object)val != (Object)null && !flag && (Object)(object)val.itemProperties != (Object)null && hashSet.Contains(val.itemProperties)) { num++; text = text ?? ((Object)val).name; } else { list.Add(val); } } if (num > 0 && !_logged) { _logged = true; Plugin.Log.LogInfo((object)("DawnLib : " + num + " objet(s) livré(s) avec un véhicule (ex. " + text + ") laissé(s) hors de la sauvegarde, comme dans le jeu d'origine (plus d'erreur « doesn't have a DawnItemInfo »).")); } return (num > 0) ? list.ToArray() : array; } catch (Exception ex) { Plugin.Log.LogWarning((object)("DawnLib : tri des objets à sauvegarder impossible (" + ex.Message + ") ; liste complète gardée.")); return array; } } private static HashSet<Item> Secondaires() { HashSet<Item> hashSet = new HashSet<Item>(); Terminal val = Object.FindObjectOfType<Terminal>(); StartOfRound instance = StartOfRound.Instance; if ((Object)(object)val == (Object)null || val.buyableVehicles == null || (Object)(object)instance == (Object)null || (Object)(object)instance.allItemsList == (Object)null) { return hashSet; } BuyableVehicle[] buyableVehicles = val.buyableVehicles; foreach (BuyableVehicle val2 in buyableVehicles) { if (val2 == null || (Object)(object)val2.secondaryPrefab == (Object)null) { continue; } GrabbableObject[] componentsInChildren = val2.secondaryPrefab.GetComponentsInChildren<GrabbableObject>(true); foreach (GrabbableObject val3 in componentsInChildren) { if ((Object)(object)val3.itemProperties != (Object)null && !instance.allItemsList.itemsList.Contains(val3.itemProperties)) { hashSet.Add(val3.itemProperties); } } } return hashSet; } } internal static class DiversityLongBoiFix { private static bool _found; internal static bool Apply(Harmony h) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown Type type = TypeIndex.Find("DiversityRemastered.Monsters.LongBoiAI"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.DeclaredMethod(type, "DelayTeleport", (Type[])null, (Type[])null)); MethodInfo methodInfo2 = ((methodInfo == null) ? null : AccessTools.EnumeratorMoveNext((MethodBase)methodInfo)); if (methodInfo2 == null) { return false; } _found = false; h.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(DiversityLongBoiFix), "Transpiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); return _found; } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerControllerB), "actualClientId"); FieldInfo fieldInfo2 = AccessTools.Field(typeof(PlayerControllerB), "playerClientId"); List<CodeInstruction> list = new List<CodeInstruction>(instructions); if (fieldInfo == null || fieldInfo2 == null || fieldInfo.FieldType != fieldInfo2.FieldType) { return list; } foreach (CodeInstruction item in list) { if (item.opcode == OpCodes.Ldfld && CodeInstructionExtensions.LoadsField(item, fieldInfo, false)) { item.operand = fieldInfo2; _found = true; } } return list; } } internal static class DuplicatePrefabFix { private static FieldInfo _hash; private static int _logged; private const int MaxLogs = 30; private static readonly HashSet<uint> Collided = new HashSet<uint>(); internal static bool Apply(Harmony h) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown _hash = AccessTools.Field(typeof(NetworkObject), "GlobalObjectIdHash"); MethodInfo methodInfo = AccessTools.Method(typeof(NetworkPrefabs), "AddPrefabRegistration", new Type[1] { typeof(NetworkPrefab) }, (Type[])null); if (_hash == null || _hash.FieldType != typeof(uint) || methodInfo == null) { return false; } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(DuplicatePrefabFix), "Prefix", (Type[])null) { priority = 800 }, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool Prefix(NetworkPrefabs __instance, NetworkPrefab __0, ref bool __result) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) try { if (__instance == null || __0 == null || (int)__0.Override != 0 || (Object)(object)__0.Prefab == (Object)null) { return true; } NetworkObject component = __0.Prefab.GetComponent<NetworkObject>(); Dictionary<uint, NetworkPrefab> networkPrefabOverrideLinks = __instance.NetworkPrefabOverrideLinks; if ((Object)(object)component == (Object)null || networkPrefabOverrideLinks == null) { return true; } uint num = (uint)_hash.GetValue(component); string name = ((Object)__0.Prefab).name; if (num == 0) { uint num2 = ByName(networkPrefabOverrideLinks, name, 0u); _hash.SetValue(component, num2); Log("« " + name + " » n'avait pas de numéro (0) ; nouveau numéro " + num2 + "."); return true; } if (networkPrefabOverrideLinks.TryGetValue(num, out var value) && value != null && (Object)(object)value.Prefab != (Object)null) { if ((Object)(object)value.Prefab == (Object)(object)__0.Prefab) { __result = false; return false; } if (((Object)value.Prefab).name == name) { Log("« " + name + " » : copie d'un objet déjà enregistré sous le même nom et le même numéro, ignorée."); __result = false; return false; } Collided.Add(num); NetworkObject val = (((int)value.Override == 0) ? value.Prefab.GetComponent<NetworkObject>() : null); if ((Object)(object)val != (Object)null && (uint)_hash.GetValue(val) == num) { uint num3 = ByName(networkPrefabOverrideLinks, ((Object)value.Prefab).name, num); networkPrefabOverrideLinks.Remove(num); _hash.SetValue(val, num3); networkPrefabOverrideLinks[num3] = value; Log("« " + ((Object)value.Prefab).name + " » partageait son numéro (" + num + ") avec « " + name + " » ; nouveau numéro " + num3 + "."); } uint num4 = ByName(networkPrefabOverrideLinks, name, num); _hash.SetValue(component, num4); Log("« " + name + " » avait le numéro de « " + ((Object)value.Prefab).name + " » (" + num + ") ; nouveau numéro " + num4 + "."); return true; } if (Collided.Contains(num)) { uint num5 = ByName(networkPrefabOverrideLinks, name, num); _hash.SetValue(component, num5); Log("« " + name + " » avait un numéro déjà en conflit (" + num + ") ; nouveau numéro " + num5 + "."); } } catch (Exception ex) { if (_logged++ < 30) { Plugin.Log.LogWarning((object)("Modèles réseau : vérification des doublons impossible (" + ex.Message + ").")); } } return true; } private static uint ByName(Dictionary<uint, NetworkPrefab> links, string name, uint oldHash) { string text = name + "\n" + oldHash; uint num = Fnv(text); int num2 = 1; while (num == 0 || links.ContainsKey(num)) { num = Fnv(text + "\n" + num2); num2++; } return num; } private static uint Fnv(string s) { uint num = 2166136261u; for (int i = 0; i < s.Length; i++) { num ^= s[i]; num *= 16777619; } return num; } private static void Log(string msg) { if (_logged++ < 30) { Plugin.Log.LogInfo((object)("Modèles réseau : " + msg)); } } } internal static class GhostConnectionFix { private struct Pending { public ulong ClientId; public int Frame; public string Who; } private static FieldInfo _connectionManager; private static FieldInfo _transportToClient; private static readonly List<Pending> Queue = new List<Pending>(); private static GameObject _runner; private static int _cleaned; private static readonly string[] SkipAssemblies = new string[9] { "Unity.", "UnityEngine", "Facepunch", "0Harmony", "HarmonyX", "MonoMod", "LethargiqueFixes", "mscorlib", "System" }; internal static bool Apply(Harmony h) { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown _connectionManager = AccessTools.Field(typeof(NetworkManager), "ConnectionManager"); _transportToClient = ((_connectionManager == null) ? null : AccessTools.Field(_connectionManager.FieldType, "TransportIdToClientIdMap")); if (_transportToClient == null || !typeof(Dictionary<ulong, ulong>).IsAssignableFrom(_transportToClient.FieldType)) { return false; } int num = 0; Type[] array = new Type[2] { typeof(UnityTransport), TypeIndex.Find("Netcode.Transports.Facepunch.FacepunchTransport") }; foreach (Type type in array) { MethodInfo methodInfo = ((type == null) ? null : AccessTools.DeclaredMethod(type, "DisconnectRemoteClient", new Type[1] { typeof(ulong) }, (Type[])null)); if (!(methodInfo == null)) { h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(GhostConnectionFix), "AfterTransportDisconnect", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); num++; } } return num > 0; } private static void AfterTransportDisconnect(ulong __0) { try { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer || !singleton.IsListening || singleton.ShutdownInProgress) { return; } object value = _connectionManager.GetValue(singleton); Dictionary<ulong, ulong> dictionary = ((value == null) ? null : (_transportToClient.GetValue(value) as Dictionary<ulong, ulong>)); if (dictionary == null || !dictionary.TryGetValue(__0, out var value2) || value2 == 0L || !IsListed(singleton, value2)) { return; } for (int i = 0; i < Queue.Count; i++) { if (Queue[i].ClientId == value2) { return; } } Queue.Add(new Pending { ClientId = value2, Frame = Time.frameCount, Who = CallerMod() }); EnsureRunner(); } catch (Exception) { } } private static bool IsListed(NetworkManager nm, ulong clientId) { IReadOnlyList<ulong> connectedClientsIds = nm.ConnectedClientsIds; for (int i = 0; i < connectedClientsIds.Count; i++) { if (connectedClientsIds[i] == clientId) { return true; } } return false; } internal static void Process() { if (Queue.Count == 0) { return; } NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer || !singleton.IsListening) { Queue.Clear(); return; } int frameCount = Time.frameCount; for (int num = Queue.Count - 1; num >= 0; num--) { Pending pending = Queue[num]; if (frameCount > pending.Frame) { Queue.RemoveAt(num); try { if (IsListed(singleton, pending.ClientId)) { singleton.DisconnectClient(pending.ClientId); _cleaned++; string text = "Réseau : le joueur n° " + pending.ClientId + " avait été coupé directement dans le transport par " + pending.Who + ", sans prévenir Netcode (joueur fantôme : envois en boucle vers lui, place gardée). Netcode a fait sa déconnexion : place libérée, plus d'envois (" + _cleaned + " depuis le lancement)."; Plugin.Log.LogWarning((object)text); NetDiag.EnsureLog(); NetDiag.Write(text); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Réseau : déconnexion propre du joueur n° " + pending.ClientId + " impossible (" + ex.GetType().Name + " : " + ex.Message + ").")); } } } } private static void EnsureRunner() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (!((Object)(object)_runner != (Object)null)) { _runner = new GameObject("LethargiqueFixes.GhostConnections"); Object.DontDestroyOnLoad((Object)(object)_runner); ((Object)_runner).hideFlags = (HideFlags)61; _runner.AddComponent<GhostConnectionRunner>(); } } private static string CallerMod() { try { StackFrame[] array = new StackTrace(1, fNeedFileInfo: false).GetFrames() ?? new StackFrame[0]; for (int i = 0; i < array.Length; i++) { MethodBase method = array[i].GetMethod(); Type type = ((method != null) ? method.DeclaringType : null); if (type == null) { continue; } string name = type.Assembly.GetName().Name; bool flag = false; string[] skipAssemblies = SkipAssemblies; foreach (string value in skipAssemblies) { if (name.StartsWith(value, StringComparison.Ordinal)) { flag = true; break; } } if (!flag) { return name + " (" + type.Name + "." + method.Name + ")"; } } } catch (Exception) { } return "un mod inconnu"; } } internal sealed class GhostConnectionRunner : MonoBehaviour { private void Update() { GhostConnectionFix.Process(); } } internal static class ImmersiveEntranceFix { private static PropertyInfo _outside; private static PropertyInfo _inside; private static PropertyInfo _doorPortal; private static FieldInfo _linked; private static bool _outsideTried; private static bool _insideTried; private static readonly HashSet<string> Logged = new HashSet<string>(); internal static bool Apply(Harmony h) { //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown Type type = TypeIndex.Find("com.github.zehsteam.ImmersiveEntrance.Managers.EntranceManager"); Type type2 = TypeIndex.Find("com.github.zehsteam.ImmersiveEntrance.Objects.MainEntranceData"); if (type == null || type2 == null) { return false; } MethodInfo methodInfo = AccessTools.Method(type, "LinkMainEntrancePortals", Type.EmptyTypes, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(type, "SpawnDoorPortal", new Type[1] { typeof(EntranceTeleport) }, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(type, "Reset", Type.EmptyTypes, (Type[])null); _outside = AccessTools.Property(type, "OutsideMainEntrance"); _inside = AccessTools.Property(type, "InsideMainEntrance"); _linked = AccessTools.Field(type, "_linkedMainEntrancePortals"); _doorPortal = AccessTools.Property(type2, "DoorPortal"); if (methodInfo == null || methodInfo2 == null || methodInfo3 == null || _outside == null || _inside == null || _linked == null || _linked.FieldType != typeof(bool) || _doorPortal == null) { return false; } h.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(ImmersiveEntranceFix), "SpawnPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(ImmersiveEntranceFix), "ResetPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(ImmersiveEntranceFix), "LinkPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static void SpawnPrefix(EntranceTeleport entranceTeleport) { if (!((Object)(object)entranceTeleport == (Object)null) && entranceTeleport.entranceId == 0) { if (entranceTeleport.isEntranceToBuilding) { _outsideTried = true; } else { _insideTried = true; } } } private static void ResetPostfix() { _outsideTried = false; _insideTried = false; } private static bool LinkPrefix() { try { if ((bool)_linked.GetValue(null)) { return true; } MonoBehaviour val = Portal(_outside.GetValue(null)); MonoBehaviour val2 = Portal(_inside.GetValue(null)); if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { return true; } _linked.SetValue(null, true); if (!_outsideTried && !_insideTried) { return false; } if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)((Component)val2).gameObject); } string text = (((Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.currentLevel != (Object)null) ? StartOfRound.Instance.currentLevel.PlanetName : "?"); string text2 = (((Object)(object)val == (Object)null && (Object)(object)val2 == (Object)null) ? "dehors et dedans" : (((Object)(object)val == (Object)null) ? "dehors" : "dedans")); if (Logged.Count < 50 && Logged.Add(text + "|" + text2)) { Plugin.Log.LogInfo((object)("ImmersiveEntrance : porte principale non reconnue (" + text2 + ") sur " + text + " ; porte normale pour cette manche.")); } return false; } catch (Exception ex) { Plugin.Log.LogWarning((object)("ImmersiveEntrance : " + ex.Message)); return true; } } private static MonoBehaviour Portal(object mainEntranceData) { if (mainEntranceData == null) { return null; } object? value = _doorPortal.GetValue(mainEntranceData); MonoBehaviour val = (MonoBehaviour)((value is MonoBehaviour) ? value : null); if (!((Object)(object)val != (Object)null)) { return null; } return val; } } internal static class StableJoinCheck { private static FieldInfo _links; private static MethodInfo _clear; private static Dictionary<uint, NetworkPrefab> _snapshot; private static readonly Dictionary<uint, string> _names = new Dictionary<uint, string>(); private static bool _bypass; private static bool _broken; internal static bool Apply(Harmony h) { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown //IL_0120: Expected O, but got Unknown _links = AccessTools.Field(typeof(NetworkPrefabs), "NetworkPrefabOverrideLinks"); _clear = AccessTools.Method(typeof(NetworkConfig), "ClearConfigHash", (Type[])null, (Type[])null); MethodInfo methodInfo = AccessTools.Method(typeof(NetworkConfig), "GetConfig", new Type[1] { typeof(bool) }, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(NetworkManager), "StartHost", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(NetworkManager), "StartClient", (Type[])null, (Type[])null); if (_links == null || methodInfo == null || methodInfo2 == null || methodInfo3 == null) { return false; } HarmonyMethod val = new HarmonyMethod(typeof(StableJoinCheck), "AfterStart", (Type[])null) { priority = 0 }; h.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(StableJoinCheck), "GetConfigPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(StableJoinCheck), "GetConfigFinalizer", (Type[])null), (HarmonyMethod)null); return true; } private static string NameOf(NetworkPrefab p) { if (p == null) { return "?"; } if ((Object)(object)p.Prefab != (Object)null) { return ((Object)p.Prefab).name; } if ((Object)(object)p.OverridingTargetPrefab != (Object)null) { return ((Object)p.OverridingTargetPrefab).name + " (remplacement)"; } return "(objet absent ou détruit)"; } private static void AfterStart(NetworkManager __instance, MethodBase __originalMethod, bool __result) { try { if (!__result || (Object)(object)__instance == (Object)null || __instance.NetworkConfig == null || __instance.NetworkConfig.Prefabs == null) { return; } NetworkConfig networkConfig = __instance.NetworkConfig; Dictionary<uint, NetworkPrefab> live = _links.GetValue(networkConfig.Prefabs) as Dictionary<uint, NetworkPrefab>; if (live == null) { return; } string text = ((__originalMethod.Name == "StartHost") ? "héberger" : "rejoindre"); if (_snapshot == null) { _snapshot = new Dictionary<uint, NetworkPrefab>(live); foreach (KeyValuePair<uint, NetworkPrefab> item in live) { _names[item.Key] = NameOf(item.Value); } Plugin.Log.LogInfo((object)("Rejoindre sans relancer : liste de référence des modèles réseau prise au premier démarrage du réseau (" + text + ") : " + _snapshot.Count + " modèles. L'empreinte comparée avec l'hôte utilisera toujours cette liste.")); } else { List<string> list = (from k in live.Keys where !_snapshot.ContainsKey(k) select NameOf(live[k]) + " [" + k + "]").ToList(); List<string> list2 = (from k in _snapshot.Keys where !live.ContainsKey(k) select _names[k] + " [" + k + "]").ToList(); string value; List<string> list3 = (from kv in live where kv.Value != null && (Object)(object)kv.Value.Prefab == (Object)null && (Object)(object)kv.Value.OverridingTargetPrefab == (Object)null select (_names.TryGetValue(kv.Key, out value) ? value : "?") + " [" + kv.Key + "]").ToList(); string text2 = "Rejoindre sans relancer (" + text + ") : liste des modèles réseau " + ((list.Count + list2.Count == 0) ? "identique à la référence" : ("différente de la référence : " + ((list.Count > 0) ? (list.Count + " ajouté(s) depuis : " + string.Join(", ", list.ToArray()) + " ; ") : "") + ((list2.Count > 0) ? (list2.Count + " retiré(s) depuis : " + string.Join(", ", list2.ToArray()) + " ; ") : "") + "l'empreinte utilise la référence (avant : refus « NetworkConfig mismatch » par un hôte qui venait de relancer)")) + ((list3.Count > 0) ? (" ; modèles détruits encore listés : " + string.Join(", ", list3.ToArray())) : "") + "."; NetDiag.Write(text2); if (list.Count + list2.Count + list3.Count > 0) { Plugin.Log.LogWarning((object)text2); } else { Plugin.Log.LogInfo((object)text2); } } if (_clear != null) { _clear.Invoke(networkConfig, null); } ulong config = networkConfig.GetConfig(false); _bypass = true; ulong config2; try { config2 = networkConfig.GetConfig(false); } finally { _bypass = false; } NetDiag.Write("Empreinte de connexion (" + text + ") : " + config + " (liste de référence) ; avec la liste du moment : " + config2 + "."); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Rejoindre sans relancer : vérification de la liste des modèles impossible (" + ex.Message + ").")); } } private static void GetConfigPrefix(NetworkConfig __instance, out object __state) { __state = null; if (_bypass || _broken || _snapshot == null || __instance == null || !__instance.ForceSamePrefabs || __instance.Prefabs == null) { return; } try { object value = _links.GetValue(__instance.Prefabs); _links.SetValue(__instance.Prefabs, new Dictionary<uint, NetworkPrefab>(_snapshot)); __state = value; } catch (Exception ex) { _broken = true; Plugin.Log.LogWarning((object)("Rejoindre sans relancer : empreinte stable impossible (" + ex.Message + ") ; empreinte du jeu gardée.")); } } private static Exception GetConfigFinalizer(NetworkConfig __instance, object __state, Exception __exception) { if (__state != null && __instance != null && __instance.Prefabs != null) { _links.SetValue(__instance.Prefabs, __state); } return __exception; } } internal static class LethalErrorDiffFix { private static int _fixedNames; internal static bool Apply(Harmony h) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown Type type = TypeIndex.Find("LethalError.Patches+<>c"); MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, "<DelayedDisconnect>b__14_0", (Type[])null, (Type[])null) : null); if (methodInfo == null) { return false; } h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(LethalErrorDiffFix), "Transpiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { MethodInfo getName = AccessTools.PropertyGetter(typeof(Object), "name"); MethodInfo safe = AccessTools.Method(typeof(LethalErrorDiffFix), "SafeName", (Type[])null, (Type[])null); int n = 0; foreach (CodeInstruction instruction in instructions) { if ((instruction.opcode == OpCodes.Callvirt || instruction.opcode == OpCodes.Call) && instruction.operand is MethodInfo methodInfo && methodInfo == getName) { instruction.opcode = OpCodes.Call; instruction.operand = safe; n++; } yield return instruction; } if (n != 1) { Plugin.Log.LogWarning((object)("LethalError : lecture des noms de modèles remplacée " + n + " fois (1 attendue) : version de LethalError différente ?")); } } private static string SafeName(Object o) { if (o != (Object)null) { return o.name; } _fixedNames++; if (_fixedNames <= 5) { NetDiag.Write("LethalError : un modèle réseau de la liste de l'hôte n'a plus d'objet (absent ou détruit) ; nom remplacé pour que LethalError puisse renvoyer le joueur avec la liste des différences."); } return "(objet absent ou détruit)"; } } internal static class JoinTimingFixes { private static MethodInfo _getDissonance; private static MethodInfo _mimicAwake; private static int _mirageDeferred; private static MethodInfo _runEvent; private static Action<GrabbableObject> _scp178Base; private static bool _scp178Logged; private static bool LocalPlayerReady { get { if ((Object)(object)GameNetworkManager.Instance != (Object)null) { return (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null; } return false; } } internal static bool ApplyMirage(Harmony h) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown Type type = TypeIndex.Find("Mirage.Hook.Dissonance"); Type type2 = TypeIndex.Find("Mirage.Unity.MimicVoice+MimicVoice"); _getDissonance = ((type == null) ? null : AccessTools.Method(type, "getDissonance", Type.EmptyTypes, (Type[])null)); _mimicAwake = ((type2 == null) ? null : AccessTools.Method(type2, "Awake", Type.EmptyTypes, (Type[])null)); if (_getDissonance == null || _mimicAwake == null) { return false; } h.Patch((MethodBase)_mimicAwake, new HarmonyMethod(typeof(JoinTimingFixes), "MimicAwakePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool DissonanceReady() { try { object? obj = _getDissonance.Invoke(null, null); return (Object)((obj is Object) ? obj : null) != (Object)null; } catch { return true; } } private static bool MimicAwakePrefix(MonoBehaviour __instance) { if (DissonanceReady() || (Object)(object)__instance == (Object)null || !((Component)__instance).gameObject.activeInHierarchy) { return true; } _mirageDeferred++; if (_mirageDeferred == 1) { Plugin.Log.LogInfo((object)"Mirage : chat vocal pas encore prêt pendant l'arrivée, voix des monstres préparée dès qu'il l'est."); } __instance.StartCoroutine(RetryMimicAwake(__instance)); return false; } private static IEnumerator RetryMimicAwake(MonoBehaviour voice) { float end = Time.realtimeSinceStartup + 60f; while (!DissonanceReady() && Time.realtimeSinceStartup < end) { yield return null; } if ((Object)(object)voice == (Object)null || !DissonanceReady()) { yield break; } try { _mimicAwake.Invoke(voice, null); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Mirage : voix non préparée (" + (ex.InnerException ?? ex).Message + ").")); } } internal static bool ApplyWesley(Harmony h) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown Type type = TypeIndex.Find("WesleysInteriorTools.Features.SteamIdEvent"); _runEvent = ((type == null) ? null : AccessTools.Method(type, "RunEvent", Type.EmptyTypes, (Type[])null)); if (_runEvent == null) { return false; } h.Patch((MethodBase)_runEvent, new HarmonyMethod(typeof(JoinTimingFixes), "RunEventPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool RunEventPrefix(MonoBehaviour __instance) { if (LocalPlayerReady) { return true; } if ((Object)(object)__instance != (Object)null && ((Component)__instance).gameObject.activeInHierarchy) { __instance.StartCoroutine(RetryRunEvent(__instance)); } return false; } private static IEnumerator RetryRunEvent(MonoBehaviour ev) { float end = Time.realtimeSinceStartup + 60f; while (!LocalPlayerReady && Time.realtimeSinceStartup < end) { yield return null; } if ((Object)(object)ev == (Object)null || !LocalPlayerReady) { yield break; } try { _runEvent.Invoke(ev, null); } catch (Exception ex) { Plugin.Log.LogWarning((object)("WesleysInteriorTools : événement Steam non lancé (" + (ex.InnerException ?? ex).Message + ").")); } } internal static bool ApplyScp178(Harmony h) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown Type type = TypeIndex.Find("HeavyItemSCPs.SCP.SCP178.SCP178Behavior"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.DeclaredMethod(type, "Update", Type.EmptyTypes, (Type[])null)); MethodInfo methodInfo2 = ((type == null || type.BaseType == null) ? null : AccessTools.Method(type.BaseType, "Update", Type.EmptyTypes, (Type[])null)); if (methodInfo == null || methodInfo2 == null || !typeof(GrabbableObject).IsAssignableFrom(type)) { return false; } _scp178Base = AccessTools.MethodDelegate<Action<GrabbableObject>>(methodInfo2, (object)null, false); h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(JoinTimingFixes), "Scp178Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool Scp178Prefix(GrabbableObject __instance) { if (LocalPlayerReady) { return true; } _scp178Base(__instance); if (!_scp178Logged) { _scp178Logged = true; Plugin.Log.LogInfo((object)"HeavyItemSCPs : SCP-178 attend que le joueur soit relié à son personnage (arrivée en cours) ; il tombe au sol normalement en attendant. Message affiché une seule fois."); } return false; } } internal static class ObjetsUtil { internal static bool HasSorLocalPlayer() { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance != (Object)null) { return (Object)(object)instance.localPlayerController != (Object)null; } return false; } internal static bool HasGnmLocalPlayer() { GameNetworkManager instance = GameNetworkManager.Instance; if ((Object)(object)instance != (Object)null) { return (Object)(object)instance.localPlayerController != (Object)null; } return false; } internal static Action<GrabbableObject> DirectCall(MethodInfo m) { if (m == null || m.IsStatic || m.GetParameters().Length != 0 || m.DeclaringType == null || !typeof(GrabbableObject).IsAssignableFrom(m.DeclaringType)) { return null; } DynamicMethod dynamicMethod = new DynamicMethod("Lethargique_" + m.DeclaringType.Name + "_" + m.Name, typeof(void), new Type[1] { typeof(GrabbableObject) }, m.DeclaringType, skipVisibility: true); ILGenerator iLGenerator = dynamicMethod.GetILGenerator(); iLGenerator.Emit(OpCodes.Ldarg_0); if (m.DeclaringType != typeof(GrabbableObject)) { iLGenerator.Emit(OpCodes.Castclass, m.DeclaringType); } iLGenerator.Emit(OpCodes.Call, m); if (m.ReturnType != typeof(void)) { iLGenerator.Emit(OpCodes.Pop); } iLGenerator.Emit(OpCodes.Ret); return (Action<GrabbableObject>)dynamicMethod.CreateDelegate(typeof(Action<GrabbableObject>)); } internal static MethodInfo BaseMethod(Type t, string name) { Type type = ((t == null) ? null : t.BaseType); while (type != null) { MethodInfo method = type.GetMethod(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); if (method != null) { return method; } type = type.BaseType; } return null; } } internal static class Scp323JoinFix { private static Action<GrabbableObject> _baseUpdate; private static bool _logged; private static bool _loggedError; internal static bool Apply(Harmony h) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown Type type = TypeIndex.Find("HeavyItemSCPs.SCP.SCP323.SCP323Behavior"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "Update", Type.EmptyTypes, (Type[])null)); if (methodInfo == null || methodInfo.DeclaringType != type) { return false; } _baseUpdate = ObjetsUtil.DirectCall(AccessTools.DeclaredMethod(type, "BaseUpdate", Type.EmptyTypes, (Type[])null)); h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Scp323JoinFix), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool Prefix(GrabbableObject __instance) { if (ObjetsUtil.HasSorLocalPlayer()) { return true; } if (_baseUpdate != null && (Object)(object)__instance != (Object)null) { try { _baseUpdate(__instance); } catch (Exception ex) { if (!_loggedError) { _loggedError = true; Plugin.Log.LogWarning((object)("HeavyItemSCPs : SCP-323, mise à jour de l'objet impossible pendant l'arrivée (" + ex.Message + ").")); } } } if (!_logged) { _logged = true; Plugin.Log.LogInfo((object)"HeavyItemSCPs : SCP-323 attend que le joueur soit relié à son personnage (arrivée en cours). Message affiché une seule fois."); } return false; } } internal static class FloppyReaderJoinFix { private static FieldInfo _mesh; private static bool _logged; internal static bool Apply(Harmony h) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown Type type = TypeIndex.Find("DiversityRemastered.Misc.FloppyReader"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "Update", Type.EmptyTypes, (Type[])null)); if (methodInfo == null || methodInfo.DeclaringType != type) { return false; } _mesh = AccessTools.Field(type, "mesh"); if (_mesh != null && !typeof(Renderer).IsAssignableFrom(_mesh.FieldType)) { _mesh = null; } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(FloppyReaderJoinFix), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool Prefix(object __instance) { if (ObjetsUtil.HasSorLocalPlayer()) { return true; } try { Renderer val = (Renderer)((_mesh != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val != (Object)null && !val.enabled) { val.enabled = true; } } catch (Exception) { } if (!_logged) { _logged = true; Plugin.Log.LogInfo((object)"Diversity : le lecteur de disquettes attend que le joueur soit relié à son personnage (arrivée en cours). Message affiché une seule fois."); } return false; } } internal static class MistressPlushieJoinFix { private static Action<GrabbableObject> _baseLateUpdate; private static bool _logged; private static bool _loggedError; internal static bool Apply(Harmony h) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown Type type = TypeIndex.Find("CodeRebirth.src.Content.Items.MistressPlushie"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "LateUpdate", Type.EmptyTypes, (Type[])null)); if (methodInfo == null || methodInfo.DeclaringType != type) { return false; } _baseLateUpdate = ObjetsUtil.DirectCall(ObjetsUtil.BaseMethod(type, "LateUpdate")); if (_baseLateUpdate == null) { return false; } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(MistressPlushieJoinFix), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool Prefix(GrabbableObject __instance) { GameNetworkManager instance = GameNetworkManager.Instance; PlayerControllerB val = (((Object)(object)instance != (Object)null) ? instance.localPlayerController : null); if ((Object)(object)val != (Object)null && (Object)(object)val.gameplayCamera != (Object)null) { return true; } try { if ((Object)(object)__instance != (Object)null) { _baseLateUpdate(__instance); } } catch (Exception ex) { if (!_loggedError) { _loggedError = true; Plugin.Log.LogWarning((object)("CodeRebirth : peluche Mistress, mise à jour de l'objet impossible pendant l'arrivée (" + ex.Message + ").")); } } if (!_logged) { _logged = true; Plugin.Log.LogInfo((object)"CodeRebirth : la peluche Mistress attend que le joueur soit relié à son personnage (arrivée en cours). Message affiché une seule fois."); } return false; } } internal static class SoccerBallJoinFix { private static bool _logged; internal static bool Apply(Harmony h) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(SoccerBallProp), "BeginKickBall", new Type[2] { typeof(Vector3), typeof(bool) }, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(SoccerBallProp), "KickBallClientRpc", new Type[4] { typeof(Vector3), typeof(int), typeof(bool), typeof(bool) }, (Type[])null); if (methodInfo == null || methodInfo2 == null) { return false; } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(SoccerBallJoinFix), "BeginPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(SoccerBallJoinFix), "ClientRpcPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool BeginPrefix() { if (ObjetsUtil.HasGnmLocalPlayer()) { return true; } LogOnce(); return false; } private static bool ClientRpcPrefix(NetworkBehaviour __instance) { if (ObjetsUtil.HasGnmLocalPlayer() || (Object)(object)__instance == (Object)null || __instance.IsServer) { return true; } LogOnce(); return false; } private static void LogOnce() { if (!_logged) { _logged = true; Plugin.Log.LogInfo((object)"Ballon de foot : frappe ignorée pendant l'arrivée du joueur (pas encore relié à son personnage). Message affiché une seule fois."); } } } internal static class LethalNetworkApiFix { private const int OwnershipUpdate = 36; private const int Initialize = 68; private const int UpdateClientList = 128; private const float JoinQuietSeconds = 2f; private static PropertyInfo _variablesProp; private static PropertyInfo _instanceProp; private static IDictionary _variables; private static Type _baseType; private static PropertyInfo _identifier; private static PropertyInfo _ownerClients; private static PropertyInfo _writePerms; private static MethodInfo _updateConnection; private static readonly Dictionary<Type, FieldInfo> ConnectedFields = new Dictionary<Type, FieldInfo>(); private static readonly object[] TrueArg = new object[1] { true }; private static object _handler; private static float _sessionStart; private static float _lastJoinMessage; private static bool _sawClientList; private static bool _joinSyncDone; private static readonly HashSet<string> PendingInit = new HashSet<string>(); private static readonly Dictionary<string, ulong[]> PendingOwners = new Dictionary<string, ulong[]>(); private static int _unknown; private static int _created; private static bool _loggedUnknown; private static bool _loggedCreated; private static bool _loggedError; internal static bool Apply(Harmony h) { //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Expected O, but got Unknown //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown Type type = TypeIndex.Find("LethalNetworkAPI.Internal.UnnamedMessageHandler"); _baseType = TypeIndex.Find("LethalNetworkAPI.Internal.LNetworkVariableBase"); if (type == null || _baseType == null) { return false; } MethodInfo methodInfo = AccessTools.Method(type, "HandleMessage", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(type, "add_VariableCheck", new Type[1] { typeof(Action) }, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(type, "CheckVariablesForChanges", Type.EmptyTypes, (Type[])null); _variablesProp = AccessTools.Property(type, "LNetworkVariables"); _instanceProp = AccessTools.Property(type, "Instance"); _identifier = AccessTools.Property(_baseType, "Identifier"); _ownerClients = AccessTools.Property(_baseType, "OwnerClients"); _writePerms = AccessTools.Property(_baseType, "WritePerms"); _updateConnection = AccessTools.Method(_baseType, "UpdateConnectionStatus", new Type[1] { typeof(bool) }, (Type[])null); if (methodInfo == null || methodInfo2 == null || methodInfo3 == null || _variablesProp == null || _identifier == null || _ownerClients == null || _writePerms == null || _updateConnection == null) { return false; } ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length != 5 || parameters[0].ParameterType != typeof(ulong) || parameters[1].ParameterType != typeof(string) || !parameters[2].ParameterType.IsEnum || Enum.GetUnderlyingType(parameters[2].ParameterType) != typeof(int) || parameters[3].ParameterType != typeof(object)) { return false; } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(LethalNetworkApiFix), "HandlePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(LethalNetworkApiFix), "OnVariableCreated", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(LethalNetworkApiFix), "TickPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static IDictionary Variables() { if (_variables == null) { _variables = _variablesProp.GetValue(null, null) as IDictionary; } return _variables; } private static void Track(object handler) { if (handler != _handler) { _handler = handler; _sessionStart = Time.realtimeSinceStartup; _lastJoinMessage = 0f; _sawClientList = false; _joinSyncDone = false; PendingInit.Clear(); PendingOwners.Clear(); _loggedUnknown = false; _loggedCreated = false; } } private static bool HandlePrefix(object __instance, ulong __0, string __1, int __2, object __3) { try { Track(__instance); switch (__2) { case 128: if (__0 == 0L) { _sawClientList = true; } return true; default: return true; case 36: case 68: { if (__0 == 0L) { _lastJoinMessage = Time.realtimeSinceStartup; } IDictionary dictionary = Variables(); if (dictionary == null || __1 == null || dictionary.Contains(__1)) { return true; } if (__0 == 0L) { if (__2 == 68) { PendingInit.Add(__1); } else { PendingOwners[__1] = __3 as ulong[]; } } _unknown++; if (!_loggedUnknown) { _loggedUnknown = true; Plugin.Log.LogInfo((object)("LethalNetworkAPI : l'hôte a envoyé l'état de « " + __1 + " », pas encore créée chez ce joueur ; gardé pour sa création au lieu de l'erreur KeyNotFound (" + _unknown + " depuis le lancement).")); } return false; } } } catch (Exception) { return true; } } private static void OnVariableCreated(Action __0) { try { object obj = __0?.Target; if (obj == null || !_baseType.IsInstanceOfType(obj)) { return; } NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { return; } object obj2 = ((_instanceProp != null) ? _instanceProp.GetValue(null, null) : null); if (obj2 != null) { Track(obj2); } if (singleton.IsServer) { MarkConnected(obj); } else { if (!singleton.IsConnectedClient) { return; } string text = _identifier.GetValue(obj, null) as string; bool num = text != null && PendingInit.Remove(text); if (text != null && PendingOwners.TryGetValue(text, out var value)) { PendingOwners.Remove(text); object value2 = _writePerms.GetValue(obj, null); if (value2 != null && value2.ToString() == "Owner") { _ownerClients.SetValue(obj, value, null); } } if (num || _joinSyncDone) { MarkConnected(obj); _created++; if (!_loggedCreated) { _loggedCreated = true; Plugin.Log.LogInfo((object)("LethalNetworkAPI : variable « " + text + " » créée en cours de partie, initialisée à sa création (comme avant la 3.4 : écritures permises, réactions aux changements de l'hôte). Message affiché une fois par partie.")); } } } } catch (Exception e) { LogErrorOnce(e); } } private static void TickPostfix(object __instance) { if (__instance != _handler) { Track(__instance); } if (_joinSyncDone) { return; } try { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null) { return; } if (singleton.IsServer) { _joinSyncDone = true; } else { if (!singleton.IsConnectedClient || !_sawClientList) { return; } float realtimeSinceStartup = Time.realtimeSinceStartup; if (!(realtimeSinceStartup - _lastJoinMessage < 2f) && !(realtimeSinceStartup - _sessionStart < 2f)) { _joinSyncDone = true; int num = SweepUnconnected(); if (num > 0) { Plugin.Log.LogInfo((object)("LethalNetworkAPI : synchro d'arrivée terminée ; " + num + " variable(s) créée(s) pendant l'arrivée, sans signal de l'hôte, initialisée(s).")); } } } } catch (Exception e) { LogErrorOnce(e); } } private static int SweepUnconnected() { IDictionary dictionary = Variables(); if (dictionary == null) { return 0; } List<object> list = new List<object>(dictionary.Count); foreach (object value2 in dictionary.Values) { if (value2 != null) { list.Add(value2); } } int num = 0; bool flag = default(bool); foreach (object item in list) { FieldInfo fieldInfo = ConnectedField(item.GetType()); int num2; if (fieldInfo != null) { object value = fieldInfo.GetValue(item); if (value is bool) { flag = (bool)value; num2 = 1; } else { num2 = 0; } } else { num2 = 0; } if (((uint)num2 & (flag ? 1u : 0u)) == 0) { MarkConnected(item); num++; } } return num; } private static FieldInfo ConnectedField(Type t) { if (!ConnectedFields.TryGetValue(t, out var value)) { value = AccessTools.Field(t, "_isConnected"); if (value != null && value.FieldType != typeof(bool)) { value = null; } ConnectedFields[t] = value; } return value; } private static void MarkConnected(object variable) { _updateConnection.Invoke(variable, TrueArg); } private static void LogErrorOnce(Exception e) { if (!_loggedError) { _loggedError = true; Exception ex = ((e is TargetInvocationException && e.InnerException != null) ? e.InnerException : e); Plugin.Log.LogWarning((object)("LethalNetworkAPI : correctif des variables sauté une fois (" + ex.GetType().Name + " : " + ex.Message + "). Message affiché une seule fois.")); } } } internal static class LguContractSpawnFix { private static Type _contractObject; private static PropertyInfo _instance; private static FieldInfo _type; private static FieldInfo _level; private static int _retires; private static string _exemple; private static readonly Dictionary<string, string> Types = new Dictionary<string, string> { { "DataRetrievalContract", "Data" }, { "DefusalContract", "Defusal" }, { "ExorcismContract", "Exorcism" }, { "ExterminatorContract", "Exterminator" }, { "ExtractionContract", "Extraction" } }; internal static bool Apply(Harmony h) { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_00f5: Expected O, but got Unknown //IL_00f5: Expected O, but got Unknown _contractObject = TypeIndex.Find("MoreShipUpgrades.UpgradeComponents.Contracts.ContractObject"); Type type = TypeIndex.Find("MoreShipUpgrades.Managers.ContractManager"); if (_contractObject == null || type == null) { return false; } _instance = AccessTools.Property(type, "Instance"); _type = AccessTools.Field(type, "contractType"); _level = AccessTools.Field(type, "contractLevel"); if (_instance == null || _type == null || _level == null) { return false; } MethodInfo methodInfo = AccessTools.Method(typeof(RoundManager), "SpawnMapObjects", (Type[])null, (Type[])null); if (methodInfo == null) { return false; } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(LguContractSpawnFix), "Avant", (Type[])null), new HarmonyMethod(typeof(LguContractSpawnFix), "Apres", (Type[])null), new HarmonyMethod(typeof(LguContractSpawnFix), "Transpiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { MethodInfo spawn = AccessTools.Method(typeof(NetworkObject), "Spawn", new Type[1] { typeof(bool) }, (Type[])null); MethodInfo nous = AccessTools.Method(typeof(LguContractSpawnFix), "EnvoyerOuRetirer", (Type[])null, (Type[])null); int n = 0; foreach (CodeInstruction instruction in instructions) { if ((instruction.opcode == OpCodes.Callvirt || instruction.opcode == OpCodes.Call) && object.Equals(instruction.operand, spawn)) { instruction.opcode = OpCodes.Call; instruction.operand = nous; n++; } yield return instruction; } if (n == 0) { Plugin.Log.LogWarning((object)"Contrats de Lategame Upgrades : envoi des dangers d'intérieur introuvable, rien n'a été changé (B-332)."); } } private static void Avant() { _retires = 0; _exemple = null; } private static void Apres() { if (_retires > 0) { Plugin.Log.LogInfo((object)("Contrats de Lategame Upgrades : " + _retires + " objet(s) d'autres contrats (ex. " + _exemple + ") retiré(s) avant l'envoi au réseau, au lieu d'être créés puis détruits chez tout le monde (B-332).")); } } private static void EnvoyerOuRetirer(NetworkObject no, bool destroyWithScene) { string text = null; try { text = AutreContrat(no); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Contrats de Lategame Upgrades : vérification impossible (" + ex.Message + ") ; objet envoyé comme avant.")); } if (text == null) { no.Spawn(destroyWithScene); return; } _retires++; _exemple = _exemple ?? text; ((Component)no).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)no).gameObject); } private static string AutreContrat(NetworkObject no) { if ((Object)(object)no == (Object)null) { return null; } Component component = ((Component)no).GetComponent(_contractObject); if ((Object)(object)component == (Object)null) { return null; } if (!Types.TryGetValue(((object)component).GetType().Name, out var value)) { return null; } object value2 = _instance.GetValue(null, null); if (value2 == null || (Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.currentLevel == (Object)null) { return null; } string obj = _type.GetValue(value2) as string; string text = _level.GetValue(value2) as string; if (obj == value && StartOfRound.Instance.currentLevel.PlanetName == text) { return null; } return ((Object)((Component)no).gameObject).name.Replace("(Clone)", ""); } } internal static class LittleCompanyAudioFix { private static FieldInfo _listField; private static Dictionary<ulong, List<AudioMixerGroup>> _list; private static bool _moreCompany; private static readonly HashSet<int> NoPitch = new HashSet<int>(); private static int _destroyed; private static bool _loggedDestroyed; private static bool _loggedError; internal static bool Apply(Harmony h) { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown Type type = TypeIndex.Find("LittleCompany.compatibility.MoreCompanyAudioCompatibilityPatch"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "CompatUpdatePitchInAudioMixers", new Type[2] { typeof(ulong), typeof(float) }, (Type[])null)); _listField = ((type == null) ? null : AccessTools.Field(type, "listOfVoicePlayer")); if (methodInfo == null || _listField == null || !_listField.IsStatic || !typeof(Dictionary<ulong, List<AudioMixerGroup>>).IsAssignableFrom(_listField.FieldType)) { return false; } _moreCompany = Chainloader.PluginInfos.ContainsKey("me.swipez.melonloader.morecompany"); h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(LittleCompanyAudioFix), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } private static bool Prefix(ulong __0, float __1) { try { if (!_moreCompany) { return false; } if (_list == null) { _list = _listField.GetValue(null) as Dictionary<ulong, List<AudioMixerGroup>>; } if (_list == null || !_list.TryGetValue(__0, out var value) || value == null) { return false; } float num2 = default(float); for (int num = value.Count - 1; num >= 0; num--) { AudioMixerGroup val = value[num]; if ((Object)(object)val == (Object)null) { value.RemoveAt(num); _destroyed++; } else { AudioMixer audioMixer = val.audioMixer; if ((Object)(object)audioMixer == (Object)null) { value.RemoveAt(num); } else { int instanceID = ((Object)audioMixer).GetInstanceID(); if (NoPitch.Contains(instanceID) || audioMixer.GetFloat("PlayerPitch0", ref num2) || !audioMixer.SetFloat("pitch", __1)) { NoPitch.Add(instanceID); value.RemoveAt(num); } } } } if (_destroyed > 0 && !_loggedDestroyed) { _loggedDestroyed = true; Plugin.Log.LogInfo((object)("LittleCompany : groupes audio de joueurs détruits avec leur bundle retirés de sa liste (" + _destroyed + " au premier passage, joueur n° " + __0 + "). Plus d'erreur en boucle à l'arrivée d'un joueur. Message affiché une seule fois.")); } } catch (Exception ex) { if (!_loggedError) { _loggedError = true; Plugin.Log.LogWarning((object)("LittleCompany : réglage de la hauteur des voix sauté (" + ex.GetType().Name + " : " + ex.Message + "). Message affiché une seule fois.")); } } return false; } } internal static class LittleCompanyLogFix { private const string ItemSuffix = "had no spawnPrefab. Unable to connect item event handler."; private const string EnemySuffix = "had no enemyPrefab. Unable to connect enemy event handler."; private static bool _binding; private static int _items; private static int _enemies; private static bool _verified; internal static bool Apply(Harmony h) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown //IL_013d: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown Type type = TypeIndex.Find("LittleCompany.Plugin"); Type type2 = ((type == null) ? null : AccessTools.Inner(type, "LogType")); Type type3 = TypeIndex.Find("LittleCompany.events.item.ItemEventManager"); Type type4 = TypeIndex.Find("LittleCompany.events.enemy.EnemyEventManager"); MethodInfo methodInfo = ((type2 == null) ? null : AccessTools.Method(type, "Log", new Type[2] { typeof(string), type2 }, (Type[])null)); MethodInfo methodInfo2 = ((type3 == null) ? null : AccessTools.Method(type3, "BindAllEventHandler", Type.EmptyTypes, (Type[])null)); MethodInfo methodInfo3 = ((type4 == null) ? null : AccessTools.Method(type4, "BindAllEventHandler", Type.EmptyTypes, (Type[])null)); if (methodInfo == null || methodInfo2 == null || methodInfo3 == null) { return false; } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(LittleCompanyLogFix), "LogPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo[] array = new MethodInfo[2] { methodInfo3, methodInfo2 }; foreach (MethodInfo methodInfo4 in array) { h.Patch((MethodBase)methodInfo4, new HarmonyMethod(typeof(LittleCompanyLogFix), "BindPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(LittleCompanyLogFix), "BindFinalizer",