using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using TMPro;
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("Supermarketmod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Supermarketmod")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8faaa57b-1d09-4887-9542-412322fd95c3")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.buttergeland.supermarkettogether.timescalemod", "buttergeland_timescale", "0.1.0")]
public class TimeScaleMod : BaseUnityPlugin
{
private ConfigEntry<KeyboardShortcut> increaseSpeedKey;
private ConfigEntry<KeyboardShortcut> resetSpeedKey;
private static ConfigEntry<bool> debugModeConfig;
private float[] cyclingSpeeds = new float[4] { 2f, 4f, 6f, 8f };
private int currentSpeedIndex = 0;
private void Awake()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
resetSpeedKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "ResetSpeedKey", new KeyboardShortcut((KeyCode)282, Array.Empty<KeyCode>()), "Key to reset the game speed");
increaseSpeedKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "IncreaseSpeedKey", new KeyboardShortcut((KeyCode)283, Array.Empty<KeyCode>()), "Key to increase the game speed");
debugModeConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DebugMode", false, "Enable or disable debug mode.");
LogDebug("Time Scale Mod loaded successfully with configurable keys!");
}
private void Update()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
KeyboardShortcut value = resetSpeedKey.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
LogDebug("Reset speed key pressed");
ResetGameSpeed();
}
value = increaseSpeedKey.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
LogDebug("Increase speed key pressed");
IncreaseGameSpeed();
}
}
private void IncreaseGameSpeed()
{
Time.timeScale = cyclingSpeeds[currentSpeedIndex];
LogDebug($"Game speed set to {Time.timeScale}x (Index Before: {currentSpeedIndex})");
ShowSpeedNotification($"Game Speed: {Time.timeScale}x");
currentSpeedIndex = (currentSpeedIndex + 1) % cyclingSpeeds.Length;
LogDebug($"(Index After Applying: {currentSpeedIndex})");
}
private void ResetGameSpeed()
{
Time.timeScale = 1f;
currentSpeedIndex = 0;
LogDebug("Game speed reset to 1x");
ShowSpeedNotification("Game Speed: 1x");
}
private void ShowSpeedNotification(string text)
{
if ((Object)(object)GameCanvas.Instance != (Object)null && (Object)(object)GameCanvas.Instance.notificationPrefab != (Object)null)
{
GameObject val = Object.Instantiate<GameObject>(GameCanvas.Instance.notificationPrefab, GameCanvas.Instance.notificationParentTransform);
TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
if ((Object)(object)component != (Object)null)
{
((TMP_Text)component).text = text;
}
val.SetActive(true);
LogDebug("Displayed speed notification: " + text);
}
else
{
LogDebug("GameCanvas or notificationPrefab is not available.");
}
}
private void LogDebug(string message)
{
if (debugModeConfig.Value)
{
Debug.Log((object)("[TimeScale Debug] " + message));
}
}
}