Decompiled source of MoreSpeeds v1.0.1

MoreSpeeds.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("MoreSpeeds")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+c9873a0fa38d5ae9fb34fcb4b1b29e4df041ae2e")]
[assembly: AssemblyProduct("More Speeds")]
[assembly: AssemblyTitle("MoreSpeeds")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 MoreSpeeds
{
	internal static class CustomSpeeds
	{
		public static readonly Dictionary<string, float> Speeds = new Dictionary<string, float>
		{
			{ "1.25x", 1.25f },
			{ "1.5x", 1.5f },
			{ "1.75x", 1.75f },
			{ "2.0x", 2f },
			{ "2.5x", 2.5f },
			{ "3x", 3f },
			{ "4x", 4f },
			{ "5x", 5f },
			{ "10x", 10f }
		};
	}
	[BepInPlugin("MoreSpeeds", "More Speeds", "1.0.1")]
	public class MoreSpeedsHost : BaseUnityPlugin
	{
		private const string MULTIPLAYER_TIME_OPTIONS_NAME = "TimeScaleMinSettingButtonOptionPanel";

		private const string BUTTON_OPTIONS_FIELD_NAME = "buttonOptions";

		internal static ManualLogSource sLogger;

		private ButtonOptionSelect mFoundOptions;

		private void Awake()
		{
			((Object)Chainloader.ManagerObject).hideFlags = (HideFlags)61;
			FileInfo fileInfo = new FileInfo(typeof(MoreSpeedsHost).Assembly.Location);
			sLogger = ((BaseUnityPlugin)this).Logger;
			sLogger.LogInfo((object)"Loaded MoreSpeeds.");
			sLogger.LogInfo((object)string.Format("Plugin {0} created at {1}.", "MoreSpeeds", fileInfo.CreationTime));
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void LateUpdate()
		{
			if (!((Object)(object)mFoundOptions != (Object)null) && SearchForTimeOptions())
			{
				sLogger.LogInfo((object)"Setting up additional time options.");
				AddCustomSpeedOptions(mFoundOptions);
			}
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			mFoundOptions = null;
		}

		private bool SearchForTimeOptions()
		{
			ButtonOptionSelect[] array = Object.FindObjectsOfType<ButtonOptionSelect>();
			foreach (ButtonOptionSelect val in array)
			{
				if (string.Equals(((Object)val).name, "TimeScaleMinSettingButtonOptionPanel", StringComparison.OrdinalIgnoreCase))
				{
					mFoundOptions = val;
					return true;
				}
			}
			IGameSettingsManager val2 = Object.FindObjectsOfType<GameSettingsManager>().OfType<IGameSettingsManager>().FirstOrDefault();
			if (val2 != null && val2 is GameSettingsManager)
			{
				GameSettingsPanel val3 = Object.FindObjectOfType<GameSettingsPanel>();
				if ((Object)(object)val3 != (Object)null)
				{
					mFoundOptions = val3.timeScaleMinSelect;
					return true;
				}
			}
			return false;
		}

		private void AddCustomSpeedOptions(ButtonOptionSelect select)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			List<ButtonOption> list = (List<ButtonOption>)typeof(ButtonOptionSelect).GetField("buttonOptions").GetValue(select);
			foreach (KeyValuePair<string, float> speed in CustomSpeeds.Speeds)
			{
				list.Add(new ButtonOption
				{
					optionText = speed.Key,
					optionFloatValue = speed.Value
				});
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MoreSpeeds";

		public const string PLUGIN_NAME = "More Speeds";

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