Decompiled source of CheatersGoBrr v1.0.1

CheatersGoBrr.dll

Decompiled 11 hours 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.Bootstrap;
using BepInEx.Configuration;
using EntityStates.NewtMonster;
using HG;
using Microsoft.CodeAnalysis;
using On.EntityStates.NewtMonster;
using On.RoR2;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CheatersGoBrr")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+003612221a4fcc026deb5b2b18e6dbf40d984d59")]
[assembly: AssemblyProduct("CheatersGoBrr")]
[assembly: AssemblyTitle("CheatersGoBrr")]
[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 CheatersGoBrr
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("FakeMichau.CheatersGoBrr", "CheatersGoBrr", "1.0.1")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class CheatersGoBrr : BaseUnityPlugin
	{
		public const string PluginGUID = "FakeMichau.CheatersGoBrr";

		public const string PluginAuthor = "FakeMichau";

		public const string PluginName = "CheatersGoBrr";

		public const string PluginVersion = "1.0.1";

		public void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			ModConfig.InitConfig(((BaseUnityPlugin)this).Config);
			NetworkUser.DeductLunarCoins += new hook_DeductLunarCoins(NetworkUser_DeductLunarCoins);
			LunarCoinDef.GrantPickup += new hook_GrantPickup(LunarCoinDef_GrantPickup);
			SpawnState.OnEnter += new hook_OnEnter(SpawnState_OnEnter);
			if (RiskOfOptionsCompat.Enabled)
			{
				RiskOfOptionsCompat.AddOptions();
			}
		}

		private void SpawnState_OnEnter(orig_OnEnter orig, SpawnState self)
		{
			orig.Invoke(self);
			Utils.SendMessage(ModConfig.OnEntryMessage.Value, "#4f8aff");
		}

		private void LunarCoinDef_GrantPickup(orig_GrantPickup orig, LunarCoinDef self, ref GrantContext context)
		{
			NetworkUser val = Util.LookUpBodyNetworkUser(context.body);
			if (Object.op_Implicit((Object)(object)val) && val.lunarCoins >= ModConfig.Threshold.Value && ModConfig.PreventStealingLunars.Value)
			{
				Utils.SendMessage(ModConfig.PSLMessage.Value, "#ffc0cb");
				context.shouldNotify = false;
				context.shouldDestroy = false;
			}
			else
			{
				orig.Invoke(self, ref context);
			}
		}

		private void NetworkUser_DeductLunarCoins(orig_DeductLunarCoins orig, NetworkUser self, uint count)
		{
			if (self.netLunarCoins >= ModConfig.Threshold.Value)
			{
				if (count == 1 << ModConfig.WarningPricePower.Value)
				{
					Utils.SendMessage(ModConfig.WarningMessage.Value, "#ff7f7f");
					self.master.inventory.GiveItemString("TonicAffliction");
				}
				else if (ModConfig.GiveTonicAffliction.Value)
				{
					self.master.inventory.GiveItemString("TonicAffliction");
				}
				if (count >= 1 << ModConfig.RemoveAllPricePower.Value)
				{
					Utils.SendMessage(ModConfig.RALMessage.Value, "#ffc0cb");
					count = self.netLunarCoins;
				}
				else
				{
					uint num = Convert.ToUIntClamped((ModConfig.DeductMultiplier.Value < 1) ? 1 : ModConfig.DeductMultiplier.Value);
					count *= num;
				}
				self.NetworknetLunarCoins = HGMath.UintSafeSubtract(self.netLunarCoins, count);
				self.CallRpcDeductLunarCoins(count);
			}
			else
			{
				orig.Invoke(self, count);
			}
		}
	}
	internal class ModConfig
	{
		public static ConfigEntry<int> Threshold;

		public static ConfigEntry<int> DeductMultiplier;

		public static ConfigEntry<int> WarningPricePower;

		public static ConfigEntry<int> RemoveAllPricePower;

		public static ConfigEntry<bool> GiveTonicAffliction;

		public static ConfigEntry<bool> PreventStealingLunars;

		public static ConfigEntry<string> PSLMessage;

		public static ConfigEntry<string> RALMessage;

		public static ConfigEntry<string> WarningMessage;

		public static ConfigEntry<string> OnEntryMessage;

		public static void InitConfig(ConfigFile config)
		{
			Threshold = config.Bind<int>("Settings", "Threshold", 5000, "Having how many lunars will activate the effects.");
			DeductMultiplier = config.Bind<int>("Effects", "Deduct Multiplier", 1, "Multiplies the cost of lunar items.\n1 effectively disables the effect.");
			WarningPricePower = config.Bind<int>("Effects", "Warning Price", 9, "Price at which there will be a warning.\nThis setting works in powers of 2. Value 9 means the effective value will be 2^9 meaning 512.");
			WarningMessage = config.Bind<string>("Effects", "Warning Message", "It's dangerous to feed the Lunar Stone so much!\nHere's a tonic for you to come down.", "Message that will appear in chat as a warning");
			RemoveAllPricePower = config.Bind<int>("Effects", "Remove All Lunar Price", 11, "At or above that price, while trying to spend lunars, all lunars will be removed from the player.\nThis setting works in powers of 2. Value 11 means the effective value will be 2^11 meaning 2048");
			RALMessage = config.Bind<string>("Effects", "RAL Message", "YOINK!", "Optional message when taking player's all lunars.\nEmpty to disable the message.");
			GiveTonicAffliction = config.Bind<bool>("Effects", "Give Tonic Affliction", false, "Activates whenever a player tries to spend their lunars.");
			PreventStealingLunars = config.Bind<bool>("Effects", "Prevent Stealing Lunars", true, "Prevents a player from picking up a lunar coin.");
			PSLMessage = config.Bind<string>("Effects", "PSL Message", "You greedy FUCK!", "Optional message when trying to pick up a lunar.\n\"Prevent Stealing Lunars\" has to be enabled.\nEmpty to disable the message.");
			OnEntryMessage = config.Bind<string>("Effects", "On Entry Message", "Don't spend too much or you will be punished", "Optional message when entering the bazaar.\nEmpty to disable the message.");
		}
	}
	internal class RiskOfOptionsCompat
	{
		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				bool valueOrDefault = _enabled.GetValueOrDefault();
				if (!_enabled.HasValue)
				{
					valueOrDefault = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
					_enabled = valueOrDefault;
				}
				return _enabled.Value;
			}
		}

		public static void AddOptions()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(ModConfig.Threshold, new IntSliderConfig
			{
				min = 0,
				max = 100000
			}));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(ModConfig.DeductMultiplier, new IntSliderConfig
			{
				min = 1,
				max = 10000
			}));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(ModConfig.WarningPricePower, new IntSliderConfig
			{
				min = 0,
				max = 25
			}));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(ModConfig.RemoveAllPricePower, new IntSliderConfig
			{
				min = 0,
				max = 25
			}));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ModConfig.GiveTonicAffliction));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ModConfig.PreventStealingLunars));
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(ModConfig.PSLMessage));
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(ModConfig.RALMessage));
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(ModConfig.OnEntryMessage));
			ModSettingsManager.SetModDescription("We hate cheaters.");
		}
	}
	internal class Utils
	{
		public static void SendMessage(string message)
		{
			if (message != "")
			{
				ChatMessage.Send(message);
			}
		}

		public static void SendMessage(string message, string hex)
		{
			if (message != "")
			{
				ChatMessage.SendColored(message, hex);
			}
		}
	}
}