Decompiled source of LunarCoinShareOnPickup v4.3.5

LunarCoinShareOnPickup.dll

Decompiled 2 days ago
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 Microsoft.CodeAnalysis;
using On.RoR2;
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: AssemblyCompany("LunarCoinShareOnPickup")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LunarCoinShareOnPickup")]
[assembly: AssemblyTitle("LunarCoinShareOnPickup")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[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 LunarCoinShareOnPickup
{
	internal class LunarConfig
	{
		public static ConfigEntry<uint> UnsharedLunarCoinAmount { get; set; }

		public static ConfigEntry<uint> SharedLunarCoinAmount { get; set; }

		public static ConfigEntry<bool> ShareWithDead { get; set; }

		public void InitConfig(ConfigFile config)
		{
			UnsharedLunarCoinAmount = config.Bind<uint>("Unshared Lunar Coins", "Amount of unshared Lunar Coins", 1u, "Defines the amount of extra Lunar Coins the person receives who picks up the Lunar Coin.\t\tGameDefault:1");
			SharedLunarCoinAmount = config.Bind<uint>("Shared Lunar Coins (SLC)", "Amount of shared Lunar Coins", 1u, "Defines the amount of Lunar Coins each player in the lobby receives if one is picked up.\t\tGameDefault:0");
			ShareWithDead = config.Bind<bool>("Shared with dead players", "Dead Player Lunar Coins", true, "If set to true, dead players receive SLC, if set to false only living players receive SLC\t\tGameDefault:false");
		}
	}
	[BepInPlugin("com.King.LunarCoinShareOnPickup", "LunarCoinShareOnPickup", "4.3.0")]
	public class LunarCoinShareOnPickup : BaseUnityPlugin
	{
		private LunarConfig config = new LunarConfig();

		public void Awake()
		{
			config.InitConfig(((BaseUnityPlugin)this).Config);
			HookLunarCoinDistribution();
		}

		public void HookLunarCoinDistribution()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			GenericPickupController.OnInteractionBegin += (hook_OnInteractionBegin)delegate(orig_OnInteractionBegin orig, GenericPickupController self, Interactor interactor)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				if (self.pickupIndex == PickupCatalog.FindPickupIndex("LunarCoin.Coin0"))
				{
					if (LunarConfig.SharedLunarCoinAmount.Value != 0)
					{
						for (int i = 0; i < PlayerCharacterMasterController.instances.Count; i++)
						{
							CharacterMaster master = PlayerCharacterMasterController.instances[i].master;
							if (!master.IsDeadAndOutOfLivesServer() || LunarConfig.ShareWithDead.Value)
							{
								PlayerCharacterMasterController.instances[i].networkUser.AwardLunarCoins(LunarConfig.SharedLunarCoinAmount.Value);
								Object.Destroy((Object)(object)((Component)self).gameObject);
							}
						}
					}
					if (LunarConfig.UnsharedLunarCoinAmount.Value != 0)
					{
						((Component)this).GetComponent<CharacterBody>().master.playerCharacterMasterController.networkUser.AwardLunarCoins(LunarConfig.UnsharedLunarCoinAmount.Value);
						Object.Destroy((Object)(object)((Component)self).gameObject);
					}
				}
				else
				{
					orig.Invoke(self, interactor);
				}
			};
		}
	}
}