Decompiled source of x5 and x10 Game Speed v1.0.0

CustomTimeScale.dll

Decompiled 6 months ago
using System;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Eremite;
using Eremite.View.HUD;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("CustomTimeScale")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Simplifies the building process by placing buildings completed.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5f6d748e7e5fd674a706f4680e6044d97f153fdc")]
[assembly: AssemblyProduct("CustomTimeScale")]
[assembly: AssemblyTitle("CustomTimeScale")]
[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 ATSUtils
{
	[BepInPlugin("CustomTimeScale", "CustomTimeScale", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin Instance;

		private Harmony harmony;

		private static float[] _overwriteTimeScales = new float[7] { 0f, 1f, 1.5f, 2f, 3f, 5f, 10f };

		private static Vector3[] _timeScaleSlotPositions = (Vector3[])(object)new Vector3[7]
		{
			new Vector3(-83.4292f, 77.0265f, 0f),
			new Vector3(-69.7224f, 43.2358f, 0f),
			new Vector3(-44.9018f, 19.485f, 0f),
			new Vector3(-12.1654f, 7.7813f, 0f),
			new Vector3(22.3388f, 10.1524f, 0f),
			new Vector3(53.1689f, 26.425f, 0f),
			new Vector3(73.1727f, 54.405f, 0f)
		};

		private void Awake()
		{
			Instance = this;
			harmony = Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin CustomTimeScale is loaded!");
		}

		[HarmonyPatch(typeof(TimeScalePanel), "SetUp")]
		[HarmonyPostfix]
		private static void HookEveryGameStart(TimeScalePanel __instance)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)__instance).transform;
			int num = transform.childCount - 2;
			Transform child = transform.GetChild(transform.childCount - 2);
			Object.Instantiate<GameObject>(((Component)child).gameObject, transform);
			Object.Instantiate<GameObject>(((Component)child).gameObject, transform);
			transform.GetChild(num + 1).SetAsLastSibling();
			for (int i = 0; i < _timeScaleSlotPositions.Length; i++)
			{
				Transform child2 = transform.GetChild(i);
				child2.localPosition = _timeScaleSlotPositions[i];
				TextMeshProUGUI componentInChildren = ((Component)child2).GetComponentInChildren<TextMeshProUGUI>();
				if (Object.op_Implicit((Object)(object)componentInChildren))
				{
					((TMP_Text)componentInChildren).text = "x" + _overwriteTimeScales[i].ToString(CultureInfo.InvariantCulture);
				}
				TimeScaleSlot component = ((Component)child2).GetComponent<TimeScaleSlot>();
				component.timeScale = _overwriteTimeScales[i];
			}
		}

		private void Update()
		{
			if (((ButtonControl)Keyboard.current.digit5Key).wasPressedThisFrame)
			{
				GameMB.TimeScaleService.Change(_overwriteTimeScales[5], true, false);
			}
			else if (((ButtonControl)Keyboard.current.digit6Key).wasPressedThisFrame)
			{
				GameMB.TimeScaleService.Change(_overwriteTimeScales[6], true, false);
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "CustomTimeScale";

		public const string PLUGIN_NAME = "CustomTimeScale";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}