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 CarlosMMOWorldHUD v1.0.2
plugins/CarlosMMOWorldHUD.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; 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("CarlosMMOWorldHUD")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CarlosMMOWorldHUD")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("c2929155-c30a-4870-bfb0-f8bc6b3aef68")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace CarlosMMO; [BepInPlugin("carlos.mmo.worldhud", "Carlos MMO World HUD", "2.4.0")] public class CarlosMMOWorldHUD : BaseUnityPlugin { private class TransientMessage { public string Text; public Color Color; public float StartTime; public float Duration; } private GUIStyle _messageStyle; private GUIStyle _messageShadowStyle; private Texture2D _whiteTex; private float _nextRefresh; private float _nextWorldPoll; private int _cachedDay = 1; private string _cachedPhase = "Dia"; private bool _stylesReady; private string _lastBiomeName = ""; private string _lastWeatherName = ""; private string _lastPhaseName = ""; private int _lastDay = -1; private readonly List<TransientMessage> _messages = new List<TransientMessage>(); private readonly string[] _stormMessages = new string[3] { "⛈ Uma tempestade avança pelas terras distantes", "\ud83c\udf29 O céu ruge acima do mundo", "\ud83d\udca8 Rajadas fortes cortam o horizonte" }; private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"CARLOS MMO WORLD HUD: Awake"); } private void Start() { RefreshData(); } private void Update() { if (Time.time >= _nextRefresh) { _nextRefresh = Time.time + 0.25f; RefreshData(); } if (Time.time >= _nextWorldPoll) { _nextWorldPoll = Time.time + 1f; PollWorldState(); } CleanupExpiredMessages(); } private void BuildStyles() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0027: 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_0053: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown if (!_stylesReady) { _whiteTex = new Texture2D(1, 1, (TextureFormat)4, false); _whiteTex.SetPixel(0, 0, Color.white); _whiteTex.Apply(); _messageStyle = new GUIStyle(GUI.skin.label); _messageStyle.fontSize = 24; _messageStyle.richText = false; _messageStyle.clipping = (TextClipping)0; _messageStyle.wordWrap = false; _messageShadowStyle = new GUIStyle(GUI.skin.label); _messageShadowStyle.fontSize = 24; _messageShadowStyle.richText = false; _messageShadowStyle.clipping = (TextClipping)0; _messageShadowStyle.wordWrap = false; _stylesReady = true; } } private void OnGUI() { if (!_stylesReady) { BuildStyles(); } if (_messageStyle != null && _messageShadowStyle != null && !((Object)(object)_whiteTex == (Object)null)) { DrawTransientMessages(); } } private void DrawTransientMessages() { //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0189: 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_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) if (_messages.Count != 0) { TransientMessage transientMessage = _messages[0]; float num = Time.time - transientMessage.StartTime; float num2 = 1f; float num3 = 0.18f; float num4 = 0.3f; if (num < num3) { num2 = Mathf.Clamp01(num / num3); } else if (num > transientMessage.Duration - num4) { num2 = Mathf.Clamp01((transientMessage.Duration - num) / num4); } Color color = default(Color); ((Color)(ref color))..ctor(0f, 0f, 0f, 0.3f * num2); Color color2 = default(Color); ((Color)(ref color2))..ctor(1f, 1f, 1f, 0.1f * num2); float num5 = Mathf.Min((float)Screen.width - 120f, 980f); float num6 = 50f; float num7 = ((float)Screen.width - num5) * 0.5f; float num8 = 54f; DrawRect(new Rect(num7, num8, num5, num6), color); DrawBorder(new Rect(num7, num8, num5, num6), color2); Color textColor = default(Color); ((Color)(ref textColor))..ctor(0f, 0f, 0f, 0.95f * num2); Color color3 = transientMessage.Color; color3.a = num2; Vector2 val = _messageStyle.CalcSize(new GUIContent(transientMessage.Text)); float num9 = num7 + Mathf.Max(16f, (num5 - val.x) * 0.5f); float num10 = num8 + Mathf.Max(10f, (num6 - val.y) * 0.5f); _messageShadowStyle.normal.textColor = textColor; _messageStyle.normal.textColor = color3; GUI.Label(new Rect(num9 + 1.5f, num10 + 1.5f, val.x + 8f, val.y + 4f), transientMessage.Text, _messageShadowStyle); GUI.Label(new Rect(num9, num10, val.x + 8f, val.y + 4f), transientMessage.Text, _messageStyle); } } private void DrawRect(Rect rect, Color color) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_whiteTex == (Object)null)) { Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(rect, (Texture)(object)_whiteTex); GUI.color = color2; } } private void DrawBorder(Rect rect, Color color) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) DrawRect(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 1f), color); DrawRect(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - 1f, ((Rect)(ref rect)).width, 1f), color); DrawRect(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), color); DrawRect(new Rect(((Rect)(ref rect)).xMax - 1f, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), color); } private void RefreshData() { _cachedDay = GetGameDaySafe(); float dayFractionSafe = GetDayFractionSafe(); _cachedPhase = GetPhaseName(dayFractionSafe); } private void PollWorldState() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } int cachedDay = _cachedDay; string cachedPhase = _cachedPhase; string currentBiomeLocalized = GetCurrentBiomeLocalized(); string currentEnvironmentName = GetCurrentEnvironmentName(); if (_lastDay >= 0 && cachedDay > _lastDay) { EnqueueMessage("☀ Um novo dia começou no mundo — Dia " + cachedDay, new Color(1f, 0.82f, 0.2f, 1f)); } _lastDay = cachedDay; if (!string.IsNullOrEmpty(cachedPhase) && cachedPhase != _lastPhaseName) { if (!string.IsNullOrEmpty(_lastPhaseName)) { EnqueueMessage(GetPhaseTransitionMessage(cachedPhase), GetPhaseColor(cachedPhase)); } _lastPhaseName = cachedPhase; } if (!string.IsNullOrEmpty(currentBiomeLocalized) && currentBiomeLocalized != _lastBiomeName) { if (!string.IsNullOrEmpty(_lastBiomeName)) { EnqueueMessage("\ud83e\udded Novo bioma detectado: " + currentBiomeLocalized, new Color(0.6f, 1f, 0.65f, 1f)); } _lastBiomeName = currentBiomeLocalized; } if (string.IsNullOrEmpty(currentEnvironmentName) || !(currentEnvironmentName != _lastWeatherName)) { return; } if (!string.IsNullOrEmpty(_lastWeatherName)) { if (IsStormWeather(currentEnvironmentName)) { string text = _stormMessages[Random.Range(0, _stormMessages.Length)]; EnqueueMessage(text, new Color(0.6f, 0.78f, 1f, 1f)); } else { EnqueueMessage(GetWeatherMessage(currentEnvironmentName), GetWeatherColor(currentEnvironmentName)); } } _lastWeatherName = currentEnvironmentName; } private void EnqueueMessage(string text, Color color) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrWhiteSpace(text)) { _messages.Clear(); _messages.Add(new TransientMessage { Text = text, Color = color, StartTime = Time.time, Duration = 3.2f }); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[WorldHUD] " + text)); } } private void CleanupExpiredMessages() { if (_messages.Count == 0) { return; } for (int num = _messages.Count - 1; num >= 0; num--) { if (Time.time - _messages[num].StartTime >= _messages[num].Duration) { _messages.RemoveAt(num); } } } private int GetGameDaySafe() { try { if ((Object)(object)EnvMan.instance == (Object)null) { return 1; } Type typeFromHandle = typeof(EnvMan); MethodInfo method = typeFromHandle.GetMethod("GetCurrentDay", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null && method.Invoke(EnvMan.instance, null) is int num) { return Mathf.Max(1, num); } method = typeFromHandle.GetMethod("GetDay", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null && method.Invoke(EnvMan.instance, null) is int num2) { return Mathf.Max(1, num2); } FieldInfo field = typeFromHandle.GetField("m_day", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { object value = field.GetValue(EnvMan.instance); if (value is int) { int num3 = (int)value; if (true) { return Mathf.Max(1, num3); } } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("CARLOS MMO WORLD HUD: erro ao ler dia: " + ex.Message)); } return 1; } private float GetDayFractionSafe() { try { if ((Object)(object)EnvMan.instance == (Object)null) { return 0.3f; } Type typeFromHandle = typeof(EnvMan); MethodInfo method = typeFromHandle.GetMethod("GetDayFraction", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null && method.Invoke(EnvMan.instance, null) is float num) { return Mathf.Clamp01(num); } FieldInfo field = typeFromHandle.GetField("m_smoothDayFraction", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field.GetValue(EnvMan.instance) is float num2) { return Mathf.Clamp01(num2); } field = typeFromHandle.GetField("m_dayFraction", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { object value = field.GetValue(EnvMan.instance); if (value is float) { float num3 = (float)value; if (true) { return Mathf.Clamp01(num3); } } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("CARLOS MMO WORLD HUD: erro ao ler hora do mundo: " + ex.Message)); } return 0.3f; } private string GetPhaseName(float fraction) { float num = Mathf.Clamp01(fraction) * 24f; if (num >= 5f && num < 8f) { return "Amanhecer"; } if (num >= 8f && num < 17f) { return "Dia"; } if (num >= 17f && num < 20f) { return "Entardecer"; } return "Noite"; } private string GetPhaseTransitionMessage(string newPhase) { return newPhase switch { "Amanhecer" => "\ud83c\udf04 O amanhecer toca o mundo", "Dia" => "☀ A luz do dia domina os céus", "Entardecer" => "\ud83c\udf19 A noite começa a cobrir as terras", "Noite" => "\ud83d\udd6f A escuridão toma conta dos caminhos", _ => "⏳ Fase do mundo: " + newPhase, }; } private Color GetPhaseColor(string phase) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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) return (Color)(phase switch { "Amanhecer" => new Color(1f, 0.72f, 0.42f, 1f), "Dia" => new Color(1f, 0.82f, 0.2f, 1f), "Entardecer" => new Color(0.8f, 0.62f, 1f, 1f), "Noite" => new Color(0.52f, 0.88f, 1f, 1f), _ => Color.white, }); } private string GetCurrentEnvironmentName() { try { if ((Object)(object)EnvMan.instance == (Object)null) { return ""; } object currentEnvironment = EnvMan.instance.GetCurrentEnvironment(); if (currentEnvironment == null) { return ""; } Type type = currentEnvironment.GetType(); FieldInfo field = type.GetField("m_name", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { object value = field.GetValue(currentEnvironment); if (value != null) { return value.ToString(); } } return currentEnvironment.ToString(); } catch { return ""; } } private string GetWeatherMessage(string weatherName) { string text = weatherName.ToLowerInvariant(); if (text.Contains("rain") || text.Contains("chuva")) { return "\ud83c\udf27 A chuva toma conta do mundo"; } if (text.Contains("storm") || text.Contains("thunder") || text.Contains("tempest")) { return "⛈ Uma tempestade se forma nos céus"; } if (text.Contains("fog") || text.Contains("mist") || text.Contains("nevo")) { return "\ud83c\udf2b Névoa intensa cobre os caminhos"; } if (text.Contains("clear") || text.Contains("sunny") || text.Contains("light")) { return "☀ Os céus se abrem sobre o mundo"; } if (text.Contains("snow") || text.Contains("blizzard") || text.Contains("neve")) { return "❄ O frio se espalha pelas terras"; } return "\ud83c\udf0d Clima alterado: " + weatherName; } private Color GetWeatherColor(string weatherName) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) string text = weatherName.ToLowerInvariant(); if (text.Contains("storm") || text.Contains("thunder")) { return new Color(0.6f, 0.78f, 1f, 1f); } if (text.Contains("rain")) { return new Color(0.52f, 0.88f, 1f, 1f); } if (text.Contains("fog") || text.Contains("mist")) { return new Color(0.95f, 0.95f, 0.95f, 1f); } if (text.Contains("snow") || text.Contains("blizzard")) { return new Color(0.95f, 0.95f, 0.95f, 1f); } if (text.Contains("clear") || text.Contains("sunny")) { return new Color(1f, 0.82f, 0.2f, 1f); } return Color.white; } private bool IsStormWeather(string weatherName) { string text = weatherName.ToLowerInvariant(); return text.Contains("storm") || text.Contains("thunder") || text.Contains("tempest"); } private string GetCurrentBiomeLocalized() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Invalid comparison between Unknown and I4 //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected I4, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Invalid comparison between Unknown and I4 //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Invalid comparison between Unknown and I4 //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Invalid comparison between Unknown and I4 //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Invalid comparison between Unknown and I4 //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Invalid comparison between Unknown and I4 try { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return ""; } Biome currentBiome = localPlayer.GetCurrentBiome(); Biome val = currentBiome; Biome val2 = val; if ((int)val2 <= 16) { switch (val2 - 1) { default: if ((int)val2 != 8) { if ((int)val2 != 16) { break; } return "Planícies"; } return "Floresta Negra"; case 0: return "Pradaria"; case 1: return "Pântano"; case 3: return "Montanha"; case 2: break; } } else if ((int)val2 <= 64) { if ((int)val2 == 32) { return "Terras das Cinzas"; } if ((int)val2 == 64) { return "Norte Profundo"; } } else { if ((int)val2 == 256) { return "Oceano"; } if ((int)val2 == 512) { return "Terras Nebulosas"; } } return ((object)(Biome)(ref currentBiome)).ToString(); } catch { return ""; } } private void OnDestroy() { if ((Object)(object)_whiteTex != (Object)null) { Object.Destroy((Object)(object)_whiteTex); _whiteTex = null; } } }