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 PersonalEulogy v0.1.2
PersonalEulogy.dll
Decompiled 2 months 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.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using R2API.Networking; using R2API.Networking.Interfaces; using R2API.Utils; using RoR2; using RoR2.Artifacts; using RoR2.UI; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PersonalEulogy")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PersonalEulogy")] [assembly: AssemblyTitle("PersonalEulogy")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace PersonalEulogy { [BepInPlugin("local.personaleulogy", "Personal Eulogy", "0.1.25")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInIncompatibility("GiGaGon.PersonalizedItemReplacement")] [BepInIncompatibility("local.personalizedeulogyredux")] [BepInIncompatibility("local.eulogyautopickupqueuecompat")] [BepInIncompatibility("local.attributedeulogy")] public sealed class Plugin : BaseUnityPlugin { public static class EulogyNamePatch { public static void Postfix(object[] __args, ref string __result) { if (__args != null && __args.Length != 0 && __args[0] is string text) { ItemDef randomlyLunar = Items.RandomlyLunar; if ((Object)(object)randomlyLunar != (Object)null && text == randomlyLunar.nameToken) { __result = "Schizophrenia"; } } } } public static class VanillaCanReplacePatch { public static bool Prefix(ref bool __result) { __result = false; return false; } } public sealed class GenericGrantState { public object OriginalState; public object OriginalProperty; public PickupIndex TemporaryReplacement; public bool UsedProperty; public bool Changed; public bool PreserveEquipmentSwapMutation; public bool DirectGrantContextPushed; } public sealed class PingCompatState { public GenericPickupController Pickup; public GenericGrantState GrantState; public ShopTerminalBehavior Terminal; public object TerminalOriginalValue; public bool TerminalUsedProperty; public bool TerminalChanged; public bool IncreasedDepth; public bool NotificationOverrideApplied; public int PreviousNotificationDepth; public PickupIndex PreviousNotificationOverride; } public static class GenericPickupUiPatch { public static void Prefix(GenericPickupController __instance, out GenericGrantState __state) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0061: Unknown result type (might be due to invalid IL or missing references) __state = null; if ((Object)(object)__instance == (Object)null || LocalUserManager.GetFirstLocalUser() == null) { return; } PickupIndex localGroundReplacement = GetLocalGroundReplacement(__instance); PickupIndex genericPickupIndex = GetGenericPickupIndex(__instance); if (localGroundReplacement == PickupIndex.none || localGroundReplacement == genericPickupIndex) { return; } LocalPickupUiReadDepth++; try { GenericGrantState genericGrantState = new GenericGrantState(); if (TryTemporarilySetGenericPickup(__instance, localGroundReplacement, genericGrantState)) { genericGrantState.Changed = true; __state = genericGrantState; } } catch (Exception ex) { if (LogDecisions != null && LogDecisions.Value) { Plugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogWarning((object)("Could not temporarily apply personalized pickup UI state: " + ex.Message)); } } } } public static Exception Finalizer(GenericPickupController __instance, GenericGrantState __state, Exception __exception) { RestoreGenericPickup(__instance, __state); if (LocalPickupUiReadDepth > 0) { LocalPickupUiReadDepth--; } return __exception; } } public static class GenericPickupIndexGetterPatch { public static void Postfix(GenericPickupController __instance, ref PickupIndex __result) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance == (Object)null) && LocalUserManager.GetFirstLocalUser() != null && (!NetworkServer.active || LocalPickupUiReadDepth > 0)) { PickupIndex localGroundReplacement = GetLocalGroundReplacement(__instance); if (localGroundReplacement != PickupIndex.none) { __result = localGroundReplacement; } } } } public static class GenericPickupGetterPatch { public static void Postfix(GenericPickupController __instance, ref UniquePickup __result) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance == (Object)null) && LocalUserManager.GetFirstLocalUser() != null && (!NetworkServer.active || LocalPickupUiReadDepth > 0)) { PickupIndex localGroundReplacement = GetLocalGroundReplacement(__instance); if (localGroundReplacement != PickupIndex.none) { __result = new UniquePickup(localGroundReplacement); } } } } public static class PingIndicatorUiPatch { public static void Prefix(PingIndicator __instance, out PingCompatState __state) { __state = null; if (!((Object)(object)__instance == (Object)null) && LocalUserManager.GetFirstLocalUser() != null) { __state = BeginLocalWorldView(__instance.pingTarget); } } public static Exception Finalizer(PingCompatState __state, Exception __exception) { EndLocalWorldView(__state); return __exception; } } public static class PingUiPatch { public static void Prefix(PingerController __instance, object[] __args, out PingCompatState __state) { __state = null; if (!((Object)(object)__instance == (Object)null) && LocalUserManager.GetFirstLocalUser() != null) { GameObject val = FindPingTarget(__instance, __args); if ((Object)(object)val == (Object)null) { val = GetCurrentPingTargetFromController(__instance); } __state = BeginLocalWorldView(val); } } public static Exception Finalizer(PingCompatState __state, Exception __exception) { EndLocalWorldView(__state); return __exception; } } public static class WorldInspectInfoPatch { public static void Prefix(object __instance, out PingCompatState __state) { __state = null; if (LocalUserManager.GetFirstLocalUser() != null) { Component val = (Component)((__instance is Component) ? __instance : null); if ((Object)(object)val != (Object)null) { __state = BeginLocalWorldView(val.gameObject); } } } public static Exception Finalizer(PingCompatState __state, Exception __exception) { EndLocalWorldView(__state); return __exception; } } public static class GroundPickupSpawnPatch { public static void Postfix(GenericPickupController __instance) { if (NetworkServer.active && !((Object)(object)__instance == (Object)null)) { EnsureGroundRecord(__instance); } } } public static class LookingGlassPingCompatPatch { public static void Prefix(object[] __args, out PingCompatState __state) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_016b: 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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) __state = null; if (LocalUserManager.GetFirstLocalUser() == null) { return; } PingerController controller = __args?.OfType<PingerController>().FirstOrDefault(); GameObject val = FindPingTarget(controller, __args); if ((Object)(object)val == (Object)null) { return; } PingCompatState pingCompatState = new PingCompatState(); GenericPickupController val2 = val.GetComponent<GenericPickupController>(); if ((Object)(object)val2 == (Object)null) { val2 = val.GetComponentInChildren<GenericPickupController>(); } if ((Object)(object)val2 == (Object)null) { val2 = val.GetComponentInParent<GenericPickupController>(); } if ((Object)(object)val2 != (Object)null) { PickupIndex localGroundReplacement = GetLocalGroundReplacement(val2); PickupIndex genericPickupIndex = GetGenericPickupIndex(val2); if (localGroundReplacement != PickupIndex.none && localGroundReplacement != genericPickupIndex) { ApplyLookingGlassNotificationOverride(pingCompatState, localGroundReplacement); pingCompatState.Pickup = val2; LocalPickupUiReadDepth++; pingCompatState.IncreasedDepth = true; GenericGrantState genericGrantState = new GenericGrantState(); if (TryTemporarilySetGenericPickup(val2, localGroundReplacement, genericGrantState)) { genericGrantState.Changed = true; pingCompatState.GrantState = genericGrantState; } } } ShopTerminalBehavior val3 = val.GetComponent<ShopTerminalBehavior>(); if ((Object)(object)val3 == (Object)null) { val3 = val.GetComponentInChildren<ShopTerminalBehavior>(); } if ((Object)(object)val3 == (Object)null) { val3 = val.GetComponentInParent<ShopTerminalBehavior>(); } if ((Object)(object)val3 != (Object)null) { PickupIndex localTerminalReplacement = GetLocalTerminalReplacement(val3); PickupIndex terminalPickupIndex = GetTerminalPickupIndex(val3); if (localTerminalReplacement != PickupIndex.none && localTerminalReplacement != terminalPickupIndex) { ApplyLookingGlassNotificationOverride(pingCompatState, localTerminalReplacement); if (TryTemporarilySetTerminalPickup(val3, localTerminalReplacement, pingCompatState)) { pingCompatState.Terminal = val3; } } } if ((Object)(object)pingCompatState.Pickup != (Object)null || pingCompatState.TerminalChanged || pingCompatState.NotificationOverrideApplied) { __state = pingCompatState; } } public static Exception Finalizer(PingCompatState __state, Exception __exception) { if (__state != null) { RestoreGenericPickup(__state.Pickup, __state.GrantState); RestoreTerminalPickup(__state); RestoreLookingGlassNotificationOverride(__state); if (__state.IncreasedDepth && LocalPickupUiReadDepth > 0) { LocalPickupUiReadDepth--; } } return __exception; } } public static class LookingGlassNotificationPatch { public static bool Prefix(CharacterMaster __0, ref PickupIndex __1) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__0 == (Object)null || !IsLookingGlassItemPingCall()) { return true; } try { if (!((NetworkBehaviour)__0).hasAuthority) { return false; } } catch { } GameObject currentPingTarget = GetCurrentPingTarget(__0); PickupIndex localReplacementForPingTarget = GetLocalReplacementForPingTarget(currentPingTarget); if (localReplacementForPingTarget != PickupIndex.none) { __1 = localReplacementForPingTarget; } return true; } } public static class LookingGlassNotificationReorderGuardPatch { public static bool Prefix(object[] __args) { if (__args == null) { return true; } foreach (object obj in __args) { CharacterMaster val = (CharacterMaster)((obj is CharacterMaster) ? obj : null); if (!((Object)(object)val == (Object)null)) { try { return ((NetworkBehaviour)val).hasAuthority; } catch { return true; } } } return true; } } public static class PickupTriggerPatch { public static bool Prefix(GenericPickupController __instance, Collider other) { if (!NetworkServer.active || (Object)(object)__instance == (Object)null || (Object)(object)other == (Object)null) { return true; } CharacterBody val = ((Component)other).GetComponent<CharacterBody>(); if ((Object)(object)val == (Object)null) { val = ((Component)other).GetComponentInParent<CharacterBody>(); } if ((Object)(object)val == (Object)null || (Object)(object)val.master == (Object)null) { return true; } return !ServerPlayerSeesLunar(__instance, val.master); } } public static class PickupInteractabilityPatch { public static void Postfix(GenericPickupController __instance, Interactor activator, ref Interactability __result) { if ((Object)(object)__instance == (Object)null || (Object)(object)activator == (Object)null) { return; } CharacterBody val = ((Component)activator).GetComponent<CharacterBody>(); if ((Object)(object)val == (Object)null) { val = ((Component)activator).GetComponentInParent<CharacterBody>(); } CharacterMaster val2 = (((Object)(object)val != (Object)null) ? val.master : null); bool num; if (!NetworkServer.active) { num = LocalPlayerSeesLunar(__instance); } else { if (!((Object)(object)val2 != (Object)null)) { return; } num = ServerPlayerSeesLunar(__instance, val2); } if (num) { __result = (Interactability)2; } } } public static class AutoItemPickupGrantPatch { public static bool Prefix(GenericPickupController __0, ref CharacterMaster __1) { if (!NetworkServer.active || (Object)(object)__0 == (Object)null || (Object)(object)__1 == (Object)null) { return true; } CharacterMaster val = __1; if (!ServerPlayerSeesLunar(__0, val)) { return true; } CharacterMaster val2 = FindAutoPickupAlternate(__0, val); if ((Object)(object)val2 != (Object)null) { __1 = val2; if (LogDecisions != null && LogDecisions.Value) { Plugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)("AutoItemPickup reassigned personalized Lunar from " + GetPlayerName(val) + " to " + GetPlayerName(val2) + ".")); } } return true; } if (LogDecisions != null && LogDecisions.Value) { Plugin instance2 = Instance; if (instance2 != null) { ((BaseUnityPlugin)instance2).Logger.LogInfo((object)"AutoItemPickup left personalized Lunar on the ground because every connected player sees it as Lunar."); } } return false; } } public static class GenericGrantPatch { public static void Prefix(GenericPickupController __instance, object[] __args, out GenericGrantState __state) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_0103: Invalid comparison between Unknown and I4 __state = null; if (!NetworkServer.active || (Object)(object)__instance == (Object)null) { return; } CharacterBody val = __args?.OfType<CharacterBody>().FirstOrDefault(); CharacterMaster val2 = (((Object)(object)val != (Object)null) ? val.master : null); if ((Object)(object)val2 == (Object)null) { return; } ServerRecord serverRecord = GetServerRecord((Component)(object)__instance, 1, 0); if (serverRecord == null) { serverRecord = EnsureGroundRecord(__instance); } if (serverRecord == null) { return; } PickupIndex playerView = GetPlayerView(serverRecord, val2); if (playerView == PickupIndex.none || playerView == serverRecord.Original) { return; } GenericGrantState genericGrantState = (__state = new GenericGrantState()); DirectGrantStack.Push(new DirectGrantContext(serverRecord, val2)); genericGrantState.DirectGrantContextPushed = true; try { if (TryTemporarilySetGenericPickup(__instance, playerView, genericGrantState)) { genericGrantState.Changed = true; PickupDef pickupDef = PickupCatalog.GetPickupDef(playerView); genericGrantState.PreserveEquipmentSwapMutation = pickupDef != null && (int)pickupDef.equipmentIndex != -1; return; } Plugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogWarning((object)"Could not temporarily substitute GenericPickupController pickup state; direct ItemIndex grant fallback remains active for this interaction."); } } catch (Exception ex) { Plugin instance2 = Instance; if (instance2 != null) { ((BaseUnityPlugin)instance2).Logger.LogWarning((object)("Could not temporarily apply personalized pickup grant: " + ex.Message)); } } } public static Exception Finalizer(GenericPickupController __instance, GenericGrantState __state, Exception __exception) { //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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) try { if (__state != null && __state.Changed && __state.PreserveEquipmentSwapMutation && (Object)(object)__instance != (Object)null) { PickupIndex rawGenericPickupIndex = GetRawGenericPickupIndex(__instance); if (rawGenericPickupIndex != PickupIndex.none && rawGenericPickupIndex != __state.TemporaryReplacement) { RebaseGroundRecordAfterEquipmentSwap(__instance, rawGenericPickupIndex); return __exception; } } RestoreGenericPickup(__instance, __state); return __exception; } finally { if (__state != null && __state.DirectGrantContextPushed && DirectGrantStack.Count > 0) { DirectGrantStack.Pop(); } } } } public sealed class PickerGrantState { public bool DirectGrantContextPushed; public bool InheritancePushed; } public static class PickerGrantPatch { public static void Prefix(PickupPickerController __instance, object[] __args, out PickerGrantState __state) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) __state = null; if (!NetworkServer.active || (Object)(object)__instance == (Object)null || !IsSupportedPicker(__instance)) { return; } int num = ExtractChoiceIndex(__args); Array pickerOptions = GetPickerOptions(__instance); if (num < 0 || pickerOptions == null || num >= pickerOptions.Length) { return; } CharacterMaster pickerParticipant = GetPickerParticipant(__instance); if ((Object)(object)pickerParticipant == (Object)null) { return; } object value = pickerOptions.GetValue(num); if (value != null && TryReadPickerOptionPickup(value, out var pickupIndex, out var _, out var _)) { ServerRecord serverRecord = GetServerRecord((Component)(object)__instance, 3, num); PickupIndex original = serverRecord?.Original ?? pickupIndex; if (serverRecord == null) { serverRecord = EnsurePickerRecord(__instance, num, original); } if (serverRecord != null) { DirectGrantStack.Push(new DirectGrantContext(serverRecord, pickerParticipant)); InheritanceStack.Push(serverRecord); __state = new PickerGrantState { DirectGrantContextPushed = true, InheritancePushed = true }; } } } public static Exception Finalizer(PickerGrantState __state, Exception __exception) { if (__state != null && __state.InheritancePushed && InheritanceStack.Count > 0) { InheritanceStack.Pop(); } if (__state != null && __state.DirectGrantContextPushed && DirectGrantStack.Count > 0) { DirectGrantStack.Pop(); } return __exception; } } public sealed class PickerDisplayState { public PickupPickerController Picker; public Array OriginalOptions; public bool Changed; } public static class PickerDisplayPatch { public static void Prefix(PickupPickerController __instance, out PickerDisplayState __state) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_00c3: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) __state = null; if ((Object)(object)__instance == (Object)null || LocalUserManager.GetFirstLocalUser() == null || !IsSupportedPicker(__instance)) { return; } Array pickerOptions = GetPickerOptions(__instance); if (pickerOptions == null || pickerOptions.Length == 0) { return; } NetworkInstanceId sourceNetId = GetSourceNetId((Component)(object)__instance); if (sourceNetId == NetworkInstanceId.Invalid || ((NetworkInstanceId)(ref sourceNetId)).Value == 0) { return; } Array originalOptions = (Array)pickerOptions.Clone(); bool flag = false; CharacterMaster pickerParticipant = GetPickerParticipant(__instance); for (int i = 0; i < pickerOptions.Length; i++) { object value = pickerOptions.GetValue(i); if (value == null || !TryReadPickerOptionPickup(value, out var pickupIndex, out var usesUniquePickup, out var member)) { continue; } PickupIndex value2 = PickupIndex.none; ClientKey key = new ClientKey(3, ((NetworkInstanceId)(ref sourceNetId)).Value, i); ClientViews.TryGetValue(key, out value2); if (value2 == PickupIndex.none && NetworkServer.active && (Object)(object)pickerParticipant != (Object)null) { ServerRecord serverRecord = GetServerRecord((Component)(object)__instance, 3, i); if (serverRecord == null) { serverRecord = EnsurePickerRecord(__instance, i, pickupIndex); } if (serverRecord != null) { PickupIndex playerView = GetPlayerView(serverRecord, pickerParticipant); if (playerView != serverRecord.Original) { value2 = playerView; } } } if (!(value2 == PickupIndex.none) && !(pickupIndex == value2)) { object option = value; if (TryWritePickerOptionPickup(ref option, value2, usesUniquePickup, member)) { pickerOptions.SetValue(option, i); flag = true; } } } if (flag) { SetPickerOptions(__instance, pickerOptions); __state = new PickerDisplayState { Picker = __instance, OriginalOptions = originalOptions, Changed = true }; } } public static Exception Finalizer(PickerDisplayState __state, Exception __exception) { if (__state != null && __state.Changed && (Object)(object)__state.Picker != (Object)null && __state.OriginalOptions != null) { SetPickerOptions(__state.Picker, __state.OriginalOptions); } return __exception; } } public static class GenericPickupCreatePatch { public static void Postfix(GenericPickupController __result) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || (Object)(object)__result == (Object)null || DirectGrantStack.Count == 0) { return; } DirectGrantContext directGrantContext = DirectGrantStack.Peek(); if (directGrantContext != null && directGrantContext.Record != null) { PickupIndex genericPickupIndex = GetGenericPickupIndex(__result); if (!(genericPickupIndex == PickupIndex.none) && !(genericPickupIndex != directGrantContext.Record.Original) && GetServerRecord((Component)(object)__result, 1, 0) == null) { CloneRecord((Component)(object)__result, 1, 0, genericPickupIndex, directGrantContext.Record); } } } } private static class ChestDropPatch { private static void Prefix(ChestBehavior __instance, out bool __state) { __state = false; if (NetworkServer.active && !((Object)(object)__instance == (Object)null)) { ServerRecord orCreateChestRecord = GetOrCreateChestRecord(__instance); if (orCreateChestRecord != null) { InheritanceStack.Push(orCreateChestRecord); __state = true; } } } private static Exception Finalizer(Exception __exception, bool __state) { if (__state && NetworkServer.active && InheritanceStack.Count > 0) { InheritanceStack.Pop(); } return __exception; } } private sealed class TerminalDropState { public bool InheritancePushed; public bool DirectGrantContextPushed; } private static class TerminalDropPatch { private static void Prefix(ShopTerminalBehavior __instance, out TerminalDropState __state) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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) __state = null; if (NetworkServer.active && !((Object)(object)__instance == (Object)null)) { PickupIndex terminalPickupIndex = GetTerminalPickupIndex(__instance); ServerRecord serverRecord = EnsureRecord((Component)(object)__instance, 2, 0, terminalPickupIndex); if (serverRecord != null) { TerminalDropState terminalDropState = new TerminalDropState(); InheritanceStack.Push(serverRecord); terminalDropState.InheritancePushed = true; DirectGrantStack.Push(new DirectGrantContext(serverRecord, null)); terminalDropState.DirectGrantContextPushed = true; __state = terminalDropState; } } } private static Exception Finalizer(Exception __exception, TerminalDropState __state) { if (__state != null && __state.DirectGrantContextPushed && DirectGrantStack.Count > 0) { DirectGrantStack.Pop(); } if (__state != null && __state.InheritancePushed && NetworkServer.active && InheritanceStack.Count > 0) { InheritanceStack.Pop(); } return __exception; } } public static class DropletPatch { public static void Prefix(object[] __args, out bool __state) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) __state = false; if (!NetworkServer.active || __args == null) { return; } bool flag = DropletHookDepth == 0; DropletHookDepth++; __state = true; if (!flag) { return; } ServerRecord serverRecord = ((InheritanceStack.Count > 0) ? InheritanceStack.Peek() : null); bool flag2 = serverRecord == null && DynamicDropContextDepth > 0; if (serverRecord == null && !flag2) { return; } PickupIndex val = PickupIndex.none; Vector3 position = Vector3.zero; bool flag3 = false; foreach (object obj in __args) { if (obj is CreatePickupInfo info) { val = GetCreatePickupInfoIndex(info); } else if (obj is UniquePickup val2) { val = val2.pickupIndex; } else if (obj is PickupIndex val3) { val = val3; } else if (!flag3 && obj is Vector3 val4) { position = val4; flag3 = true; } } if (!(val == PickupIndex.none) && flag3 && IsEligibleForReplacement(val)) { PendingDrops.Add(new PendingDrop { Original = val, Position = position, Source = serverRecord, AllowFresh = flag2, CreatedAt = Time.fixedTime }); } } public static Exception Finalizer(Exception __exception, bool __state) { if (__state && DropletHookDepth > 0) { DropletHookDepth--; } return __exception; } } public static class TerminalNoPickupPatch { public static void Postfix(ShopTerminalBehavior __instance) { if (!((Object)(object)__instance == (Object)null)) { if (NetworkServer.active) { RemoveServerRecord((Component)(object)__instance, 2, 0); } ClearTerminalClientState(__instance); } } } public static class TeleporterBossDropPatch { public static void Prefix(BossGroup __instance, out bool __state) { __state = NetworkServer.active && (Object)(object)__instance != (Object)null && !IsBazaarScene() && !IsPrimeMeridianScene() && !IsSolusHeartScene(); if (__state) { OpenBossRewardWindow(__instance); DynamicDropContextDepth++; } } public static Exception Finalizer(Exception __exception, bool __state) { if (__state) { DynamicDropContextDepth = Math.Max(0, DynamicDropContextDepth - 1); } return __exception; } } public static class DynamicVanillaDropPatch { public static void Prefix(out bool __state) { __state = NetworkServer.active && !IsBazaarScene(); if (__state) { DynamicDropContextDepth++; } } public static Exception Finalizer(Exception __exception, bool __state) { if (__state) { DynamicDropContextDepth = Math.Max(0, DynamicDropContextDepth - 1); } return __exception; } } public static class PlayerDirectGiveItemPatch { public static void Prefix(Inventory __instance, object[] __args) { //IL_00c1: 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_00c7: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_0104: 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_011a: Invalid comparison between Unknown and I4 //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Invalid comparison between Unknown and I4 //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || (Object)(object)__instance == (Object)null || __args == null || DirectGrantStack.Count == 0) { return; } CharacterMaster val = ((Component)__instance).GetComponent<CharacterMaster>(); if ((Object)(object)val == (Object)null) { val = ((Component)__instance).GetComponentInParent<CharacterMaster>(); } if ((Object)(object)val == (Object)null || (Object)(object)val.playerCharacterMasterController == (Object)null) { return; } DirectGrantContext directGrantContext = DirectGrantStack.Peek(); if (directGrantContext == null || directGrantContext.Record == null || ((Object)(object)directGrantContext.ExpectedMaster != (Object)null && directGrantContext.ExpectedMaster != val)) { return; } PickupIndex playerView = GetPlayerView(directGrantContext.Record, val); if (playerView == PickupIndex.none || playerView == directGrantContext.Record.Original) { return; } PickupDef pickupDef = PickupCatalog.GetPickupDef(directGrantContext.Record.Original); PickupDef pickupDef2 = PickupCatalog.GetPickupDef(playerView); if (pickupDef == null || pickupDef2 == null || (int)pickupDef.itemIndex == -1 || (int)pickupDef2.itemIndex == -1) { return; } for (int i = 0; i < __args.Length; i++) { if (!(__args[i] is ItemIndex val2) || val2 != pickupDef.itemIndex) { continue; } __args[i] = pickupDef2.itemIndex; if (LogDecisions != null && LogDecisions.Value) { Plugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)("Direct player grant Eulogy: " + ((object)Unsafe.As<ItemIndex, ItemIndex>(ref pickupDef.itemIndex)/*cast due to .constrained prefix*/).ToString() + " -> " + ((object)Unsafe.As<ItemIndex, ItemIndex>(ref pickupDef2.itemIndex)/*cast due to .constrained prefix*/).ToString() + " for " + GetPlayerName(val))); } } break; } } } public static class MonsterGiveItemPatch { public unsafe static void Prefix(Inventory __instance, object[] __args) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Invalid comparison between Unknown and I4 //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Invalid comparison between Unknown and I4 //IL_0150: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || (Object)(object)__instance == (Object)null || __args == null) { return; } CharacterMaster val = ((Component)__instance).GetComponent<CharacterMaster>(); if ((Object)(object)val == (Object)null) { val = ((Component)__instance).GetComponentInParent<CharacterMaster>(); } if ((Object)(object)val == (Object)null || (Object)(object)val.playerCharacterMasterController != (Object)null) { return; } int num = -1; ItemIndex val2 = (ItemIndex)(-1); for (int i = 0; i < __args.Length; i++) { if (__args[i] is ItemIndex) { num = i; val2 = (ItemIndex)__args[i]; break; } } if (num < 0 || (int)val2 == -1) { return; } PickupIndex pickupIndex = PickupCatalog.FindPickupIndex(val2); if (!IsEligibleForReplacement(pickupIndex)) { return; } int num2 = CountAllPlayerEulogyStacks(); if ((Object)(object)val.inventory != (Object)null) { num2 += val.inventory.GetItemCountEffective(Items.RandomlyLunar.itemIndex); } if (num2 <= 0 || !RollChance(num2)) { return; } PickupIndex val3 = PickLunarCandidate(itemsOnly: true); PickupDef pickupDef = PickupCatalog.GetPickupDef(val3); if (pickupDef == null || (int)pickupDef.itemIndex == -1) { return; } __args[num] = pickupDef.itemIndex; if (LogDecisions != null && LogDecisions.Value) { Plugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)("Monster inventory Eulogy: " + ((object)(*(ItemIndex*)(&val2))/*cast due to .constrained prefix*/).ToString() + " -> " + ((object)Unsafe.As<ItemIndex, ItemIndex>(ref pickupDef.itemIndex)/*cast due to .constrained prefix*/).ToString())); } } } } private readonly struct PickupWireRef { public readonly byte Type; public readonly int CatalogIndex; public PickupWireRef(byte type, int catalogIndex) { Type = type; CatalogIndex = catalogIndex; } public static PickupWireRef FromPickup(PickupIndex pickup) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected I4, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected I4, but got Unknown if (pickup == PickupIndex.none) { return new PickupWireRef(0, -1); } PickupDef pickupDef = PickupCatalog.GetPickupDef(pickup); if (pickupDef == null) { return new PickupWireRef(0, -1); } if ((int)pickupDef.itemIndex != -1) { return new PickupWireRef(1, (int)pickupDef.itemIndex); } if ((int)pickupDef.equipmentIndex != -1) { return new PickupWireRef(2, (int)pickupDef.equipmentIndex); } return new PickupWireRef(0, -1); } public static PickupIndex ToPickup(byte type, int catalogIndex) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (type == 1 && catalogIndex >= 0) { return PickupCatalog.FindPickupIndex((ItemIndex)catalogIndex); } if (type == 2 && catalogIndex >= 0) { return PickupCatalog.FindPickupIndex((EquipmentIndex)catalogIndex); } return PickupIndex.none; } } private readonly struct ServerKey : IEquatable<ServerKey> { public readonly byte Kind; public readonly int InstanceId; public readonly int Slot; public ServerKey(byte kind, int instanceId, int slot) { Kind = kind; InstanceId = instanceId; Slot = slot; } public bool Equals(ServerKey other) { return Kind == other.Kind && InstanceId == other.InstanceId && Slot == other.Slot; } public override bool Equals(object obj) { return obj is ServerKey other && Equals(other); } public override int GetHashCode() { return (((Kind * 397) ^ InstanceId) * 397) ^ Slot; } } private readonly struct ClientKey : IEquatable<ClientKey> { public readonly byte Kind; public readonly uint NetId; public readonly int Slot; public ClientKey(byte kind, uint netId, int slot) { Kind = kind; NetId = netId; Slot = slot; } public bool Equals(ClientKey other) { return Kind == other.Kind && NetId == other.NetId && Slot == other.Slot; } public override bool Equals(object obj) { return obj is ClientKey other && Equals(other); } public override int GetHashCode() { return (int)(((uint)(Kind * 397) ^ NetId) * 397) ^ Slot; } } private sealed class ServerRecord { public ServerKey Key; public Component Source; public byte Kind; public int Slot; public PickupIndex Original; public PickupIndex Candidate; public bool Eligible; public readonly Dictionary<uint, bool> ProcByMaster = new Dictionary<uint, bool>(); public readonly Dictionary<uint, string> SentViewByMaster = new Dictionary<uint, string>(); public readonly Dictionary<uint, float> LastSentAtByMaster = new Dictionary<uint, float>(); } private sealed class DirectGrantContext { public readonly ServerRecord Record; public readonly CharacterMaster ExpectedMaster; public DirectGrantContext(ServerRecord record, CharacterMaster expectedMaster) { Record = record; ExpectedMaster = expectedMaster; } } private sealed class CandidateGroup { public string Signature; public Vector3 Center; public float OpenUntil; public readonly HashSet<int> PickerInstanceIds = new HashSet<int>(); public readonly Dictionary<PickupIndex, PickupIndex> Candidates = new Dictionary<PickupIndex, PickupIndex>(); } private sealed class BossRewardWindow { public int BossGroupInstanceId; public float ExpiresAt; public readonly List<Vector3> Centers = new List<Vector3>(); public readonly HashSet<int> ExistingPickupIds = new HashSet<int>(); public readonly HashSet<int> ClaimedPickupIds = new HashSet<int>(); public readonly Dictionary<PickupIndex, PickupIndex> SharedCandidates = new Dictionary<PickupIndex, PickupIndex>(); } private sealed class PendingDrop { public PickupIndex Original; public Vector3 Position; public ServerRecord Source; public bool AllowFresh; public float CreatedAt; } public const string PluginGuid = "local.personaleulogy"; public const string PluginName = "Personal Eulogy"; public const string PluginVersion = "0.1.25"; private static Plugin Instance; private static Harmony HarmonyInstance; private static ConfigEntry<float> ChancePerStack; private static ConfigEntry<bool> LogDecisions; private static Xoroshiro128Plus PersonalRng; private static ulong FallbackSeedCounter = 14313749767032793493uL; private const byte KindGround = 1; private const byte KindTerminal = 2; private const byte KindPicker = 3; private const byte KindChest = 4; private static readonly Dictionary<ServerKey, ServerRecord> ServerRecords = new Dictionary<ServerKey, ServerRecord>(); private static readonly Dictionary<ClientKey, PickupIndex> ClientViews = new Dictionary<ClientKey, PickupIndex>(); private static readonly Dictionary<ClientKey, PickupIndex> ClientPickerOriginals = new Dictionary<ClientKey, PickupIndex>(); private static readonly List<PendingDrop> PendingDrops = new List<PendingDrop>(); private static readonly List<BossRewardWindow> BossRewardWindows = new List<BossRewardWindow>(); private static readonly List<CandidateGroup> OpenPickerCandidateGroups = new List<CandidateGroup>(); private static readonly Dictionary<int, CandidateGroup> PickerCandidateGroupByInstance = new Dictionary<int, CandidateGroup>(); private static readonly Stack<ServerRecord> InheritanceStack = new Stack<ServerRecord>(); private static readonly Stack<DirectGrantContext> DirectGrantStack = new Stack<DirectGrantContext>(); private static int DynamicDropContextDepth; [ThreadStatic] private static int DropletHookDepth; [ThreadStatic] private static int LocalPickupUiReadDepth; [ThreadStatic] private static int LookingGlassPingNotificationDepth; [ThreadStatic] private static PickupIndex LookingGlassPingNotificationOverride; private static float nextServerSweep; private static float nextClientSweep; private static readonly FieldInfo GenericPickupStateField = AccessTools.Field(typeof(GenericPickupController), "_pickupState"); private static readonly PropertyInfo GenericPickupProperty = AccessTools.Property(typeof(GenericPickupController), "pickup"); private static readonly FieldInfo ShopTerminalPickupField = AccessTools.Field(typeof(ShopTerminalBehavior), "pickup") ?? AccessTools.Field(typeof(ShopTerminalBehavior), "_pickup") ?? AccessTools.Field(typeof(ShopTerminalBehavior), "Networkpickup"); private static readonly PropertyInfo ShopTerminalPickupProperty = AccessTools.Property(typeof(ShopTerminalBehavior), "pickup"); private static readonly FieldInfo PickerOptionsField = AccessTools.Field(typeof(PickupPickerController), "options"); private static readonly PropertyInfo PickerOptionsProperty = AccessTools.Property(typeof(PickupPickerController), "options"); private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown Instance = this; HarmonyInstance = new Harmony("local.personaleulogy"); ChancePerStack = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Chance per Eulogy Zero stack", 0.05f, new ConfigDescription("Personal replacement chance contributed by each Eulogy Zero stack. 0.05 = 5%, 0.10 = 10%. Final chance is capped at 100%.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); LogDecisions = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Log personalized decisions", false, "Logs personalized Eulogy decisions. This can be noisy and is intended only for testing."); NetworkingAPI.RegisterMessageType<ViewSyncMessage>(); Run.onRunStartGlobal += OnRunStart; Run.onRunDestroyGlobal += OnRunDestroy; Stage.onStageStartGlobal += OnStageStart; try { PatchVanillaEulogy(); PatchEulogyRenameLocalization(); PatchGenericPickupGrant(); PatchGenericPickupUi(); PatchGenericPickupViewGetters(); PatchGenericPickupInteractionBehavior(); PatchGenericPickupSpawnInitialization(); PatchGenericPickupCreation(); PatchWorldInspectInfo(); PatchPingUi(); PatchPickerSelection(); PatchPickerDisplay(); PatchTerminalLifecycle(); PatchInheritanceSources(); PatchDropletCreation(); PatchDynamicVanillaSources(); PatchMonsterItemGrants(); PatchPlayerDirectItemGrants(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Personal Eulogy loaded."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Player-facing Eulogy results are personalized; one Lunar candidate is shared by all players who proc on the same source."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"All players should run this mod. Vanilla team-wide player-facing Eulogy replacement is disabled."); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Chance per stack: " + (ChancePerStack.Value * 100f).ToString("0.##") + "%.")); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Personal Eulogy initialization failed:\n" + ex)); } } private void Start() { PatchAutoItemPickupCompatibility(); PatchLookingGlassPingCompatibility(); } private void OnDestroy() { Run.onRunStartGlobal -= OnRunStart; Run.onRunDestroyGlobal -= OnRunDestroy; Stage.onStageStartGlobal -= OnStageStart; Harmony harmonyInstance = HarmonyInstance; if (harmonyInstance != null) { harmonyInstance.UnpatchSelf(); } ClearState(); Instance = null; } private static void OnRunStart(Run run) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown ClearState(); try { PersonalRng = new Xoroshiro128Plus(run.seed ^ 0x9E3779B97F4A7C15uL); } catch { PersonalRng = new Xoroshiro128Plus(++FallbackSeedCounter); } } private static void OnRunDestroy(Run run) { ClearState(); PersonalRng = null; } private static void OnStageStart(Stage stage) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) ServerRecords.Clear(); ClientViews.Clear(); ClientPickerOriginals.Clear(); PendingDrops.Clear(); BossRewardWindows.Clear(); OpenPickerCandidateGroups.Clear(); PickerCandidateGroupByInstance.Clear(); InheritanceStack.Clear(); DirectGrantStack.Clear(); DynamicDropContextDepth = 0; DropletHookDepth = 0; LookingGlassPingNotificationDepth = 0; LookingGlassPingNotificationOverride = PickupIndex.none; nextServerSweep = 0f; nextClientSweep = 0f; } private static void ClearState() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) ServerRecords.Clear(); ClientViews.Clear(); ClientPickerOriginals.Clear(); PendingDrops.Clear(); BossRewardWindows.Clear(); OpenPickerCandidateGroups.Clear(); PickerCandidateGroupByInstance.Clear(); InheritanceStack.Clear(); DirectGrantStack.Clear(); DynamicDropContextDepth = 0; DropletHookDepth = 0; LookingGlassPingNotificationDepth = 0; LookingGlassPingNotificationOverride = PickupIndex.none; } private void PatchEulogyRenameLocalization() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown MethodInfo[] array = typeof(Language).GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Where(delegate(MethodInfo m) { if (m.ReturnType != typeof(string)) { return false; } ParameterInfo[] parameters = m.GetParameters(); return parameters.Length == 1 && !(parameters[0].ParameterType != typeof(string)) && (m.Name == "GetString" || m.Name == "GetLocalizedStringByToken"); }).ToArray(); if (array.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find a Language token lookup method; Eulogy Zero will keep its original display name."); return; } HarmonyMethod val = new HarmonyMethod(typeof(EulogyNamePatch), "Postfix", (Type[])null); MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { HarmonyInstance.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private void FixedUpdate() { if (!((Object)(object)Run.instance == (Object)null)) { if (NetworkServer.active && Time.fixedTime >= nextServerSweep) { nextServerSweep = Time.fixedTime + 0.3f; ServerSweep(); } if (LocalUserManager.GetFirstLocalUser() != null && Time.fixedTime >= nextClientSweep) { nextClientSweep = Time.fixedTime + 0.25f; ClientSweep(); } } } private void PatchVanillaEulogy() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown Type type = typeof(Inventory).Assembly.GetType("RoR2.Items.RandomlyLunarUtils"); if (type == null) { throw new TypeLoadException("RoR2.Items.RandomlyLunarUtils was not found."); } MethodInfo[] array = (from m in type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == "CanReplace" && m.ReturnType == typeof(bool) select m).ToArray(); if (array.Length == 0) { throw new MissingMethodException(type.FullName, "CanReplace"); } HarmonyMethod val = new HarmonyMethod(typeof(VanillaCanReplacePatch), "Prefix", (Type[])null); MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { HarmonyInstance.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private void PatchGenericPickupGrant() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown MethodInfo[] array = typeof(GenericPickupController).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Where(delegate(MethodInfo m) { ParameterInfo[] parameters = m.GetParameters(); return m.Name == "AttemptGrant" && parameters.Length == 1 && parameters[0].ParameterType == typeof(CharacterBody); }).ToArray(); if (array.Length == 0) { throw new MissingMethodException(typeof(GenericPickupController).FullName, "AttemptGrant(CharacterBody)"); } HarmonyMethod val = new HarmonyMethod(typeof(GenericGrantPatch), "Prefix", (Type[])null); HarmonyMethod val2 = new HarmonyMethod(typeof(GenericGrantPatch), "Finalizer", (Type[])null); MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { HarmonyInstance.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null); } } private void PatchGenericPickupUi() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown string[] array = new string[2] { "GetDisplayName", "GetContextString" }; string[] array2 = array; foreach (string methodName in array2) { MethodInfo[] array3 = (from m in typeof(GenericPickupController).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == methodName && m.ReturnType == typeof(string) select m).ToArray(); if (array3.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("GenericPickupController." + methodName + " was not found; personalized pickup UI text may show the underlying item.")); continue; } HarmonyMethod val = new HarmonyMethod(typeof(GenericPickupUiPatch), "Prefix", (Type[])null); HarmonyMethod val2 = new HarmonyMethod(typeof(GenericPickupUiPatch), "Finalizer", (Type[])null); MethodInfo[] array4 = array3; foreach (MethodInfo methodInfo in array4) { HarmonyInstance.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null); } } } private void PatchGenericPickupViewGetters() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(GenericPickupController), "pickupIndex"); if (methodInfo != null) { HarmonyInstance.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(GenericPickupIndexGetterPatch), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"GenericPickupController.pickupIndex getter was not found; some ping/UI mods may show the underlying item."); } MethodInfo methodInfo2 = AccessTools.PropertyGetter(typeof(GenericPickupController), "pickup"); if (methodInfo2 != null && methodInfo2.ReturnType == typeof(UniquePickup)) { HarmonyInstance.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(GenericPickupGetterPatch), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private void PatchGenericPickupSpawnInitialization() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown MethodInfo[] array = (from m in typeof(GenericPickupController).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where (m.Name == "OnStartServer" || m.Name == "Start") && m.GetParameters().Length == 0 select m).ToArray(); if (array.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"GenericPickupController Start/OnStartServer was not found; fresh printer/chest drops may briefly show the underlying pickup."); return; } HarmonyMethod val = new HarmonyMethod(typeof(GroundPickupSpawnPatch), "Postfix", (Type[])null); MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { HarmonyInstance.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private void PatchGenericPickupCreation() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown MethodInfo[] array = (from m in typeof(GenericPickupController).GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == "CreatePickup" && m.ReturnType == typeof(GenericPickupController) select m).ToArray(); if (array.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"GenericPickupController.CreatePickup was not found; picker rewards created directly may lose their personalized source record."); return; } HarmonyMethod val = new HarmonyMethod(typeof(GenericPickupCreatePatch), "Postfix", (Type[])null); MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { HarmonyInstance.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private void PatchWorldInspectInfo() { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown try { Type providerInterface = AccessTools.TypeByName("RoR2.IInspectInfoProvider"); if (providerInterface == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"IInspectInfoProvider was not found; hold-TAB world inspection may show underlying pickups."); return; } Type[] source; try { source = typeof(GenericPickupController).Assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { source = ex.Types.Where((Type t) => t != null).ToArray(); } MethodInfo[] array = (from m in source.Where((Type t) => t != null && !t.IsAbstract && providerInterface.IsAssignableFrom(t) && typeof(Component).IsAssignableFrom(t)).SelectMany((Type t) => t.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) where !m.IsAbstract && m.GetParameters().Length == 0 && (m.Name == "GetInfo" || m.Name.EndsWith(".GetInfo", StringComparison.Ordinal)) && m.ReturnType != typeof(void) select m).Distinct().ToArray(); HarmonyMethod val = new HarmonyMethod(typeof(WorldInspectInfoPatch), "Prefix", (Type[])null); HarmonyMethod val2 = new HarmonyMethod(typeof(WorldInspectInfoPatch), "Finalizer", (Type[])null); MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { HarmonyInstance.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Patched " + array.Length + " world inspect provider(s) for personalized hold-TAB descriptions.")); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not patch hold-TAB world inspection: " + ex2.Message)); } } private void PatchPingUi() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown MethodInfo[] array = (from m in typeof(PingIndicator).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == "RebuildPing" select m).ToArray(); if (array.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"PingIndicator.RebuildPing was not found; personalized ping text/chat may show the underlying item."); } else { HarmonyMethod val = new HarmonyMethod(typeof(PingIndicatorUiPatch), "Prefix", (Type[])null); HarmonyMethod val2 = new HarmonyMethod(typeof(PingIndicatorUiPatch), "Finalizer", (Type[])null); MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { HarmonyInstance.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null); } } MethodInfo[] array3 = (from m in typeof(PingerController).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == "SetCurrentPing" || m.Name == "RebuildPing" select m).ToArray(); if (array3.Length != 0) { HarmonyMethod val3 = new HarmonyMethod(typeof(PingUiPatch), "Prefix", (Type[])null); HarmonyMethod val4 = new HarmonyMethod(typeof(PingUiPatch), "Finalizer", (Type[])null); MethodInfo[] array4 = array3; foreach (MethodInfo methodInfo2 in array4) { HarmonyInstance.Patch((MethodBase)methodInfo2, val3, (HarmonyMethod)null, (HarmonyMethod)null, val4, (HarmonyMethod)null); } } } private void PatchGenericPickupInteractionBehavior() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown MethodInfo[] array = (from m in typeof(GenericPickupController).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == "OnTriggerStay" && m.GetParameters().Length == 1 && m.GetParameters()[0].ParameterType == typeof(Collider) select m).ToArray(); MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { HarmonyInstance.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(PickupTriggerPatch), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } MethodInfo[] array3 = (from m in typeof(GenericPickupController).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == "GetInteractability" && m.ReturnType == typeof(Interactability) && m.GetParameters().Length == 1 && m.GetParameters()[0].ParameterType == typeof(Interactor) select m).ToArray(); MethodInfo[] array4 = array3; foreach (MethodInfo methodInfo2 in array4) { HarmonyInstance.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(PickupInteractabilityPatch), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (array.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"GenericPickupController.OnTriggerStay was not found; personalized Lunar pickups may still auto-collect on contact."); } if (array3.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"GenericPickupController.GetInteractability was not found; personalized Lunar pickups may not be manually interactable."); } } private void PatchAutoItemPickupCompatibility() { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown try { Type type = (from a in AppDomain.CurrentDomain.GetAssemblies() select a.GetType("AutoItemPickup.AutoItemPickup", throwOnError: false)).FirstOrDefault((Type t) => t != null); if (type == null) { return; } MethodInfo methodInfo = type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault(delegate(MethodInfo m) { if (m.Name != "GrantItem") { return false; } ParameterInfo[] parameters = m.GetParameters(); return parameters.Length == 2 && parameters[0].ParameterType == typeof(GenericPickupController) && parameters[1].ParameterType == typeof(CharacterMaster); }); if (methodInfo == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"AutoItemPickup was found, but its GrantItem(GenericPickupController, CharacterMaster) method was not. Personalized Lunars may be swept at stage end."); return; } HarmonyInstance.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(AutoItemPickupGrantPatch), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"AutoItemPickup compatibility active: personalized Lunars are reassigned to another player who sees the original item when possible."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not patch optional AutoItemPickup compatibility: " + ex.Message)); } } private void PatchLookingGlassPingCompatibility() { //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown try { Type type = AccessTools.TypeByName("LookingGlass.ItemStatsNameSpace.ItemStats"); if (type == null) { return; } MethodInfo methodInfo = typeof(CharacterMasterNotificationQueue).GetMethod("PushPickupNotification", BindingFlags.Static | BindingFlags.Public, null, new Type[4] { typeof(CharacterMaster), typeof(PickupIndex), typeof(bool), typeof(int) }, null); if (methodInfo == null) { methodInfo = typeof(CharacterMasterNotificationQueue).GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault(delegate(MethodInfo m) { if (m.Name != "PushPickupNotification") { return false; } ParameterInfo[] parameters = m.GetParameters(); return parameters.Length >= 2 && parameters[0].ParameterType == typeof(CharacterMaster) && parameters[1].ParameterType == typeof(PickupIndex); }); } if (methodInfo != null) { HarmonyInstance.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(LookingGlassNotificationPatch), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LookingGlass compatibility active: world-item descriptions resolve the current personalized ping target at notification time."); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"LookingGlass was found, but CharacterMasterNotificationQueue.PushPickupNotification could not be patched. World-item descriptions may still show the original pickup."); } MethodInfo methodInfo2 = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo m) => m.Name == "PutLastNotificationFirst" && m.GetParameters().Any((ParameterInfo p) => p.ParameterType == typeof(CharacterMaster))); if (methodInfo2 != null) { HarmonyInstance.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(LookingGlassNotificationReorderGuardPatch), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not patch optional LookingGlass ping compatibility: " + ex.Message)); } } private void PatchPickerSelection() { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown MethodInfo[] array = (from m in typeof(PickupPickerController).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where string.Equals(m.Name, "HandlePickupSelected", StringComparison.OrdinalIgnoreCase) && m.GetParameters().Any((ParameterInfo x) => x.ParameterType == typeof(int)) select m).Distinct().ToArray(); if (array.Length == 0) { array = (from m in typeof(PickupPickerController).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where string.Equals(m.Name, "SubmitChoice", StringComparison.OrdinalIgnoreCase) && m.GetParameters().Any((ParameterInfo x) => x.ParameterType == typeof(int)) select m).Distinct().ToArray(); } if (array.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"No PickupPickerController selection method was found; personalized Void/Blessing potentials may display correctly but grant the original pickup."); return; } HarmonyMethod val = new HarmonyMethod(typeof(PickerGrantPatch), "Prefix", (Type[])null); HarmonyMethod val2 = new HarmonyMethod(typeof(PickerGrantPatch), "Finalizer", (Type[])null); MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { HarmonyInstance.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null); } } private void PatchPickerDisplay() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown MethodInfo[] array = (from m in typeof(PickupPickerController).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where string.Equals(m.Name, "OnDisplayBegin", StringComparison.OrdinalIgnoreCase) select m).ToArray(); if (array.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"PickupPickerController.OnDisplayBegin was not found; picker displays may show original options."); return; } HarmonyMethod val = new HarmonyMethod(typeof(PickerDisplayPatch), "Prefix", (Type[])null); HarmonyMethod val2 = new HarmonyMethod(typeof(PickerDisplayPatch), "Finalizer", (Type[])null); MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { HarmonyInstance.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null); } } private void PatchTerminalLifecycle() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown MethodInfo[] array = (from m in typeof(ShopTerminalBehavior).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == "SetNoPickup" select m).ToArray(); if (array.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"ShopTerminalBehavior.SetNoPickup was not found; spent multishop displays may retain a personalized model."); return; } HarmonyMethod val = new HarmonyMethod(typeof(TerminalNoPickupPatch), "Postfix", (Type[])null); MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { HarmonyInstance.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private void PatchInheritanceSources() { PatchNamedMethods(typeof(ChestBehavior), "ItemDrop", typeof(ChestDropPatch)); PatchNamedMethods(typeof(ShopTerminalBehavior), "DropPickup", typeof(TerminalDropPatch)); } private void PatchDropletCreation() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown MethodInfo[] array = typeof(PickupDropletController).GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Where(delegate(MethodInfo m) { if (m.Name != "CreatePickupDroplet") { return false; } ParameterInfo[] parameters = m.GetParameters(); bool flag = parameters.Any((ParameterInfo x) => x.ParameterType == typeof(CreatePickupInfo) || x.ParameterType == typeof(PickupIndex) || x.ParameterType == typeof(UniquePickup)); bool flag2 = parameters.Any((ParameterInfo x) => x.ParameterType == typeof(Vector3)); return flag && flag2; }).ToArray(); if (array.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"No supported PickupDropletController.CreatePickupDroplet overload was found; terminal/chest/teleporter inheritance may miss some drops."); return; } HarmonyMethod val = new HarmonyMethod(typeof(DropletPatch), "Prefix", (Type[])null); HarmonyMethod val2 = new HarmonyMethod(typeof(DropletPatch), "Finalizer", (Type[])null); MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { HarmonyInstance.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Patched " + array.Length + " CreatePickupDroplet overload(s) for source inheritance.")); } private void PatchDynamicVanillaSources() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown PatchDynamicMethods(typeof(ShrineChanceBehavior), "AddShrineStack", "Shrine of Chance"); PatchDynamicMethods(typeof(SacrificeArtifactManager), "OnServerCharacterDeath", "Artifact of Sacrifice"); PatchDynamicMethods(typeof(EquipmentSlot), "FireBossHunter", "Trophy Hunter's Tricorn"); MethodInfo[] array = (from m in typeof(BossGroup).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == "DropRewards" select m).ToArray(); if (array.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find BossGroup.DropRewards; teleporter boss rewards may not be personalized."); return; } HarmonyMethod val = new HarmonyMethod(typeof(TeleporterBossDropPatch), "Prefix", (Type[])null); HarmonyMethod val2 = new HarmonyMethod(typeof(TeleporterBossDropPatch), "Finalizer", (Type[])null); MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { HarmonyInstance.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null); } } private void PatchDynamicMethods(Type type, string methodName, string label) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown MethodInfo[] array = (from m in type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == methodName select m).ToArray(); if (array.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not find " + type.Name + "." + methodName + "; " + label + " may not be personalized.")); } else { HarmonyMethod val = new HarmonyMethod(typeof(DynamicVanillaDropPatch), "Prefix", (Type[])null); HarmonyMethod val2 = new HarmonyMethod(typeof(DynamicVanillaDropPatch), "Finalizer", (Type[])null); MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { HarmonyInstance.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null); } } } private void PatchMonsterItemGrants() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown MethodInfo[] array = (from m in typeof(Inventory).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == "GiveItemPermanent" && m.GetParameters().Any((ParameterInfo p) => p.ParameterType == typeof(ItemIndex)) select m).ToArray(); if (array.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Inventory.GiveItemPermanent(ItemIndex, ...) was not found; monster-inventory Eulogy behavior will remain disabled in this build."); return; } HarmonyMethod val = new HarmonyMethod(typeof(MonsterGiveItemPatch), "Prefix", (Type[])null); MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { HarmonyInstance.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private void PatchPlayerDirectItemGrants() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown MethodInfo[] array = (from m in typeof(Inventory).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where (m.Name == "GiveItem" || m.Name == "GiveItemPermanent") && m.GetParameters().Any((ParameterInfo p) => p.ParameterType == typeof(ItemIndex)) select m).Distinct().ToArray(); if (array.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"No Inventory.GiveItem/GiveItemPermanent(ItemIndex, ...) methods were found; direct picker/printer grants may still give the original item."); return; } HarmonyMethod val = new HarmonyMethod(typeof(PlayerDirectGiveItemPatch), "Prefix", (Type[])null); MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { HarmonyInstance.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Patched " + array.Length + " Inventory direct-item grant overload(s) for scoped personalized grants.")); } private void PatchNamedMethods(Type targetType, string methodName, Type patchType) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown MethodInfo[] array = (from m in targetType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == methodName select m).ToArray(); if (array.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)(targetType.Name + "." + methodName + " was not found.")); return; } HarmonyMethod val = new HarmonyMethod(patchType, "Prefix", (Type[])null); HarmonyMethod val2 = new HarmonyMethod(patchType, "Finalizer", (Type[])null); MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { HarmonyInstance.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null); } } private static CharacterMaster FindAutoPickupAlternate(GenericPickupController pickup, CharacterMaster rejectedMaster) { if ((Object)(object)pickup == (Object)null) { return null; } List<CharacterMaster> list = new List<CharacterMaster>(); foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { CharacterMaster val = (((Object)(object)instance != (Object)null) ? instance.master : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)rejectedMaster) && !((Object)(object)val.inventory == (Object)null)) { NetworkUser networkUser = instance.networkUser; if (!((Object)(object)networkUser == (Object)null) && !ServerPlayerSeesLunar(pickup, val)) { list.Add(val); } } } if (list.Count == 0) { return null; } List<CharacterMaster> list2 = new List<CharacterMaster>(); foreach (PlayerCharacterMasterController instance2 in PlayerCharacterMasterController.instances) { if ((Object)(object)instance2 != (Object)null && (Object)(object)instance2.master != (Object)null && (Object)(object)instance2.networkUser != (Object)null) { list2.Add(instance2.master); } } int num = list2.IndexOf(rejectedMaster); if (num >= 0 && list2.Count > 1) { for (int i = 1; i < list2.Count; i++) { CharacterMaster val2 = list2[(num + i) % list2.Count]; if (list.Contains(val2)) { return val2; } } } return list[0]; } private static GenericPickupController FindPingPickup(PingerController controller, object[] args) { try { if (args != null) { foreach (object obj in args) { if (obj == null) { continue; } Type type = obj.GetType(); if (type.Name != "PingInfo") { continue; } GameObject val = null; FieldInfo fieldInfo = AccessTools.Field(type, "targetGameObject"); PropertyInfo propertyInfo = AccessTools.Property(type, "targetGameObject"); if (fieldInfo != null) { object? value = fieldInfo.GetValue(obj); val = (GameObject)((value is GameObject) ? value : null); } else if (propertyInfo != null && propertyInfo.CanRead) { object? value2 = propertyInfo.GetValue(obj, null); val = (GameObject)((value2 is GameObject) ? value2 : null); } if ((Object)(object)val == (Object)null) { object obj2 = null; FieldInfo fieldInfo2 = AccessTools.Field(type, "targetNetworkIdentity"); PropertyInfo propertyInfo2 = AccessTools.Property(type, "targetNetworkIdentity"); if (fieldInfo2 != null) { obj2 = fieldInfo2.GetValue(obj); } else if (propertyInfo2 != null && propertyInfo2.CanRead) { obj2 = propertyInfo2.GetValue(obj, null); } NetworkIdentity val2 = (NetworkIdentity)((obj2 is NetworkIdentity) ? obj2 : null); if ((Object)(object)val2 != (Object)null) { val = ((Component)val2).gameObject; } } if ((Object)(object)val != (Object)null) { GenericPickupController val3 = val.GetComponent<GenericPickupController>(); if ((Object)(object)val3 == (Object)null) { val3 = val.GetComponentInChildren<GenericPickupController>(); } if ((Object)(object)val3 != (Object)null) { return val3; } } } } if ((Object)(object)controller != (Object)null) { FieldInfo fieldInfo3 = AccessTools.Field(typeof(PingerController), "pingIndicator"); PropertyInfo propertyInfo3 = AccessTools.Property(typeof(PingerController), "pingIndicator"); PingIndicator val4 = (PingIndicator)((fieldInfo3 != null) ? /*isinst with value type is only supported in some contexts*/: ((propertyInfo3 != null && propertyInfo3.CanRead) ? /*isinst with value type is only supported in some contexts*/: null)); GameObject val5 = (((Object)(object)val4 != (Object)null) ? val4.pingTarget : null); if ((Object)(object)val5 != (Object)null) { GenericPickupController val6 = val5.GetComponent<GenericPickupController>(); if ((Object)(object)val6 == (Object)null) { val6 = val5.GetComponentInChildren<GenericPickupController>(); } return val6; } } } catch { } return null; } private static PickupIndex GetServerGroundView(GenericPickupController pickup, CharacterMaster master) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0050: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || (Object)(object)pickup == (Object)null || (Object)(object)master == (Object)null) { return PickupIndex.none; } ServerRecord serverRecord = GetServerRecord((Component)(object)pickup, 1, 0); if (serverRecord == null) { serverRecord = EnsureGroundRecord(pickup); } return (serverRecord != null) ? GetPlayerView(serverRecord, master) : PickupIndex.none; } private static bool ServerPlayerSeesLunar(GenericPickupController pickup, CharacterMaster master) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) PickupIndex serverGroundView = GetServerGroundView(pickup, master); return ((serverGroundView != PickupIndex.none) ? PickupCatalog.GetPickupDef(serverGroundView) : null)?.isLunar ?? false; } private static bool LocalPlayerSeesLunar(GenericPickupController pickup) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) PickupIndex localGroundReplacement = GetLocalGroundReplacement(pickup); return ((localGroundReplacement != PickupIndex.none) ? PickupCatalog.GetPickupDef(localGroundReplacement) : null)?.isLunar ?? false; } private static PickupIndex GetRawGenericPickupIndex(GenericPickupController controller) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: 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) if ((Object)(object)controller == (Object)null) { return PickupIndex.none; } try { if (GenericPickupStateField != null) { object value = GenericPickupStateField.GetValue(controller); Type fieldType = GenericPickupStateField.FieldType; if (fieldType == typeof(UniquePickup)) { return ((UniquePickup)value).pickupIndex; } if (fieldType == typeof(PickupIndex)) { return (PickupIndex)value; } if (value != null) { FieldInfo fieldInfo = fieldType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((FieldInfo f) => f.FieldType == typeof(UniquePickup)); if (fieldInfo != null) { return ((UniquePickup)fieldInfo.GetValue(value)).pickupIndex; } FieldInfo fieldInfo2 = fieldType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((FieldInfo f) => f.FieldType == typeof(PickupIndex)); if (fieldInfo2 != null) { return (PickupIndex)fieldInfo2.GetValue(value); } PropertyInfo propertyInfo = fieldType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((PropertyInfo p) => p.PropertyType == typeof(UniquePickup) && p.CanRead); if (propertyInfo != null) { return ((UniquePickup)propertyInfo.GetValue(value, null)).pickupIndex; } PropertyInfo propertyInfo2 = fieldType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((PropertyInfo p) => p.PropertyType == typeof(PickupIndex) && p.CanRead); if (propertyInfo2 != null) { return (PickupIndex)propertyInfo2.GetValue(value, null); } } } } catch { } return PickupIndex.none; } private static void RebaseGroundRecordAfterEquipmentSwap(GenericPickupController pickup, PickupIndex actualPickup) { //IL_0011: 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) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || (Object)(object)pickup == (Object)null || actualPickup == PickupIndex.none) { return; } ServerRecord serverRecord = GetServerRecord((Component)(object)pickup, 1, 0); if (serverRecord == null) { return; } serverRecord.Original = actualPickup; serverRecord.Candidate = PickupIndex.none; serverRecord.Eligible = false; serverRecord.ProcByMaster.Clear(); serverRecord.SentViewByMaster.Clear(); serverRecord.LastSentAtByMaster.Clear(); foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { CharacterMaster val = (((Object)(object)instance != (Object)null) ? instance.master : null); if (!((Object)(object)val == (Object)null)) { uint masterNetId = GetMasterNetId(val); if (masterNetId != 0) { serverRecord.ProcByMaster[masterNetId] = false; SendRecordToPlayer(serverRecord, instance, masterNetId); } } } } private static void RestoreGenericPickup(GenericPickupController controller, GenericGrantState state) { if (state == null || !state.Changed || (Object)(object)controller == (Object)null) { return; } try { if (state.UsedProperty && GenericPickupProperty != null && GenericPickupProperty.CanWrite) { GenericPickupProperty.SetValue(controller, state.OriginalProperty, null); } else if (GenericPickupStateField != null) { GenericPickupStateField.SetValue(controller, state.OriginalState);