Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RunicClock v1.0.3
plugins/RunicClock/RunicClock.dll
Decompiled 3 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization.Json; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using Runic.Localization; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Chazman")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Client-only in-game time, day count, and optional local clock.")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2")] [assembly: AssemblyProduct("RunicClock")] [assembly: AssemblyTitle("RunicClock")] [assembly: AssemblyVersion("1.0.2.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 Runic.Localization { internal sealed class LanguageCatalog { private readonly Dictionary<string, string> _english; private Dictionary<string, string> _selected = new Dictionary<string, string>(); private readonly Func<string, string> _read; private string _language; internal LanguageCatalog(string english, Func<string, string> read) { _english = Parse(english); _read = read; } internal static Dictionary<string, string> Parse(string json) { if (string.IsNullOrWhiteSpace(json)) { return new Dictionary<string, string>(); } if (json.Length > 2097152) { throw new InvalidDataException("Language file exceeds 2 MiB."); } DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(Dictionary<string, string>), new DataContractJsonSerializerSettings { UseSimpleDictionaryFormat = true }); using MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(json.TrimStart('\ufeff'))); return ((Dictionary<string, string>)dataContractJsonSerializer.ReadObject(stream)) ?? new Dictionary<string, string>(); } internal void Select(string language) { language = (string.IsNullOrWhiteSpace(language) ? "English" : language); if (string.Equals(language, _language, StringComparison.Ordinal)) { return; } _language = language; _selected = new Dictionary<string, string>(); if (language.IndexOfAny(new char[4] { '/', '\\', ':', '\0' }) >= 0 || language == "." || language == "..") { return; } try { _selected = Parse(_read(language)); } catch (Exception) { } } internal string Get(string key) { _english.TryGetValue(key, out var value); if (_selected.TryGetValue(key, out var value2) && !string.IsNullOrWhiteSpace(value2) && (value == null || SameFields(value, value2))) { return value2; } return value ?? key; } internal string English(string key) { if (!_english.TryGetValue(key, out var value)) { return key; } return value; } internal string TranslateEnglish(string text) { foreach (KeyValuePair<string, string> item in _english) { if (item.Value == text) { return Get(item.Key); } } return text; } internal string Format(string key, params object[] args) { _english.TryGetValue(key, out var value); string text = Get(key); if (value != null && !SameFields(value, text)) { text = value; } try { return string.Format(CultureInfo.CurrentCulture, text, args); } catch (FormatException) { try { return string.Format(CultureInfo.CurrentCulture, value ?? key, args); } catch (FormatException) { return value ?? key; } } } private static bool SameFields(string a, string b) { try { return Fields(a).SetEquals(Fields(b)); } catch (FormatException) { return false; } } private static HashSet<int> Fields(string text) { HashSet<int> hashSet = new HashSet<int>(); for (int i = 0; i < text.Length; i++) { if (text[i] == '}') { if (i + 1 >= text.Length || text[i + 1] != '}') { throw new FormatException(); } i++; } else { if (text[i] != '{') { continue; } if (i + 1 < text.Length && text[i + 1] == '{') { i++; continue; } int num = ++i; for (; i < text.Length && char.IsDigit(text[i]); i++) { } if (num == i || !int.TryParse(text.Substring(num, i - num), out var result)) { throw new FormatException(); } hashSet.Add(result); for (; i < text.Length && text[i] != '}'; i++) { if (text[i] == '{') { throw new FormatException(); } } if (i == text.Length) { throw new FormatException(); } } } return hashSet; } } internal static class RunicText { private static readonly Assembly Owner = typeof(RunicText).Assembly; private static readonly string Module = Owner.GetName().Name; private static readonly LanguageCatalog Catalog = Create(); private static LanguageCatalog Create() { using Stream stream = Owner.GetManifestResourceStream("Runic.Localization.English.json"); using StreamReader streamReader = ((stream == null) ? null : new StreamReader(stream)); return new LanguageCatalog(streamReader?.ReadToEnd() ?? "{}", ReadLanguage); } private static string ReadLanguage(string language) { string path = Path.Combine(Path.Combine(Path.GetDirectoryName(Owner.Location), "Translations", Module), language + ".json"); if (!File.Exists(path)) { return null; } return File.ReadAllText(path); } private static void SelectLanguage() { string language = "English"; try { Localization instance = Localization.instance; language = ((instance != null) ? instance.GetSelectedLanguage() : null) ?? "English"; } catch { } Catalog.Select(language); } internal static string Get(string key) { SelectLanguage(); return Catalog.Get(key); } internal static string English(string key) { return Catalog.English(key); } internal static string TranslateEnglish(string text) { SelectLanguage(); return Catalog.TranslateEnglish(text); } internal static string Format(string key, params object[] args) { SelectLanguage(); return Catalog.Format(key, args); } } } namespace RunicClock { internal sealed class ClockConfig { internal readonly ConfigEntry<bool> Enabled; internal readonly ConfigEntry<bool> Visible; internal readonly ConfigEntry<bool> Use24Hour; internal readonly ConfigEntry<bool> ShowDay; internal readonly ConfigEntry<bool> ShowIndicator; internal readonly ConfigEntry<bool> ShowRealTime; internal readonly ConfigEntry<bool> RealTime24Hour; internal readonly ConfigEntry<bool> HideInMenus; internal readonly ConfigEntry<float> Scale; internal readonly ConfigEntry<float> OffsetX; internal readonly ConfigEntry<float> OffsetY; internal readonly ConfigEntry<float> BackgroundOpacity; internal readonly ConfigEntry<ClockAnchor> Anchor; internal readonly ConfigEntry<KeyboardShortcut> ToggleKey; internal ClockConfig(ConfigFile config) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Expected O, but got Unknown //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Expected O, but got Unknown Enabled = config.Bind<bool>("General", "Enabled", true, RunicText.Get("text_78cf8eb401b2")); Visible = config.Bind<bool>("General", "Visible", true, RunicText.Get("text_51fb57908b0f")); ToggleKey = config.Bind<KeyboardShortcut>("General", "ToggleShortcut", new KeyboardShortcut((KeyCode)99, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), RunicText.Get("text_4f83e880ad86")); Use24Hour = config.Bind<bool>("Clock", "Use24Hour", true, RunicText.Get("text_cb603c524349")); ShowDay = config.Bind<bool>("Clock", "ShowDay", true, RunicText.Get("text_7249b2c66cc5")); ShowIndicator = config.Bind<bool>("Clock", "ShowSunMoon", true, RunicText.Get("text_be831133ec1a")); ShowRealTime = config.Bind<bool>("Clock", "ShowRealWorldTime", false, RunicText.Get("text_be4fa73da1f2")); RealTime24Hour = config.Bind<bool>("Clock", "RealWorldUse24Hour", true, RunicText.Get("text_30e89d7617d0")); Anchor = config.Bind<ClockAnchor>("Display", "Anchor", ClockAnchor.TopCenter, RunicText.Get("text_45f207c536dc")); OffsetX = config.Bind<float>("Display", "OffsetX", 0f, new ConfigDescription(RunicText.Get("text_e8f31dcb1a5f"), (AcceptableValueBase)(object)new AcceptableValueRange<float>(-4096f, 4096f), Array.Empty<object>())); OffsetY = config.Bind<float>("Display", "OffsetY", 64f, new ConfigDescription(RunicText.Get("text_86214a9260e0"), (AcceptableValueBase)(object)new AcceptableValueRange<float>(-4096f, 4096f), Array.Empty<object>())); Scale = config.Bind<float>("Display", "Scale", 1f, new ConfigDescription(RunicText.Get("text_7d0b625e1025"), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.6f, 2f), Array.Empty<object>())); BackgroundOpacity = config.Bind<float>("Display", "BackgroundOpacity", 0.65f, new ConfigDescription(RunicText.Get("text_9409bab3d014"), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); HideInMenus = config.Bind<bool>("Display", "HideInMenus", true, RunicText.Get("text_1f7ab3406e2f")); } } public enum ClockAnchor { TopLeft, TopCenter, TopRight, MiddleLeft, Center, MiddleRight, BottomLeft, BottomCenter, BottomRight } internal static class ClockModel { internal static bool TryGameTime(double dayFraction, bool use24Hour, out string text) { text = string.Empty; if (double.IsNaN(dayFraction) || double.IsInfinity(dayFraction) || dayFraction < 0.0 || dayFraction > 1.0) { return false; } int num = ((dayFraction != 1.0) ? Math.Min(1439, (int)Math.Floor(dayFraction * 1440.0)) : 0); text = FormatTime(num / 60, num % 60, use24Hour); return true; } internal static string FormatTime(int hour, int minute, bool use24Hour) { if (hour < 0 || hour > 23 || minute < 0 || minute > 59) { throw new ArgumentOutOfRangeException(); } if (use24Hour) { return hour.ToString("00", CultureInfo.InvariantCulture) + ":" + minute.ToString("00", CultureInfo.InvariantCulture); } int num = hour % 12; return ((num == 0) ? 12 : num).ToString(CultureInfo.InvariantCulture) + ":" + minute.ToString("00", CultureInfo.InvariantCulture) + ((hour < 12) ? RunicText.Get("text_02f0185c8297") : RunicText.Get("text_cb6f53dae980")); } internal static double Clamp(double value, double min, double max, double fallback) { if (!double.IsNaN(value) && !double.IsInfinity(value)) { return Math.Max(min, Math.Min(max, value)); } return fallback; } internal static (double X, double Y) Position(ClockAnchor anchor, double safeX, double safeY, double safeWidth, double safeHeight, double width, double height, double offsetX, double offsetY) { int num = (int)anchor; if (num < 0 || num > 8) { num = 1; } double num2 = Math.Max(0.0, safeWidth - width); double num3 = Math.Max(0.0, safeHeight - height); double val = safeX + num2 * (double)(num % 3) / 2.0 + Clamp(offsetX, -4096.0, 4096.0, 0.0); double val2 = safeY + num3 * (double)(num / 3) / 2.0 + Clamp(offsetY, -4096.0, 4096.0, 0.0); return (X: Math.Max(safeX, Math.Min(safeX + num2, val)), Y: Math.Max(safeY, Math.Min(safeY + num3, val2))); } } internal sealed class ClockView : IDisposable { private readonly ClockConfig _settings; private readonly GUIContent _time = new GUIContent(); private readonly GUIContent _day = new GUIContent(); private readonly GUIContent _local = new GUIContent(); private GUIStyle _large; private GUIStyle _small; private int _fontSize; private bool _isDay; private Texture2D _sun; private Texture2D _moon; private static readonly Color Gold = new Color(1f, 0.8f, 0.35f); internal ClockView(ClockConfig settings) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown _settings = settings; } internal void SetText(string time, string day, string local, bool isDay) { _time.text = time; _day.text = day; _local.text = local; _isDay = isDay; } internal void Draw() { //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) float num = (float)ClockModel.Clamp(_settings.Scale.Value, 0.6, 2.0, 1.0) * Mathf.Clamp((float)Screen.height / 1080f, 0.5f, 3f); EnsureStyles(Mathf.Max(12, Mathf.RoundToInt(24f * num))); if ((Object)(object)_sun == (Object)null) { _sun = CreateSymbol(moon: false); } if ((Object)(object)_moon == (Object)null) { _moon = CreateSymbol(moon: true); } Rect safeArea = Screen.safeArea; if (((Rect)(ref safeArea)).width <= 0f || ((Rect)(ref safeArea)).height <= 0f) { ((Rect)(ref safeArea))..ctor(0f, 0f, (float)Screen.width, (float)Screen.height); } float num2 = (float)Screen.height - ((Rect)(ref safeArea)).yMax; float num3 = 10f * num; float num4 = 31f * num; float num5 = 21f * num; float num6 = 24f * num; bool value = _settings.ShowIndicator.Value; bool value2 = _settings.ShowDay.Value; bool value3 = _settings.ShowRealTime.Value; float num7 = _large.CalcSize(_time).x + (value ? (num6 + 8f * num) : 0f); float num8 = num7; if (value2) { num8 = Mathf.Max(num8, _small.CalcSize(_day).x); } if (value3) { num8 = Mathf.Max(num8, _small.CalcSize(_local).x); } float num9 = Mathf.Min(((Rect)(ref safeArea)).width, Mathf.Max(180f * num, num8 + num3 * 2f)); float num10 = Mathf.Min(((Rect)(ref safeArea)).height, num3 * 2f + num4 + (value2 ? num5 : 0f) + (value3 ? num5 : 0f)); (double, double) tuple = ClockModel.Position(_settings.Anchor.Value, ((Rect)(ref safeArea)).x, num2, ((Rect)(ref safeArea)).width, ((Rect)(ref safeArea)).height, num9, num10, _settings.OffsetX.Value, _settings.OffsetY.Value); Rect area = default(Rect); ((Rect)(ref area))..ctor((float)tuple.Item1, (float)tuple.Item2, num9, num10); Color color = GUI.color; try { float num11 = (float)ClockModel.Clamp(_settings.BackgroundOpacity.Value, 0.0, 1.0, 0.65); if (num11 > 0f) { Paint(area, new Color(0.025f, 0.035f, 0.06f, num11)); Paint(new Rect(((Rect)(ref area)).x, ((Rect)(ref area)).y, ((Rect)(ref area)).width, Mathf.Max(1f, num)), new Color(Gold.r, Gold.g, Gold.b, num11)); } float num12 = ((Rect)(ref area)).x + (((Rect)(ref area)).width - num7) / 2f; float num13 = ((Rect)(ref area)).y + num3; if (value) { GUI.color = (Color)(_isDay ? Gold : new Color(0.77f, 0.86f, 1f)); GUI.DrawTexture(new Rect(num12, num13 + (num4 - num6) / 2f, num6, num6), (Texture)(object)(_isDay ? _sun : _moon)); num12 += num6 + 8f * num; } GUI.color = Color.white; GUI.Label(new Rect(num12, num13, _large.CalcSize(_time).x, num4), _time, _large); num13 += num4; if (value2) { GUI.Label(new Rect(((Rect)(ref area)).x, num13, num9, num5), _day, _small); num13 += num5; } if (value3) { GUI.Label(new Rect(((Rect)(ref area)).x, num13, num9, num5), _local, _small); } } finally { GUI.color = color; } } private static void Paint(Rect area, Color color) { //IL_0000: 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) GUI.color = color; GUI.DrawTexture(area, (Texture)(object)Texture2D.whiteTexture); } private void EnsureStyles(int fontSize) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0060: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_00a7: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if (_large == null || _fontSize != fontSize) { _fontSize = fontSize; _large = new GUIStyle(GUI.skin.label) { fontSize = fontSize, fontStyle = (FontStyle)1, alignment = (TextAnchor)4, richText = false, wordWrap = false, padding = new RectOffset(0, 0, 0, 0) }; _large.normal.textColor = Gold; _small = new GUIStyle(_large) { fontSize = Mathf.Max(10, Mathf.RoundToInt((float)fontSize * 0.62f)), fontStyle = (FontStyle)0 }; _small.normal.textColor = new Color(0.91f, 0.92f, 0.95f); } } private static Texture2D CreateSymbol(bool moon) { //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Expected O, but got Unknown //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) Color[] array = (Color[])(object)new Color[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num = 0f; for (int k = 0; k < 2; k++) { for (int l = 0; l < 2; l++) { double num2 = ((double)j + ((double)l + 0.5) / 2.0 - 32.0) / 32.0; double num3 = ((double)i + ((double)k + 0.5) / 2.0 - 32.0) / 32.0; double num4 = Math.Sqrt(num2 * num2 + num3 * num3); bool num5; if (!moon) { if (num4 < 0.48) { goto IL_014b; } if (!(num4 > 0.62) || !(num4 < 0.9)) { continue; } num5 = Math.Abs(Math.Sin(Math.Atan2(num3, num2) * 4.0)) < 0.18; } else { if (!(num4 < 0.85)) { continue; } num5 = (num2 - 0.4) * (num2 - 0.4) + (num3 - 0.2) * (num3 - 0.2) > 0.5184; } if (!num5) { continue; } goto IL_014b; IL_014b: num += 0.25f; } } array[i * 64 + j] = new Color(1f, 1f, 1f, num); } } Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false) { name = (moon ? "RunicClock Moon" : "RunicClock Sun"), hideFlags = (HideFlags)61, filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; val.SetPixels(array); val.Apply(false, true); return val; } public void Dispose() { if ((Object)(object)_sun != (Object)null) { Object.Destroy((Object)(object)_sun); } if ((Object)(object)_moon != (Object)null) { Object.Destroy((Object)(object)_moon); } _sun = (_moon = null); } } [BepInPlugin("chazman.RunicClock", "Runic Clock", "1.0.2")] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "chazman.RunicClock"; public const string Name = "Runic Clock"; public const string Version = "1.0.2"; private ClockConfig _settings; private ClockView _view; private Player _player; private EnvMan _environment; private ZNet _network; private float _nextRefresh; private volatile bool _refreshRequested; private bool _ready; private bool _failed; private void Awake() { if (Application.isBatchMode) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"RunicClock is client-only; no server runtime started."); return; } _settings = new ClockConfig(((BaseUnityPlugin)this).Config); _view = new ClockView(_settings); ((BaseUnityPlugin)this).Config.SettingChanged += SettingsChanged; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Runic Clock 1.0.2 ready. Left Alt+C toggles the clock; all settings are local."); } private void SettingsChanged(object sender, SettingChangedEventArgs args) { _refreshRequested = true; } private void Update() { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) if (_settings == null || _failed) { return; } try { if (!_settings.Enabled.Value || !HasWorld()) { _ready = false; _nextRefresh = 0f; _player = null; _environment = null; _network = null; return; } if (_player != Player.m_localPlayer || _environment != EnvMan.instance || _network != ZNet.instance) { _player = Player.m_localPlayer; _environment = EnvMan.instance; _network = ZNet.instance; _ready = false; _nextRefresh = 0f; } if (!InputBlocked()) { KeyboardShortcut value = _settings.ToggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { _settings.Visible.Value = !_settings.Visible.Value; } } if (!_settings.Visible.Value) { _ready = false; return; } float unscaledTime = Time.unscaledTime; if (_refreshRequested) { _refreshRequested = false; _nextRefresh = 0f; } if (unscaledTime < _nextRefresh && unscaledTime >= _nextRefresh - 0.25f) { return; } _nextRefresh = unscaledTime + 0.25f; _ready = ClockModel.TryGameTime(_environment.GetDayFraction(), _settings.Use24Hour.Value, out var text); if (_ready) { int day = _environment.GetDay(); if (day < 0) { _ready = false; return; } DateTime now = DateTime.Now; _view.SetText(text, RunicText.Get("text_df2441a485d2") + day.ToString(CultureInfo.InvariantCulture), RunicText.Get("text_a15ca5cd809e") + ClockModel.FormatTime(now.Hour, now.Minute, _settings.RealTime24Hour.Value), EnvMan.IsDay()); } } catch (Exception error) { Fail(error); } } private static bool HasWorld() { if ((Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)EnvMan.instance != (Object)null && (Object)(object)ZNet.instance != (Object)null) { return (Object)(object)Hud.instance != (Object)null; } return false; } private static bool InputBlocked() { if (!Menu.IsVisible() && !Console.IsVisible() && !TextInput.IsVisible() && !InventoryGui.IsVisible() && !Minimap.IsOpen() && !StoreGui.IsVisible() && !Hud.IsPieceSelectionVisible() && !UnifiedPopup.IsVisible() && !ConnectPanel.IsVisible() && !Feedback.IsVisible() && !PlayerCustomizaton.IsBarberGuiVisible() && !ZInput.VirtualKeyboardOpen && !Game.IsPaused() && (!((Object)(object)TextViewer.instance != (Object)null) || !TextViewer.instance.IsVisible())) { if ((Object)(object)Chat.instance != (Object)null) { if (!Chat.instance.HasFocus()) { return Chat.instance.IsChatDialogWindowVisible(); } return true; } return false; } return true; } private void OnGUI() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Invalid comparison between Unknown and I4 if (_settings == null || _failed || !_ready || !_settings.Enabled.Value || !_settings.Visible.Value || Event.current == null || (int)Event.current.type != 7) { return; } try { if (HasWorld() && _player == Player.m_localPlayer && _environment == EnvMan.instance && _network == ZNet.instance && !Hud.instance.m_userHidden && Hud.instance.IsVisible() && (!((Object)(object)Hud.instance.m_loadingScreen != (Object)null) || !((Component)Hud.instance.m_loadingScreen).gameObject.activeInHierarchy) && (!_settings.HideInMenus.Value || !InputBlocked())) { _view.Draw(); } } catch (Exception error) { Fail(error); } } private void Fail(Exception error) { _failed = true; _ready = false; ((BaseUnityPlugin)this).Logger.LogError((object)("RunicClock stopped its overlay after an error; gameplay is unchanged. " + error)); } private void OnDestroy() { if (_settings != null) { ((BaseUnityPlugin)this).Config.SettingChanged -= SettingsChanged; } _view?.Dispose(); _view = null; _ready = false; _player = null; _environment = null; _network = null; } } }