using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Reptile;
using Speedometer.Patches;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Speedometer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Speedometer")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a4d63e50-8158-4b22-881b-fd1d815984a9")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Speedometer
{
[BepInPlugin("com.Dragsun.Speedometer", "Speedometer", "1.1.0")]
public class SpeedometerPlugin : BaseUnityPlugin
{
private const string MyGUID = "com.Dragsun.Speedometer";
private const string PluginName = "Speedometer";
private const string VersionString = "1.1.0";
public static ConfigEntry<string> MyDictionaryConfig;
public static Dictionary<string, float> MyDictionary = new Dictionary<string, float>();
public static GameplayUI ui;
public static TextMeshProUGUI m_label;
public static TextMeshProUGUI m_labelpause;
public static PauseMenu pausemenu;
public static bool pausemenuactive;
public static float playerspeed;
private bool isRainbowActive = false;
public static int maxSpeedForRainbow = 80;
private Color targetColor;
public float t = 0f;
public static UIManager uimanager;
private float executionTimer = 0f;
private bool conditionMet = false;
private float requiredTime = 0.1f;
private float conditionTimer = 0f;
private float highestSpeed = 0f;
private static readonly Harmony Harmony = new Harmony("com.Dragsun.Speedometer");
public static ManualLogSource Log = new ManualLogSource("Speedometer");
public static Player player { get; set; }
private void Awake()
{
MyDictionaryConfig = ((BaseUnityPlugin)this).Config.Bind<string>("MyDictionary", "Data", SerializeDictionary(MyDictionary), "Serialized dictionary data");
DeserializeDictionary(MyDictionaryConfig.Value, MyDictionary);
((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: Speedometer, VersionString: 1.1.0 is loading...");
Harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: Speedometer, VersionString: 1.1.0 is loaded.");
Log = ((BaseUnityPlugin)this).Logger;
}
private void Update()
{
//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)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)player != (Object)null))
{
return;
}
((TMP_Text)m_labelpause).alpha = ((TMP_Text)pausemenu.highestComboValueText).alpha;
Dictionary<string, float> myDictionary = MyDictionary;
Stage currentStage = Utility.GetCurrentStage();
if (!myDictionary.ContainsKey(((object)(Stage)(ref currentStage)).ToString()))
{
Dictionary<string, float> myDictionary2 = MyDictionary;
currentStage = Utility.GetCurrentStage();
myDictionary2[((object)(Stage)(ref currentStage)).ToString()] = 0f;
MyDictionaryConfig.Value = SerializeDictionary(MyDictionary);
}
playerspeed = player.GetTotalSpeed();
UI.Instance.ShowNotification($"{playerspeed:0.0}".Replace(".", "").Replace(",", ""));
Dictionary<string, float> myDictionary3 = MyDictionary;
currentStage = Utility.GetCurrentStage();
if (myDictionary3[((object)(Stage)(ref currentStage)).ToString()] < playerspeed)
{
conditionTimer += Time.deltaTime;
}
else
{
conditionTimer = 0f;
}
if (conditionTimer >= requiredTime)
{
highestSpeed = playerspeed;
Dictionary<string, float> myDictionary4 = MyDictionary;
currentStage = Utility.GetCurrentStage();
myDictionary4[((object)(Stage)(ref currentStage)).ToString()] = playerspeed;
MyDictionaryConfig.Value = SerializeDictionary(MyDictionary);
}
if (playerspeed > (float)maxSpeedForRainbow)
{
if (!isRainbowActive)
{
isRainbowActive = true;
((MonoBehaviour)this).StartCoroutine(AnimateRainbow());
}
}
else
{
isRainbowActive = false;
((MonoBehaviour)this).StopCoroutine(AnimateRainbow());
UpdateTextColor(playerspeed);
}
}
private void ConfigSettingChanged(object sender, EventArgs e)
{
SettingChangedEventArgs val = (SettingChangedEventArgs)(object)((e is SettingChangedEventArgs) ? e : null);
if (val != null)
{
}
}
private void UpdateTextColor(float speed)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//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_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
Color white = Color.white;
Color red = Color.red;
if (speed < 30f)
{
((Graphic)m_label).color = Color.white;
return;
}
float num = Mathf.Clamp01((speed - 30f) / 40f);
Color color = Color.Lerp(white, red, num);
((Graphic)m_label).color = color;
}
private IEnumerator AnimateRainbow()
{
Color[] rainbowColors = (Color[])(object)new Color[6]
{
Color.red,
Color.yellow,
Color.green,
Color.cyan,
Color.blue,
Color.magenta
};
((Graphic)m_label).color = Color.red;
int currentIndex2 = 0;
float timer = 0f;
float rainbowSpeed = 0.3f;
while (isRainbowActive)
{
timer += Time.deltaTime;
if (timer >= rainbowSpeed)
{
timer = 0f;
currentIndex2++;
currentIndex2 = ((currentIndex2 < rainbowColors.Length) ? currentIndex2 : 0);
Color startColor = ((Graphic)m_label).color;
Color targetColor = rainbowColors[currentIndex2];
float duration = rainbowSpeed;
float elapsedTime = 0f;
while (elapsedTime < duration)
{
elapsedTime += Time.deltaTime;
float t = Mathf.Clamp01(elapsedTime / duration);
((Graphic)m_label).color = Color.Lerp(startColor, targetColor, t);
yield return null;
}
((Graphic)m_label).color = targetColor;
}
yield return null;
}
}
private string SerializeDictionary(Dictionary<string, float> dictionary)
{
return string.Join("|", dictionary.Select((KeyValuePair<string, float> kv) => $"{kv.Key}:{kv.Value}"));
}
private void DeserializeDictionary(string serializedData, Dictionary<string, float> dictionary)
{
dictionary.Clear();
string[] array = serializedData.Split(new char[1] { '|' });
string[] array2 = array;
foreach (string text in array2)
{
string[] array3 = text.Split(new char[1] { ':' });
if (array3.Length == 2 && float.TryParse(array3[1], out var result))
{
dictionary[array3[0]] = result;
}
}
}
}
}
namespace Speedometer.Patches
{
[HarmonyPatch(typeof(GameplayUI))]
public class GameplayUIPatch
{
[HarmonyPostfix]
[HarmonyPatch("Init")]
public static void Init(GameplayUI __instance)
{
SpeedometerPlugin.ui = __instance;
((Component)__instance.gameplayScreen).gameObject.AddComponent<UI>();
}
}
[HarmonyPatch(typeof(PauseMenu))]
internal class PauseMenuPatches
{
[HarmonyPatch("Init")]
[HarmonyPostfix]
public static void Init_Postfix(PauseMenu __instance)
{
if ((Object)(object)SpeedometerPlugin.pausemenu == (Object)null)
{
SpeedometerPlugin.pausemenu = __instance;
}
}
}
[HarmonyPatch(typeof(Player))]
internal class PlayerPatches
{
[HarmonyPatch("Init")]
[HarmonyPrefix]
public static bool Awake_Prefix(Player __instance)
{
if ((Object)(object)SpeedometerPlugin.player == (Object)null)
{
SpeedometerPlugin.player = __instance;
}
return true;
}
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void Awake_Postfix(Player __instance)
{
}
}
public class UI : MonoBehaviour
{
public static UI Instance;
private TextMeshProUGUI m_label = null;
private TextMeshProUGUI m_labelpause = null;
private float m_notificationTimer = 5f;
private bool m_active;
private void Awake()
{
Instance = this;
SetupLabel();
SetupLabelPause();
}
private void FixedUpdate()
{
UpdateTimer();
}
public void ShowNotification(string text)
{
((TMP_Text)m_label).text = text;
m_notificationTimer = 5f;
if (!m_active)
{
m_active = true;
((Component)m_label).gameObject.SetActive(true);
}
}
public void ShowNotificationPause(string text)
{
((TMP_Text)m_labelpause).text = text;
((Component)m_labelpause).gameObject.SetActive(true);
}
public void HideNotificationPause()
{
((Component)m_labelpause).gameObject.SetActive(false);
((TMP_Text)m_labelpause).text = "";
}
private void UpdateTimer()
{
if (m_notificationTimer < 0f && m_active)
{
m_notificationTimer = 5f;
m_active = false;
((Component)m_label).gameObject.SetActive(false);
((TMP_Text)m_label).text = "";
}
if (m_active)
{
m_notificationTimer -= Time.fixedDeltaTime;
}
}
private void SetupLabel()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
m_label = new GameObject("Speedometer").AddComponent<TextMeshProUGUI>();
UIManager uIManager = Core.Instance.UIManager;
GameplayUI value = Traverse.Create((object)uIManager).Field<GameplayUI>("gameplay").Value;
TextMeshProUGUI graffitiNewLabel = value.graffitiNewLabel;
((TMP_Text)m_label).font = ((TMP_Text)graffitiNewLabel).font;
((TMP_Text)m_label).fontSize = 42f;
((TMP_Text)m_label).fontMaterial = ((TMP_Text)graffitiNewLabel).fontMaterial;
((TMP_Text)m_label).alignment = (TextAlignmentOptions)260;
RectTransform rectTransform = ((TMP_Text)m_label).rectTransform;
rectTransform.anchorMin = new Vector2(0.1f, 0.5f);
rectTransform.anchorMax = new Vector2(0.868f, 0.16f);
rectTransform.pivot = new Vector2(0f, 1f);
rectTransform.anchoredPosition = new Vector2(1f, 0.2f);
((Transform)((TMP_Text)m_label).rectTransform).SetParent((Transform)(object)((Component)value.gameplayScreen).GetComponent<RectTransform>(), false);
SpeedometerPlugin.m_label = m_label;
m_labelpause = new GameObject("topspeedmyman").AddComponent<TextMeshProUGUI>();
PauseMenu pausemenu = SpeedometerPlugin.pausemenu;
TextMeshProUGUI highestComboValueText = pausemenu.highestComboValueText;
((TMP_Text)m_labelpause).font = ((TMP_Text)highestComboValueText).font;
((TMP_Text)m_labelpause).fontSize = ((TMP_Text)highestComboValueText).fontSize;
((TMP_Text)m_labelpause).fontMaterial = ((TMP_Text)highestComboValueText).fontMaterial;
((Graphic)m_labelpause).color = ((Graphic)highestComboValueText).color;
((TMP_Text)m_labelpause).alignment = (TextAlignmentOptions)260;
RectTransform rectTransform2 = ((TMP_Text)m_labelpause).rectTransform;
rectTransform2.anchorMin = new Vector2(0.1f, 0.6f);
rectTransform2.anchorMax = new Vector2(0.8875f, 0.7f);
rectTransform2.pivot = new Vector2(0f, 1f);
rectTransform2.anchoredPosition = new Vector2(1f, 0.2f);
Transform parent = ((Component)value).transform.parent;
string text = "PauseMenu";
Transform val = null;
for (int i = 0; i < parent.childCount; i++)
{
Transform child = parent.GetChild(i);
if (((Object)child).name == text)
{
val = child;
break;
}
}
if ((Object)(object)val != (Object)null)
{
((Transform)((TMP_Text)m_labelpause).rectTransform).SetParent((Transform)(object)((Component)((Component)val).transform).GetComponent<RectTransform>(), false);
}
SpeedometerPlugin.m_labelpause = m_labelpause;
}
private void SetupLabelPause()
{
}
}
[HarmonyPatch(typeof(UIManager))]
internal class UIManagerPatches
{
[HarmonyPatch("Init")]
[HarmonyPostfix]
public static void Init_Postfix(UIManager __instance)
{
if ((Object)(object)SpeedometerPlugin.uimanager == (Object)null)
{
SpeedometerPlugin.uimanager = __instance;
}
}
[HarmonyPatch("ShowPauseMenu")]
[HarmonyPostfix]
public static void ShowPauseMenu_Postfix(UIManager __instance)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
Dictionary<string, float> myDictionary = SpeedometerPlugin.MyDictionary;
Stage currentStage = Utility.GetCurrentStage();
float num = myDictionary[((object)(Stage)(ref currentStage)).ToString()];
UI.Instance.ShowNotificationPause("Highest speed: " + $"{num:0.0}".Replace(".", "").Replace(",", ""));
}
[HarmonyPatch("HidePauseMenu")]
[HarmonyPostfix]
public static void HidePauseMenu_Postfix(UIManager __instance)
{
}
}
}
namespace Speedometer.MonoBehaviours
{
internal class SpeedometerComponent : MonoBehaviour
{
public void Awake()
{
}
public void Start()
{
}
public void Update()
{
}
public void LateUpdate()
{
}
}
}