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.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 AskaExpandedParty { [BepInPlugin("com.community.askaexpandedparty", "Aska Expanded Party", "0.4.0")] public class ExpandedPartyPlugin : BasePlugin { public const string PluginGuid = "com.community.askaexpandedparty"; public const string PluginName = "Aska Expanded Party"; public const string PluginVersion = "0.4.0"; internal static ManualLogSource Log; public static ConfigEntry CfgEnabled; public static ConfigEntry CfgPartyCapacity; public static ConfigEntry CfgDebugLogging; public static ConfigEntry CfgScalePartyWidget; public static ConfigEntry CfgTwoColumnLeftShift; public override void Load() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Expected O, but got Unknown Log = ((BasePlugin)this).Log; CfgEnabled = ((BasePlugin)this).Config.Bind("General", "Enabled", true, "Enable expanded player party capacity."); CfgPartyCapacity = ((BasePlugin)this).Config.Bind("General", "PartyCapacity", 6, new ConfigDescription("Maximum number of NPC villagers allowed in the player party. Vanilla is 3.", (AcceptableValueBase)(object)new AcceptableValueRange(3, 20), Array.Empty())); CfgDebugLogging = ((BasePlugin)this).Config.Bind("Diagnostics", "DebugLogging", false, "Log every party-capacity override."); CfgScalePartyWidget = ((BasePlugin)this).Config.Bind("UI", "ScalePartyWidget", true, "Scale the party HUD member container down when PartyCapacity is above 3."); CfgTwoColumnLeftShift = ((BasePlugin)this).Config.Bind("UI", "TwoColumnLeftShift", 230f, new ConfigDescription("Pixels to shift the party HUD container left when it switches to two-column mode (party > 10). Default 230 pulls the right-edge widget toward screen center so the second column (left of the first) is fully visible. Reduce toward 0 if the widget sits too far from the right edge; increase up to 600 if the second column still clips.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 600f), Array.Empty())); bool flag = default(bool); try { Harmony harmony = new Harmony("com.community.askaexpandedparty"); Type type = AccessTools.TypeByName("SSSGame.PlayerParty"); if (type == null) { Log.LogError((object)"Could not find SSSGame.PlayerParty. Mod cannot function."); return; } NativePartyHardcapPatch.Apply(type); PatchMethod(harmony, type, "Spawned", typeof(PlayerPartyLifecyclePatch), "SpawnedPostfix"); PatchMethod(harmony, type, "Despawned", typeof(PlayerPartyLifecyclePatch), "DespawnedPostfix"); PatchMethod(harmony, type, "GetAgentsCapacity", typeof(PlayerPartyCapacityPatch), "Postfix"); Type type2 = AccessTools.TypeByName("SSSGame.PlayerPartyWidget"); if (type2 != null) { PatchMethod(harmony, type2, "Activate", typeof(PlayerPartyWidgetPatch), "ActivatePostfix"); PatchMethod(harmony, type2, "_OnVillagerAdded", typeof(PlayerPartyWidgetPatch), "OnVillagerAddedPrefix", "WidgetChangedPostfix"); PatchMethod(harmony, type2, "_OnVillagerRemoved", typeof(PlayerPartyWidgetPatch), "WidgetChangedPostfix"); } else { Log.LogWarning((object)"Could not find SSSGame.PlayerPartyWidget. Party HUD scaling disabled."); } ManualLogSource log = Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(25, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("Aska Expanded Party"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("0.4.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded. PartyCapacity="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(CfgPartyCapacity.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); } catch (Exception ex) { ManualLogSource log2 = Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(33, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to apply Harmony patches: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log2.LogError(val2); } } private static void PatchMethod(Harmony harmony, Type targetType, string methodName, Type patchClass, string postfixName) { PatchMethod(harmony, targetType, methodName, patchClass, null, postfixName); } private static void PatchMethod(Harmony harmony, Type targetType, string methodName, Type patchClass, string prefixName, string postfixName) { //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(targetType, methodName, (Type[])null, (Type[])null); bool flag = default(bool); if (methodInfo == null) { ManualLogSource log = Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(27, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not find "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(targetType.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(methodName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". Skipping."); } log.LogWarning(val); return; } MethodInfo methodInfo2 = ((prefixName == null) ? null : patchClass.GetMethod(prefixName, BindingFlags.Static | BindingFlags.NonPublic)); if (prefixName != null && methodInfo2 == null) { ManualLogSource log2 = Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(17, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Could not find "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(patchClass.Name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(prefixName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log2.LogError(val2); return; } MethodInfo methodInfo3 = ((postfixName == null) ? null : patchClass.GetMethod(postfixName, BindingFlags.Static | BindingFlags.NonPublic)); if (postfixName != null && methodInfo3 == null) { ManualLogSource log3 = Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(17, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Could not find "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(patchClass.Name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(postfixName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log3.LogError(val2); return; } try { harmony.Patch((MethodBase)methodInfo, (methodInfo2 == null) ? ((HarmonyMethod)null) : new HarmonyMethod(methodInfo2), (methodInfo3 == null) ? ((HarmonyMethod)null) : new HarmonyMethod(methodInfo3), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ManualLogSource log4 = Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(13, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Patched "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(targetType.Name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("."); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(methodName); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" -> "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(patchClass.Name); } log4.LogInfo(val3); } catch (Exception ex) { ManualLogSource log5 = Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(19, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to patch "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(targetType.Name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(methodName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log5.LogError(val2); } } } internal static class NativePartyHardcapPatch { private static bool _applied; internal static void Apply(Type playerPartyType) { //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown if (_applied) { return; } bool flag = default(bool); try { FieldInfo field = playerPartyType.GetField("NativeMethodInfoPtr_SetTaskAgent_Public_Virtual_Final_New_Boolean_ITaskAgent_0", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { ExpandedPartyPlugin.Log.LogError((object)"Could not find PlayerParty.SetTaskAgent native method info field."); return; } if (!(field.GetValue(null) is IntPtr intPtr) || intPtr == IntPtr.Zero) { ExpandedPartyPlugin.Log.LogError((object)"PlayerParty.SetTaskAgent native method info pointer is unavailable."); return; } IntPtr intPtr2 = Marshal.ReadIntPtr(intPtr); if (intPtr2 == IntPtr.Zero) { ExpandedPartyPlugin.Log.LogError((object)"PlayerParty.SetTaskAgent native method pointer is unavailable."); return; } int value = ExpandedPartyPlugin.CfgPartyCapacity.Value; if (!TryPatchImmediate(intPtr2, value, out var patchAddress)) { ManualLogSource log = ExpandedPartyPlugin.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(74, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not find PlayerParty.SetTaskAgent hardcoded party-size gate near 0x"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(intPtr2.ToInt64(), "X"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogError(val); return; } _applied = true; ManualLogSource log2 = ExpandedPartyPlugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(62, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Patched PlayerParty.SetTaskAgent native party limit to "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(value); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" at 0x"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(patchAddress.ToInt64(), "X"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log2.LogInfo(val2); } catch (Exception ex) { ManualLogSource log3 = ExpandedPartyPlugin.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(61, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to patch PlayerParty.SetTaskAgent native party limit: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log3.LogError(val); } } private unsafe static bool TryPatchImmediate(IntPtr methodPointer, int limit, out IntPtr patchAddress) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown patchAddress = IntPtr.Zero; byte* ptr = (byte*)methodPointer.ToPointer(); bool flag = default(bool); for (int i = 0; i < 4096; i++) { if (ptr[i] != 131 || ptr[i + 1] != 120 || ptr[i + 2] != 24 || ptr[i + 3] != 3 || !LooksLikeRejectedBranch(ptr + i + 4)) { continue; } patchAddress = methodPointer + i + 3; if (!VirtualProtect(patchAddress, (UIntPtr)1uL, 64u, out var lpflOldProtect)) { ManualLogSource log = ExpandedPartyPlugin.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(64, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("VirtualProtect failed while patching PlayerParty.SetTaskAgent: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Marshal.GetLastWin32Error()); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogError(val); return false; } ptr[i + 3] = checked((byte)limit); VirtualProtect(patchAddress, (UIntPtr)1uL, lpflOldProtect, out var _); return true; } return false; } private unsafe static bool LooksLikeRejectedBranch(byte* branchBytes) { if (*branchBytes != 15 || branchBytes[1] != 141) { return *branchBytes == 125; } return true; } [DllImport("kernel32", SetLastError = true)] private static extern bool VirtualProtect(IntPtr lpAddress, UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect); } internal static class PlayerPartyCapacityPatch { private static bool _loggedOverride; internal static void Postfix(object __instance, ref int __result) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown bool flag = default(bool); try { if (!ExpandedPartyPlugin.CfgEnabled.Value || !IsInGameplay() || !PlayerPartyLifecyclePatch.IsActiveParty(__instance)) { return; } int value = ExpandedPartyPlugin.CfgPartyCapacity.Value; if (__result >= value) { return; } int num = __result; __result = value; if (ExpandedPartyPlugin.CfgDebugLogging.Value && !_loggedOverride) { _loggedOverride = true; ManualLogSource log = ExpandedPartyPlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(35, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("PlayerParty.GetAgentsCapacity: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(__result); } log.LogInfo(val); } } catch (Exception ex) { ManualLogSource log2 = ExpandedPartyPlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(57, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("GetAgentsCapacity patch failed; leaving vanilla result "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(__result); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log2.LogWarning(val2); } } private static bool IsInGameplay() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) try { Scene activeScene = SceneManager.GetActiveScene(); return ((Scene)(ref activeScene)).name == "StreamingWorld"; } catch { return false; } } } internal static class PlayerPartyLifecyclePatch { private static IntPtr _activePartyPtr; internal static void SpawnedPostfix(object __instance) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown try { if (__instance == null) { return; } if (!LooksRuntimeReady(__instance)) { if (ExpandedPartyPlugin.CfgDebugLogging.Value) { ExpandedPartyPlugin.Log.LogInfo((object)"PlayerParty.Spawned observed but party is not runtime-ready yet."); } } else { _activePartyPtr = GetNativePointer(__instance); ExpandedPartyPlugin.Log.LogInfo((object)"PlayerParty spawned and expanded capacity is armed."); } } catch (Exception ex) { ManualLogSource log = ExpandedPartyPlugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(34, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("PlayerParty.Spawned patch failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } internal static void DespawnedPostfix(object __instance) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown try { if (__instance != null) { IntPtr nativePointer = GetNativePointer(__instance); if (nativePointer != IntPtr.Zero && nativePointer == _activePartyPtr) { _activePartyPtr = IntPtr.Zero; ExpandedPartyPlugin.Log.LogInfo((object)"PlayerParty despawned and expanded capacity is disarmed."); } } } catch (Exception ex) { ManualLogSource log = ExpandedPartyPlugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("PlayerParty.Despawned patch failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } internal static bool IsActiveParty(object party) { if (party == null || _activePartyPtr == IntPtr.Zero) { return false; } return GetNativePointer(party) == _activePartyPtr; } private static bool LooksRuntimeReady(object party) { if (GetPropertyValue(party, "session") != null && GetPropertyValue(party, "_networkParty") != null && GetPropertyValue(party, "_partyMembers") != null) { if (GetPropertyValue(party, "_pc") == null) { return InvokeMethod(party, "GetCharacter") != null; } return true; } return false; } private static object GetPropertyValue(object target, string name) { try { return target.GetType().GetProperty(name, BindingFlags.Instance | BindingFlags.Public)?.GetValue(target); } catch { return null; } } private static object InvokeMethod(object target, string name) { try { return target.GetType().GetMethod(name, BindingFlags.Instance | BindingFlags.Public)?.Invoke(target, null); } catch { return null; } } private static IntPtr GetNativePointer(object target) { try { if (target.GetType().GetProperty("Pointer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(target) is IntPtr result) { return result; } object obj = target.GetType().GetField("Pointer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(target); if (obj is IntPtr) { return (IntPtr)obj; } } catch { } return IntPtr.Zero; } } internal static class PlayerPartyWidgetPatch { private const int TwoColumnThreshold = 10; private const int MaxRowsPerColumn = 10; private const float ColumnGap = 16f; private static float? _originalSpacing; private static Vector2? _originalContentPosition; private static Vector2? _originalContentSize; private static bool? _originalLayoutEnabled; private static Vector2? _columnTemplateOrigin; private static float? _columnTemplateRowStep; private static float? _columnTemplateScale; private static Vector2? _columnTemplateContentSize; private static Vector2? _columnTemplateContentPosition; private static bool _columnTemplateValid; private static FitMode? _savedFitHorizontal; private static FitMode? _savedFitVertical; private static bool _contentSizeFitterNeutralized; private static bool _layoutElementSizesPinned; private static float _savedLayoutMinWidth; private static float _savedLayoutMinHeight; private static float _savedLayoutPreferredWidth; private static float _savedLayoutPreferredHeight; private static VerticalLayoutGroup _frozenParentLayout; private static Vector2? _twoColumnBasePosition; [ThreadStatic] private static bool _inPostfix; [ThreadStatic] private static bool _isEnsuringVisible; internal static void OnVillagerAddedPrefix(object __instance) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown if (!ExpandedPartyPlugin.CfgEnabled.Value || !ExpandedPartyPlugin.CfgScalePartyWidget.Value) { return; } bool flag = default(bool); try { object propertyValue = GetPropertyValue(__instance, "Content"); Transform val = (Transform)((propertyValue is Transform) ? propertyValue : null); if ((Object)(object)val == (Object)null) { return; } VerticalLayoutGroup component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null || val.childCount < 10 || !((Behaviour)component).enabled) { return; } ((Behaviour)component).enabled = false; if (ExpandedPartyPlugin.CfgDebugLogging.Value) { ManualLogSource log = ExpandedPartyPlugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(52, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("PlayerPartyWidget disabled VLG before adding child "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val.childCount + 1); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log.LogInfo(val2); } } catch (Exception ex) { if (ExpandedPartyPlugin.CfgDebugLogging.Value) { ManualLogSource log2 = ExpandedPartyPlugin.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(30, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("OnVillagerAddedPrefix failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } log2.LogWarning(val3); } } } internal static void WidgetChangedPostfix(object __instance) { //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Expected O, but got Unknown //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) if (_inPostfix) { return; } bool flag = default(bool); try { _inPostfix = true; if (!ExpandedPartyPlugin.CfgEnabled.Value || !ExpandedPartyPlugin.CfgScalePartyWidget.Value) { return; } int num = EnsureCurrentPartyMembersAreVisible(__instance); object propertyValue = GetPropertyValue(__instance, "Content"); Transform val = (Transform)((propertyValue is Transform) ? propertyValue : null); if ((Object)(object)val == (Object)null) { return; } SyncChildOrderToParty(__instance, val); VerticalLayoutGroup component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null) { return; } RectTransform component2 = ((Component)val).GetComponent(); if ((Object)(object)component2 == (Object)null) { return; } float valueOrDefault = _originalSpacing.GetValueOrDefault(); if (!_originalSpacing.HasValue) { valueOrDefault = ((HorizontalOrVerticalLayoutGroup)component).spacing; _originalSpacing = valueOrDefault; } Vector2 valueOrDefault2 = _originalContentPosition.GetValueOrDefault(); if (!_originalContentPosition.HasValue) { valueOrDefault2 = component2.anchoredPosition; _originalContentPosition = valueOrDefault2; } valueOrDefault2 = _originalContentSize.GetValueOrDefault(); if (!_originalContentSize.HasValue) { Rect rect = component2.rect; valueOrDefault2 = ((Rect)(ref rect)).size; _originalContentSize = valueOrDefault2; } flag = _originalLayoutEnabled.GetValueOrDefault(); if (!_originalLayoutEnabled.HasValue) { flag = ((Behaviour)component).enabled; _originalLayoutEnabled = flag; } int childCount = val.childCount; int num2 = Math.Max(num, childCount); if (ExpandedPartyPlugin.CfgDebugLogging.Value) { int count = GetCount(GetPropertyValue(__instance, "PartyMembers")); ManualLogSource log = ExpandedPartyPlugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(106, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("PlayerPartyWidget diag: content.childCount="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(childCount); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", _partyMembers.Count="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", PartyMembers.Count="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", layoutMemberCount="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num2); } log.LogInfo(val2); if (num > childCount) { ManualLogSource log2 = ExpandedPartyPlugin.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(148, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("PlayerPartyWidget is missing panels: party has "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", but Content only has "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(childCount); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(". Layout will use the party count, but only existing panels can be positioned."); } log2.LogWarning(val3); } } if (childCount == 0) { return; } if (num2 <= 3) { RestoreVerticalLayout(val, component2, component, childCount); return; } Vector2 childSize = GetChildSize(val); if (!(childSize == Vector2.zero)) { if (num2 > 10) { ApplyTwoColumnLayout(val, component2, component, childCount, num2, childSize); } else { ApplySingleColumnLayout(val, component2, component, childCount, num2, childSize.y); } } } catch (Exception ex) { if (ExpandedPartyPlugin.CfgDebugLogging.Value) { ManualLogSource log3 = ExpandedPartyPlugin.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(38, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("PlayerPartyWidget scale patch failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex); } log3.LogWarning(val3); } } finally { _inPostfix = false; } } internal static void ActivatePostfix(object __instance) { WidgetChangedPostfix(__instance); } private static void RestoreVerticalLayout(Transform content, RectTransform contentRect, VerticalLayoutGroup layoutGroup, int visiblePanelCount) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) UnpinContentSize(content); ((Behaviour)layoutGroup).enabled = _originalLayoutEnabled.GetValueOrDefault(true); ((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = _originalSpacing.Value; contentRect.anchoredPosition = _originalContentPosition.Value; contentRect.SetSizeWithCurrentAnchors((Axis)0, _originalContentSize.Value.x); contentRect.SetSizeWithCurrentAnchors((Axis)1, _originalContentSize.Value.y); for (int i = 0; i < visiblePanelCount; i++) { Transform child = content.GetChild(i); child.localScale = Vector3.one; SetIgnoreLayout(child, ignoreLayout: false); } RestoreParentMasks(content); LayoutRebuilder.ForceRebuildLayoutImmediate(contentRect); _columnTemplateValid = false; } private static void ApplySingleColumnLayout(Transform content, RectTransform contentRect, VerticalLayoutGroup layoutGroup, int visiblePanelCount, int layoutMemberCount, float childHeight) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) UnpinContentSize(content); ((Behaviour)layoutGroup).enabled = _originalLayoutEnabled.GetValueOrDefault(true); DisableParentMasks(content); float num = Math.Clamp(3f / (float)layoutMemberCount, 0.5f, 1f); ((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = _originalSpacing.Value * num - childHeight * (1f - num); float num2 = Math.Min(24f, childHeight * 0.2f); contentRect.anchoredPosition = _originalContentPosition.Value + new Vector2(0f, num2); float val = (float)visiblePanelCount * childHeight * num + (float)Math.Max(0, visiblePanelCount - 1) * ((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing; contentRect.SetSizeWithCurrentAnchors((Axis)1, Math.Max(_originalContentSize.Value.y, val)); for (int i = 0; i < visiblePanelCount; i++) { Transform child = content.GetChild(i); child.localScale = new Vector3(num, num, 1f); SetIgnoreLayout(child, ignoreLayout: false); } if (layoutMemberCount != 10 || visiblePanelCount < 2) { return; } LayoutRebuilder.ForceRebuildLayoutImmediate(contentRect); RectTransform component = ((Component)content.GetChild(0)).GetComponent(); RectTransform component2 = ((Component)content.GetChild(1)).GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null) { _columnTemplateOrigin = component.anchoredPosition; _columnTemplateScale = ((Transform)component).localScale.x; _columnTemplateRowStep = Mathf.Abs(component.anchoredPosition.y - component2.anchoredPosition.y); Rect rect = contentRect.rect; _columnTemplateContentSize = ((Rect)(ref rect)).size; _columnTemplateContentPosition = contentRect.anchoredPosition; _columnTemplateValid = true; if (ExpandedPartyPlugin.CfgDebugLogging.Value) { ManualLogSource log = ExpandedPartyPlugin.Log; string[] obj = new string[18] { "ColumnTemplate N=10: origin=", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }; Vector2 val2 = _columnTemplateOrigin.Value; obj[1] = ((Vector2)(ref val2)).ToString("F2"); obj[2] = ", contentPos="; val2 = _columnTemplateContentPosition.Value; obj[3] = ((Vector2)(ref val2)).ToString("F2"); obj[4] = ", scale="; obj[5] = _columnTemplateScale.Value.ToString("F3"); obj[6] = ", rowStep="; obj[7] = _columnTemplateRowStep.Value.ToString("F2"); obj[8] = ", anchorMin="; val2 = component.anchorMin; obj[9] = ((object)(Vector2)(ref val2)).ToString(); obj[10] = ", anchorMax="; val2 = component.anchorMax; obj[11] = ((object)(Vector2)(ref val2)).ToString(); obj[12] = ", pivot="; val2 = component.pivot; obj[13] = ((object)(Vector2)(ref val2)).ToString(); obj[14] = ", childHeight="; obj[15] = childHeight.ToString("F2"); obj[16] = ", spacing="; obj[17] = ((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing.ToString("F2"); log.LogInfo((object)string.Concat(obj)); } } } private static void ApplyTwoColumnLayout(Transform content, RectTransform contentRect, VerticalLayoutGroup layoutGroup, int visiblePanelCount, int layoutMemberCount, Vector2 childSize) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) ((Behaviour)layoutGroup).enabled = false; DisableParentMasks(content); Vector2 value = default(Vector2); float num; float num2; if (_columnTemplateValid && _columnTemplateOrigin.HasValue && _columnTemplateRowStep.HasValue && _columnTemplateScale.HasValue) { value = _columnTemplateOrigin.Value; num = _columnTemplateRowStep.Value; num2 = _columnTemplateScale.Value; } else { float num3 = _originalSpacing ?? ((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing; num2 = Math.Clamp(0.3f, 0.5f, 1f); num = num2 * (childSize.y + num3); RectOffset padding = ((LayoutGroup)layoutGroup).padding; ((Vector2)(ref value))..ctor((float)padding.left + childSize.x * 0.5f, 0f - ((float)padding.top + childSize.y * 0.5f)); } float num4 = childSize.x * num2 + 16f; Vector2? columnTemplateContentSize = _columnTemplateContentSize; Vector2 val; if (!columnTemplateContentSize.HasValue) { Vector2? originalContentSize = _originalContentSize; if (!originalContentSize.HasValue) { Rect rect = contentRect.rect; val = ((Rect)(ref rect)).size; } else { val = originalContentSize.GetValueOrDefault(); } } else { val = columnTemplateContentSize.GetValueOrDefault(); } Vector2 size = val; PinContentSize(content, contentRect, size); Vector2 val2; if (_twoColumnBasePosition.HasValue) { val2 = _twoColumnBasePosition.Value; } else { VerticalLayoutGroup val3 = (((Object)(object)content.parent != (Object)null) ? ((Component)content.parent).GetComponent() : null); RectTransform val4 = (((Object)(object)content.parent != (Object)null) ? ((Component)content.parent).GetComponent() : null); if ((Object)(object)val3 != (Object)null && ((Behaviour)val3).enabled && (Object)(object)val4 != (Object)null) { LayoutRebuilder.ForceRebuildLayoutImmediate(val4); val2 = contentRect.anchoredPosition; } else { val2 = (Vector2)((_columnTemplateValid && _columnTemplateContentPosition.HasValue) ? _columnTemplateContentPosition.Value : (((??)_originalContentPosition) ?? contentRect.anchoredPosition)); } _twoColumnBasePosition = val2; } FreezeParentLayout(content); float num5 = Mathf.Max(0f, ExpandedPartyPlugin.CfgTwoColumnLeftShift.Value); contentRect.anchoredPosition = val2 - new Vector2(num5, 0f); if (ExpandedPartyPlugin.CfgDebugLogging.Value) { ContentSizeFitter component = ((Component)content).GetComponent(); VerticalLayoutGroup val5 = (((Object)(object)content.parent != (Object)null) ? ((Component)content.parent).GetComponent() : null); HorizontalLayoutGroup val6 = (((Object)(object)content.parent != (Object)null) ? ((Component)content.parent).GetComponent() : null); ManualLogSource log = ExpandedPartyPlugin.Log; string[] obj = new string[20] { "ContentDiag: pivot=", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }; Vector2 pivot = contentRect.pivot; obj[1] = ((object)(Vector2)(ref pivot)).ToString(); obj[2] = ", CSF="; object obj2; if (!((Object)(object)component == (Object)null)) { FitMode val7 = component.horizontalFit; string? text = ((object)(FitMode)(ref val7)).ToString(); val7 = component.verticalFit; obj2 = text + "/" + ((object)(FitMode)(ref val7)).ToString(); } else { obj2 = "none"; } obj[3] = (string)obj2; obj[4] = ", parent="; obj[5] = (((Object)(object)content.parent != (Object)null) ? ((Object)content.parent).name : "null"); obj[6] = ", parentVLG="; obj[7] = ((Object)(object)val5 != (Object)null).ToString(); obj[8] = " (enabled="; obj[9] = ((Object)(object)val5 != (Object)null && ((Behaviour)val5).enabled).ToString(); obj[10] = "), parentHLG="; obj[11] = ((Object)(object)val6 != (Object)null).ToString(); obj[12] = ", pinnedSize="; obj[13] = ((Vector2)(ref size)).ToString("F1"); obj[14] = ", basePos="; obj[15] = ((Vector2)(ref val2)).ToString("F1"); obj[16] = " (cached="; obj[17] = _twoColumnBasePosition.HasValue.ToString(); obj[18] = "), leftShift="; obj[19] = num5.ToString("F1"); log.LogInfo((object)string.Concat(obj)); } for (int i = 0; i < visiblePanelCount; i++) { Transform child = content.GetChild(i); RectTransform component2 = ((Component)child).GetComponent(); if (!((Object)(object)component2 == (Object)null)) { LayoutElement val8 = ((Component)child).GetComponent(); if ((Object)(object)val8 == (Object)null) { val8 = ((Component)child).gameObject.AddComponent(); } val8.ignoreLayout = true; int num6 = i / 10; int num7 = i % 10; component2.anchorMin = new Vector2(0f, 1f); component2.anchorMax = new Vector2(0f, 1f); child.localScale = new Vector3(num2, num2, 1f); component2.anchoredPosition = new Vector2(value.x + (float)num6 * num4, value.y - (float)num7 * num); } } if (ExpandedPartyPlugin.CfgDebugLogging.Value) { string text2 = (_columnTemplateValid ? "template" : "analytic"); ExpandedPartyPlugin.Log.LogInfo((object)("TwoColumnLayout: source=" + text2 + ", perColumn=" + 10 + ", scale=" + num2.ToString("F3") + ", rowStep=" + num.ToString("F2") + ", colStep=" + num4.ToString("F2") + ", origin=" + ((Vector2)(ref value)).ToString("F2"))); } } private static Vector2 GetChildSize(Transform content) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (content.childCount == 0) { return Vector2.zero; } RectTransform component = ((Component)content.GetChild(0)).GetComponent(); if (!((Object)(object)component == (Object)null)) { Rect rect = component.rect; return ((Rect)(ref rect)).size; } return Vector2.zero; } private static int EnsureCurrentPartyMembersAreVisible(object widgetInstance) { //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown int partyMemberCount = GetPartyMemberCount(widgetInstance); if (_isEnsuringVisible || partyMemberCount == 0) { return partyMemberCount; } bool flag = default(bool); try { _isEnsuringVisible = true; object propertyValue = GetPropertyValue(widgetInstance, "_playerParty"); object obj = ((propertyValue != null) ? GetPropertyValue(propertyValue, "_partyMembers") : null); object propertyValue2 = GetPropertyValue(widgetInstance, "PartyMembers"); MethodInfo methodInfo = propertyValue2?.GetType().GetMethod("ContainsKey"); MethodInfo method = widgetInstance.GetType().GetMethod("_OnVillagerAdded", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); MethodInfo methodInfo2 = obj?.GetType().GetMethod("get_Item"); if (obj == null || method == null || methodInfo2 == null) { return partyMemberCount; } int num = 0; for (int i = 0; i < partyMemberCount; i++) { object obj2 = methodInfo2.Invoke(obj, new object[1] { i }); if (obj2 != null && (!(methodInfo != null) || propertyValue2 == null || !(bool)methodInfo.Invoke(propertyValue2, new object[1] { obj2 }))) { method.Invoke(widgetInstance, new object[1] { obj2 }); num++; } } if (ExpandedPartyPlugin.CfgDebugLogging.Value && num > 0) { ManualLogSource log = ExpandedPartyPlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(87, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("PlayerPartyWidget ensured "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" missing party member panels were created (total in party: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(partyMemberCount); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } log.LogInfo(val); } } catch (Exception ex) { if (ExpandedPartyPlugin.CfgDebugLogging.Value) { ManualLogSource log2 = ExpandedPartyPlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(44, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("EnsureCurrentPartyMembersAreVisible failed: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log2.LogWarning(val2); } } finally { _isEnsuringVisible = false; } return partyMemberCount; } private static void SyncChildOrderToParty(object widgetInstance, Transform content) { //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown bool flag = default(bool); try { object propertyValue = GetPropertyValue(widgetInstance, "_playerParty"); object obj = ((propertyValue != null) ? GetPropertyValue(propertyValue, "_partyMembers") : null); object propertyValue2 = GetPropertyValue(widgetInstance, "PartyMembers"); if (obj == null || propertyValue2 == null) { return; } int count = GetCount(obj); if (count == 0) { return; } MethodInfo method = obj.GetType().GetMethod("get_Item"); MethodInfo method2 = propertyValue2.GetType().GetMethod("get_Item"); if (method == null || method2 == null) { return; } int num = 0; for (int i = 0; i < count; i++) { object obj2 = method.Invoke(obj, new object[1] { i }); if (obj2 != null) { object? obj3 = method2.Invoke(propertyValue2, new object[1] { obj2 }); Transform val = (Transform)((obj3 is Transform) ? obj3 : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val.parent != (Object)(object)content) && val.GetSiblingIndex() != i) { val.SetSiblingIndex(i); num++; } } } if (ExpandedPartyPlugin.CfgDebugLogging.Value && num > 0) { ManualLogSource log = ExpandedPartyPlugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(56, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("PlayerPartyWidget reordered "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" panels to match party list."); } log.LogInfo(val2); } } catch (Exception ex) { if (ExpandedPartyPlugin.CfgDebugLogging.Value) { ManualLogSource log2 = ExpandedPartyPlugin.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(30, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("SyncChildOrderToParty failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex); } log2.LogWarning(val3); } } } private static int GetPartyMemberCount(object widgetInstance) { object propertyValue = GetPropertyValue(widgetInstance, "_playerParty"); return GetCount((propertyValue != null) ? GetPropertyValue(propertyValue, "_partyMembers") : null); } private static int GetCount(object collection) { if (collection == null) { return 0; } try { object obj = collection.GetType().GetProperty("Count", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(collection); return (obj != null) ? Convert.ToInt32(obj) : 0; } catch { return 0; } } private static void DisableParentMasks(Transform content) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown Transform parent = content.parent; bool flag = default(bool); while ((Object)(object)parent != (Object)null) { RectMask2D component = ((Component)parent).GetComponent(); if ((Object)(object)component != (Object)null && ((Behaviour)component).enabled) { ((Behaviour)component).enabled = false; if (ExpandedPartyPlugin.CfgDebugLogging.Value) { ManualLogSource log = ExpandedPartyPlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Disabled RectMask2D on "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)parent).name); } log.LogInfo(val); } } Mask component2 = ((Component)parent).GetComponent(); if ((Object)(object)component2 != (Object)null && ((Behaviour)component2).enabled) { ((Behaviour)component2).enabled = false; if (ExpandedPartyPlugin.CfgDebugLogging.Value) { ManualLogSource log2 = ExpandedPartyPlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(17, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Disabled Mask on "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)parent).name); } log2.LogInfo(val); } } parent = parent.parent; } } private static void RestoreParentMasks(Transform content) { Transform parent = content.parent; while ((Object)(object)parent != (Object)null) { RectMask2D component = ((Component)parent).GetComponent(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = true; } Mask component2 = ((Component)parent).GetComponent(); if ((Object)(object)component2 != (Object)null) { ((Behaviour)component2).enabled = true; } parent = parent.parent; } } private static void PinContentSize(Transform content, RectTransform contentRect, Vector2 size) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) ContentSizeFitter component = ((Component)content).GetComponent(); if ((Object)(object)component != (Object)null && !_contentSizeFitterNeutralized) { _savedFitHorizontal = component.horizontalFit; _savedFitVertical = component.verticalFit; component.horizontalFit = (FitMode)0; component.verticalFit = (FitMode)0; _contentSizeFitterNeutralized = true; } LayoutElement val = ((Component)content).GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)content).gameObject.AddComponent(); } if (!_layoutElementSizesPinned) { _savedLayoutMinWidth = val.minWidth; _savedLayoutMinHeight = val.minHeight; _savedLayoutPreferredWidth = val.preferredWidth; _savedLayoutPreferredHeight = val.preferredHeight; _layoutElementSizesPinned = true; } val.minWidth = size.x; val.minHeight = size.y; val.preferredWidth = size.x; val.preferredHeight = size.y; contentRect.SetSizeWithCurrentAnchors((Axis)0, size.x); contentRect.SetSizeWithCurrentAnchors((Axis)1, size.y); } private static void UnpinContentSize(Transform content) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (_contentSizeFitterNeutralized) { ContentSizeFitter component = ((Component)content).GetComponent(); if ((Object)(object)component != (Object)null) { if (_savedFitHorizontal.HasValue) { component.horizontalFit = _savedFitHorizontal.Value; } if (_savedFitVertical.HasValue) { component.verticalFit = _savedFitVertical.Value; } } _contentSizeFitterNeutralized = false; } if (_layoutElementSizesPinned) { LayoutElement component2 = ((Component)content).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.minWidth = _savedLayoutMinWidth; component2.minHeight = _savedLayoutMinHeight; component2.preferredWidth = _savedLayoutPreferredWidth; component2.preferredHeight = _savedLayoutPreferredHeight; } _layoutElementSizesPinned = false; } UnfreezeParentLayout(); _twoColumnBasePosition = null; } private static void FreezeParentLayout(Transform content) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown if ((Object)(object)_frozenParentLayout != (Object)null || (Object)(object)content.parent == (Object)null) { return; } VerticalLayoutGroup component = ((Component)content.parent).GetComponent(); if (!((Object)(object)component != (Object)null) || !((Behaviour)component).enabled) { return; } ((Behaviour)component).enabled = false; _frozenParentLayout = component; if (ExpandedPartyPlugin.CfgDebugLogging.Value) { ManualLogSource log = ExpandedPartyPlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Froze parent VerticalLayoutGroup on "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)content.parent).name); } log.LogInfo(val); } } private static void UnfreezeParentLayout() { if ((Object)(object)_frozenParentLayout != (Object)null) { ((Behaviour)_frozenParentLayout).enabled = true; _frozenParentLayout = null; } } private static void SetIgnoreLayout(Transform child, bool ignoreLayout) { LayoutElement component = ((Component)child).GetComponent(); if ((Object)(object)component != (Object)null) { component.ignoreLayout = ignoreLayout; } } private static object GetPropertyValue(object target, string name) { if (target == null) { return null; } try { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Type type = target.GetType(); PropertyInfo property = type.GetProperty(name, bindingAttr); if (property != null) { return property.GetValue(target); } return type.GetField(name, bindingAttr)?.GetValue(target); } catch { return null; } } } }