using System;
using System.Collections;
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 EntityStates;
using EntityStates.Missions.BrotherEncounter;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.EntityStates.Missions.BrotherEncounter;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("ItemMultiplier")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ItemMultiplier")]
[assembly: AssemblyTitle("ItemMultiplier")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ItemMultiplier
{
[BepInPlugin("HIFU.ItemMultiplier", "ItemMultiplier", "1.0.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Main : BaseUnityPlugin
{
public const string PluginGUID = "HIFU.ItemMultiplier";
public const string PluginAuthor = "HIFU";
public const string PluginName = "ItemMultiplier";
public const string PluginVersion = "1.0.2";
public static AssetBundle itemMultiplier;
public static ManualLogSource logger;
public static int cachedMaxScrap = -123;
public static bool multiply = true;
public static ConfigEntry<int> multiplier { get; set; }
public static ConfigEntry<bool> fixScrappers { get; set; }
public static ConfigEntry<bool> fixCauldrons { get; set; }
public static ConfigEntry<bool> fixMithrix { get; set; }
public static ConfigEntry<bool> multiplyRemoval { get; set; }
public void Awake()
{
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Expected O, but got Unknown
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Expected O, but got Unknown
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Expected O, but got Unknown
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Expected O, but got Unknown
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Expected O, but got Unknown
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Expected O, but got Unknown
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Expected O, but got Unknown
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Expected O, but got Unknown
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Expected O, but got Unknown
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Expected O, but got Unknown
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Expected O, but got Unknown
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Expected O, but got Unknown
logger = ((BaseUnityPlugin)this).Logger;
itemMultiplier = AssetBundle.LoadFromFile(Assembly.GetExecutingAssembly().Location.Replace("ItemMultiplier.dll", "itemmultiplier"));
multiplier = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Multiplier", 3, "Item Count Multiplier. Updates in realtime with Risk of Options.");
fixScrappers = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Fix Scrappers?", true, "Makes scrappers only scrap 1 item at a time to prevent multiplying scrap. Updates in realtime with Risk of Options.");
fixCauldrons = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Fix Cauldrons?", true, "Makes cauldrons show and take the multiplied amount of items. Updates in realtime with Risk of Options.");
fixMithrix = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Fix Mithrix?", true, "Makes Mithrix give back the proper amount of items. Updates in realtime with Risk of Options.");
multiplyRemoval = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Multiply removals?", true, "Multiplies the removal of items (be it scrapper, printer, cauldron, etc). Updates in realtime with Risk of Options.");
if (multiplier.Value <= 0)
{
multiplier.Value = 3;
}
ModSettingsManager.SetModIcon(itemMultiplier.LoadAsset<Sprite>("texItemMultiplier.png"));
ModSettingsManager.AddOption((BaseOption)new IntSliderOption(multiplier, new IntSliderConfig
{
min = 1,
max = 1000
}));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(fixScrappers, false));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(fixCauldrons, false));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(multiplyRemoval, false));
multiplier.SettingChanged += delegate
{
if (multiplier.Value <= 0)
{
multiplier.Value = 3;
}
};
Inventory.GiveItem_ItemIndex_int += new hook_GiveItem_ItemIndex_int(Inventory_GiveItem_ItemIndex_int);
Inventory.RemoveItem_ItemIndex_int += new hook_RemoveItem_ItemIndex_int(Inventory_RemoveItem_ItemIndex_int);
ScrapperController.BeginScrapping += new hook_BeginScrapping(ScrapperController_BeginScrapping);
BossDeath.OnEnter += new hook_OnEnter(BossDeath_OnEnter);
PurchaseInteraction.GetContextString += new Manipulator(PurchaseInteraction_GetContextString);
CostHologramContent.FixedUpdate += new Manipulator(CostHologramContent_FixedUpdate);
PurchaseInteraction.CanBeAffordedByInteractor += new Manipulator(PurchaseInteraction_CanBeAffordedByInteractor);
}
private void BossDeath_OnEnter(orig_OnEnter orig, BossDeath self)
{
if (fixMithrix.Value)
{
((MonoBehaviour)((EntityState)self).outer).StartCoroutine(FixMithrix());
}
orig.Invoke(self);
}
private IEnumerator FixMithrix()
{
multiply = false;
yield return (object)new WaitForSeconds(1f);
multiply = true;
}
private void PurchaseInteraction_CanBeAffordedByInteractor(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchLdfld<PurchaseInteraction>(x, "cost")
}))
{
int index = val.Index;
val.Index = index + 1;
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Func<int, PurchaseInteraction, int>>((Func<int, PurchaseInteraction, int>)delegate(int orig, PurchaseInteraction self)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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)
//IL_0019: 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_001d: Invalid comparison between Unknown and I4
//IL_0021: 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_0026: Invalid comparison between Unknown and I4
if (fixCauldrons.Value)
{
CostTypeIndex costType = self.costType;
CostTypeIndex val2 = costType;
if (val2 - 4 <= 2 || val2 - 9 <= 4)
{
return orig * multiplier.Value;
}
return orig;
}
return orig;
});
}
else
{
logger.LogError((object)"Failed to apply Can Be Afforded By Interactor hook");
}
}
private void CostHologramContent_FixedUpdate(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchLdfld<CostHologramContent>(x, "displayValue")
}))
{
int index = val.Index;
val.Index = index + 1;
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Func<int, CostHologramContent, int>>((Func<int, CostHologramContent, int>)delegate(int orig, CostHologramContent self)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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)
//IL_0019: 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_001d: Invalid comparison between Unknown and I4
//IL_0021: 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_0026: Invalid comparison between Unknown and I4
if (fixCauldrons.Value)
{
CostTypeIndex costType = self.costType;
CostTypeIndex val2 = costType;
if (val2 - 4 <= 2 || val2 - 9 <= 4)
{
return orig * multiplier.Value;
}
return orig;
}
return orig;
});
}
else
{
logger.LogError((object)"Failed to apply Cost Hologram Content Fixed Update hook");
}
}
private void PurchaseInteraction_GetContextString(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchLdfld<PurchaseInteraction>(x, "cost")
}))
{
int index = val.Index;
val.Index = index + 1;
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Func<int, PurchaseInteraction, int>>((Func<int, PurchaseInteraction, int>)((int orig, PurchaseInteraction self) => (fixCauldrons.Value && self.displayNameToken == "BAZAAR_CAULDRON_NAME") ? (orig * multiplier.Value) : orig));
}
else
{
logger.LogError((object)"Failed to apply Get Context String hook");
}
}
private void ScrapperController_BeginScrapping(orig_BeginScrapping orig, ScrapperController self, int intPickupIndex)
{
if (cachedMaxScrap == -123)
{
cachedMaxScrap = self.maxItemsToScrapAtATime;
}
self.maxItemsToScrapAtATime = ((fixScrappers.Value && multiplier.Value > 1) ? 1 : cachedMaxScrap);
orig.Invoke(self, intPickupIndex);
}
private void Inventory_RemoveItem_ItemIndex_int(orig_RemoveItem_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count)
{
//IL_0008: 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_002a: Invalid comparison between Unknown and I4
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Invalid comparison between Unknown and I4
PlayerCharacterMasterController component = ((Component)self).GetComponent<PlayerCharacterMasterController>();
ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex);
if (Object.op_Implicit((Object)(object)component) && multiplyRemoval.Value && ((int)itemDef.tier != 5 || (int)itemDef.deprecatedTier != 5) && !itemDef.hidden)
{
count *= multiplier.Value;
}
orig.Invoke(self, itemIndex, count);
}
private void Inventory_GiveItem_ItemIndex_int(orig_GiveItem_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count)
{
//IL_0008: 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)
//IL_001e: Invalid comparison between Unknown and I4
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Invalid comparison between Unknown and I4
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
PlayerCharacterMasterController component = ((Component)self).GetComponent<PlayerCharacterMasterController>();
ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex);
if (Object.op_Implicit((Object)(object)component) && ((int)itemDef.tier != 5 || (int)itemDef.deprecatedTier != 5) && !itemDef.hidden && multiply)
{
count *= multiplier.Value;
}
orig.Invoke(self, itemIndex, count);
}
}
}