using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LookingGlass.ItemStatsNameSpace; using LookingGlass.LookingGlassLanguage; using LunarScrap.Compatibility; using LunarScrap.Content; using LunarScrap.Hooks; using LunarScrap.Utils; using Microsoft.CodeAnalysis; using MonoMod.RuntimeDetour; using MoreStats; using On.RoR2; using R2API; using R2API.Utils; using RoR2; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LunarScrap")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+c5929095e6a007e1326697244bd2740dbeeb205a")] [assembly: AssemblyProduct("LunarScrap")] [assembly: AssemblyTitle("LunarScrap")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LunarScrap { internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } [BepInPlugin("Geritos.Lunar_Scrap", "Lunar_Scrap", "1.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class LunarScrapPlugin : BaseUnityPlugin { public const string PluginGUID = "Geritos.Lunar_Scrap"; public const string PluginAuthor = "Geritos"; public const string PluginName = "Lunar_Scrap"; public const string PluginVersion = "1.0.2"; internal static ConfigEntry MultiplierConfig; public void Awake() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) Log.Init(((BaseUnityPlugin)this).Logger); BindConfig(); LunarScrapItem.Init(); ScrapTierHook.Init(); DrifterTinkerHook.Init(); new Harmony("Geritos.Lunar_Scrap").PatchAll(); ApplyExtensions(); } private void BindConfig() { MultiplierConfig = ((BaseUnityPlugin)this).Config.Bind("Lunar Scrap Buff", "Trash To Tresure Blue Buff", 0.05f, "Trash to Tresure (Drifter's passive) lunar scrap bonus luck per stack."); } private static void ApplyExtensions() { if (!MoreStatsCompatibility.Enabled) { return; } MoreStatsCompatibility.ApplyTrashToTresureHook(); if (LookingGlassCompatibility.Enabled) { LookingGlassCompatibility.LookingGlassPatch(); RoR2Application.onLoad = delegate { LookingGlassCompatibility.AddLunarScrapDescription(); LookingGlassCompatibility.AddLunarScrapBuffDescription(); }; } } } } namespace LunarScrap.Utils { internal static class AssetManagement { private static readonly string _assetPath = "LunarScrap.Assets."; internal static Sprite LoadSpriteFromResources(string resourceName, float ppu = 50f) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(_assetPath + resourceName); byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ImageConversion.LoadImage(val, array, true); ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), ppu); } } } namespace LunarScrap.Hooks { [HarmonyPatch(typeof(LunarItemOrEquipmentCostTypeHelper), "PayCost")] internal static class CleansingPoolPriorityPatch { private static void Prefix(PayCostContext context, PayCostResults result) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0065: 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) Inventory activatorInventory = context.activatorInventory; if (!((Object)(object)activatorInventory == (Object)null) && activatorInventory.GetItemCountPermanent(LunarScrapItem.LunarScrapItemDef.itemIndex) > 0) { ItemTransformation val = default(ItemTransformation); ((ItemTransformation)(ref val)).allowWhenDisabled = true; ((ItemTransformation)(ref val)).forbidTempItems = true; ((ItemTransformation)(ref val)).minToTransform = 1; ((ItemTransformation)(ref val)).maxToTransform = 1; ((ItemTransformation)(ref val)).originalItemIndex = LunarScrapItem.LunarScrapItemDef.itemIndex; ((ItemTransformation)(ref val)).newItemIndex = (ItemIndex)(-1); ItemTransformation val2 = val; TryTransformResult val3 = default(TryTransformResult); if (((ItemTransformation)(ref val2)).TryTransform(activatorInventory, ref val3)) { result.AddTakenItemsFromTransformation(ref val3); context.cost = 0; } } } } internal static class DrifterTinkerHook { [CompilerGenerated] private static class <>O { public static hook_IsWhitelist <0>__HandleLunarTinker; public static hook_RollTemporaryItemFromItemIndex <1>__HandleLunarToTemporary; } internal static void Init() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__HandleLunarTinker; if (obj == null) { hook_IsWhitelist val = HandleLunarTinker; <>O.<0>__HandleLunarTinker = val; obj = (object)val; } DrifterTracker.IsWhitelist += (hook_IsWhitelist)obj; object obj2 = <>O.<1>__HandleLunarToTemporary; if (obj2 == null) { hook_RollTemporaryItemFromItemIndex val2 = HandleLunarToTemporary; <>O.<1>__HandleLunarToTemporary = val2; obj2 = (object)val2; } Util.RollTemporaryItemFromItemIndex += (hook_RollTemporaryItemFromItemIndex)obj2; } private static ItemIndex HandleLunarToTemporary(orig_RollTemporaryItemFromItemIndex orig, ItemIndex itemIndex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) PickupIndex val = PickupCatalog.FindPickupIndex(itemIndex); if (((PickupIndex)(ref val)).pickupDef.isLunar && itemIndex != LunarScrapItem.LunarScrapItemDef.itemIndex) { return itemIndex; } return orig.Invoke(itemIndex); } private static bool HandleLunarTinker(orig_IsWhitelist orig, DrifterTracker self, ref UniquePickup pickup) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if ((int)PickupCatalog.GetPickupDef(pickup.pickupIndex).itemTier == 3 && ((PickupIndex)(ref pickup.pickupIndex)).itemIndex != LunarScrapItem.LunarScrapItemDef.itemIndex) { return true; } return orig.Invoke(self, ref pickup); } } internal static class DrifterTrashToTreasureHook { [CompilerGenerated] private static class <>O { public static MoreStatHookEventHandler <0>__ApplyStatBuffs; public static hook_OnInventoryChanged <1>__SetLunarScrapBuff; public static hook_UpdateBuffCounts <2>__SetLunarScrapBuff; public static hook_ResetBuffCounts <3>__ResetLunarScrapBuff; public static hook_SetCurrentLanguage <4>__AppendRecycleDescription; } internal static void Init() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0090: 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_009b: Expected O, but got Unknown object obj = <>O.<0>__ApplyStatBuffs; if (obj == null) { MoreStatHookEventHandler val = ApplyStatBuffs; <>O.<0>__ApplyStatBuffs = val; obj = (object)val; } StatHooks.GetMoreStatCoefficients += (MoreStatHookEventHandler)obj; object obj2 = <>O.<1>__SetLunarScrapBuff; if (obj2 == null) { hook_OnInventoryChanged val2 = SetLunarScrapBuff; <>O.<1>__SetLunarScrapBuff = val2; obj2 = (object)val2; } DrifterTrashToTreasureController.OnInventoryChanged += (hook_OnInventoryChanged)obj2; object obj3 = <>O.<2>__SetLunarScrapBuff; if (obj3 == null) { hook_UpdateBuffCounts val3 = SetLunarScrapBuff; <>O.<2>__SetLunarScrapBuff = val3; obj3 = (object)val3; } DrifterTrashToTreasureController.UpdateBuffCounts += (hook_UpdateBuffCounts)obj3; object obj4 = <>O.<3>__ResetLunarScrapBuff; if (obj4 == null) { hook_ResetBuffCounts val4 = ResetLunarScrapBuff; <>O.<3>__ResetLunarScrapBuff = val4; obj4 = (object)val4; } DrifterTrashToTreasureController.ResetBuffCounts += (hook_ResetBuffCounts)obj4; object obj5 = <>O.<4>__AppendRecycleDescription; if (obj5 == null) { hook_SetCurrentLanguage val5 = AppendRecycleDescription; <>O.<4>__AppendRecycleDescription = val5; obj5 = (object)val5; } Language.SetCurrentLanguage += (hook_SetCurrentLanguage)obj5; } private static void ApplyStatBuffs(CharacterBody body, MoreStatHookEventArgs args) { if (Object.op_Implicit((Object)(object)body) && body.HasBuff(TrashToTreasureBlue.LunarScrapBuffDef)) { args.luckAdd += TrashToTreasureBlue.Multiplier * (float)body.GetBuffCount(TrashToTreasureBlue.LunarScrapBuffDef); } } private static void SetLunarScrapBuff(orig_OnInventoryChanged orig, DrifterTrashToTreasureController self) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); self.body.SetBuffCount(TrashToTreasureBlue.LunarScrapBuffDef.buffIndex, self.body.inventory.GetItemCountEffective(LunarScrapItem.LunarScrapItemDef)); } private static void SetLunarScrapBuff(orig_UpdateBuffCounts orig, DrifterTrashToTreasureController self) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); self.body.SetBuffCount(TrashToTreasureBlue.LunarScrapBuffDef.buffIndex, self.body.inventory.GetItemCountEffective(LunarScrapItem.LunarScrapItemDef)); } private static void ResetLunarScrapBuff(orig_ResetBuffCounts orig, DrifterTrashToTreasureController self) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); self.body.SetBuffCount(TrashToTreasureBlue.LunarScrapBuffDef.buffIndex, 0); } private static void AppendRecycleDescription(orig_SetCurrentLanguage orig, string newCurrentLanguageName) { orig.Invoke(newCurrentLanguageName); string text = Language.GetString("DRIFTER_RECYCLE_TOOLTIP"); int num = text.Length; if (text.EndsWith("")) { num -= "".Length; } text = text.Insert(num, $"\r\nLunar - +{TrashToTreasureBlue.Multiplier} luck (per stack)."); LanguageAPI.Add("DRIFTER_RECYCLE_TOOLTIP", text); } } [HarmonyPatch(typeof(ScrapperController), "AssignPotentialInteractor")] internal static class ScrapperLunarDisplayPatch { private static void Postfix(ScrapperController __instance, Interactor potentialInteractor) { //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_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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0074: 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_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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) PickupPickerController pickupPickerController = __instance.pickupPickerController; Inventory inventory = ((Component)potentialInteractor).GetComponent().inventory; List