using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("FlockFocusCOTLMPCompat")] [assembly: AssemblyDescription("COTLMP compatibility patch for FlockFocus.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FlockFocusCOTLMPCompat")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("5865765f-2797-4117-bb83-f07d06f5d1d4")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [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 FlockFocusCOTLMPCompat { [BepInPlugin("com.cotl.flockfocus.cotlmpcompat", "FlockFocus COTLMP Compat", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class FlockFocusCOTLMPCompatPlugin : BaseUnityPlugin { public const string PluginGuid = "com.cotl.flockfocus.cotlmpcompat"; public const string PluginName = "FlockFocus COTLMP Compat"; public const string PluginVersion = "0.1.0"; internal static ManualLogSource Log; private Harmony _harmony; private void Awake() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Type type = ResolveCOTLMPPatchesType(); MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, "HUD_Update", (Type[])null, (Type[])null) : null); if (methodInfo == null) { Log.LogInfo((object)"COTLMP HUD_Update was not found. Compat patch is idle."); return; } COTLMPHudUpdatePatch.Bind(type); _harmony = new Harmony("com.cotl.flockfocus.cotlmpcompat"); _harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(COTLMPHudUpdatePatch), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"FlockFocus COTLMP compat loaded."); } private static Type ResolveCOTLMPPatchesType() { Type type = AccessTools.TypeByName("COTLMultiplayerExpansion.Patches"); if (type != null) { return type; } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type type2 = assemblies[i].GetType("COTLMultiplayerExpansion.Patches", throwOnError: false); if (type2 != null) { return type2; } } return null; } private void OnDestroy() { if (_harmony != null) { _harmony.UnpatchSelf(); } } } internal static class COTLMPHudUpdatePatch { private static readonly string[] WidgetFieldNames = new string[3] { "_p2Widget", "_p3Widget", "_p4Widget" }; private static PropertyInfo _shouldHideIndicatorsNow; private static FieldInfo[] _widgetFields = new FieldInfo[0]; internal static void Bind(Type cotlmpPatchesType) { Type type = AccessTools.TypeByName("FlockFocus.FlockFocusPlugin"); _shouldHideIndicatorsNow = ((type != null) ? AccessTools.Property(type, "ShouldHideIndicatorsNow") : null); if (cotlmpPatchesType == null) { _widgetFields = new FieldInfo[0]; return; } FieldInfo[] array = new FieldInfo[WidgetFieldNames.Length]; for (int i = 0; i < WidgetFieldNames.Length; i++) { array[i] = AccessTools.Field(cotlmpPatchesType, WidgetFieldNames[i]); } _widgetFields = array; } public static bool Prefix() { if (!ShouldSuppressCOTLMPWidgets()) { return true; } HideExistingWidgets(); return false; } private static bool ShouldSuppressCOTLMPWidgets() { try { return _shouldHideIndicatorsNow != null && (bool)_shouldHideIndicatorsNow.GetValue(null, null); } catch (Exception ex) { ManualLogSource log = FlockFocusCOTLMPCompatPlugin.Log; if (log != null) { log.LogWarning((object)("Failed to query FlockFocus indicator state: " + ex.Message)); } return false; } } private static void HideExistingWidgets() { for (int i = 0; i < _widgetFields.Length; i++) { FieldInfo fieldInfo = _widgetFields[i]; if (!(fieldInfo == null)) { object? value = fieldInfo.GetValue(null); Component val = (Component)((value is Component) ? value : null); if ((Object)(object)val != (Object)null && (Object)(object)val.gameObject != (Object)null && val.gameObject.activeSelf) { val.gameObject.SetActive(false); } } } } } }