using System;
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 LunarDeflation;
using LunarEconomyReworked;
using On.RoR2;
using On.RoR2.UI.MainMenu;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Artifacts;
using RoR2.UI.MainMenu;
using UnityEngine;
using UnityEngine.AddressableAssets;
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 = "")]
[assembly: AssemblyCompany("LunarEconomyReworked")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LunarEconomyReworked")]
[assembly: AssemblyTitle("LunarEconomyReworked")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace LunarEconomyReworked
{
[BepInPlugin("hlieb.SecondTestPlugin", "SecondTestPlugin", "1.0.0")]
public class MyPluginInfo : BaseUnityPlugin
{
public const string PLUGIN_GUID = "hlieb.SecondTestPlugin";
public const string PLUGIN_NAME = "SecondTestPlugin";
public const string PLUGIN_VERSION = "1.0.0";
}
public static class LunarConfig
{
public static ConfigEntry<int> ShrineRestackCostOption;
public static ConfigEntry<int> SeerStationCostOption;
public static ConfigEntry<int> LunarShopTerminalCostOption;
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[BepInPlugin("hlieb.LunarEconomyReworked", "LunarEconomyReworked", "1.0.0")]
public class LunarEconomyReworked : BaseUnityPlugin
{
public enum commandEnum
{
Disabled,
Balanced,
Unbalanced
}
private ConfigEntry<int> startingCoinsConfig;
public static ConfigEntry<commandEnum> commandDropsConfig;
public static ConfigEntry<float> lunarRefreshScalar;
private int lunarCoinRewardAmount = 1;
public static ConfigEntry<int> lunarCoinRewardOption;
private static uint BalancedCommandEnumMaxCoinAmount = 3u;
private bool isSubscribed_PickupDropletController_CreatePickup = false;
public IntFieldOption setLunarCoins;
private void OnEnable()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
if (!isSubscribed_PickupDropletController_CreatePickup)
{
PickupDropletController.CreatePickup += new hook_CreatePickup(PickupDropletController_CreatePickup);
isSubscribed_PickupDropletController_CreatePickup = true;
}
ShrineBossBehavior.AddShrineStack += new hook_AddShrineStack(OnAddShrineStack);
ChargedState.OnEnter += new hook_OnEnter(OnChargedStateEnter);
PurchaseInteraction.Awake += new hook_Awake(OnPurchaseInteractionAwake);
BaseMainMenuScreen.Awake += new hook_Awake(OnBaseMainMenuScreenAwake);
PurchaseInteraction.ScaleCost += new hook_ScaleCost(PurchaseInteractionScaleCost);
}
private void OnDisable()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
if (isSubscribed_PickupDropletController_CreatePickup)
{
PickupDropletController.CreatePickup -= new hook_CreatePickup(PickupDropletController_CreatePickup);
isSubscribed_PickupDropletController_CreatePickup = false;
}
ShrineBossBehavior.AddShrineStack -= new hook_AddShrineStack(OnAddShrineStack);
ChargedState.OnEnter -= new hook_OnEnter(OnChargedStateEnter);
PurchaseInteraction.Awake -= new hook_Awake(OnPurchaseInteractionAwake);
BaseMainMenuScreen.Awake -= new hook_Awake(OnBaseMainMenuScreenAwake);
}
public void Awake()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Expected O, but got Unknown
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Expected O, but got Unknown
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Expected O, but got Unknown
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Expected O, but got Unknown
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Expected O, but got Unknown
Run.onRunStartGlobal += Run_onRunStartGlobal;
startingCoinsConfig = ((BaseUnityPlugin)this).Config.Bind<int>("LunarEconomyReworked", "Starting Coins", 1, "Initial lunar coin allocation for new runs\nRecommended: 1 for balanced gameplay");
ModSettingsManager.AddOption((BaseOption)new IntFieldOption(startingCoinsConfig));
commandDropsConfig = ((BaseUnityPlugin)this).Config.Bind<commandEnum>("LunarEconomyReworked", "Command Lunar Items", commandEnum.Disabled, "Transform lunar items into blue lunar cubes:\n• Balanced Mode: Limited to 3 coins maximum\n• Unbalanced Mode: No coin restrictions");
ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)commandDropsConfig));
lunarRefreshScalar = ((BaseUnityPlugin)this).Config.Bind<float>("LunarEconomyReworked", "Reroll Scale", 1f, "The cost multiplier per use of the Slab (reroller) in BTB. Vanilla is 2, Recommended is 1");
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(lunarRefreshScalar));
lunarCoinRewardOption = ((BaseUnityPlugin)this).Config.Bind<int>("LunarEconomyReworked", "Coin Reward", 1, "The amount of lunar coins players get for clearing the teleporter. Recommended is 1. Negative to turn off");
ModSettingsManager.AddOption((BaseOption)new IntFieldOption(lunarCoinRewardOption));
LunarConfig.ShrineRestackCostOption = ((BaseUnityPlugin)this).Config.Bind<int>("LunarEconomyReworked", "Shrine Restack Cost", 1, "The cost of Shrine Restack. Recommended is 1. Negative values are converted to positive");
LunarConfig.SeerStationCostOption = ((BaseUnityPlugin)this).Config.Bind<int>("LunarEconomyReworked", "Seer Station Cost", 1, "The cost of using the Seer Station. Recommended is 1. Negative values are converted to positive");
LunarConfig.LunarShopTerminalCostOption = ((BaseUnityPlugin)this).Config.Bind<int>("LunarEconomyReworked", "Lunar Item Cost", 1, "The cost of all lunar items. Recommended is 1. Negative values are converted to positive");
ModSettingsManager.AddOption((BaseOption)new IntFieldOption(LunarConfig.ShrineRestackCostOption));
ModSettingsManager.AddOption((BaseOption)new IntFieldOption(LunarConfig.SeerStationCostOption));
ModSettingsManager.AddOption((BaseOption)new IntFieldOption(LunarConfig.LunarShopTerminalCostOption));
}
private void commandDropConfigCheck()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
if (commandDropsConfig.Value == commandEnum.Disabled && isSubscribed_PickupDropletController_CreatePickup)
{
PickupDropletController.CreatePickup -= new hook_CreatePickup(PickupDropletController_CreatePickup);
isSubscribed_PickupDropletController_CreatePickup = false;
}
else if (commandDropsConfig.Value != 0 && !isSubscribed_PickupDropletController_CreatePickup)
{
PickupDropletController.CreatePickup += new hook_CreatePickup(PickupDropletController_CreatePickup);
isSubscribed_PickupDropletController_CreatePickup = true;
}
}
private void lunarCoinRewardOptionCheck()
{
if (lunarCoinRewardOption.Value < 0)
{
lunarCoinRewardAmount = 0;
}
else
{
lunarCoinRewardAmount = lunarCoinRewardOption.Value;
}
}
private void Run_onRunStartGlobal(Run obj)
{
commandDropConfigCheck();
lunarCoinRewardOptionCheck();
if (!NetworkServer.active)
{
return;
}
foreach (NetworkUser readOnlyInstances in NetworkUser.readOnlyInstancesList)
{
uint coins = (readOnlyInstances.NetworknetLunarCoins = (uint)startingCoinsConfig.Value);
if (readOnlyInstances.localUser != null)
{
readOnlyInstances.localUser.userProfile.coins = coins;
}
}
}
private void PickupDropletController_CreatePickup(orig_CreatePickup orig, PickupDropletController self)
{
//IL_0012: 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_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Invalid comparison between Unknown and I4
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Invalid comparison between Unknown and I4
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: 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: Invalid comparison between Unknown and I4
if (true)
{
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);
}
private void NetworkUser_DeductLunarCoins(orig_DeductLunarCoins orig, NetworkUser self, uint count)
{
if (true)
{
count = 1u;
}
orig.Invoke(self, count);
}
private void OnAddShrineStack(orig_AddShrineStack orig, ShrineBossBehavior self, Interactor interactor)
{
if (NetworkServer.active && lunarCoinRewardOption.Value >= 0)
{
lunarCoinRewardAmount++;
}
orig.Invoke(self, interactor);
}
private void OnChargedStateEnter(orig_OnEnter orig, ChargedState self)
{
foreach (NetworkUser readOnlyInstances in NetworkUser.readOnlyInstancesList)
{
uint num = (uint)lunarCoinRewardAmount;
readOnlyInstances.NetworknetLunarCoins += num;
if (readOnlyInstances.NetworknetLunarCoins > BalancedCommandEnumMaxCoinAmount && commandDropsConfig.Value == commandEnum.Balanced)
{
readOnlyInstances.NetworknetLunarCoins = BalancedCommandEnumMaxCoinAmount;
}
if (readOnlyInstances.localUser != null)
{
UserProfile userProfile = readOnlyInstances.localUser.userProfile;
userProfile.coins += num;
if (readOnlyInstances.localUser.userProfile.coins > BalancedCommandEnumMaxCoinAmount && commandDropsConfig.Value == commandEnum.Balanced)
{
readOnlyInstances.localUser.userProfile.coins = BalancedCommandEnumMaxCoinAmount;
}
}
}
lunarCoinRewardOptionCheck();
orig.Invoke(self);
}
private void OnPurchaseInteractionAwake(orig_Awake orig, PurchaseInteraction self)
{
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (Object.op_Implicit((Object)(object)self) && ((Object)self).name.Contains("LunarShopTerminal"))
{
((Component)self).gameObject.AddComponent<LunarShopTerminalPriceSetter>();
}
if (Object.op_Implicit((Object)(object)self) && ((Object)self).name.Contains("SeerStation"))
{
((Component)self).gameObject.AddComponent<SeerStationPriceSetter>();
}
if (Object.op_Implicit((Object)(object)self) && ((Object)self).name.Contains("FrogInteractable"))
{
self.costType = (CostTypeIndex)0;
self.cost = 0;
}
}
private void ReduceCosts()
{
//IL_0006: 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_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/ShrineRestack/ShrineRestack.prefab").WaitForCompletion();
if (Object.op_Implicit((Object)(object)val))
{
PurchaseInteraction component = val.GetComponent<PurchaseInteraction>();
if (Object.op_Implicit((Object)(object)component))
{
component.cost = Math.Abs(LunarConfig.ShrineRestackCostOption.Value);
component.costType = (CostTypeIndex)0;
}
}
val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/bazaar/SeerStation.prefab").WaitForCompletion();
if (Object.op_Implicit((Object)(object)val))
{
PurchaseInteraction component2 = val.GetComponent<PurchaseInteraction>();
if (Object.op_Implicit((Object)(object)component2))
{
component2.cost = Math.Abs(LunarConfig.SeerStationCostOption.Value);
component2.automaticallyScaleCostWithDifficulty = false;
}
val.AddComponent<SeerStationPriceSetter>();
}
val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/LunarShopTerminal/LunarShopTerminal.prefab").WaitForCompletion();
if (Object.op_Implicit((Object)(object)val))
{
PurchaseInteraction component3 = val.GetComponent<PurchaseInteraction>();
if (Object.op_Implicit((Object)(object)component3))
{
component3.cost = Math.Abs(LunarConfig.LunarShopTerminalCostOption.Value);
component3.automaticallyScaleCostWithDifficulty = false;
}
val.AddComponent<LunarShopTerminalPriceSetter>();
}
}
private void PurchaseInteractionScaleCost(orig_ScaleCost orig, PurchaseInteraction self, float scalar)
{
if (((Object)self).name.StartsWith("LunarRecycler"))
{
scalar = lunarRefreshScalar.Value;
}
orig.Invoke(self, scalar);
}
private void OnBaseMainMenuScreenAwake(orig_Awake orig, BaseMainMenuScreen self)
{
ReduceCosts();
orig.Invoke(self);
}
}
}
namespace LunarDeflation
{
public class LunarShopTerminalPriceSetter : MonoBehaviour
{
private void Start()
{
PurchaseInteraction component = ((Component)this).GetComponent<PurchaseInteraction>();
if (Object.op_Implicit((Object)(object)component))
{
component.cost = LunarConfig.LunarShopTerminalCostOption.Value;
component.automaticallyScaleCostWithDifficulty = false;
}
Object.Destroy((Object)(object)this);
}
}
public class SeerStationPriceSetter : MonoBehaviour
{
private void Start()
{
PurchaseInteraction component = ((Component)this).GetComponent<PurchaseInteraction>();
if (Object.op_Implicit((Object)(object)component))
{
component.cost = LunarConfig.SeerStationCostOption.Value;
component.automaticallyScaleCostWithDifficulty = false;
}
Object.Destroy((Object)(object)this);
}
}
}
namespace ExamplePlugin
{
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);
}
}
}