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 HardheimCompass v0.8.5
plugins/HardheimCompass.dll
Decompiled 2 weeks agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Extensions; using Jotunn.Managers; using Jotunn.Utils; 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: AssemblyTitle("HardheimCompass")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("HardheimCompass")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("b1dca667-fc9a-4af8-ba43-a7ebe1a9593c")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace HardheimCompass; [BepInPlugin("h4nz0.hardheimcompass", "Hardheim Compass", "0.8.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] [SynchronizationMode(/*Could not decode attribute arguments.*/)] public class HardheimCompass : BaseUnityPlugin { private const string ModGuid = "h4nz0.hardheimcompass"; private const string ModName = "Hardheim Compass"; private const string ModVersion = "0.8.5"; private ConfigEntry<bool> _enabled; private ConfigEntry<bool> _showWind; private ConfigEntry<bool> _hideWhenNoPlayer; private ConfigEntry<float> _size; private ConfigEntry<float> _posX; private ConfigEntry<float> _posY; private ConfigEntry<float> _opacity; private ConfigEntry<bool> _verbose; private ConfigEntry<bool> _showNearbyPins; private ConfigEntry<float> _nearbyPinRange; private ConfigEntry<int> _maxNearbyPins; private ConfigEntry<bool> _showNearbyPinNames; private ConfigEntry<string> _importantPinNameKeywords; private ConfigEntry<bool> _avoidMinimap; private ConfigEntry<float> _minimapPadding; private Canvas _canvas; private CanvasScaler _canvasScaler; private RectTransform _root; private RectTransform _ring; private RectTransform _windIcon; private RectTransform _windDirArrow; private Image _windIconImage; private Image _windDirArrowImage; private RectTransform _centerArrow; private Image _centerArrowImage; private RectTransform _sunIcon; private RectTransform _moonIcon; private Image _sunIconImage; private Image _moonIconImage; private float _lastBuiltSize = -1f; private float _lastBuiltOpacity = -1f; private Sprite _ringSprite; private Sprite _arrowSprite; private Sprite _windSprite; private Sprite _sunSprite; private Sprite _moonSprite; private Sprite _itemIconSprite; private void Awake() { _enabled = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "Általános", "Engedélyezve", true, "Hardheim Compass be/ki kapcsolása.\nEnable or disable the Hardheim Compass.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); _showWind = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "Általános", "Szél megjelenítése", true, "Mutassa a szél irányát az iránytűn.\nShow wind direction on the compass.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); _hideWhenNoPlayer = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "Általános", "Elrejtés játékos nélkül", true, "Elrejti az iránytűt, ha nincs aktív játékos.\nHide the compass when there is no active player.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); _size = ConfigFileExtensions.BindConfig<float>(((BaseUnityPlugin)this).Config, "UI", "Méret", 150f, "Az iránytű mérete pixelben.\nCompass size in pixels.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); _posX = ConfigFileExtensions.BindConfig<float>(((BaseUnityPlugin)this).Config, "UI", "Pozíció X", -60f, "Pozíció a jobb felső saroktól balra. Negatív érték = balra.\nPosition from the top right corner. Negative value = left.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); _posY = ConfigFileExtensions.BindConfig<float>(((BaseUnityPlugin)this).Config, "UI", "Pozíció Y", -60f, "Pozíció a jobb felső saroktól lefelé. Negatív érték = lefelé.\nPosition from the top right corner. Negative value = down.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); _opacity = ConfigFileExtensions.BindConfig<float>(((BaseUnityPlugin)this).Config, "UI", "Átlátszóság", 0.95f, "Az iránytű átlátszósága (0-1).\nCompass opacity (0-1).", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); _showNearbyPins = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "Közeli jelölések", "Jelölések mutatása", true, "Mutassa a fontos közeli térkép jelöléseket.\nShow important nearby map pins.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); _nearbyPinRange = ConfigFileExtensions.BindConfig<float>(((BaseUnityPlugin)this).Config, "Közeli jelölések", "Hatótáv", 250f, "Milyen távolságból jelenjenek meg a jelölések.\nMaximum distance for nearby pins to appear.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); _maxNearbyPins = ConfigFileExtensions.BindConfig<int>(((BaseUnityPlugin)this).Config, "Közeli jelölések", "Max jelölések", 6, "Maximum hány jelölés látszódjon egyszerre.\nMaximum number of nearby pins shown at once.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); _showNearbyPinNames = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "Közeli jelölések", "Nevek megjelenítése", true, "Mutassa a jelölések nevét az iránytűn.\nShow nearby pin names on the compass.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); _importantPinNameKeywords = ConfigFileExtensions.BindConfig<string>(((BaseUnityPlugin)this).Config, "Közeli jelölések", "Fontos kulcsszavak", "base,bázis,bazis,altar,oltár,oltar,eikthyr,elder,bonemass,moder,yagluth,queen,hildir,trader,kereskedő,kereskedo", "Vesszővel elválasztott kulcsszavak. Ezeket tartalmazó jelölések fontosnak számítanak.\nComma separated keywords. Pins containing these keywords are considered important.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); _verbose = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "Debug", "Részletes log", false, "Részletes debug logok bekapcsolása.\nEnable verbose debug logging.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); _avoidMinimap = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "UI", "Minimap kerülése", true, "Ha a minimap látszik, az iránytű automatikusan a minimap bal oldalára kerül.\nIf the minimap is visible, the compass is moved to the left side of it.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); _minimapPadding = ConfigFileExtensions.BindConfig<float>(((BaseUnityPlugin)this).Config, "UI", "Minimap távolság", 20f, "Távolság az iránytű és a minimap között pixelben.\nDistance between the compass and the minimap in pixels.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Hardheim Compass loaded."); LoadAssets(); PrefabManager.OnVanillaPrefabsAvailable += RegisterCompassItem; } private void Update() { if (!_enabled.Value) { if ((Object)(object)_root != (Object)null) { ((Component)_root).gameObject.SetActive(false); } return; } if ((Object)(object)_canvas == (Object)null) { CreateCompass(); } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { if (_hideWhenNoPlayer.Value && (Object)(object)_root != (Object)null) { ((Component)_root).gameObject.SetActive(false); } return; } if (!PlayerHasCompassItem(localPlayer)) { if ((Object)(object)_root != (Object)null) { ((Component)_root).gameObject.SetActive(false); } return; } if ((Object)(object)_root != (Object)null && !((Component)_root).gameObject.activeSelf) { ((Component)_root).gameObject.SetActive(true); } UpdateLayout(); UpdateCompass(localPlayer); } private void RegisterCompassItem() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable -= RegisterCompassItem; ItemConfig val = new ItemConfig(); val.Name = "Iránytű"; val.Description = "Egy kézzel készített iránytű. Ha fel van szerelve, megjelenik az iránytű."; val.Amount = 1; val.CraftingStation = "piece_workbench"; val.MinStationLevel = 4; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("FineWood", 5, 0, true), new RequirementConfig("Bronze", 2, 0, true), new RequirementConfig("BronzeNails", 1, 0, true), new RequirementConfig("SurtlingCore", 1, 0, true) }; ItemConfig val2 = val; CustomItem val3 = new CustomItem("HH_Compass", "Wishbone", val2); ApplyAssetBundleCompassModel(val3); if ((Object)(object)_itemIconSprite != (Object)null) { val3.ItemDrop.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { _itemIconSprite }; } val3.ItemDrop.m_itemData.m_shared.m_startEffect = null; val3.ItemDrop.m_itemData.m_shared.m_equipStatusEffect = null; val3.ItemDrop.m_itemData.m_shared.m_setStatusEffect = null; val3.ItemDrop.m_itemData.m_shared.m_useDurability = false; ItemManager.Instance.AddItem(val3); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Compass] HH_Compass registered with AssetBundle model."); } private void ApplyAssetBundleCompassModel(CustomItem item) { //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) if (item == null || (Object)(object)item.ItemDrop == (Object)null) { return; } string text = Path.Combine(Paths.ConfigPath, "HardheimCompass/assets/hardheimcompass"); if (!File.Exists(text)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Compass] AssetBundle not found: " + text)); return; } AssetBundle val = AssetBundle.LoadFromFile(text); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Compass] Failed to load AssetBundle: " + text)); return; } GameObject val2 = val.LoadAsset<GameObject>("HH_Compass_Model"); if ((Object)(object)val2 == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[Compass] HH_Compass_Model not found inside AssetBundle."); val.Unload(false); return; } GameObject gameObject = ((Component)item.ItemDrop).gameObject; Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>(true); Renderer[] array = componentsInChildren; foreach (Renderer val3 in array) { if ((Object)(object)val3 != (Object)null) { val3.enabled = false; } } GameObject val4 = Object.Instantiate<GameObject>(val2); ((Object)val4).name = "HH_Compass_Model"; val4.transform.SetParent(gameObject.transform, false); val4.transform.localPosition = new Vector3(0f, -0.05f, 0f); val4.transform.localRotation = Quaternion.Euler(270f, 0f, 0f); val4.transform.localScale = new Vector3(8f, 8f, 8f); Collider[] componentsInChildren2 = val4.GetComponentsInChildren<Collider>(true); Collider[] array2 = componentsInChildren2; foreach (Collider val5 in array2) { if ((Object)(object)val5 != (Object)null) { Object.DestroyImmediate((Object)(object)val5); } } Renderer[] componentsInChildren3 = val4.GetComponentsInChildren<Renderer>(true); Renderer[] array3 = componentsInChildren3; foreach (Renderer val6 in array3) { Material[] materials = val6.materials; foreach (Material val7 in materials) { if (!((Object)(object)val7 == (Object)null)) { if (val7.HasProperty("_Color")) { Color color = val7.color; color *= 2.2f; val7.color = color; } if (val7.HasProperty("_EmissionColor")) { val7.EnableKeyword("_EMISSION"); val7.SetColor("_EmissionColor", val7.color * 0.4f); } } } } Light[] componentsInChildren4 = gameObject.GetComponentsInChildren<Light>(true); Light[] array4 = componentsInChildren4; foreach (Light val8 in array4) { val8.color = new Color(1f, 0.78f, 0.15f); val8.intensity *= 1.2f; } ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Compass] AssetBundle 3D model applied to HH_Compass."); } private bool PlayerHasCompassItem(Player player) { if ((Object)(object)player == (Object)null || ((Humanoid)player).GetInventory() == null) { return false; } foreach (ItemData allItem in ((Humanoid)player).GetInventory().GetAllItems()) { if (allItem != null && allItem.m_equipped) { if ((Object)(object)allItem.m_dropPrefab != (Object)null && ((Object)allItem.m_dropPrefab).name == "HH_Compass") { return true; } if (allItem.m_shared != null && allItem.m_shared.m_name == "Iránytű" && allItem.m_equipped) { return true; } } } return false; } private void LoadAssets() { string path = Path.Combine(Paths.ConfigPath, "HardheimCompass/assets"); _ringSprite = LoadSprite(Path.Combine(path, "compass_ring.png")); _arrowSprite = LoadSprite(Path.Combine(path, "compass_arrow.png")); _windSprite = LoadSprite(Path.Combine(path, "compass_wind.png")); _sunSprite = LoadSprite(Path.Combine(path, "compass_sun.png")); _moonSprite = LoadSprite(Path.Combine(path, "compass_moon.png")); _itemIconSprite = LoadSprite(Path.Combine(path, "compass_icon.png")); if (_verbose.Value) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Compass] Assets loaded."); } } private Sprite LoadSprite(string path) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) if (!File.Exists(path)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Compass] Missing: " + path)); return null; } byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); Type type = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule"); if (type == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"[Compass] UnityEngine.ImageConversionModule not found at runtime."); return null; } MethodInfo method = type.GetMethod("LoadImage", new Type[2] { typeof(Texture2D), typeof(byte[]) }); if (method == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"[Compass] ImageConversion.LoadImage(Texture2D, byte[]) not found."); return null; } if (!(bool)method.Invoke(null, new object[2] { val, array })) { ((BaseUnityPlugin)this).Logger.LogError((object)("[Compass] Failed to load image: " + path)); return null; } ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); } private Sprite CreateCircleSprite(int size) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false); Color val2 = default(Color); ((Color)(ref val2))..ctor(0f, 0f, 0f, 0f); Color white = Color.white; float num = (float)(size - 1) * 0.5f; float num2 = (float)size * 0.5f; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num3 = (float)j - num; float num4 = (float)i - num; float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4); val.SetPixel(j, i, (num5 <= num2) ? white : val2); } } val.Apply(); ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f), 100f); } private void CreateCompass() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0174: 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_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: 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_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Expected O, but got Unknown //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Expected O, but got Unknown //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("HardheimCompass_Canvas"); Object.DontDestroyOnLoad((Object)(object)val); _canvas = val.AddComponent<Canvas>(); _canvas.renderMode = (RenderMode)0; _canvas.sortingOrder = 500; _canvasScaler = val.AddComponent<CanvasScaler>(); _canvasScaler.uiScaleMode = (ScaleMode)0; _canvasScaler.scaleFactor = GetHudScaleFactor(); _canvasScaler.referencePixelsPerUnit = 100f; val.AddComponent<GraphicRaycaster>(); GameObject val2 = new GameObject("HardheimCompass_Root"); val2.transform.SetParent(val.transform, false); _root = val2.AddComponent<RectTransform>(); _root.anchorMin = new Vector2(1f, 1f); _root.anchorMax = new Vector2(1f, 1f); _root.pivot = new Vector2(1f, 1f); GameObject val3 = new GameObject("HardheimCompass_Ring"); Image val4 = val3.AddComponent<Image>(); if ((Object)(object)_ringSprite != (Object)null) { val4.sprite = _ringSprite; ((Graphic)val4).color = new Color(1f, 1f, 1f, _opacity.Value); val4.preserveAspect = true; } else { ((Graphic)val4).color = new Color(0f, 0f, 0f, 0.3f); } val3.transform.SetParent(val2.transform, false); _ring = val3.GetComponent<RectTransform>(); _ring.anchorMin = new Vector2(0.5f, 0.5f); _ring.anchorMax = new Vector2(0.5f, 0.5f); _ring.pivot = new Vector2(0.5f, 0.5f); CreateDayNightIcons(val2.transform); CreatePlayerArrow(val2.transform); GameObject val5 = new GameObject("HardheimCompass_WindIcon"); val5.transform.SetParent(val2.transform, false); _windIconImage = val5.AddComponent<Image>(); _windIconImage.sprite = _windSprite; ((Graphic)_windIconImage).color = new Color(1f, 1f, 1f, _opacity.Value); _windIconImage.preserveAspect = true; ((Graphic)_windIconImage).raycastTarget = false; _windIcon = val5.GetComponent<RectTransform>(); _windIcon.anchorMin = new Vector2(0.5f, 0.5f); _windIcon.anchorMax = new Vector2(0.5f, 0.5f); _windIcon.pivot = new Vector2(0.5f, 0.5f); GameObject val6 = new GameObject("HardheimCompass_WindDirectionArrow"); val6.transform.SetParent(val2.transform, false); _windDirArrowImage = val6.AddComponent<Image>(); _windDirArrowImage.sprite = _arrowSprite; ((Graphic)_windDirArrowImage).color = new Color(1f, 0.95f, 0.78f, _opacity.Value); _windDirArrowImage.preserveAspect = true; ((Graphic)_windDirArrowImage).raycastTarget = false; _windDirArrow = val6.GetComponent<RectTransform>(); _windDirArrow.anchorMin = new Vector2(0.5f, 0.5f); _windDirArrow.anchorMax = new Vector2(0.5f, 0.5f); _windDirArrow.pivot = new Vector2(0.5f, 0.5f); UpdateLayout(); } private void UpdateLayout() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_root == (Object)null) { return; } if ((Object)(object)_canvasScaler != (Object)null) { _canvasScaler.scaleFactor = GetHudScaleFactor(); } float num = Mathf.Max(80f, _size.Value); _root.sizeDelta = new Vector2(num, num); Vector2 anchoredPosition = default(Vector2); ((Vector2)(ref anchoredPosition))..ctor(_posX.Value, _posY.Value); if (_avoidMinimap.Value && IsSmallMinimapVisible(out var width)) { anchoredPosition.x -= width + _minimapPadding.Value; } _root.anchoredPosition = anchoredPosition; if ((Object)(object)_ring != (Object)null) { _ring.sizeDelta = new Vector2(num, num); } if (Mathf.Abs(_lastBuiltSize - num) > 0.01f || Mathf.Abs(_lastBuiltOpacity - _opacity.Value) > 0.01f || ((Object)(object)_ring != (Object)null && ((Transform)_ring).childCount == 0)) { _lastBuiltSize = num; _lastBuiltOpacity = _opacity.Value; } Graphic[] componentsInChildren = ((Component)_root).GetComponentsInChildren<Graphic>(true); Graphic[] array = componentsInChildren; foreach (Graphic val in array) { Color color = val.color; color.a = Mathf.Clamp01(_opacity.Value); val.color = color; } if ((Object)(object)_windIcon != (Object)null) { _windIcon.anchoredPosition = new Vector2((0f - num) * 0.3f, (0f - num) * 0.55f); _windIcon.sizeDelta = new Vector2(num * 0.42f, num * 0.42f); } if ((Object)(object)_windDirArrow != (Object)null) { _windDirArrow.anchoredPosition = new Vector2(num * 0.18f, (0f - num) * 0.55f); _windDirArrow.sizeDelta = new Vector2(num * 0.18f, num * 0.18f); } if ((Object)(object)_centerArrow != (Object)null) { _centerArrow.anchoredPosition = Vector2.zero; _centerArrow.sizeDelta = new Vector2(num * 0.18f, num * 0.3f); ((Transform)_centerArrow).SetAsLastSibling(); if ((Object)(object)_centerArrowImage != (Object)null) { ((Graphic)_centerArrowImage).color = new Color(1f, 0.95f, 0.78f, 1f); } } if ((Object)(object)_sunIcon != (Object)null) { _sunIcon.sizeDelta = new Vector2(num * 0.12f, num * 0.12f); } if ((Object)(object)_moonIcon != (Object)null) { _moonIcon.sizeDelta = new Vector2(num * 0.12f, num * 0.12f); } } private float GetHudScaleFactor() { try { if ((Object)(object)Hud.instance != (Object)null) { CanvasScaler componentInParent = ((Component)Hud.instance).GetComponentInParent<CanvasScaler>(); if ((Object)(object)componentInParent != (Object)null && componentInParent.scaleFactor > 0.01f) { return componentInParent.scaleFactor; } } CanvasScaler[] array = Resources.FindObjectsOfTypeAll<CanvasScaler>(); CanvasScaler[] array2 = array; foreach (CanvasScaler val in array2) { if (!((Object)(object)val == (Object)null)) { string text = ((Object)((Component)val).gameObject).name.ToLowerInvariant(); if ((text.Contains("hud") || text.Contains("gui")) && val.scaleFactor > 0.01f) { return val.scaleFactor; } } } } catch { } return 1f; } private bool IsSmallMinimapVisible(out float width) { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) width = 256f; if ((Object)(object)Minimap.instance == (Object)null) { return false; } try { FieldInfo field = typeof(Minimap).GetField("m_smallRoot", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { return false; } object value = field.GetValue(Minimap.instance); GameObject val = null; GameObject val2 = (GameObject)((value is GameObject) ? value : null); if (val2 != null) { val = val2; } else { Component val3 = (Component)((value is Component) ? value : null); if (val3 != null) { val = val3.gameObject; } } if ((Object)(object)val == (Object)null || !val.activeInHierarchy) { return false; } RectTransform component = val.GetComponent<RectTransform>(); if ((Object)(object)component != (Object)null) { Rect rect = component.rect; if (((Rect)(ref rect)).width > 1f) { rect = component.rect; width = ((Rect)(ref rect)).width; } } return true; } catch { return false; } } private void UpdateCompass(Player player) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0088: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) Vector3 forward = ((Component)player).transform.forward; if ((Object)(object)Camera.main != (Object)null) { forward = ((Component)Camera.main).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.001f) { forward = ((Component)player).transform.forward; } } float num = Mathf.Atan2(forward.x, forward.z) * 57.29578f; if ((Object)(object)_ring != (Object)null) { ((Transform)_ring).localEulerAngles = Vector3.zero; } if ((Object)(object)_centerArrow != (Object)null) { ((Transform)_centerArrow).localEulerAngles = new Vector3(0f, 0f, 0f - num); if ((Object)(object)_centerArrowImage != (Object)null) { ((Graphic)_centerArrowImage).color = new Color(1f, 0.95f, 0.78f, 1f); } } UpdateWind(num); UpdateDayNightIcons(); } private void UpdateWind(float playerYaw) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) bool value = _showWind.Value; if ((Object)(object)_windIcon != (Object)null) { ((Component)_windIcon).gameObject.SetActive(value); } if ((Object)(object)_windDirArrow != (Object)null) { ((Component)_windDirArrow).gameObject.SetActive(value); } if (value && !((Object)(object)_windDirArrow == (Object)null) && !((Object)(object)EnvMan.instance == (Object)null)) { Vector3 windDir = EnvMan.instance.GetWindDir(); if (!(((Vector3)(ref windDir)).sqrMagnitude < 0.001f)) { float num = Mathf.Atan2(windDir.x, windDir.z) * 57.29578f; num += 180f; float num2 = num - playerYaw; ((Transform)_windDirArrow).localEulerAngles = new Vector3(0f, 0f, 0f - num2); } } } private void UpdateDayNightIcons() { //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) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)EnvMan.instance == (Object)null || (Object)(object)_sunIcon == (Object)null || (Object)(object)_moonIcon == (Object)null || (Object)(object)EnvMan.instance.m_dirLight == (Object)null) { return; } float num = Mathf.Max(80f, _size.Value); float radius = num * 0.22f; float dayFraction = EnvMan.instance.GetDayFraction(); bool flag = dayFraction > 0.22f && dayFraction < 0.78f; Vector3 val = -((Component)EnvMan.instance.m_dirLight).transform.forward; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude < 0.001f)) { float num2 = Mathf.Atan2(val.x, val.z) * 57.29578f; _sunIcon.anchoredPosition = AngleToCompassPosition(90f - num2, radius); _moonIcon.anchoredPosition = AngleToCompassPosition(90f - num2 + 180f, radius); if (flag) { _sunIcon.anchoredPosition = AngleToCompassPosition(90f - num2, radius); ((Component)_sunIcon).gameObject.SetActive(true); ((Component)_moonIcon).gameObject.SetActive(false); } else { _moonIcon.anchoredPosition = AngleToCompassPosition(90f - num2 + 180f, radius); ((Component)_sunIcon).gameObject.SetActive(false); ((Component)_moonIcon).gameObject.SetActive(true); } } } private Transform GetEnvManTransform(string fieldName) { try { FieldInfo field = typeof(EnvMan).GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null || (Object)(object)EnvMan.instance == (Object)null) { return null; } object value = field.GetValue(EnvMan.instance); Transform val = (Transform)((value is Transform) ? value : null); if (val != null) { return val; } GameObject val2 = (GameObject)((value is GameObject) ? value : null); if (val2 != null) { return val2.transform; } Component val3 = (Component)((value is Component) ? value : null); if (val3 != null) { return val3.transform; } } catch { } return null; } private Vector2 AngleToCompassPosition(float angleDeg, float radius) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) float num = angleDeg * ((float)Math.PI / 180f); return new Vector2(Mathf.Cos(num) * radius, Mathf.Sin(num) * radius); } private void CreateDayNightIcons(Transform parent) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: 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_01d8: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("HardheimCompass_SunIcon"); val.transform.SetParent(parent, false); _sunIconImage = val.AddComponent<Image>(); _sunIconImage.sprite = (((Object)(object)_sunSprite != (Object)null) ? _sunSprite : CreateCircleSprite(64)); ((Graphic)_sunIconImage).color = new Color(1f, 0.78f, 0.18f, _opacity.Value); _sunIconImage.preserveAspect = true; ((Graphic)_sunIconImage).raycastTarget = false; _sunIcon = val.GetComponent<RectTransform>(); _sunIcon.anchorMin = new Vector2(0.5f, 0.5f); _sunIcon.anchorMax = new Vector2(0.5f, 0.5f); _sunIcon.pivot = new Vector2(0.5f, 0.5f); GameObject val2 = new GameObject("HardheimCompass_MoonIcon"); val2.transform.SetParent(parent, false); _moonIconImage = val2.AddComponent<Image>(); _moonIconImage.sprite = (((Object)(object)_moonSprite != (Object)null) ? _moonSprite : CreateCircleSprite(64)); ((Graphic)_moonIconImage).color = new Color(0.65f, 0.8f, 1f, _opacity.Value); _moonIconImage.preserveAspect = true; ((Graphic)_moonIconImage).raycastTarget = false; _moonIcon = val2.GetComponent<RectTransform>(); _moonIcon.anchorMin = new Vector2(0.5f, 0.5f); _moonIcon.anchorMax = new Vector2(0.5f, 0.5f); _moonIcon.pivot = new Vector2(0.5f, 0.5f); } private void CreatePlayerArrow(Transform parent) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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) GameObject val = new GameObject("HardheimCompass_PlayerArrow"); val.transform.SetParent(parent, false); _centerArrowImage = val.AddComponent<Image>(); _centerArrowImage.sprite = (((Object)(object)_arrowSprite != (Object)null) ? _arrowSprite : CreateTriangleSprite(64, 64)); _centerArrowImage.preserveAspect = true; ((Graphic)_centerArrowImage).color = new Color(1f, 0.95f, 0.78f, 1f); ((Graphic)_centerArrowImage).raycastTarget = false; _centerArrow = val.GetComponent<RectTransform>(); _centerArrow.anchorMin = new Vector2(0.5f, 0.5f); _centerArrow.anchorMax = new Vector2(0.5f, 0.5f); _centerArrow.pivot = new Vector2(0.5f, 0.5f); _centerArrow.anchoredPosition = Vector2.zero; _centerArrow.sizeDelta = new Vector2(42f, 70f); ((Transform)_centerArrow).SetAsLastSibling(); } private Sprite CreateTriangleSprite(int width, int height) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height, (TextureFormat)4, false); ((Texture)val).filterMode = (FilterMode)1; Color val2 = default(Color); ((Color)(ref val2))..ctor(0f, 0f, 0f, 0f); Color white = Color.white; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { val.SetPixel(j, i, val2); } } Vector2 a = default(Vector2); ((Vector2)(ref a))..ctor((float)width * 0.5f, (float)height * 0.9f); Vector2 b = default(Vector2); ((Vector2)(ref b))..ctor((float)width * 0.25f, (float)height * 0.15f); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor((float)width * 0.5f, (float)height * 0.32f); Vector2 c = default(Vector2); ((Vector2)(ref c))..ctor((float)width * 0.75f, (float)height * 0.15f); FillTriangle(val, a, b, val3, white); FillTriangle(val, a, val3, c, white); val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f); } private void FillTriangle(Texture2D tex, Vector2 a, Vector2 b, Vector2 c, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0063: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Clamp(Mathf.FloorToInt(Mathf.Min(a.x, Mathf.Min(b.x, c.x))), 0, ((Texture)tex).width - 1); int num2 = Mathf.Clamp(Mathf.CeilToInt(Mathf.Max(a.x, Mathf.Max(b.x, c.x))), 0, ((Texture)tex).width - 1); int num3 = Mathf.Clamp(Mathf.FloorToInt(Mathf.Min(a.y, Mathf.Min(b.y, c.y))), 0, ((Texture)tex).height - 1); int num4 = Mathf.Clamp(Mathf.CeilToInt(Mathf.Max(a.y, Mathf.Max(b.y, c.y))), 0, ((Texture)tex).height - 1); Vector2 p = default(Vector2); for (int i = num3; i <= num4; i++) { for (int j = num; j <= num2; j++) { ((Vector2)(ref p))..ctor((float)j, (float)i); if (PointInTriangle(p, a, b, c)) { tex.SetPixel(j, i, color); } } } } private bool PointInTriangle(Vector2 p, Vector2 a, Vector2 b, Vector2 c) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_001a: Unknown result type (might be due to invalid IL or missing references) float num = Sign(p, a, b); float num2 = Sign(p, b, c); float num3 = Sign(p, c, a); bool flag = num < 0f || num2 < 0f || num3 < 0f; bool flag2 = num > 0f || num2 > 0f || num3 > 0f; return !(flag && flag2); } private float Sign(Vector2 p1, Vector2 p2, Vector2 p3) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_002f: Unknown result type (might be due to invalid IL or missing references) return (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y); } private Color GetPinColor(PinData pin) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) string text = ((object)(PinType)(ref pin.m_type)).ToString().ToLowerInvariant(); string text2 = (string.IsNullOrEmpty(pin.m_name) ? "" : pin.m_name.ToLowerInvariant()); if (text.Contains("boss") || text2.Contains("altar") || text2.Contains("oltár") || text2.Contains("oltar")) { return new Color(1f, 0.35f, 0.25f, Mathf.Clamp01(_opacity.Value)); } if (text.Contains("bed") || text2.Contains("base") || text2.Contains("bázis") || text2.Contains("bazis")) { return new Color(0.45f, 0.85f, 1f, Mathf.Clamp01(_opacity.Value)); } return new Color(1f, 0.86f, 0.35f, Mathf.Clamp01(_opacity.Value)); } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= RegisterCompassItem; if ((Object)(object)_canvas != (Object)null) { Object.Destroy((Object)(object)((Component)_canvas).gameObject); } } }