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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LcCountdownTimer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A countdown timer for Lethal Company")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+9a5804a797aecaefe9476e4807d1c66a6b11f24f")]
[assembly: AssemblyProduct("LcCountdownTimer")]
[assembly: AssemblyTitle("LcCountdownTimer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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 LcCountdownTimer
{
[BepInPlugin("LcCountdownTimer", "LcCountdownTimer", "0.1.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
private void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Harmony val = new Harmony("LcCountdownTimer");
val.PatchAll();
Log.LogInfo((object)"Plugin LcCountdownTimer is loaded!");
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "LcCountdownTimer";
public const string PLUGIN_NAME = "LcCountdownTimer";
public const string PLUGIN_VERSION = "0.1.0";
}
}
namespace LcCountdownTimer.Patches
{
[HarmonyPatch]
internal class CountdownTimerPatch
{
private static GameObject _timerObject;
private static TextMeshProUGUI _timerTextMesh;
private static float _lastUpdated;
[HarmonyPatch(typeof(TimeOfDay), "Update")]
[HarmonyPostfix]
public static void Update(TimeOfDay __instance)
{
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
_lastUpdated += Time.deltaTime;
if (_lastUpdated < 0.5f)
{
return;
}
_lastUpdated = 0f;
if (!Object.op_Implicit((Object)(object)_timerObject) && !CreateTimerObject())
{
return;
}
if (!StartOfRound.Instance.shipDoorsEnabled || !TimeOfDay.Instance.currentDayTimeStarted)
{
((TMP_Text)_timerTextMesh).text = "";
return;
}
double num;
if (StartOfRound.Instance.shipIsLeaving)
{
num = 0.0;
}
else
{
float num2 = __instance.shipLeaveAutomaticallyTime - __instance.normalizedTimeOfDay;
num = num2 * __instance.totalTime / __instance.globalTimeSpeedMultiplier / __instance.currentLevel.DaySpeedMultiplier;
}
if (num < 0.0)
{
num = 0.0;
}
int num3 = (int)Math.Floor(num / 60.0);
int num4 = (int)Math.Floor(num % 60.0);
Color color = Color.green;
if (num3 < 2)
{
color = Color.red;
}
else if (num3 < 5)
{
color = Color.yellow;
}
((TMP_Text)_timerTextMesh).text = $"{num3:D2}:{num4:D2}";
((TMP_Text)_timerTextMesh).color = color;
}
private static bool CreateTimerObject()
{
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/TopRightCorner/ControlTip1");
if (!Object.op_Implicit((Object)(object)val))
{
Plugin.Log.LogError((object)"Could not find ControlTip1");
return false;
}
GameObject val2 = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/TopRightCorner/ControlTip2");
if (!Object.op_Implicit((Object)(object)val2))
{
Plugin.Log.LogError((object)"Could not find ControlTip2");
return false;
}
_timerObject = Object.Instantiate<GameObject>(val.gameObject, val.transform.parent, false);
((Object)_timerObject).name = "LcCountdownTimer";
float num = val.transform.position.y - val2.transform.position.y;
_timerObject.transform.Translate(0f, num, 0f);
_timerTextMesh = _timerObject.GetComponentInChildren<TextMeshProUGUI>();
Plugin.Log.LogInfo((object)"LcCountdownTimer created");
return true;
}
}
}