using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Atomicrops.Core.Upgrades;
using Atomicrops.Game.Data;
using Atomicrops.Game.GameState;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SharedLib;
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: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("SpeedrunTimer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SpeedrunTimer")]
[assembly: AssemblyTitle("SpeedrunTimer")]
[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 Template
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "SpeedrunTimer";
public const string PLUGIN_NAME = "SpeedrunTimer";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace SpeedrunTimer
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "pauli.plugin.SpeedrunTimer";
public const string PLUGIN_NAME = "SpeedrunTimer";
public const string PLUGIN_VERSION = "1.0.0";
}
[BepInPlugin("pauli.plugin.SpeedrunTimer", "SpeedrunTimer", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource Log;
public static bool IsRobustaCharacter;
private void Awake()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Logger.LogInfo((object)"SpeedrunTimer 1.0.0 is loaded!");
Harmony val = new Harmony("pauli.plugin.SpeedrunTimer");
val.PatchAll();
}
}
public class CustomTimerComponent : MonoBehaviour
{
private static float elapsedTime = 0f;
public Text timerText;
private static readonly float robustaTimeScale = 0.7518797f;
public void Update()
{
elapsedTime += Time.deltaTime * (Plugin.IsRobustaCharacter ? robustaTimeScale : 1f);
UpdateTimerDisplay();
}
private void UpdateTimerDisplay()
{
int num = Mathf.FloorToInt(elapsedTime / 60f);
int num2 = Mathf.FloorToInt(elapsedTime % 60f);
timerText.text = $"{num:00}:{num2:00}";
}
public static void ResetTimerStatic()
{
elapsedTime = 0f;
}
}
[HarmonyPatch(typeof(UiHudTime), "OnEnable")]
public static class UiHudTime_OnEnable_Patch
{
private static void Postfix(UiHudTime __instance)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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_00de: Unknown result type (might be due to invalid IL or missing references)
CustomTimerComponent component = ((Component)__instance).gameObject.GetComponent<CustomTimerComponent>();
if ((Object)(object)component == (Object)null)
{
component = ((Component)__instance).gameObject.AddComponent<CustomTimerComponent>();
GameObject val = new GameObject("CustomTimerText");
Text val2 = val.AddComponent<Text>();
val2.font = __instance.Clock.font;
val2.fontSize = __instance.Clock.fontSize;
val2.alignment = (TextAnchor)2;
((Graphic)val2).color = Color.white;
val.transform.SetParent(((Component)__instance).transform, false);
RectTransform component2 = val.GetComponent<RectTransform>();
component2.anchorMin = new Vector2(1f, 1f);
component2.anchorMax = new Vector2(1f, 1f);
component2.pivot = new Vector2(1f, 1f);
component2.anchoredPosition = new Vector2(-6f, -7f);
component.timerText = val2;
}
}
}
[HarmonyPatch(typeof(GameDataPresets), "NewGameData")]
public static class GameDataPresets_NewGameData_Patch
{
private static void Postfix(ProfileModel profile)
{
Plugin.IsRobustaCharacter = (Object)(object)ProfileModelUtils.GetSelectedCharacter(profile) == (Object)(object)SingletonScriptableObject<ConfigGame>.I.Player.Robusta;
CustomTimerComponent.ResetTimerStatic();
}
}
[HarmonyPatch(typeof(VictoryHandler), "OnVictory")]
public static class VictoryHandler_OnVictory_Patch
{
private static string finalTime = "99:99";
private static void Prefix()
{
CustomTimerComponent customTimerComponent = Object.FindObjectOfType<CustomTimerComponent>();
if ((Object)(object)customTimerComponent != (Object)null)
{
finalTime = customTimerComponent.timerText.text;
}
}
private static void Postfix()
{
GameObject val = GameObject.Find("UiScreenGameOver(Clone)/UiScreenGameOver/Grp/RightPanel/FinalScore (1)");
if ((Object)(object)val != (Object)null)
{
Text component = val.GetComponent<Text>();
if ((Object)(object)component != (Object)null)
{
component.text = "Time: " + finalTime + "\n";
Plugin.Log.LogInfo((object)"Final score text updated with time.");
}
else
{
Plugin.Log.LogInfo((object)"No text component found on FinalScore (1) GameObject.");
}
}
else
{
Plugin.Log.LogInfo((object)"FinalScore (1) GameObject not found.");
}
}
}
[HarmonyPatch(typeof(CatBonusUtils), "GetUnlockedUpgradesAndStacks")]
public static class CatBonusUtils_GetUnlockedUpgradesAndStacks_Patch
{
public static bool Prefix(ref List<KeyValuePair<UpgradeDef, int>> __result)
{
__result = new List<KeyValuePair<UpgradeDef, int>>();
return false;
}
}
}