Decompiled source of GoinDropper v1.0.0

Mods/GoinDropper.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using GoinDropper;
using GoinGrabber;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Players;
using Il2CppRUMBLE.Utilities;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using Microsoft.CodeAnalysis;
using RumbleModUI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "GoinDropper", "1.0.0", "Kpaiy", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 100, 233, 245)]
[assembly: MelonAuthorColor(255, 216, 19, 62)]
[assembly: VerifyLoaderVersion(0, 6, 6, true)]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("GoinDropper")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+81a1256718dba08fb9d8873703ad3eebc43fc7dd")]
[assembly: AssemblyProduct("GoinDropper")]
[assembly: AssemblyTitle("GoinDropper")]
[assembly: NeutralResourcesLanguage("en-US")]
[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 GoinDropper
{
	public static class BuildInfo
	{
		public const string ModName = "GoinDropper";

		public const string ModVersion = "1.0.0";

		public const string Description = "Drops goins on big hits.";

		public const string Author = "Kpaiy";

		public const string Company = "";
	}
	public class Core : MelonMod
	{
		[CompilerGenerated]
		private sealed class <ActivateGoinDropper>d__12 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Core <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ActivateGoinDropper>d__12(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.goinDropperActive = true;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <DropGoins>d__17 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PlayerController playerController;

			public int damage;

			public Core <>4__this;

			private int <numGoins>5__1;

			private Transform <playerChest>5__2;

			private int <i>5__3;

			private float <force>5__4;

			private float <randomY>5__5;

			private Quaternion <randomRotation>5__6;

			private GameObject <goin>5__7;

			private Rigidbody <goinRB>5__8;

			private Vector3 <forceDirection>5__9;

			private GoinHandler <goinHandler>5__10;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DropGoins>d__17(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<playerChest>5__2 = null;
				<goin>5__7 = null;
				<goinRB>5__8 = null;
				<goinHandler>5__10 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_0125: Unknown result type (might be due to invalid IL or missing references)
				//IL_0131: Unknown result type (might be due to invalid IL or missing references)
				//IL_013c: Unknown result type (might be due to invalid IL or missing references)
				//IL_015d: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<numGoins>5__1 = (int)Math.Floor(Math.Min(40.0, Math.Pow(1.7, -damage) - 1.0));
					<playerChest>5__2 = <>4__this.GetPlayerChest(playerController);
					<i>5__3 = 0;
					break;
				case 1:
					<>1__state = -1;
					<goin>5__7 = null;
					<goinRB>5__8 = null;
					<goinHandler>5__10 = null;
					<i>5__3++;
					break;
				}
				if (<i>5__3 < <numGoins>5__1)
				{
					<force>5__4 = (float)(-damage) * 0.5f;
					<randomY>5__5 = Random.Range(0f, 360f);
					<randomRotation>5__6 = Quaternion.Euler(0f, <randomY>5__5, 0f);
					<goin>5__7 = GoinManager.Instance.AddGoinToScene(<playerChest>5__2.position);
					<goin>5__7.transform.rotation = <randomRotation>5__6;
					<goinRB>5__8 = <goin>5__7.GetComponent<Rigidbody>();
					<goinRB>5__8.useGravity = true;
					<forceDirection>5__9 = RandomDirectionInCone(Vector3.up, 20f);
					<goinRB>5__8.AddForce(<forceDirection>5__9 * <force>5__4, (ForceMode)1);
					<goinRB>5__8.angularVelocity = new Vector3(0f, 20f, 0f);
					<goinHandler>5__10 = <goin>5__7.GetComponent<GoinHandler>();
					<goinHandler>5__10.flipAudioSource.volume = 0.3f;
					<goinHandler>5__10.flipAudioSource.Play();
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private Mod mod = new Mod();

		private ModSetting<int> maxGoinsSetting;

		private const int INITIAL_MAX_GOINS = 50;

		private int maxGoins = 50;

		private Dictionary<string, int> playerHps = new Dictionary<string, int>();

		private bool roundInProgress = false;

		private bool goinDropperActive = false;

		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg("Initialized.");
		}

		public override void OnLateInitializeMelon()
		{
			((MelonBase)this).OnLateInitializeMelon();
			UI.instance.UI_Initialized += OnUIInit;
		}

		private void OnUIInit()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			mod.ModName = "GoinDropper";
			mod.ModVersion = "1.0.0";
			mod.SetFolder("GoinDropper");
			maxGoinsSetting = mod.AddToList("Max Goins", 50, "Clean up old goins if there are more than this many goins.", new Tags());
			mod.GetFromFile();
			UI.instance.AddMod(mod);
			MelonLogger.Msg("Added to ModUI");
			((ModSetting)maxGoinsSetting).SavedValueChanged += MaxGoinCountChanged;
			UpdateMaxGoinsFromModSetting();
		}

		public void MaxGoinCountChanged(object sender, EventArgs e)
		{
			UpdateMaxGoinsFromModSetting();
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			GoinManager.Instance.ClearGoins();
			GoinManager.Instance.maxGoins = maxGoins;
			Random.seed = (int)DateTime.Now.Ticks;
			goinDropperActive = false;
			MelonCoroutines.Start(ActivateGoinDropper());
		}

		[IteratorStateMachine(typeof(<ActivateGoinDropper>d__12))]
		private IEnumerator ActivateGoinDropper()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ActivateGoinDropper>d__12(0)
			{
				<>4__this = this
			};
		}

		private void UpdateMaxGoinsFromModSetting()
		{
			GoinManager instance = GoinManager.Instance;
			maxGoins = (int)((ModSetting)maxGoinsSetting).Value;
			if (maxGoins < 0)
			{
				maxGoins = 0;
			}
			MelonLogger.Msg("New maxGoins: " + maxGoins);
			instance.maxGoins = maxGoins;
			while (instance.activeGoins.Count > maxGoins)
			{
				instance.DestroyGoin(instance.activeGoins.First());
			}
		}

		private Transform GetPlayerChest(PlayerController playerController)
		{
			return ((Component)playerController).transform.GetChild(0).GetChild(1).GetChild(0)
				.GetChild(4)
				.GetChild(0);
		}

		private int UpdatePlayer(Player player)
		{
			string playFabMasterId = player.Data.GeneralData.PlayFabMasterId;
			PlayerController controller = player.Controller;
			if ((Object)(object)controller == (Object)null)
			{
				return 0;
			}
			if (!playerHps.ContainsKey(playFabMasterId))
			{
				playerHps[playFabMasterId] = player.Data.HealthPoints;
				return player.Data.HealthPoints;
			}
			int num = playerHps[playFabMasterId];
			int num2 = player.Data.HealthPoints - num;
			playerHps[playFabMasterId] = player.Data.HealthPoints;
			if (num2 < 0 && roundInProgress && goinDropperActive)
			{
				MelonCoroutines.Start(DropGoins(controller, num2));
			}
			return player.Data.HealthPoints;
		}

		private static Vector3 RandomDirectionInCone(Vector3 coneDirection, float angle)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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)
			float num = angle * ((float)Math.PI / 180f);
			float num2 = Mathf.Cos(num);
			float num3 = Mathf.Sin(num);
			float num4 = Random.value * 2f * (float)Math.PI;
			float num5 = Mathf.Cos(num4) * num3;
			float num6 = Mathf.Sin(num4) * num3;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(num5, num6, num2);
			Quaternion val2 = Quaternion.FromToRotation(Vector3.forward, coneDirection);
			return val2 * val;
		}

		[IteratorStateMachine(typeof(<DropGoins>d__17))]
		private IEnumerator DropGoins(PlayerController playerController, int damage)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DropGoins>d__17(0)
			{
				<>4__this = this,
				playerController = playerController,
				damage = damage
			};
		}

		public override void OnUpdate()
		{
			if ((Object)(object)Singleton<PlayerManager>.Instance == (Object)null)
			{
				return;
			}
			bool flag = true;
			bool flag2 = false;
			Enumerator<Player> enumerator = Singleton<PlayerManager>.Instance.AllPlayers.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Player current = enumerator.Current;
				int num = UpdatePlayer(current);
				if (num != 20)
				{
					flag = false;
				}
				if (num == 0)
				{
					flag2 = true;
				}
			}
			if (flag)
			{
				roundInProgress = true;
			}
			if (flag2 && Singleton<PlayerManager>.Instance.AllPlayers.Count == 2)
			{
				roundInProgress = false;
			}
		}
	}
	public class NonNegativeValidation : ValidationParameters
	{
		public override bool DoValidation(string input)
		{
			MelonLogger.Msg(input);
			return true;
		}
	}
}