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 BetterStealthIndicator v0.4.12
BetterStealthIndicator.dll
Decompiled 9 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; 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("BetterStealthIndicator")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BetterStealthIndicator")] [assembly: AssemblyTitle("BetterStealthIndicator")] [assembly: AssemblyVersion("1.0.0.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 BetterStealthIndicator { [BepInPlugin("jaybird.BetterStealthIndicator", "Better Stealth Indicator", "0.4.8")] public class Plugin : BaseUnityPlugin { private enum AwarenessState { Undetected, Searching, Detected } public const string ModGuid = "jaybird.BetterStealthIndicator"; public const string ModName = "Better Stealth Indicator"; public const string ModVersion = "0.4.8"; internal static ManualLogSource Log; private ConfigEntry<bool> _enabled; private ConfigEntry<bool> _useOdinsEyeSet; private ConfigEntry<float> _brightness; private ConfigEntry<float> _scale; private bool _snappingConfig; private ConfigEntry<float> _horizontalOffset; private ConfigEntry<float> _verticalOffset; private ConfigEntry<bool> _showStateText; private Texture2D _undetected; private Texture2D _searching; private Texture2D _detected; private Texture2D _solid; private string _loadedSetKey = string.Empty; private AwarenessState _state; private float _visibility; private bool _vanillaVisible; private float _detectedPulseStart = -999f; private const float DetectedPulseDuration = 4f; private const float DetectedPulseScale = 1.45f; private Type _hudType; private object _hudInstance; private GameObject _stealthBarGo; private GameObject _hiddenGo; private GameObject _targetedGo; private GameObject _targetedAlertGo; private float _nextHudRefresh; private Type _inventoryGuiType; private Type _menuType; private Type _consoleType; private Type _configManagerType; private object _configManagerInstance; private MethodInfo _getStealthFactor; private readonly Dictionary<CanvasRenderer, float> _rendererAlpha = new Dictionary<CanvasRenderer, float>(); private void Awake() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; _enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable Better Stealth Indicator. Disable this to use Valheim's original indicator only."); _useOdinsEyeSet = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UseOdinsEyeSet", false, "Art set toggle. OFF = The Beast. ON = Odins Eye."); _brightness = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "Brightness", 1f, new ConfigDescription("Indicator brightness. Snaps to 0.25 steps from 0.50 to 2.00. Default is 1.00.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>())); _scale = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "Scale", 1f, new ConfigDescription("Custom indicator size. Snaps to 0.25 steps from 0.50 to 2.00.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>())); _brightness.SettingChanged += SnapSteppedAppearanceValues; _scale.SettingChanged += SnapSteppedAppearanceValues; SnapSteppedAppearanceValues(null, EventArgs.Empty); _horizontalOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Position", "HorizontalOffset", 0f, new ConfigDescription("Move the Better indicator left/right from screen center. Negative = left, positive = right. Snaps to 10 pixel steps.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-300f, 300f), Array.Empty<object>())); _verticalOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Position", "VerticalOffset", -80f, new ConfigDescription("Move the Better indicator up/down from screen center. Negative = up, positive = down. Snaps to 10 pixel steps.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-300f, 300f), Array.Empty<object>())); _horizontalOffset.SettingChanged += SnapPositionValues; _verticalOffset.SettingChanged += SnapPositionValues; SnapPositionValues(null, EventArgs.Empty); _showStateText = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "ShowStateText", true, "Debug comparison mode. Shows state text and keeps Valheim's original stealth indicator visible beside Better Stealth Indicator."); LoadTextures(); CacheTypes(); CachePlayerMethods(); RefreshHudReferences(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Better Stealth Indicator 0.4.8 loaded. Direct vanilla HUD mirror enabled."); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Active art set: " + GetDisplaySetName(_loadedSetKey))); ((BaseUnityPlugin)this).Logger.LogInfo((object)"State is now read directly from Hud.m_hidden, Hud.m_targeted, and Hud.m_targetedAlert."); } private void SnapSteppedAppearanceValues(object sender, EventArgs e) { if (_snappingConfig) { return; } _snappingConfig = true; try { if (_brightness != null) { _brightness.Value = SnapQuarter(_brightness.Value, 0.5f, 2f); } if (_scale != null) { _scale.Value = SnapQuarter(_scale.Value, 0.5f, 2f); } } finally { _snappingConfig = false; } } private float SnapQuarter(float value, float min, float max) { value = Mathf.Clamp(value, min, max); return Mathf.Round(value * 4f) / 4f; } private void SnapPositionValues(object sender, EventArgs e) { if (_snappingConfig) { return; } _snappingConfig = true; try { if (_horizontalOffset != null) { _horizontalOffset.Value = SnapTen(_horizontalOffset.Value, -300f, 300f); } if (_verticalOffset != null) { _verticalOffset.Value = SnapTen(_verticalOffset.Value, -300f, 300f); } } finally { _snappingConfig = false; } } private float SnapTen(float value, float min, float max) { value = Mathf.Clamp(value, min, max); return Mathf.Round(value / 10f) * 10f; } private string GetConfiguredSetKey() { if (_useOdinsEyeSet == null || !_useOdinsEyeSet.Value) { return "the_beast"; } return "odins_eye"; } private string GetDisplaySetName(string key) { if (!(key == "odins_eye")) { return "The Beast"; } return "Odins Eye"; } private void EnsureTexturesMatchConfig() { if (!string.Equals(GetConfiguredSetKey(), _loadedSetKey, StringComparison.Ordinal)) { LoadTextures(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Indicator set changed to: " + GetDisplaySetName(_loadedSetKey))); } } private void DisposeLoadedTextures() { if ((Object)(object)_undetected != (Object)null) { Object.Destroy((Object)(object)_undetected); } if ((Object)(object)_searching != (Object)null) { Object.Destroy((Object)(object)_searching); } if ((Object)(object)_detected != (Object)null) { Object.Destroy((Object)(object)_detected); } _undetected = null; _searching = null; _detected = null; } private void LoadTextures() { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) DisposeLoadedTextures(); string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? ".", "assets"); string configuredSetKey = GetConfiguredSetKey(); string path2 = Path.Combine(path, configuredSetKey); _undetected = LoadPng(Path.Combine(path2, "undetected.png")) ?? LoadPng(Path.Combine(path, "undetected.png")); _searching = LoadPng(Path.Combine(path2, "searching.png")) ?? LoadPng(Path.Combine(path, "searching.png")); _detected = LoadPng(Path.Combine(path2, "detected.png")) ?? LoadPng(Path.Combine(path, "detected.png")); _loadedSetKey = configuredSetKey; if ((Object)(object)_solid == (Object)null) { _solid = new Texture2D(1, 1, (TextureFormat)4, false); _solid.SetPixel(0, 0, Color.white); _solid.Apply(); } } private Texture2D LoadPng(string path) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown try { if (!File.Exists(path)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Missing icon asset: " + path)); return null; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path), false)) { Object.Destroy((Object)(object)val); return null; } ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; return val; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not load " + path + ": " + ex.Message)); return null; } } private void CacheTypes() { _hudType = FindTypeExactOrName("Hud"); _inventoryGuiType = FindTypeExactOrName("InventoryGui"); _menuType = FindTypeExactOrName("Menu"); _consoleType = FindTypeExactOrName("Console"); _configManagerType = FindTypeExactOrName("ConfigurationManager.ConfigurationManager", "ConfigurationManager"); } private void CachePlayerMethods() { try { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; _getStealthFactor = typeof(Player).GetMethod("GetStealthFactor", bindingAttr, null, Type.EmptyTypes, null); } catch { } } private Type FindTypeExactOrName(params string[] names) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { string[] array = names; foreach (string name in array) { try { Type type = assembly.GetType(name, throwOnError: false); if (type != null) { return type; } } catch { } } try { Type[] types = assembly.GetTypes(); foreach (Type type2 in types) { if (type2 == null) { continue; } array = names; foreach (string b in array) { if (string.Equals(type2.Name, b, StringComparison.Ordinal) || string.Equals(type2.FullName, b, StringComparison.Ordinal)) { return type2; } } } } catch { } } return null; } private void Update() { EnsureTexturesMatchConfig(); Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { ShowOriginalHud(show: true); return; } if (Time.unscaledTime >= _nextHudRefresh || _hudInstance == null || (Object)(object)_stealthBarGo == (Object)null) { _nextHudRefresh = Time.unscaledTime + 0.5f; RefreshHudReferences(); } SampleVanillaHud(localPlayer); } private void LateUpdate() { ShowOriginalHud(!_enabled.Value || _showStateText.Value); } private void RefreshHudReferences() { if (_hudType == null) { return; } try { BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; if (_hudInstance == null) { FieldInfo fieldInfo = _hudType.GetField("instance", bindingFlags) ?? _hudType.GetField("m_instance", bindingFlags); if (fieldInfo != null && fieldInfo.IsStatic) { _hudInstance = fieldInfo.GetValue(null); } if (_hudInstance == null) { PropertyInfo propertyInfo = _hudType.GetProperty("instance", bindingFlags) ?? _hudType.GetProperty("m_instance", bindingFlags); if (propertyInfo != null) { MethodInfo? getMethod = propertyInfo.GetGetMethod(nonPublic: true); if ((object)getMethod != null && getMethod.IsStatic) { _hudInstance = propertyInfo.GetValue(null, null); } } } } if (_hudInstance != null) { _stealthBarGo = ReadHudGameObject("m_stealthBar", bindingFlags); _hiddenGo = ReadHudGameObject("m_hidden", bindingFlags); _targetedGo = ReadHudGameObject("m_targeted", bindingFlags); _targetedAlertGo = ReadHudGameObject("m_targetedAlert", bindingFlags); CaptureRendererAlphas(_stealthBarGo); CaptureRendererAlphas(_hiddenGo); CaptureRendererAlphas(_targetedGo); CaptureRendererAlphas(_targetedAlertGo); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogDebug((object)("HUD reference refresh skipped: " + ex.Message)); } } private GameObject ReadHudGameObject(string fieldName, BindingFlags any) { try { FieldInfo field = _hudType.GetField(fieldName, any); if (field == null) { return null; } object value = field.GetValue(_hudInstance); GameObject val = (GameObject)((value is GameObject) ? value : null); if (val != null) { return val; } Component val2 = (Component)((value is Component) ? value : null); if (val2 != null) { return val2.gameObject; } } catch { } return null; } private void SampleVanillaHud(Player player) { _visibility = GetStealthFactor(player); bool flag = IsActive(_hiddenGo); bool flag2 = IsActive(_targetedGo); bool flag3 = IsActive(_targetedAlertGo); bool flag4 = IsActive(_stealthBarGo); AwarenessState awarenessState = (flag3 ? AwarenessState.Detected : (flag2 ? AwarenessState.Searching : AwarenessState.Undetected)); if (awarenessState == AwarenessState.Detected && _state != AwarenessState.Detected) { _detectedPulseStart = Time.unscaledTime; ((BaseUnityPlugin)this).Logger.LogDebug((object)"Detected pulse triggered."); } _state = awarenessState; _vanillaVisible = flag4 || flag || flag2 || flag3; } private bool IsActive(GameObject go) { if ((Object)(object)go != (Object)null && go.activeSelf) { return go.activeInHierarchy; } return false; } private float GetStealthFactor(Player player) { try { if (_getStealthFactor != null && _getStealthFactor.Invoke(player, null) is float num) { return Mathf.Clamp01(num); } } catch { } return 0f; } private void CaptureRendererAlphas(GameObject root) { if ((Object)(object)root == (Object)null) { return; } try { CanvasRenderer[] componentsInChildren = root.GetComponentsInChildren<CanvasRenderer>(true); foreach (CanvasRenderer val in componentsInChildren) { if ((Object)(object)val != (Object)null && !_rendererAlpha.ContainsKey(val)) { _rendererAlpha[val] = val.GetAlpha(); } } } catch { } } private void ShowOriginalHud(bool show) { CaptureRendererAlphas(_stealthBarGo); CaptureRendererAlphas(_hiddenGo); CaptureRendererAlphas(_targetedGo); CaptureRendererAlphas(_targetedAlertGo); foreach (KeyValuePair<CanvasRenderer, float> item in _rendererAlpha) { try { if ((Object)(object)item.Key != (Object)null) { item.Key.SetAlpha(show ? item.Value : 0f); } } catch { } } } private bool IsConfigurationManagerOpen() { try { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; if (_configManagerType == null || _configManagerType.GetProperty("DisplayingWindow", bindingAttr) == null) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { try { Type type = assembly.GetType("ConfigurationManager.ConfigurationManager", throwOnError: false); if (type != null && type.GetProperty("DisplayingWindow", bindingAttr) != null) { _configManagerType = type; break; } } catch { } } } if (_configManagerInstance == null && _configManagerType != null) { Type[] nestedTypes = _configManagerType.GetNestedTypes(bindingAttr); foreach (Type type2 in nestedTypes) { try { FieldInfo field = type2.GetField("Plugin", bindingAttr); if (field != null && field.IsStatic) { object value = field.GetValue(null); if (value != null) { _configManagerInstance = value; break; } } } catch { } } } if (_configManagerInstance == null) { try { if ((typeof(BaseUnityPlugin).Assembly.GetType("BepInEx.Bootstrap.Chainloader", throwOnError: false)?.GetProperty("PluginInfos", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))?.GetValue(null, null) is IDictionary dictionary) { foreach (DictionaryEntry item in dictionary) { if ((item.Key?.ToString() ?? string.Empty).IndexOf("ConfigurationManager", StringComparison.OrdinalIgnoreCase) < 0) { continue; } object value2 = item.Value; object obj3 = (value2?.GetType().GetProperty("Instance", bindingAttr))?.GetValue(value2, null); if (obj3 == null) { continue; } Type type3 = obj3.GetType(); if (type3.GetProperty("DisplayingWindow", bindingAttr) != null) { _configManagerType = type3; _configManagerInstance = obj3; break; } FieldInfo[] fields = type3.GetFields(bindingAttr); foreach (FieldInfo fieldInfo in fields) { object obj4 = null; try { obj4 = fieldInfo.GetValue(obj3); } catch { } if (obj4 != null) { Type type4 = obj4.GetType(); if (type4.GetProperty("DisplayingWindow", bindingAttr) != null) { _configManagerType = type4; _configManagerInstance = obj4; break; } } } if (_configManagerInstance != null) { break; } } } } catch { } } if (_configManagerInstance == null || _configManagerType == null) { return false; } PropertyInfo property = _configManagerType.GetProperty("DisplayingWindow", bindingAttr); if (property != null && property.GetValue(_configManagerInstance, null) is bool result) { return result; } FieldInfo field2 = _configManagerType.GetField("_displayingWindow", bindingAttr); if (field2 != null && field2.GetValue(_configManagerInstance) is bool result2) { return result2; } } catch { } return false; } private bool ShouldHideForUi() { if (IsConfigurationManagerOpen()) { return false; } if (!IsUiTypeVisible(_inventoryGuiType) && !IsUiTypeVisible(_menuType)) { return IsUiTypeVisible(_consoleType); } return true; } private bool IsUiTypeVisible(Type type) { if (type == null) { return false; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; try { string[] array = new string[2] { "IsVisible", "IsOpen" }; foreach (string name in array) { MethodInfo method = type.GetMethod(name, bindingAttr, null, Type.EmptyTypes, null); if (method != null && method.IsStatic && method.ReturnType == typeof(bool)) { return (bool)method.Invoke(null, null); } } } catch { } object obj2 = null; try { FieldInfo fieldInfo = type.GetField("instance", bindingAttr) ?? type.GetField("m_instance", bindingAttr); if (fieldInfo != null && fieldInfo.IsStatic) { obj2 = fieldInfo.GetValue(null); } if (obj2 == null) { PropertyInfo propertyInfo = type.GetProperty("instance", bindingAttr) ?? type.GetProperty("m_instance", bindingAttr); if (propertyInfo != null) { MethodInfo? getMethod = propertyInfo.GetGetMethod(nonPublic: true); if ((object)getMethod != null && getMethod.IsStatic) { obj2 = propertyInfo.GetValue(null, null); } } } } catch { } if (obj2 == null) { return false; } try { string[] array = new string[2] { "IsVisible", "IsOpen" }; foreach (string name2 in array) { MethodInfo method2 = type.GetMethod(name2, bindingAttr, null, Type.EmptyTypes, null); if (method2 != null && !method2.IsStatic && method2.ReturnType == typeof(bool)) { return (bool)method2.Invoke(obj2, null); } } } catch { } try { Behaviour val = (Behaviour)((obj2 is Behaviour) ? obj2 : null); return (Object)(object)val != (Object)null && val.isActiveAndEnabled && ((Component)val).gameObject.activeInHierarchy; } catch { return false; } } private void OnGUI() { //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Expected O, but got Unknown //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) if (!_enabled.Value) { return; } bool flag = IsConfigurationManagerOpen(); if ((!_vanillaVisible && !flag) || (!flag && ShouldHideForUi())) { return; } float num = Mathf.Clamp(_scale.Value, 0.5f, 2f); if (_state == AwarenessState.Detected) { float num2 = Time.unscaledTime - _detectedPulseStart; if (num2 >= 0f && num2 <= 4f) { float num3 = num2 % 0.8f / 0.8f; float num4 = 0.5f - 0.5f * Mathf.Cos(num3 * MathF.PI * 2f); num *= Mathf.Lerp(1f, 1.45f, num4); } } float num5 = 100f * num; float num6 = 50f * num; float num7 = (float)Screen.width * 0.5f + Mathf.Clamp(_horizontalOffset.Value, -300f, 300f); float num8 = (float)Screen.height * 0.5f + Mathf.Clamp(_verticalOffset.Value, -300f, 300f); Texture2D val = _undetected; float num9 = 0f; if (_state == AwarenessState.Searching) { val = _searching; num9 = Mathf.Sin(Time.unscaledTime * 1.25f * MathF.PI * 2f) * 7f; } else if (_state == AwarenessState.Detected) { val = _detected; } float num10 = num7 - num5 * 0.5f + num9; float num11 = num8 - num6 * 0.5f; float num12 = Mathf.Clamp(_brightness.Value, 0.5f, 2f); Color color = GUI.color; GUI.color = new Color(num12, num12, num12, Mathf.Clamp01(num12)); if ((Object)(object)val != (Object)null) { GUI.DrawTexture(new Rect(num10, num11, num5, num6), (Texture)(object)val, (ScaleMode)2, true); } GUI.color = color; DrawVisibilityBar(num7 - num5 * 0.5f, num11 + num6 + 5f, num5, _visibility, num12); if (_showStateText.Value) { GUIStyle val2 = new GUIStyle(GUI.skin.label); val2.alignment = (TextAnchor)1; val2.fontSize = 11; val2.normal.textColor = new Color(1f, 1f, 1f, 0.82f); GUI.Label(new Rect(num7 - 120f, num11 + num6 + 13f, 240f, 30f), _state.ToString().ToUpperInvariant() + $" V:{_visibility:0.00} SET:{GetDisplaySetName(_loadedSetKey).ToUpperInvariant()}", val2); } } private void DrawVisibilityBar(float x, float y, float width, float factor, float intensity) { //IL_000f: 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_0042: 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_00a4: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_solid == (Object)null)) { Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, Mathf.Clamp01(0.45f * intensity)); GUI.DrawTexture(new Rect(x, y, width, 5f), (Texture)(object)_solid); GUI.color = new Color(1f, 0.78f, 0.24f, Mathf.Clamp01(0.75f * intensity)); GUI.DrawTexture(new Rect(x + 1f, y + 1f, Mathf.Max(0f, (width - 2f) * Mathf.Clamp01(factor)), 3f), (Texture)(object)_solid); GUI.color = color; } } private void OnDestroy() { ShowOriginalHud(show: true); DisposeLoadedTextures(); if ((Object)(object)_solid != (Object)null) { Object.Destroy((Object)(object)_solid); } } } }