using System.Diagnostics;
using System.IO;
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 On.RoR2;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Artifacts;
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.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("DontCareAboutLunarCoins")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DontCareAboutLunarCoins")]
[assembly: AssemblyTitle("DontCareAboutLunarCoins")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace DontCareAboutLunarCoins;
[BepInPlugin("com.themysticsword.dontcareaboutlunarcoins", "Don't Care About Lunar Coins", "1.0.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class DontCareAboutLunarCoinsPlugin : BaseUnityPlugin
{
public const string PluginGUID = "com.themysticsword.dontcareaboutlunarcoins";
public const string PluginName = "Don't Care About Lunar Coins";
public const string PluginVersion = "1.0.3";
public ConfigEntry<int> setLunarCoins;
public ConfigEntry<bool> noLunarCoinDeduction;
public ConfigEntry<bool> lunarCommandEssences;
public void Awake()
{
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Expected O, but got Unknown
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Expected O, but got Unknown
setLunarCoins = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Set Lunar Coins To", int.MaxValue, "Sets your Lunar Coins to this value at the start of a run. If -1, Lunar Coins don't get changed");
noLunarCoinDeduction = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "No Lunar Coin Deduction", true, "Prevents Lunar Coin purchases from reducing your coin count");
lunarCommandEssences = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Lunar Command Essences", true, "Turns all Lunar item drops into Blue Command Essences, allowing you to choose your Lunar item");
if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
{
SetUpRiskOfOptionsSupport();
}
Run.onRunStartGlobal += Run_onRunStartGlobal;
NetworkUser.DeductLunarCoins += new hook_DeductLunarCoins(NetworkUser_DeductLunarCoins);
PickupDropletController.CreatePickup += new hook_CreatePickup(PickupDropletController_CreatePickup);
}
private void Run_onRunStartGlobal(Run obj)
{
if (!NetworkServer.active || setLunarCoins.Value == -1)
{
return;
}
foreach (NetworkUser readOnlyInstances in NetworkUser.readOnlyInstancesList)
{
uint coins = (readOnlyInstances.NetworknetLunarCoins = (uint)setLunarCoins.Value);
if (readOnlyInstances.localUser != null)
{
readOnlyInstances.localUser.userProfile.coins = coins;
}
}
}
private void NetworkUser_DeductLunarCoins(orig_DeductLunarCoins orig, NetworkUser self, uint count)
{
if (noLunarCoinDeduction.Value)
{
count = 0u;
}
orig.Invoke(self, count);
}
private void PickupDropletController_CreatePickup(orig_CreatePickup orig, PickupDropletController self)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: 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_0031: Invalid comparison between Unknown and I4
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Invalid comparison between Unknown and I4
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: 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_0043: Invalid comparison between Unknown and I4
if (lunarCommandEssences.Value)
{
PickupIndex pickupIndex = ((CreatePickupInfo)(ref self.createPickupInfo)).pickupIndex;
PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
if (pickupDef != null && ((int)pickupDef.itemIndex != -1 || (int)pickupDef.equipmentIndex != -1 || (int)pickupDef.itemTier != 5) && pickupDef.isLunar)
{
GameObject val = Object.Instantiate<GameObject>(CommandArtifactManager.commandCubePrefab, self.createPickupInfo.position, self.createPickupInfo.rotation);
val.GetComponent<PickupIndexNetworker>().NetworkpickupIndex = pickupIndex;
PickupPickerController component = val.GetComponent<PickupPickerController>();
component.SetOptionsFromPickupForCommandArtifact(pickupIndex);
component.chestGeneratedFrom = self.createPickupInfo.chest;
NetworkServer.Spawn(val);
return;
}
}
orig.Invoke(self);
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
private void SetUpRiskOfOptionsSupport()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
//IL_0053: 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_007f: 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_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Expected O, but got Unknown
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Expected O, but got Unknown
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Expected O, but got Unknown
ModSettingsManager.SetModDescription("");
Texture2D val = new Texture2D(2, 2);
ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "icon.png")));
Sprite modIcon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f), 100f);
ModSettingsManager.SetModIcon(modIcon);
ModSettingsManager.AddOption((BaseOption)new IntSliderOption(setLunarCoins, new IntSliderConfig
{
min = -1,
max = int.MaxValue
}));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(noLunarCoinDeduction));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(lunarCommandEssences));
}
}