Decompiled source of Invested v1.0.1

Invested/ShockwaveMod.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ShockwaveMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ShockwaveMod")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("214e7a6c-9fbf-4f00-a54d-246195cf5c9c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ShockwaveMod;

[BepInPlugin("com.yourname.shockwave", "Shockwave Ability Mod", "1.0.0")]
public class ShockwaveMod : BaseUnityPlugin
{
	private float cooldown = 60f;

	private float lastUsedTime = -9999f;

	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		GameObject val = new GameObject("ShockwaveModObject");
		((Object)val).hideFlags = (HideFlags)61;
		val.AddComponent<ShockwaveBehaviour>();
		Object.DontDestroyOnLoad((Object)(object)val);
		Debug.Log((object)"ShockwaveMod initialized.");
	}
}
public class ShockwaveBehaviour : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <WaitAndPlay>d__4 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public WWW www;

		public ShockwaveBehaviour <>4__this;

		private AudioClip <clip>5__1;

		private GameObject <audioObject>5__2;

		private AudioSource <source>5__3;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<clip>5__1 = null;
			<audioObject>5__2 = null;
			<source>5__3 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = www;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				if (!string.IsNullOrEmpty(www.error))
				{
					Debug.LogError((object)("[ShockwaveMod] Failed to load sound: " + www.error));
					return false;
				}
				<clip>5__1 = www.GetAudioClip(false, false, (AudioType)14);
				<audioObject>5__2 = new GameObject("ShockwaveSound");
				<audioObject>5__2.transform.position = ((Component)<>4__this).transform.position;
				<source>5__3 = <audioObject>5__2.AddComponent<AudioSource>();
				<source>5__3.clip = <clip>5__1;
				<source>5__3.volume = 0.25f;
				<source>5__3.spatialBlend = 1f;
				<source>5__3.Play();
				Object.Destroy((Object)(object)<audioObject>5__2, <clip>5__1.length + 0.5f);
				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 float cooldown = 60f;

	private float lastUsedTime = -9999f;

	private bool showGUI = false;

	private void Update()
	{
		if (Input.GetKeyDown((KeyCode)114) && Time.time - lastUsedTime > cooldown)
		{
			TriggerShockwave();
			lastUsedTime = Time.time;
		}
	}

	private void PlayCustomShockwaveSound()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		string text = Path.Combine(Paths.PluginPath, "JGreen-Invested", "explosion.ogg");
		WWW www = new WWW("file://" + text);
		((MonoBehaviour)this).StartCoroutine(WaitAndPlay(www));
	}

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

	private void TriggerShockwave()
	{
		//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_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: 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_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: 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_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		Debug.Log((object)"Shockwave triggered!");
		Vector3 position = ((Component)this).transform.position;
		float num = 10f;
		float num2 = 500f;
		Collider[] array = Physics.OverlapSphere(position, num);
		Collider[] array2 = array;
		foreach (Collider val in array2)
		{
			Rigidbody attachedRigidbody = val.attachedRigidbody;
			if ((Object)(object)attachedRigidbody != (Object)null && (Object)(object)((Component)attachedRigidbody).gameObject != (Object)(object)((Component)this).gameObject)
			{
				Vector3 val2 = ((Component)attachedRigidbody).transform.position - position;
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				attachedRigidbody.AddForce(normalized * num2, (ForceMode)1);
			}
		}
		GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)0);
		val3.transform.position = position;
		val3.transform.localScale = Vector3.one * 0.1f;
		Object.Destroy((Object)(object)val3.GetComponent<Collider>());
		ParticleSystem val4 = val3.AddComponent<ParticleSystem>();
		MainModule main = val4.main;
		((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Color.cyan);
		((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(1.5f);
		((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0.5f);
		((MainModule)(ref main)).simulationSpeed = 2f;
		val4.Play();
		Object.Destroy((Object)(object)val3, 2f);
		PlayCustomShockwaveSound();
	}

	private void OnGUI()
	{
		//IL_004a: 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_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Expected O, but got Unknown
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		if (showGUI)
		{
			float num = Time.time - lastUsedTime;
			float num2 = Mathf.Clamp01(num / cooldown);
			float num3 = 200f;
			float num4 = 15f;
			float num5 = 120f;
			float num6 = 330f;
			GUI.color = Color.gray;
			GUI.DrawTexture(new Rect(num5, num6, num3, num4), (Texture)(object)Texture2D.whiteTexture);
			GUI.color = Color.cyan;
			GUI.DrawTexture(new Rect(num5, num6, num3 * num2, num4), (Texture)(object)Texture2D.whiteTexture);
			GUI.color = Color.white;
			GUIStyle val = new GUIStyle(GUI.skin.label);
			val.fontSize = 18;
			val.alignment = (TextAnchor)3;
			GUI.Label(new Rect(num5, num6 - 30f, num3, 30f), (num2 >= 1f) ? "Shockwave Ready!" : "Shockwave Charging...", val);
		}
	}

	private static AudioClip CreateSoftExplosionSound()
	{
		int num = 44100;
		int num2 = 1;
		AudioClip val = AudioClip.Create("SoftBoom", num * num2, 1, num, false);
		float[] array = new float[num * num2];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = Mathf.PerlinNoise((float)i * 0.05f, 0f) * 0.2f;
		}
		val.SetData(array, 0);
		return val;
	}

	private void OnEnable()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		Application.logMessageReceived += new LogCallback(HandleLogMessage);
	}

	private void OnDisable()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		Application.logMessageReceived -= new LogCallback(HandleLogMessage);
	}

	private void HandleLogMessage(string logString, string stackTrace, LogType type)
	{
		string text = logString.ToLowerInvariant();
		if (text.Contains("level"))
		{
			showGUI = true;
			lastUsedTime = Time.time - cooldown;
			Debug.Log((object)"[ShockwaveMod] Entered gameplay — showing GUI and resetting cooldown.");
		}
		else if (text.Contains("lobby") || text.Contains("leav"))
		{
			showGUI = false;
			Debug.Log((object)"[ShockwaveMod] Entered lobby/menu — hiding GUI.");
		}
	}
}