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 Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.ExpansionManagement;
using UnityEngine;
using UnityEngine.AddressableAssets;
[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: AssemblyCompany("VoidCoins")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VoidCoins")]
[assembly: AssemblyTitle("VoidCoins")]
[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 VoidCoins
{
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);
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("acanthi.VoidCoinUtils", "VoidCoinUtils", "1.0.0")]
public class VoidCoins : BaseUnityPlugin
{
public enum SimulacrumOptions
{
SimulacrumOnly,
ClassicOnly,
All
}
public class VoidCoinUserStorage
{
public NetworkUser user = null;
public PlayerCharacterMasterController userPlayerCharacterMaster = null;
public int coinsCreatedThisStage = 0;
}
public const string PluginGUID = "acanthi.VoidCoinUtils";
public const string PluginAuthor = "acanthi";
public const string PluginName = "VoidCoinUtils";
public const string PluginVersion = "1.0.0";
public static ConfigEntry<float> dropChance;
public static ConfigEntry<float> dropChanceMultiplier;
public static ConfigEntry<bool> onlyVoidEnemies;
public static ConfigEntry<bool> shareVoidCoins;
public static ConfigEntry<SimulacrumOptions> simulacrum;
public static ConfigEntry<bool> editLanguage;
public static ExpansionDef expansionNeeded;
public List<VoidCoinUserStorage> coinStorage = new List<VoidCoinUserStorage>();
public void ResetCoinStorage()
{
coinStorage.Clear();
}
public void SetUpCoinStorage()
{
foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
{
if ((Object)(object)instance.networkUser == (Object)null)
{
continue;
}
bool flag = false;
foreach (VoidCoinUserStorage item in coinStorage)
{
if ((Object)(object)item.user == (Object)(object)instance.networkUser)
{
flag = true;
}
}
if (!flag)
{
VoidCoinUserStorage voidCoinUserStorage = new VoidCoinUserStorage();
voidCoinUserStorage.user = instance.networkUser;
voidCoinUserStorage.userPlayerCharacterMaster = instance;
voidCoinUserStorage.coinsCreatedThisStage = 0;
coinStorage.Add(voidCoinUserStorage);
((BaseUnityPlugin)this).Logger.LogDebug((object)("Registered " + voidCoinUserStorage.user.userName + " to the Void Coin Storage!"));
}
}
}
public VoidCoinUserStorage FindCoinStorageFromPlayerCharacter(PlayerCharacterMasterController playerCharacterMaster)
{
foreach (VoidCoinUserStorage item in coinStorage)
{
if ((Object)(object)item.userPlayerCharacterMaster == (Object)(object)playerCharacterMaster)
{
return item;
}
}
return null;
}
public void Awake()
{
//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_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Expected O, but got Unknown
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Expected O, but got Unknown
Log.Init(((BaseUnityPlugin)this).Logger);
InitConfig();
if (editLanguage.Value)
{
CreateLang();
}
expansionNeeded = Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC1/Common/DLC1.asset").WaitForCompletion();
GlobalEventManager.onCharacterDeathGlobal += GlobalEventManager_onCharacterDeathGlobal;
Run.OnUserAdded += new hook_OnUserAdded(Run_OnUserAdded);
Run.OnUserRemoved += new hook_OnUserRemoved(Run_OnUserRemoved);
Run.Start += new hook_Start(Run_Start);
Run.BeginGameOver += new hook_BeginGameOver(Run_BeginGameOver);
Run.OnServerSceneChanged += new hook_OnServerSceneChanged(Run_OnServerSceneChanged);
if (shareVoidCoins.Value)
{
VoidCoinDef.GrantPickup += new hook_GrantPickup(VoidCoinDef_GrantPickup);
}
}
private void CreateLang()
{
LanguageAPI.Add("PICKUP_VOID_COIN", "Void Coin");
LanguageAPI.Add("VOID_COIN_PICKUP_CONTEXT", "Pick up Void Coin");
LanguageAPI.Add("PICKUP_VOID_COIN_DESCRIPTION", "A <sprite name=\"VoidCoin\" tint=1>Void Coin. Radiates a ominous energy. Used as currency.");
((ResourceAvailability)(ref MiscPickupCatalog.availability)).CallWhenAvailable((Action)delegate
{
MiscPickups.VoidCoin.descriptionToken = "PICKUP_VOID_COIN_DESCRIPTION";
});
}
private void VoidCoinDef_GrantPickup(orig_GrantPickup orig, VoidCoinDef self, ref GrantContext context)
{
orig.Invoke(self, ref context);
NetworkUser val = Util.LookUpBodyNetworkUser(context.body);
foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
{
if (Object.op_Implicit((Object)(object)instance.networkUser) && (Object)(object)instance.networkUser != (Object)(object)val)
{
instance.master.GiveVoidCoins(1u);
}
}
}
private void Run_OnServerSceneChanged(orig_OnServerSceneChanged orig, Run self, string sceneName)
{
orig.Invoke(self, sceneName);
foreach (VoidCoinUserStorage item in coinStorage)
{
item.coinsCreatedThisStage = 0;
}
}
private void Run_Start(orig_Start orig, Run self)
{
orig.Invoke(self);
SetUpCoinStorage();
}
private void Run_BeginGameOver(orig_BeginGameOver orig, Run self, GameEndingDef gameEndingDef)
{
orig.Invoke(self, gameEndingDef);
ResetCoinStorage();
}
private void Run_OnUserAdded(orig_OnUserAdded orig, Run self, NetworkUser user)
{
orig.Invoke(self, user);
SetUpCoinStorage();
}
private void Run_OnUserRemoved(orig_OnUserRemoved orig, Run self, NetworkUser user)
{
orig.Invoke(self, user);
foreach (VoidCoinUserStorage item in coinStorage)
{
if ((Object)(object)item.user == (Object)(object)user)
{
coinStorage.Remove(item);
}
}
}
private void GlobalEventManager_onCharacterDeathGlobal(DamageReport damageReport)
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Invalid comparison between Unknown and I4
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
CharacterMaster val = damageReport.attackerMaster;
if (!Run.instance.IsExpansionEnabled(expansionNeeded) || !Object.op_Implicit((Object)(object)val))
{
return;
}
if (Object.op_Implicit((Object)(object)val.minionOwnership.ownerMaster))
{
val = val.minionOwnership.ownerMaster;
}
PlayerCharacterMasterController component = ((Component)val).GetComponent<PlayerCharacterMasterController>();
if (((int)damageReport.victimBody.teamComponent.teamIndex == 4 || !onlyVoidEnemies.Value) && (Run.instance is InfiniteTowerRun || simulacrum.Value != 0) && (!(Run.instance is InfiniteTowerRun) || simulacrum.Value != SimulacrumOptions.ClassicOnly) && Object.op_Implicit((Object)(object)component))
{
float num = (float)((double)dropChance.Value * Math.Pow(dropChanceMultiplier.Value / 100f, FindCoinStorageFromPlayerCharacter(component).coinsCreatedThisStage));
((BaseUnityPlugin)this).Logger.LogDebug((object)num.ToString());
if (Util.CheckRoll(num, 0f, (CharacterMaster)null))
{
PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(MiscPickups.VoidCoin.miscPickupIndex), ((Component)damageReport.victim).transform.position, Vector3.up * 10f);
FindCoinStorageFromPlayerCharacter(component).coinsCreatedThisStage++;
}
}
}
private void InitConfig()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Expected O, but got Unknown
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Expected O, but got Unknown
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Expected O, but got Unknown
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Expected O, but got Unknown
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Expected O, but got Unknown
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Expected O, but got Unknown
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Expected O, but got Unknown
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Expected O, but got Unknown
dropChance = ((BaseUnityPlugin)this).Config.Bind<float>("Coin Drops", "Initial Drop Chance", 13f, new ConfigDescription("How likely is it for an enemy to drop a Void Coin...", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
dropChanceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Coin Drops", "Repeat Drop Multiplier", 50f, new ConfigDescription("After an enemy is killed, reduce the original chance by... (50% = Half the initial chance; Resets on stage start.)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
onlyVoidEnemies = ((BaseUnityPlugin)this).Config.Bind<bool>("Coin Drops", "Only Void Enemies", true, "Only Void enemies may drop Void Coins...");
shareVoidCoins = ((BaseUnityPlugin)this).Config.Bind<bool>("Coin Drops", "Share Void Coin Pickups", false, "Void Coin pickups are shared...");
simulacrum = ((BaseUnityPlugin)this).Config.Bind<SimulacrumOptions>("Coin Drops", "Game Modes Allowed", SimulacrumOptions.All, "Void Coins will only drop in...");
editLanguage = ((BaseUnityPlugin)this).Config.Bind<bool>("Language", "Edit Language Files", true, "Void Coins will have better language formatting. (Requires restart!)");
ModSettingsManager.SetModDescription("Fully comprehensive Void Coins mod!");
ModSettingsManager.AddOption((BaseOption)new StepSliderOption(dropChance, new StepSliderConfig
{
min = 0f,
max = 100f,
increment = 0.1f
}));
ModSettingsManager.AddOption((BaseOption)new StepSliderOption(dropChanceMultiplier, new StepSliderConfig
{
min = 0f,
max = 100f,
increment = 1f
}));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(onlyVoidEnemies));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(shareVoidCoins));
shareVoidCoins.SettingChanged += delegate
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
if (shareVoidCoins.Value)
{
VoidCoinDef.GrantPickup += new hook_GrantPickup(VoidCoinDef_GrantPickup);
}
else
{
VoidCoinDef.GrantPickup -= new hook_GrantPickup(VoidCoinDef_GrantPickup);
}
};
ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)simulacrum));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(editLanguage, true));
}
}
}