Decompiled source of TimeScaleSetter v0.1.1

TimeScaleSetter.dll

Decompiled 8 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TimeScaleSetter.patches;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;

[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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TimeScaleSetter")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Your Mod Description Goes Here")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TimeScaleSetter")]
[assembly: AssemblyTitle("TimeScaleSetter")]
[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 TimeScaleSetter
{
	[BepInPlugin("org.agmas.TimeScaleSetter", "TimeScaleSetter", "0.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "org.agmas.TimeScaleSetter";

		private const string modName = "TimeScaleSetter";

		private const string modVersion = "0.1.0";

		public ConfigEntry<string> url;

		private readonly Harmony harmony = new Harmony("org.agmas.TimeScaleSetter");

		public static Plugin Instance;

		public ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("org.agmas.TimeScaleSetter");
			mls.LogInfo((object)"We're up and running!");
			harmony.PatchAll(typeof(HudManagerPatch));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "TimeScaleSetter";

		public const string PLUGIN_NAME = "TimeScaleSetter";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace TimeScaleSetter.patches
{
	[HarmonyPatch(typeof(HUDManager))]
	internal class HudManagerPatch
	{
		[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
		[HarmonyPrefix]
		private static bool undo2(HUDManager __instance, ref CallbackContext context)
		{
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (!((CallbackContext)(ref context)).performed || (Object)(object)localPlayerController == (Object)null || !localPlayerController.isTypingChat || ((!((NetworkBehaviour)localPlayerController).IsOwner || (((NetworkBehaviour)__instance).IsServer && !localPlayerController.isHostPlayerObject)) && !localPlayerController.isTestingPlayer) || localPlayerController.isPlayerDead)
			{
				return false;
			}
			if (__instance.chatTextField.text.StartsWith("/ts "))
			{
				__instance.AddTextToChatOnServer(__instance.chatTextField.text, -1);
				localPlayerController.isTypingChat = false;
				__instance.chatTextField.text = "";
				EventSystem.current.SetSelectedGameObject((GameObject)null);
				__instance.PingHUDElement(__instance.Chat, 2f, 1f, 0.2f);
				((Behaviour)__instance.typingIndicator).enabled = false;
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(HUDManager), "AddChatMessage")]
		[HarmonyPrefix]
		private static bool undo(HUDManager __instance, string chatMessage, string nameOfUserWhoTyped = "")
		{
			if (string.IsNullOrEmpty(nameOfUserWhoTyped) && chatMessage.StartsWith("/ts "))
			{
				Time.timeScale = float.Parse(chatMessage.Split(" ")[1]);
				HUDManager.Instance.DisplayTip("TimeScaleSetter", "Set TS to " + float.Parse(chatMessage.Split(" ")[1]), false, false, "LC_Tip1");
				return false;
			}
			return true;
		}
	}
}