using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [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: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("REPOJP")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("zabuMod")] [assembly: AssemblyTitle("zabuMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace REPOJP.DroneToOrbItem { [BepInPlugin("REPOJP.DroneToOrbItem", "DroneToOrbItem", "4.0.0")] public sealed class DroneToOrbItemPlugin : BaseUnityPlugin { public const string PluginGuid = "REPOJP.DroneToOrbItem"; public const string PluginName = "DroneToOrbItem"; public const string PluginVersion = "4.0.0"; internal static ManualLogSource Log = null; internal static DroneToOrbItemPlugin Instance = null; private Harmony harmony = null; internal static bool Registered; internal static readonly List Definitions = new List(); internal static readonly Dictionary RealItemsByInternalName = new Dictionary(StringComparer.Ordinal); internal static readonly Dictionary OriginalItemVolumes = new Dictionary(StringComparer.Ordinal); internal static readonly Dictionary PlannedCounts = new Dictionary(StringComparer.Ordinal); internal static int GuaranteedRegularSlots; internal static int GuaranteedHealthPackSlots; internal static ConfigEntry CfgCountPurchasedAgainstMax = null; internal static ConfigEntry CfgCommonOrbBatteryDrainRate = null; internal static ConfigEntry CfgOrbBatteryExtraDrainRate = null; internal static ConfigEntry CfgOrbHealRate = null; internal static ConfigEntry CfgOrbHealAmount = null; internal static ConfigEntry CfgHealDroneRate = null; internal static ConfigEntry CfgHealDroneAmount = null; private void Awake() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogInfo((object)"\n█████████████████████████████████████████████████████████████████████████████████████████████\n▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄ ▄▄ ▄▄▄▄▄ \n███▀▀██▄ ▀▀▀███▀▀▀ ▄███████▄ ██ ███ ██ \n███ ███ ████▄ ▄███▄ ████▄ ▄█▀█▄ ███ ▄███▄ ███ ███ ████▄ ████▄ ███ ▀██▀▀ ▄█▀█▄ ███▄███▄ \n███ ███ ██ ▀▀ ██ ██ ██ ██ ██▄█▀ ███ ██ ██ ███▄▄▄███ ██ ▀▀ ██ ██ ███ ██ ██▄█▀ ██ ██ ██ \n██████▀ ██ ▀███▀ ██ ██ ▀█▄▄▄ ███ ▀███▀ ▀█████▀ ██ ████▀ ▄███▄ ██ ▀█▄▄▄ ██ ██ ██ \n \n█████████████████████████████████████████████████████████████████████████████████████████████\n"); try { ((Component)this).transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); InitializeGlobalConfig(); InitializeDefinitions(); harmony = new Harmony("REPOJP.DroneToOrbItem"); harmony.PatchAll(); Log.LogInfo((object)"Loaded"); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failure: Awake\n" + ex)); } } private void OnDestroy() { try { if (harmony != null) { harmony.UnpatchSelf(); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failure: OnDestroy\n" + ex)); } } private void InitializeGlobalConfig() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown CfgCountPurchasedAgainstMax = ((BaseUnityPlugin)this).Config.Bind("General", "Count Purchased Against Max", true, "If true, purchased count is subtracted from the per-shop maximum.購入済み数をショップ最大個数から差し引くかどうか"); CfgCommonOrbBatteryDrainRate = ((BaseUnityPlugin)this).Config.Bind("Orb Common", "Common Orb Battery Drain Rate", 0.1f, new ConfigDescription("Fallback common battery drain rate for orb items.オーブ系アイテムの共通消費量の既定値", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); CfgOrbBatteryExtraDrainRate = ((BaseUnityPlugin)this).Config.Bind("Orb Battery", "Orb Battery Extra Drain Rate", 1.5f, new ConfigDescription("Additional battery drain used by Orb Battery when it charges targets.Orb Batteryが対象を充電した時の追加消費量", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); CfgOrbHealRate = ((BaseUnityPlugin)this).Config.Bind("Orb Heal", "Orb Heal Rate", 2f, new ConfigDescription("Heal interval in seconds for Orb Heal.Orb Healの回復間隔 秒", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 100f), Array.Empty())); CfgOrbHealAmount = ((BaseUnityPlugin)this).Config.Bind("Orb Heal", "Orb Heal Amount", 10, new ConfigDescription("Heal amount per tick for Orb Heal.Orb Healの1回あたり回復量", (AcceptableValueBase)(object)new AcceptableValueRange(0, 1000), Array.Empty())); CfgHealDroneRate = ((BaseUnityPlugin)this).Config.Bind("Heal Drone", "Heal Drone Rate", 2f, new ConfigDescription("Heal interval in seconds for Heal Drone.Heal Droneの回復間隔 秒", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 100f), Array.Empty())); CfgHealDroneAmount = ((BaseUnityPlugin)this).Config.Bind("Heal Drone", "Heal Drone Amount", 10, new ConfigDescription("Heal amount per tick for Heal Drone.Heal Droneの1回あたり回復量", (AcceptableValueBase)(object)new AcceptableValueRange(0, 1000), Array.Empty())); } private void InitializeDefinitions() { if (Definitions.Count <= 0) { Definitions.Add(new UnlockDefinition((BaseUnityPlugin)(object)this, "Orb Battery", "Item Orb Battery", "Charges nearby battery items while active", "起動中に周囲のバッテリー系アイテムを充電", (itemType)1, typeof(ItemOrbBattery), 1, 10, createHealSlotConfig: false, 1f, 0)); Definitions.Add(new UnlockDefinition((BaseUnityPlugin)(object)this, "Orb Feather", "Item Orb Feather", "Makes nearby players and objects lighter while active", "起動中に周囲のプレイヤーや物体を軽くする", (itemType)1, typeof(ItemOrbFeather), 1, 10, createHealSlotConfig: false, 1f, 0)); Definitions.Add(new UnlockDefinition((BaseUnityPlugin)(object)this, "Orb Heal", "Item Orb Heal", "Heals the player while active", "起動中にプレイヤーを回復", (itemType)1, typeof(ItemOrbHeal), 1, 10, createHealSlotConfig: true, 1f, 20)); Definitions.Add(new UnlockDefinition((BaseUnityPlugin)(object)this, "Orb Indestructible", "Item Orb Indestructible", "Makes nearby objects indestructible while active", "起動中に周囲の物体へ無敵効果を付与", (itemType)1, typeof(ItemOrbIndestructible), 1, 10, createHealSlotConfig: false, 1f, 0)); Definitions.Add(new UnlockDefinition((BaseUnityPlugin)(object)this, "Orb Magnet", "Item Orb Magnet", "Pulls nearby objects toward itself while active", "起動中に周囲の物体を引き寄せ", (itemType)1, typeof(ItemOrbMagnet), 1, 10, createHealSlotConfig: false, 1f, 20)); Definitions.Add(new UnlockDefinition((BaseUnityPlugin)(object)this, "Orb Torque", "Item Orb Torque", "Applies sticky control to nearby objects while active", "起動中に周囲の物体へ粘着的な制御を付与", (itemType)1, typeof(ItemOrbTorque), 1, 0, createHealSlotConfig: false, 1f, 0)); Definitions.Add(new UnlockDefinition((BaseUnityPlugin)(object)this, "Orb Zero Gravity", "Item Orb Zero Gravity", "Applies zero gravity to nearby players and objects while active", "起動中に周囲のプレイヤーや物体へ無重力効果を付与", (itemType)1, typeof(ItemOrbZeroGravity), 1, 10, createHealSlotConfig: false, 1f, 0)); Definitions.Add(new UnlockDefinition((BaseUnityPlugin)(object)this, "Heal Drone", "Item Drone Heal", "Heals the targeted player while active", "起動中に対象プレイヤーを回復", (itemType)0, typeof(ItemDroneHeal), 1, 10, createHealSlotConfig: false, 1f, 20)); } } internal static List CollectAllItems() { Dictionary dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); try { foreach (UnlockDefinition definition in Definitions) { if (definition != null && !string.IsNullOrEmpty(definition.InternalName)) { string[] targetResourcePathCandidates = GetTargetResourcePathCandidates(definition.InternalName); for (int i = 0; i < targetResourcePathCandidates.Length; i++) { Item item = Resources.Load(targetResourcePathCandidates[i]); RegisterItemToMap(dictionary, item); } } } } catch (Exception ex) { Log.LogError((object)("Failure: Load target item resources\n" + ex)); } try { Item[] array = Resources.FindObjectsOfTypeAll(); for (int j = 0; j < array.Length; j++) { RegisterItemToMap(dictionary, array[j]); } } catch (Exception ex2) { Log.LogError((object)("Failure: Resources.FindObjectsOfTypeAll\n" + ex2)); } return new List(dictionary.Values); } private static string[] GetTargetResourcePathCandidates(string internalName) { if (string.IsNullOrEmpty(internalName)) { return new string[0]; } return new string[2] { "Items/" + internalName, "Items/Removed Items/" + internalName }; } private static void RegisterItemToMap(Dictionary map, Item item) { if (!((Object)(object)item == (Object)null)) { string uniqueItemKey = GetUniqueItemKey(item); if (!string.IsNullOrEmpty(uniqueItemKey) && !map.ContainsKey(uniqueItemKey)) { map.Add(uniqueItemKey, item); } } } internal static string GetUniqueItemKey(Item item) { if ((Object)(object)item == (Object)null) { return string.Empty; } string prefabResourcePath = GetPrefabResourcePath(item); if (!string.IsNullOrEmpty(prefabResourcePath)) { return prefabResourcePath; } if (!string.IsNullOrEmpty(((Object)item).name)) { return ((Object)item).name; } if (!string.IsNullOrEmpty(item.itemName)) { return item.itemName; } return string.Empty; } internal static string GetPrefabResourcePath(Item item) { try { if ((Object)(object)item != (Object)null && item.prefab != null && !string.IsNullOrEmpty(item.prefab.ResourcePath)) { return item.prefab.ResourcePath; } } catch { } return string.Empty; } internal static string GetItemDisplayName(Item item) { if ((Object)(object)item == (Object)null) { return "Unknown"; } if (!string.IsNullOrEmpty(item.itemName)) { return item.itemName; } if (!string.IsNullOrEmpty(((Object)item).name)) { return ((Object)item).name; } return "Unknown"; } } internal sealed class UnlockDefinition { public string DisplayName; public string InternalName; public string DescriptionEn; public string DescriptionJa; public itemType DefaultItemType; public Type ComponentType; public ConfigEntry CfgEnabled; public ConfigEntry CfgMaxInShop; public ConfigEntry CfgChancePercent; public ConfigEntry CfgPriceDelta; public ConfigEntry CfgHealUseHealthPackSlot; public ConfigEntry CfgOrbRadius; public ConfigEntry CfgOrbBatteryDrainRate; public ConfigEntry CfgAllowThroughWalls; public ConfigEntry CfgOnlyActiveWhileHeld; public UnlockDefinition(BaseUnityPlugin plugin, string displayName, string internalName, string descriptionEn, string descriptionJa, itemType defaultItemType, Type componentType, int defaultMaxInShop, int defaultChancePercent, bool createHealSlotConfig, float defaultRadius, int defaultPriceDelta) { //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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Expected O, but got Unknown DisplayName = displayName; InternalName = internalName; DescriptionEn = descriptionEn; DescriptionJa = descriptionJa; DefaultItemType = defaultItemType; ComponentType = componentType; CfgEnabled = plugin.Config.Bind("Enabled", displayName + " Enabled", true, displayName + " enabled in shop rolls.ショップ抽選対象に含めるかどうか"); CfgMaxInShop = plugin.Config.Bind("Shop Max Amount", displayName + " Max Amount In Shop", defaultMaxInShop, new ConfigDescription(displayName + " maximum possible amount per shop roll.ショップ1回の抽選で出現しうる最大個数", (AcceptableValueBase)(object)new AcceptableValueRange(1, 10), Array.Empty())); CfgChancePercent = plugin.Config.Bind("Shop Spawn Chance", displayName + " Spawn Chance Percent", defaultChancePercent, new ConfigDescription(displayName + " shop appearance chance percent.ショップ出現確率パーセント", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); CfgPriceDelta = plugin.Config.Bind("Shop Price Delta", displayName + " Price Delta", defaultPriceDelta, new ConfigDescription(displayName + " price delta added to the generated shop price.生成されたショップ価格へ加算減算する差分", (AcceptableValueBase)(object)new AcceptableValueRange(-50, 50), Array.Empty())); if (createHealSlotConfig) { CfgHealUseHealthPackSlot = plugin.Config.Bind("Orb Heal", "Orb Heal Use HealthPack Slot", false, "Use health-pack slot behavior for Orb Heal.Orb Healをヘルスパック枠扱いにするかどうか"); } CfgOrbRadius = plugin.Config.Bind("Orb Radius", displayName + " Radius", defaultRadius, new ConfigDescription(displayName + " effect radius and visual effect size.効果範囲サイズと表示エフェクトサイズ", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 100f), Array.Empty())); CfgOrbBatteryDrainRate = plugin.Config.Bind("Orb Individual Battery Drain", displayName + " Battery Drain Rate", 0.1f, new ConfigDescription(displayName + " individual common battery drain override.各オーブ個別の共通消費量上書き", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); CfgAllowThroughWalls = plugin.Config.Bind("Orb Through Walls", displayName + " Allow Through Walls", true, displayName + " can affect targets through walls.壁越しでも効果を適用するかどうか"); CfgOnlyActiveWhileHeld = plugin.Config.Bind("Orb Held Only", displayName + " Only Active While Held", false, displayName + " works only while the item is being held.持っている時だけ有効にするかどうか"); } } [HarmonyPatch] internal static class DroneToOrbItemPatches { private static readonly FieldInfo ItemAttributesValueField = AccessTools.Field(typeof(ItemAttributes), "value"); private static readonly FieldInfo ItemAttributesShopItemField = AccessTools.Field(typeof(ItemAttributes), "shopItem"); private static readonly FieldInfo ItemOrbRadiusOriginalField = AccessTools.Field(typeof(ItemOrb), "orbRadiusOriginal"); private static readonly FieldInfo ItemOrbObjectAffectedField = AccessTools.Field(typeof(ItemOrb), "objectAffected"); private static readonly FieldInfo ItemOrbLocalPlayerAffectedField = AccessTools.Field(typeof(ItemOrb), "localPlayerAffected"); private static readonly FieldInfo ItemOrbHealRateField = AccessTools.Field(typeof(ItemOrbHeal), "healRate"); private static readonly FieldInfo ItemOrbHealAmountField = AccessTools.Field(typeof(ItemOrbHeal), "healAmount"); private static readonly FieldInfo ItemDroneHealRateField = AccessTools.Field(typeof(ItemDroneHeal), "healRate"); private static readonly FieldInfo ItemDroneHealAmountField = AccessTools.Field(typeof(ItemDroneHeal), "healAmount"); private static int originalItemSpawnTargetAmount; private static int originalItemHealthPacksAmount; [HarmonyPostfix] [HarmonyPatch(typeof(StatsManager), "RunStartStats")] private static void StatsManager_RunStartStats_Postfix() { if (IsHostAuthority()) { TryRegisterTargets(); } } [HarmonyPostfix] [HarmonyPatch(typeof(StatsManager), "ResetAllStats")] private static void StatsManager_ResetAllStats_Postfix() { if (IsHostAuthority()) { DroneToOrbItemPlugin.Registered = false; TryRegisterTargets(); } } [HarmonyPrefix] [HarmonyPatch(typeof(ShopManager), "ShopInitialize")] private static void ShopManager_ShopInitialize_Prefix() { if (IsHostAuthority()) { DroneToOrbItemPlugin.PlannedCounts.Clear(); DroneToOrbItemPlugin.GuaranteedRegularSlots = 0; DroneToOrbItemPlugin.GuaranteedHealthPackSlots = 0; TryRegisterTargets(); } } [HarmonyPostfix] [HarmonyPatch(typeof(ShopManager), "GetAllItemsFromStatsManager")] private static void ShopManager_GetAllItemsFromStatsManager_Postfix(ShopManager __instance) { //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Invalid comparison between Unknown and I4 if (!IsHostAuthority()) { return; } try { if ((Object)(object)__instance == (Object)null || (Object)(object)StatsManager.instance == (Object)null) { return; } TryRegisterTargets(); DroneToOrbItemPlugin.PlannedCounts.Clear(); DroneToOrbItemPlugin.GuaranteedRegularSlots = 0; DroneToOrbItemPlugin.GuaranteedHealthPackSlots = 0; RemoveTargetItemsFromPotentialLists(__instance); foreach (UnlockDefinition definition in DroneToOrbItemPlugin.Definitions) { if (!definition.CfgEnabled.Value) { LogShopRoll(definition, 0, "disabled"); continue; } Item val = FindRegisteredItemByDefinition(definition); if ((Object)(object)val == (Object)null) { DroneToOrbItemPlugin.Log.LogWarning((object)("Failure: Registered item not found - " + definition.InternalName)); continue; } ApplyPerShopSettings(val, definition); int num = CalculatePlannedCount(val, definition); DroneToOrbItemPlugin.PlannedCounts[((Object)val).name] = num; if (num > 0) { AddItemToCorrectPotentialList(__instance, val, num); if (definition.CfgChancePercent.Value >= 100) { if ((int)val.itemType == 8) { DroneToOrbItemPlugin.GuaranteedHealthPackSlots += num; } else { DroneToOrbItemPlugin.GuaranteedRegularSlots += num; } } } LogShopRoll(definition, num, ((object)(itemType)(ref val.itemType)).ToString() + " path=" + DroneToOrbItemPlugin.GetPrefabResourcePath(val)); } DroneToOrbItemPlugin.Log.LogInfo((object)("Shop Roll Summary: regularGuaranteed=" + DroneToOrbItemPlugin.GuaranteedRegularSlots + " healthGuaranteed=" + DroneToOrbItemPlugin.GuaranteedHealthPackSlots)); } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogError((object)("Failure: ShopManager_GetAllItemsFromStatsManager_Postfix\n" + ex)); } } [HarmonyPrefix] [HarmonyPatch(typeof(PunManager), "ShopPopulateItemVolumes")] private static void PunManager_ShopPopulateItemVolumes_Prefix() { if (!IsHostAuthority()) { return; } try { if (!((Object)(object)ShopManager.instance == (Object)null)) { originalItemSpawnTargetAmount = ShopManager.instance.itemSpawnTargetAmount; originalItemHealthPacksAmount = ShopManager.instance.itemHealthPacksAmount; ShopManager instance = ShopManager.instance; instance.itemSpawnTargetAmount += DroneToOrbItemPlugin.GuaranteedRegularSlots; ShopManager instance2 = ShopManager.instance; instance2.itemHealthPacksAmount += DroneToOrbItemPlugin.GuaranteedHealthPackSlots; } } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogError((object)("Failure: PunManager_ShopPopulateItemVolumes_Prefix\n" + ex)); } } [HarmonyPostfix] [HarmonyPatch(typeof(PunManager), "ShopPopulateItemVolumes")] private static void PunManager_ShopPopulateItemVolumes_Postfix() { if (!IsHostAuthority()) { return; } try { if (!((Object)(object)ShopManager.instance == (Object)null)) { ShopManager.instance.itemSpawnTargetAmount = originalItemSpawnTargetAmount; ShopManager.instance.itemHealthPacksAmount = originalItemHealthPacksAmount; } } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogError((object)("Failure: PunManager_ShopPopulateItemVolumes_Postfix\n" + ex)); } } [HarmonyPostfix] [HarmonyPatch(typeof(ItemAttributes), "GetValue")] private static void ItemAttributes_GetValue_Postfix(ItemAttributes __instance) { if (!IsHostAuthority()) { return; } try { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.item == (Object)null || !GetShopItemFlag(__instance)) { return; } UnlockDefinition unlockDefinition = FindDefinitionByItem(__instance.item); if (unlockDefinition != null && unlockDefinition.CfgEnabled.Value) { int itemAttributesValue = GetItemAttributesValue(__instance); int num = Mathf.Clamp(unlockDefinition.CfgPriceDelta.Value, -50, 50); int num2 = Mathf.Max(0, itemAttributesValue + num); SetItemAttributesValue(__instance, num2); PhotonView component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null && PhotonNetwork.IsMasterClient) { component.RPC("GetValueRPC", (RpcTarget)1, new object[1] { num2 }); } } } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogError((object)("Failure: ItemAttributes_GetValue_Postfix\n" + ex)); } } [HarmonyPrefix] [HarmonyPatch(typeof(ItemOrb), "Update")] private static void ItemOrb_Update_Prefix(ItemOrb __instance) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 try { if ((Object)(object)__instance == (Object)null) { return; } UnlockDefinition unlockDefinition = FindDefinitionByGameObject(((Component)__instance).gameObject); if (unlockDefinition != null && (int)unlockDefinition.DefaultItemType == 1) { float num = (__instance.orbRadius = Mathf.Max(0.01f, unlockDefinition.CfgOrbRadius.Value)); if (ItemOrbRadiusOriginalField != null) { ItemOrbRadiusOriginalField.SetValue(__instance, num); } ItemBattery component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { component.batteryDrainRate = (__instance.batteryDrainRate = Mathf.Max(0f, unlockDefinition.CfgOrbBatteryDrainRate.Value)); } } } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogError((object)("Failure: ItemOrb_Update_Prefix\n" + ex)); } } [HarmonyPrefix] [HarmonyPatch(typeof(ItemOrb), "OrbConstantLogic")] private static bool ItemOrb_OrbConstantLogic_Prefix(ItemOrb __instance) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__instance == (Object)null) { return true; } UnlockDefinition unlockDefinition = FindDefinitionByGameObject(((Component)__instance).gameObject); if (unlockDefinition == null || (int)unlockDefinition.DefaultItemType != 1) { return true; } if (!IsHostAuthority()) { return true; } ItemBattery component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null) { SetObjectAffected(__instance, new List()); SetLocalPlayerAffected(__instance, value: false); return false; } if (component.batteryLifeInt == 0 || component.batteryLife <= 0f || !__instance.itemActive) { SetObjectAffected(__instance, new List()); SetLocalPlayerAffected(__instance, value: false); return false; } PhysGrabObject component2 = ((Component)__instance).GetComponent(); bool flag = (Object)(object)component2 != (Object)null && component2.grabbed; if (unlockDefinition.CfgOnlyActiveWhileHeld.Value && !flag) { SetObjectAffected(__instance, new List()); SetLocalPlayerAffected(__instance, value: false); return false; } bool flag2 = !unlockDefinition.CfgAllowThroughWalls.Value; List list = new List(); if (__instance.targetEnemies || __instance.targetNonValuables || __instance.targetValuables) { List list2 = SemiFunc.PhysGrabObjectGetAllWithinRange(__instance.orbRadius, ((Component)__instance).transform.position, flag2, LayerMask.op_Implicit(LayerMask.GetMask(new string[2] { "Default", "PhysGrabObject" })), component2); ITargetingCondition component3 = ((Component)__instance).GetComponent(); for (int i = 0; i < list2.Count; i++) { PhysGrabObject val = list2[i]; if (!((Object)(object)val == (Object)null)) { bool flag3 = component3 == null || component3.CustomTargetingCondition(((Component)val).gameObject); if (__instance.targetEnemies && val.isEnemy && flag3) { list.Add(val); } else if (__instance.targetNonValuables && val.isNonValuable && flag3) { list.Add(val); } else if (__instance.targetValuables && val.isValuable && flag3) { list.Add(val); } } } } bool value = false; if (__instance.targetPlayers) { value = SemiFunc.LocalPlayerOverlapCheck(__instance.orbRadius, ((Component)__instance).transform.position, flag2); } SetObjectAffected(__instance, list); SetLocalPlayerAffected(__instance, value); return false; } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogError((object)("Failure: ItemOrb_OrbConstantLogic_Prefix\n" + ex)); try { SetObjectAffected(__instance, new List()); SetLocalPlayerAffected(__instance, value: false); } catch { } return false; } } [HarmonyPostfix] [HarmonyPatch(typeof(ItemOrbHeal), "Start")] private static void ItemOrbHeal_Start_Postfix(ItemOrbHeal __instance) { if (!((Object)(object)__instance == (Object)null)) { UnlockDefinition unlockDefinition = FindDefinitionByGameObject(((Component)__instance).gameObject); if (unlockDefinition != null && !(unlockDefinition.ComponentType != typeof(ItemOrbHeal))) { ApplyHealOrbConfig(__instance); } } } [HarmonyPrefix] [HarmonyPatch(typeof(ItemOrbHeal), "Update")] private static bool ItemOrbHeal_Update_Prefix(ItemOrbHeal __instance) { if ((Object)(object)__instance == (Object)null) { return true; } UnlockDefinition unlockDefinition = FindDefinitionByGameObject(((Component)__instance).gameObject); if (unlockDefinition == null || unlockDefinition.ComponentType != typeof(ItemOrbHeal)) { return true; } if (unlockDefinition.CfgOnlyActiveWhileHeld.Value) { PhysGrabObject component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null && !component.grabbed) { return false; } } ApplyHealOrbConfig(__instance); return true; } [HarmonyPrefix] [HarmonyPatch(typeof(ItemOrbBattery), "BatteryDrain")] private static bool ItemOrbBattery_BatteryDrain_Prefix(ItemOrbBattery __instance, ref float amount) { if ((Object)(object)__instance == (Object)null) { return true; } UnlockDefinition unlockDefinition = FindDefinitionByGameObject(((Component)__instance).gameObject); if (unlockDefinition == null || unlockDefinition.ComponentType != typeof(ItemOrbBattery)) { return true; } if (!IsHostAuthority()) { return true; } if (unlockDefinition.CfgOnlyActiveWhileHeld.Value) { PhysGrabObject component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null && !component.grabbed) { return false; } } amount = Mathf.Max(0f, DroneToOrbItemPlugin.CfgOrbBatteryExtraDrainRate.Value); return true; } [HarmonyPostfix] [HarmonyPatch(typeof(ItemDroneHeal), "Start")] private static void ItemDroneHeal_Start_Postfix(ItemDroneHeal __instance) { if (!((Object)(object)__instance == (Object)null)) { UnlockDefinition unlockDefinition = FindDefinitionByGameObject(((Component)__instance).gameObject); if (unlockDefinition != null && !(unlockDefinition.ComponentType != typeof(ItemDroneHeal))) { ApplyHealDroneConfig(__instance); } } } [HarmonyPrefix] [HarmonyPatch(typeof(ItemDroneHeal), "Update")] private static bool ItemDroneHeal_Update_Prefix(ItemDroneHeal __instance) { if ((Object)(object)__instance == (Object)null) { return true; } UnlockDefinition unlockDefinition = FindDefinitionByGameObject(((Component)__instance).gameObject); if (unlockDefinition == null || unlockDefinition.ComponentType != typeof(ItemDroneHeal)) { return true; } ApplyHealDroneConfig(__instance); return true; } private static bool IsHostAuthority() { try { return SemiFunc.IsMasterClientOrSingleplayer(); } catch { return false; } } private static void ApplyHealOrbConfig(ItemOrbHeal itemOrbHeal) { try { if (!((Object)(object)itemOrbHeal == (Object)null)) { if (ItemOrbHealRateField != null) { ItemOrbHealRateField.SetValue(itemOrbHeal, Mathf.Max(0.01f, DroneToOrbItemPlugin.CfgOrbHealRate.Value)); } if (ItemOrbHealAmountField != null) { ItemOrbHealAmountField.SetValue(itemOrbHeal, Mathf.Max(0, DroneToOrbItemPlugin.CfgOrbHealAmount.Value)); } } } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogError((object)("Failure: ApplyHealOrbConfig\n" + ex)); } } private static void ApplyHealDroneConfig(ItemDroneHeal itemDroneHeal) { try { if (!((Object)(object)itemDroneHeal == (Object)null)) { if (ItemDroneHealRateField != null) { ItemDroneHealRateField.SetValue(itemDroneHeal, Mathf.Max(0.01f, DroneToOrbItemPlugin.CfgHealDroneRate.Value)); } if (ItemDroneHealAmountField != null) { ItemDroneHealAmountField.SetValue(itemDroneHeal, Mathf.Max(0, DroneToOrbItemPlugin.CfgHealDroneAmount.Value)); } } } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogError((object)("Failure: ApplyHealDroneConfig\n" + ex)); } } private static Item FindRegisteredItemByDefinition(UnlockDefinition definition) { if (definition == null) { return null; } if (DroneToOrbItemPlugin.RealItemsByInternalName.TryGetValue(definition.InternalName, out Item value)) { return value; } return null; } private static void TryRegisterTargets() { try { if ((Object)(object)StatsManager.instance == (Object)null) { return; } if (DroneToOrbItemPlugin.Registered) { EnsureDictionaryKeysForTargets(); return; } List allItems = DroneToOrbItemPlugin.CollectAllItems(); int num = 0; foreach (UnlockDefinition definition in DroneToOrbItemPlugin.Definitions) { if (RegisterRealExistingItem(definition, allItems)) { num++; } } DroneToOrbItemPlugin.Registered = num > 0; DroneToOrbItemPlugin.Log.LogInfo((object)("Target registration completed count=" + num)); } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogError((object)("Failure: TryRegisterTargets\n" + ex)); } } private static bool RegisterRealExistingItem(UnlockDefinition definition, List allItems) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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) try { Item val = FindRealItemByDefinition(definition, allItems); if ((Object)(object)val == (Object)null) { DroneToOrbItemPlugin.Log.LogWarning((object)("Failure: Real item asset not found - " + definition.InternalName)); return false; } string prefabResourcePath = DroneToOrbItemPlugin.GetPrefabResourcePath(val); if (string.IsNullOrEmpty(prefabResourcePath)) { DroneToOrbItemPlugin.Log.LogWarning((object)("Failure: Real item resource path empty - " + definition.InternalName)); return false; } val.disabled = false; val.itemSecretShopType = (itemSecretShopType)0; val.physicalItem = true; val.maxPurchase = false; val.maxPurchaseAmount = 1; val.itemType = definition.DefaultItemType; val.maxAmountInShop = Mathf.Max(val.maxAmountInShop, 1); val.maxAmount = Mathf.Max(val.maxAmount, val.maxAmountInShop); if (string.IsNullOrEmpty(val.itemName) || val.itemName == "N/A") { val.itemName = definition.DisplayName; } if (string.IsNullOrEmpty(val.description)) { val.description = definition.DescriptionEn + "." + definition.DescriptionJa; } if (!DroneToOrbItemPlugin.RealItemsByInternalName.ContainsKey(definition.InternalName)) { DroneToOrbItemPlugin.RealItemsByInternalName.Add(definition.InternalName, val); } else { DroneToOrbItemPlugin.RealItemsByInternalName[definition.InternalName] = val; } if (!DroneToOrbItemPlugin.OriginalItemVolumes.ContainsKey(((Object)val).name)) { DroneToOrbItemPlugin.OriginalItemVolumes.Add(((Object)val).name, val.itemVolume); } if (!StatsManager.instance.itemDictionary.ContainsKey(((Object)val).name)) { StatsManager.instance.itemDictionary.Add(((Object)val).name, val); } else { StatsManager.instance.itemDictionary[((Object)val).name] = val; } AddMissingDictionaryKeys(((Object)val).name); DroneToOrbItemPlugin.Log.LogInfo((object)("Registered real item: " + ((Object)val).name + " path=" + prefabResourcePath)); return true; } catch (Exception ex) { string text = ((definition != null) ? definition.InternalName : "Unknown"); DroneToOrbItemPlugin.Log.LogError((object)("Failure: RegisterRealExistingItem " + text + "\n" + ex)); return false; } } private static bool IsItemNameMatch(Item item, UnlockDefinition definition) { if ((Object)(object)item == (Object)null || definition == null) { return false; } if (string.Equals(((Object)item).name, definition.InternalName, StringComparison.OrdinalIgnoreCase)) { return true; } if (string.Equals(((Object)item).name, definition.DisplayName, StringComparison.OrdinalIgnoreCase)) { return true; } if (string.Equals(item.itemName, definition.InternalName, StringComparison.OrdinalIgnoreCase)) { return true; } if (string.Equals(item.itemName, definition.DisplayName, StringComparison.OrdinalIgnoreCase)) { return true; } return false; } private static Item FindRealItemByDefinition(UnlockDefinition definition, List allItems) { if (definition == null || allItems == null) { return null; } for (int i = 0; i < allItems.Count; i++) { Item val = allItems[i]; if (!((Object)(object)val == (Object)null) && IsItemNameMatch(val, definition) && !string.IsNullOrEmpty(DroneToOrbItemPlugin.GetPrefabResourcePath(val))) { return val; } } for (int j = 0; j < allItems.Count; j++) { Item val2 = allItems[j]; if ((Object)(object)val2 == (Object)null) { continue; } GameObject val3 = null; try { if (val2.prefab != null && !string.IsNullOrEmpty(DroneToOrbItemPlugin.GetPrefabResourcePath(val2))) { val3 = val2.prefab.Prefab; } } catch { } if (!((Object)(object)val3 == (Object)null) && (Object)(object)val3.GetComponent(definition.ComponentType) != (Object)null) { return val2; } } return null; } private static void RemoveTargetItemsFromPotentialLists(ShopManager shopManager) { if ((Object)(object)shopManager == (Object)null) { return; } HashSet targetNames = new HashSet(); foreach (UnlockDefinition definition in DroneToOrbItemPlugin.Definitions) { Item val = FindRegisteredItemByDefinition(definition); if ((Object)(object)val != (Object)null) { targetNames.Add(((Object)val).name); } } shopManager.potentialItems.RemoveAll((Item item) => (Object)(object)item != (Object)null && targetNames.Contains(((Object)item).name)); shopManager.potentialItemConsumables.RemoveAll((Item item) => (Object)(object)item != (Object)null && targetNames.Contains(((Object)item).name)); shopManager.potentialItemUpgrades.RemoveAll((Item item) => (Object)(object)item != (Object)null && targetNames.Contains(((Object)item).name)); shopManager.potentialItemHealthPacks.RemoveAll((Item item) => (Object)(object)item != (Object)null && targetNames.Contains(((Object)item).name)); } private static void AddItemToCorrectPotentialList(ShopManager shopManager, Item item, int count) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Invalid comparison between Unknown and I4 //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Invalid comparison between Unknown and I4 if ((Object)(object)shopManager == (Object)null || (Object)(object)item == (Object)null || count <= 0) { return; } for (int i = 0; i < count; i++) { if ((int)item.itemType == 8) { shopManager.potentialItemHealthPacks.Add(item); } else if ((int)item.itemType == 5) { shopManager.potentialItemConsumables.Add(item); } else if ((int)item.itemType == 3) { shopManager.potentialItemUpgrades.Add(item); } else { shopManager.potentialItems.Add(item); } } } private static void ApplyPerShopSettings(Item item, UnlockDefinition definition) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_00a4: 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_007e: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null || definition == null) { return; } item.disabled = false; item.itemSecretShopType = (itemSecretShopType)0; item.physicalItem = true; item.maxPurchase = false; item.maxPurchaseAmount = 1; if (definition.ComponentType == typeof(ItemOrbHeal) && definition.CfgHealUseHealthPackSlot != null) { if (definition.CfgHealUseHealthPackSlot.Value) { Item val = FindHealthPackTemplate(); item.itemType = (itemType)8; if ((Object)(object)val != (Object)null) { item.itemVolume = val.itemVolume; } } else { item.itemType = definition.DefaultItemType; if (DroneToOrbItemPlugin.OriginalItemVolumes.TryGetValue(((Object)item).name, out var value)) { item.itemVolume = value; } } } else { item.itemType = definition.DefaultItemType; if (DroneToOrbItemPlugin.OriginalItemVolumes.TryGetValue(((Object)item).name, out var value2)) { item.itemVolume = value2; } } item.maxAmountInShop = Mathf.Clamp(definition.CfgMaxInShop.Value, 1, 10); item.maxAmount = Mathf.Max(item.maxAmount, item.maxAmountInShop); } private static int CalculatePlannedCount(Item item, UnlockDefinition definition) { try { if ((Object)(object)item == (Object)null || definition == null || !definition.CfgEnabled.Value) { return 0; } int num = SemiFunc.StatGetItemsPurchased(((Object)item).name); int num2 = Mathf.Clamp(definition.CfgMaxInShop.Value, 1, 10); int num3 = (DroneToOrbItemPlugin.CfgCountPurchasedAgainstMax.Value ? Mathf.Max(0, num2 - num) : num2); if (num3 <= 0) { return 0; } int num4 = Mathf.Clamp(definition.CfgChancePercent.Value, 0, 100); if (num4 <= 0) { return 0; } if (num4 >= 100) { return Random.Range(1, num3 + 1); } if (Random.Range(0, 100) >= num4) { return 0; } return Random.Range(1, num3 + 1); } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogError((object)("Failure: CalculatePlannedCount " + definition.InternalName + "\n" + ex)); return 0; } } private static void LogShopRoll(UnlockDefinition definition, int count, string categoryText) { try { string text = "Shop Roll: " + definition.DisplayName + " enabled=" + definition.CfgEnabled.Value + " count=" + count + " max=" + definition.CfgMaxInShop.Value + " chance=" + definition.CfgChancePercent.Value + " category=" + categoryText + " radius=" + definition.CfgOrbRadius.Value + " drain=" + definition.CfgOrbBatteryDrainRate.Value + " throughWalls=" + definition.CfgAllowThroughWalls.Value + " heldOnly=" + definition.CfgOnlyActiveWhileHeld.Value; DroneToOrbItemPlugin.Log.LogInfo((object)text); } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogError((object)("Failure: LogShopRoll\n" + ex)); } } private static void EnsureDictionaryKeysForTargets() { try { foreach (UnlockDefinition definition in DroneToOrbItemPlugin.Definitions) { Item val = FindRegisteredItemByDefinition(definition); if ((Object)(object)val != (Object)null) { AddMissingDictionaryKeys(((Object)val).name); } } } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogError((object)("Failure: EnsureDictionaryKeysForTargets\n" + ex)); } } private static void AddMissingDictionaryKeys(string itemName) { try { if (!((Object)(object)StatsManager.instance == (Object)null) && !string.IsNullOrEmpty(itemName)) { int num = 0; num += AddMissingDictionaryKeysFromFields(itemName); num += AddMissingDictionaryKeysFromDictionaryOfDictionaries(itemName); if (num > 0) { DroneToOrbItemPlugin.Log.LogInfo((object)("Added missing item stat keys: " + itemName + " count=" + num)); } } } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogError((object)("Failure: AddMissingDictionaryKeys " + itemName + "\n" + ex)); } } private static int AddMissingDictionaryKeysFromFields(string itemName) { int num = 0; try { FieldInfo[] fields = typeof(StatsManager).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (!(fieldInfo == null) && !(fieldInfo.FieldType != typeof(Dictionary)) && IsItemStatDictionaryName(fieldInfo.Name) && fieldInfo.GetValue(StatsManager.instance) is Dictionary dictionary && !dictionary.ContainsKey(itemName)) { dictionary.Add(itemName, 0); num++; } } } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogWarning((object)("Failure: AddMissingDictionaryKeysFromFields " + itemName + "\n" + ex)); } return num; } private static int AddMissingDictionaryKeysFromDictionaryOfDictionaries(string itemName) { int num = 0; try { FieldInfo[] fields = typeof(StatsManager).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo == null || fieldInfo.FieldType != typeof(Dictionary>) || !(fieldInfo.GetValue(StatsManager.instance) is Dictionary> dictionary)) { continue; } foreach (KeyValuePair> item in dictionary) { if (IsItemStatDictionaryName(item.Key) && item.Value != null && !item.Value.ContainsKey(itemName)) { item.Value.Add(itemName, 0); num++; } } } } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogWarning((object)("Failure: AddMissingDictionaryKeysFromDictionaryOfDictionaries " + itemName + "\n" + ex)); } return num; } private static bool IsItemStatDictionaryName(string dictionaryName) { if (string.IsNullOrEmpty(dictionaryName)) { return false; } return dictionaryName.StartsWith("item", StringComparison.OrdinalIgnoreCase) || dictionaryName.StartsWith("items", StringComparison.OrdinalIgnoreCase) || dictionaryName.IndexOf("item", StringComparison.OrdinalIgnoreCase) >= 0; } private static bool GetShopItemFlag(ItemAttributes itemAttributes) { try { if (ItemAttributesShopItemField == null || (Object)(object)itemAttributes == (Object)null) { return false; } object value = ItemAttributesShopItemField.GetValue(itemAttributes); return value is bool && (bool)value; } catch { return false; } } private static int GetItemAttributesValue(ItemAttributes itemAttributes) { try { if (ItemAttributesValueField == null || (Object)(object)itemAttributes == (Object)null) { return 0; } object value = ItemAttributesValueField.GetValue(itemAttributes); return (value is int) ? ((int)value) : 0; } catch { return 0; } } private static void SetItemAttributesValue(ItemAttributes itemAttributes, int value) { try { if (ItemAttributesValueField != null && (Object)(object)itemAttributes != (Object)null) { ItemAttributesValueField.SetValue(itemAttributes, value); } } catch { } } private static UnlockDefinition FindDefinitionByItem(Item item) { try { if ((Object)(object)item == (Object)null) { return null; } foreach (UnlockDefinition definition in DroneToOrbItemPlugin.Definitions) { if (string.Equals(((Object)item).name, definition.InternalName, StringComparison.Ordinal) || string.Equals(item.itemName, definition.DisplayName, StringComparison.Ordinal)) { return definition; } } return null; } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogError((object)("Failure: FindDefinitionByItem\n" + ex)); return null; } } private static UnlockDefinition FindDefinitionByGameObject(GameObject target) { try { if ((Object)(object)target == (Object)null) { return null; } foreach (UnlockDefinition definition in DroneToOrbItemPlugin.Definitions) { if (definition.ComponentType != null && (Object)(object)target.GetComponent(definition.ComponentType) != (Object)null) { return definition; } } } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogError((object)("Failure: FindDefinitionByGameObject\n" + ex)); } return null; } private static Item FindHealthPackTemplate() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Invalid comparison between Unknown and I4 try { if ((Object)(object)StatsManager.instance == (Object)null) { return null; } foreach (Item value in StatsManager.instance.itemDictionary.Values) { if ((Object)(object)value != (Object)null && (int)value.itemType == 8) { return value; } } } catch (Exception ex) { DroneToOrbItemPlugin.Log.LogError((object)("Failure: FindHealthPackTemplate\n" + ex)); } return null; } private static void SetObjectAffected(ItemOrb itemOrb, List list) { try { if (ItemOrbObjectAffectedField != null && (Object)(object)itemOrb != (Object)null) { ItemOrbObjectAffectedField.SetValue(itemOrb, list ?? new List()); } } catch { } } private static void SetLocalPlayerAffected(ItemOrb itemOrb, bool value) { try { if (ItemOrbLocalPlayerAffectedField != null && (Object)(object)itemOrb != (Object)null) { ItemOrbLocalPlayerAffectedField.SetValue(itemOrb, value); } } catch { } } } }