Decompiled source of Time Stop v1.0.8

time stop.dll

Decompiled 3 weeks 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.Versioning;
using BepInEx;
using InControl;
using UnboundLib.Cards;
using UnityEngine;

[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("time stop")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("time stop")]
[assembly: AssemblyTitle("time stop")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MyAwesomeRoundsMod;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.yourname.rounds.myawesomemod", "My Awesome Mod", "1.0.0")]
[BepInProcess("Rounds.exe")]
public class MyMod : BaseUnityPlugin
{
	private const string ModId = "com.yourname.rounds.myawesomemod";

	private const string ModName = "My Awesome Mod";

	private const string Version = "1.0.0";

	public static GameObject timeStopArt;

	private void Awake()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Expected O, but got Unknown
		//IL_004c: 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_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		string path = Path.Combine(Paths.PluginPath, "time stop card.png");
		if (File.Exists(path))
		{
			byte[] array = File.ReadAllBytes(path);
			Texture2D val = new Texture2D(2, 2);
			ImageConversion.LoadImage(val, array);
			Sprite sprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			timeStopArt = new GameObject("TimeStopArt");
			SpriteRenderer val2 = timeStopArt.AddComponent<SpriteRenderer>();
			val2.sprite = sprite;
			Object.DontDestroyOnLoad((Object)(object)timeStopArt);
		}
		else
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find 'time stop card.png' in the plugins folder!");
		}
	}

	private void Start()
	{
		CustomCard.BuildCard<TimeStopCard>();
	}
}
public class TimeStopCard : CustomCard
{
	public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
	{
		cardInfo.allowMultiple = false;
	}

	public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
	{
		((Component)player).gameObject.AddComponent<TimeStopEffect>();
	}

	public override void OnRemoveCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
	{
		Object.Destroy((Object)(object)((Component)player).gameObject.GetComponent<TimeStopEffect>());
	}

	protected override string GetTitle()
	{
		return "times end";
	}

	protected override string GetDescription()
	{
		return "Stand still for 7s to stop time for 7s.";
	}

	protected override GameObject GetCardArt()
	{
		return MyMod.timeStopArt;
	}

	protected override Rarity GetRarity()
	{
		return (Rarity)2;
	}

	protected override CardThemeColorType GetTheme()
	{
		return (CardThemeColorType)3;
	}

	protected override CardInfoStat[] GetStats()
	{
		return (CardInfoStat[])(object)new CardInfoStat[0];
	}
}
public class TimeStopEffect : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <StopTimeRoutine>d__10 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public TimeStopEffect <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_007a: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>4__this.isTimeStopped = true;
				<>4__this.idleTimer = 0f;
				<>4__this.UpdateRingVisual(0f);
				if ((Object)(object)Camera.main != (Object)null)
				{
					<>4__this.screenOverlay.transform.position = ((Component)Camera.main).transform.position + new Vector3(0f, 0f, 10f);
				}
				<>4__this.screenOverlay.SetActive(true);
				<>4__this.originalSpeed = <>4__this.player.data.stats.movementSpeed;
				Time.timeScale = 0.02f;
				Time.fixedDeltaTime = 0.02f * Time.timeScale;
				<>4__this.player.data.stats.movementSpeed = <>4__this.originalSpeed * 50f;
				<>2__current = (object)new WaitForSecondsRealtime(7f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				Time.timeScale = 1f;
				Time.fixedDeltaTime = 0.02f;
				<>4__this.player.data.stats.movementSpeed = <>4__this.originalSpeed;
				<>4__this.screenOverlay.SetActive(false);
				<>4__this.isTimeStopped = false;
				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 Player player;

	private float idleTimer = 0f;

	private bool isTimeStopped = false;

	private LineRenderer ringRenderer;

	private GameObject screenOverlay;

	private float timeToWait = 7f;

	private float originalSpeed;

	private void Start()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Expected O, but got Unknown
		//IL_0035: 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_0095: Expected O, but got Unknown
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Expected O, but got Unknown
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Expected O, but got Unknown
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		player = ((Component)this).GetComponent<Player>();
		GameObject val = new GameObject("TimeStopRing");
		val.transform.SetParent(((Component)player).transform);
		val.transform.localPosition = Vector3.zero;
		ringRenderer = val.AddComponent<LineRenderer>();
		ringRenderer.useWorldSpace = false;
		ringRenderer.startWidth = 0.15f;
		ringRenderer.endWidth = 0.15f;
		((Renderer)ringRenderer).material = new Material(Shader.Find("Sprites/Default"));
		((Renderer)ringRenderer).sortingOrder = 100;
		ringRenderer.startColor = Color.cyan;
		ringRenderer.endColor = Color.cyan;
		screenOverlay = new GameObject("TimeStopTint");
		SpriteRenderer val2 = screenOverlay.AddComponent<SpriteRenderer>();
		Texture2D val3 = new Texture2D(1, 1);
		val3.SetPixel(0, 0, Color.white);
		val3.Apply();
		val2.sprite = Sprite.Create(val3, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f));
		val2.color = new Color(0.1f, 0f, 0.4f, 0.6f);
		((Renderer)val2).sortingOrder = 32000;
		screenOverlay.transform.localScale = new Vector3(100f, 100f, 1f);
		screenOverlay.SetActive(false);
	}

	private void Update()
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: 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)
		if (isTimeStopped)
		{
			if ((Object)(object)Camera.main != (Object)null && screenOverlay.activeSelf)
			{
				screenOverlay.transform.position = ((Component)Camera.main).transform.position + new Vector3(0f, 0f, 10f);
			}
			return;
		}
		float num = Mathf.Abs(((TwoAxisInputControl)player.data.playerActions.Move).Value.x);
		float num2 = Mathf.Abs(((TwoAxisInputControl)player.data.playerActions.Move).Value.y);
		if (num < 0.3f && num2 < 0.3f)
		{
			idleTimer += Time.deltaTime;
			UpdateRingVisual(idleTimer / timeToWait);
			if (idleTimer >= timeToWait)
			{
				((MonoBehaviour)this).StartCoroutine(StopTimeRoutine());
			}
		}
		else
		{
			idleTimer = 0f;
			UpdateRingVisual(0f);
		}
	}

	private void UpdateRingVisual(float percentage)
	{
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		int num = 60;
		float num2 = 2f;
		int num3 = Mathf.Clamp(Mathf.FloorToInt((float)num * percentage), 0, num);
		if (num3 < 2)
		{
			ringRenderer.positionCount = 0;
			return;
		}
		ringRenderer.positionCount = num3;
		for (int i = 0; i < num3; i++)
		{
			float num4 = (float)i / (float)num * MathF.PI * 2f;
			float num5 = Mathf.Sin(num4) * num2;
			float num6 = Mathf.Cos(num4) * num2;
			ringRenderer.SetPosition(i, new Vector3(num5, num6, 0f));
		}
	}

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

	private void OnDestroy()
	{
		if (isTimeStopped)
		{
			Time.timeScale = 1f;
			Time.fixedDeltaTime = 0.02f;
			if ((Object)(object)player != (Object)null)
			{
				player.data.stats.movementSpeed = originalSpeed;
			}
		}
		if ((Object)(object)screenOverlay != (Object)null)
		{
			Object.Destroy((Object)(object)screenOverlay);
		}
	}
}