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 ShipPins v1.2.1
ShipPins.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ShipPins")] [assembly: AssemblyDescription("Pins every ship and cart on the map, modded ones included")] [assembly: AssemblyFileVersion("1.2.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.2.1.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 ShipPins { [BepInPlugin("onononoki.ShipPins", "ShipPins", "1.2.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private enum Category { VanillaShip, ModdedShip, VanillaCart, ModdedCart, Siege } private sealed class Kind { internal string Label; internal string FallbackLabel; internal Sprite Icon; internal bool Vanilla; internal Category Category; } private sealed class SameZdo : IEqualityComparer<ZDO> { public bool Equals(ZDO a, ZDO b) { return a == b; } public int GetHashCode(ZDO zdo) { return RuntimeHelpers.GetHashCode(zdo); } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__71_0; internal void <MakeSwitches>b__71_0() { _optionsOpen = !_optionsOpen; SetSwitchesActive(_enabled.Value && _showMapToggles.Value); } } public const string ModGuid = "onononoki.ShipPins"; public const string ModName = "ShipPins"; public const string ModVersion = "1.2.1"; private const string VPlusGuid = "org.bepinex.plugins.valheim_plus"; private const string VPlusPins = "ValheimPlus.GameClasses.displayCartsAndBoatsOnMap"; private const string VPlusConfig = "ValheimPlus.Configurations.Configuration"; internal static ManualLogSource Log; private static ConfigEntry<bool> _enabled; private static ConfigEntry<float> _updateSeconds; private static ConfigEntry<float> _iconSize; private static ConfigEntry<bool> _showMapToggles; private static ConfigEntry<bool> _hideOverlappingLabels; private static ConfigEntry<bool>[] _shows; private static readonly FieldRef<ZDOMan, List<ZDO>[]> ObjectsBySector = AccessTools.FieldRefAccess<ZDOMan, List<ZDO>[]>("m_objectsBySector"); private static readonly Dictionary<string, string> VanillaLabels = new Dictionary<string, string> { { "Cart", "Cart" }, { "Raft", "Raft" }, { "Karve", "Karve" }, { "VikingShip", "Longship" } }; private static readonly HashSet<string> VanillaShipNames = new HashSet<string> { "Raft", "Karve", "VikingShip", "VikingShip_Ashlands" }; private static readonly HashSet<string> SiegeNames = new HashSet<string> { "Catapult", "BatteringRam" }; private static readonly string[] CategoryLabels = new string[5] { "Vanilla ships", "Modded ships", "Vanilla carts", "Modded carts", "Siege carts" }; private static readonly Dictionary<int, Kind> Kinds = new Dictionary<int, Kind>(); private static readonly Dictionary<ZDO, PinData> Pins = new Dictionary<ZDO, PinData>(new SameZdo()); private static readonly Dictionary<ZDO, Kind> Known = new Dictionary<ZDO, Kind>(new SameZdo()); private static readonly List<ZDO> Gone = new List<ZDO>(); private static ZDOMan _knownFor; private static Minimap _map; private static float _timer = float.MaxValue; private static bool _failed; private const int FirstScanPerFrame = 20000; private const int ScanPerFrame = 2000; private const float SearchSeconds = 30f; private static int _scanAt = -1; private static float _searchTimer = float.MaxValue; private static bool _firstPass = true; private static bool _vplus; private static bool _vplusSilenced; private static PropertyInfo _configCurrent; private static PropertyInfo _configMap; private static PropertyInfo _mapEnabled; private static PropertyInfo _mapDisplay; private const float NameGap = 0.1f; private static readonly List<Rect> LabelRects = new List<Rect>(); private static readonly FieldRef<Minimap, Toggle> PublicPosition = AccessTools.FieldRefAccess<Minimap, Toggle>("m_publicPosition"); private static readonly FieldRef<Minimap, GameObject> SharedMapHint = AccessTools.FieldRefAccess<Minimap, GameObject>("m_sharedMapHint"); private static Toggle[] _switches; private static RectTransform[] _switchRows; private static Button _optionsButton; private static RectTransform _optionsPanel; private static TMP_Text _optionsArrow; private static bool _optionsOpen; private const float RowGap = 6f; private void Awake() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Expected O, but got Unknown //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; _enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Pin every ship and cart on the map, modded ones included. With ValheimPlus installed, its own four boat and cart pins are replaced, so each ship has one pin. Off: no pins from this mod (V+ shows its own again)."); _updateSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "UpdateSeconds", 2f, new ConfigDescription("How often the pins move to where the ships and carts are, in seconds (V+ uses 5).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>())); _iconSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "IconSize", 1.5f, new ConfigDescription("Size of the ship and cart pins. 1 is the game's normal pin size, 2 is V+'s.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 2f), Array.Empty<object>())); _showMapToggles = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "ShowMapToggles", true, "Shows ShipPins Options on the large map. Click to expand the category switches. Off: the menu is hidden, and the pins still follow the values below."); _hideOverlappingLabels = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "HideOverlappingLabels", true, "Hide a ship or cart label when it overlaps another ShipPins label. Icons stay visible. Zoom in to separate the labels. Off: show every label."); _shows = new ConfigEntry<bool>[5] { ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "ShowVanillaShips", true, "Pins for the vanilla ships: Raft, Karve, Longship and Drakkar."), ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "ShowModdedShips", true, "Pins for every other ship, modded ones included."), ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "ShowVanillaCarts", true, "Pins for the vanilla Cart."), ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "ShowModdedCarts", true, "Pins for every other cart, wagon and siege machine, modded ones included."), ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "ShowSiegeCarts", true, "Pins for the vanilla Catapult and battering ram.") }; _vplus = Chainloader.PluginInfos.ContainsKey("org.bepinex.plugins.valheim_plus"); Harmony val = new Harmony("onononoki.ShipPins"); val.Patch((MethodBase)AccessTools.Method(typeof(Minimap), "UpdateMap", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "UpdatePins", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Minimap), "UpdatePins", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "FitPins", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); try { HarmonyMethod val2 = new HarmonyMethod(typeof(Plugin), "Loaded", (Type[])null); val.Patch((MethodBase)AccessTools.Method(typeof(Ship), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Vagon), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("ships and carts that load are found by the search only (the game's Awake changed?): " + ex.Message)); } if (_vplus) { SilenceVPlus(val); } Localization.OnLanguageChange = (Action)Delegate.Combine(Localization.OnLanguageChange, new Action(RefreshPinLabels)); if (!_vplus) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"ShipPins 1.2.1 loaded, pinning every ship and cart"); } else if (_vplusSilenced) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"ShipPins 1.2.1 loaded, pinning every ship and cart in place of V+'s boat and cart pins"); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"ShipPins 1.2.1 loaded, V+'s boat pin code not found (V+ update?): V+ keeps its four vanilla pins whenever its map setting shows them, ShipPins pins the rest"); } } private void OnDestroy() { Localization.OnLanguageChange = (Action)Delegate.Remove(Localization.OnLanguageChange, new Action(RefreshPinLabels)); } private static void RefreshPinLabels() { if (Object.op_Implicit((Object)(object)_map)) { Clear(_map); } } internal static MethodInfo ResolveVPlus() { Type type = AccessTools.TypeByName("ValheimPlus.Configurations.Configuration"); _configCurrent = ((type == null) ? null : AccessTools.Property(type, "Current")); _configMap = ((_configCurrent == null) ? null : AccessTools.Property(_configCurrent.PropertyType, "Map")); _mapEnabled = ((_configMap == null) ? null : AccessTools.Property(_configMap.PropertyType, "IsEnabled")); _mapDisplay = ((_configMap == null) ? null : AccessTools.Property(_configMap.PropertyType, "displayCartsAndBoats")); Type type2 = AccessTools.TypeByName("ValheimPlus.GameClasses.displayCartsAndBoatsOnMap"); Type type3 = ((type2 == null) ? null : AccessTools.Inner(type2, "Minimap_UpdateMap_Patch")); if (!(type3 == null)) { return AccessTools.Method(type3, "Postfix", (Type[])null, (Type[])null); } return null; } private static void SilenceVPlus(Harmony harmony) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown try { MethodInfo methodInfo = ResolveVPlus(); if (!(methodInfo == null)) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Plugin), "SkipVPlusPins", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _vplusSilenced = true; } } catch (Exception ex) { Log.LogWarning((object)("V+'s boat pin code changed shape: " + ex.Message)); } } private static bool SkipVPlusPins() { if (!_failed) { return !_enabled.Value; } return true; } internal static bool VPlusDrawsPins() { if (!_vplus || _vplusSilenced) { return false; } try { if (_configCurrent == null || _configMap == null || _mapEnabled == null || _mapDisplay == null) { return true; } object value = _configMap.GetValue(_configCurrent.GetValue(null, null), null); return value == null || ((bool)_mapEnabled.GetValue(value, null) && (bool)_mapDisplay.GetValue(value, null)); } catch { return true; } } private static void UpdatePins(Minimap __instance, Player player, float dt) { if (_failed) { return; } try { if ((Object)(object)__instance != (Object)(object)_map) { Pins.Clear(); _map = __instance; _timer = float.MaxValue; _searchTimer = float.MaxValue; _scanAt = -1; _firstPass = true; _switches = null; _switchRows = null; _optionsButton = null; _optionsPanel = null; _optionsArrow = null; _optionsOpen = false; } if (_switches == null) { MakeSwitches(__instance); } SetSwitchesActive(_enabled.Value && _showMapToggles.Value); if (!_enabled.Value) { Clear(__instance); _scanAt = -1; } else if (Object.op_Implicit((Object)(object)player) && ZDOMan.instance != null && Object.op_Implicit((Object)(object)ZNetScene.instance)) { ForgetOtherWorld(); _searchTimer += dt; if (_scanAt < 0 && _searchTimer >= 30f) { _searchTimer = 0f; _scanAt = 0; } if (_scanAt >= 0) { Search(__instance, player); } _timer += dt; if (!(_timer < _updateSeconds.Value)) { _timer = 0f; Move(__instance, player); } } } catch (Exception arg) { _failed = true; Log.LogError((object)$"pin update failed, ShipPins stops (V+ shows its own pins again if installed): {arg}"); try { Clear(__instance); } catch (Exception) { Pins.Clear(); } } } private static void Search(Minimap map, Player player) { List<ZDO>[] array = ObjectsBySector.Invoke(ZDOMan.instance); int num = (_firstPass ? 20000 : 2000); while (_scanAt < array.Length && num > 0) { List<ZDO> list = array[_scanAt++]; num--; if (list == null) { continue; } num -= list.Count; foreach (ZDO item in list) { Kind kind = KindOf(item.GetPrefab()); if (kind != null && !Known.ContainsKey(item)) { Known[item] = kind; if (Shown(kind) && (!kind.Vanilla || !VPlusDrawsPins())) { Pin(map, player.GetControlledShip(), item, kind); } } } } if (_scanAt >= array.Length) { _scanAt = -1; _firstPass = false; } } private static void Move(Minimap map, Player player) { bool flag = VPlusDrawsPins(); Ship controlledShip = player.GetControlledShip(); Gone.Clear(); foreach (KeyValuePair<ZDO, Kind> item in Known) { ZDO key = item.Key; if (!key.IsValid() || KindOf(key.GetPrefab()) != item.Value) { Gone.Add(key); } else if (!Shown(item.Value) || (item.Value.Vanilla && flag)) { Unpin(map, key); } else { Pin(map, controlledShip, key, item.Value); } } foreach (ZDO item2 in Gone) { Known.Remove(item2); Unpin(map, item2); } } private static bool Shown(Kind kind) { return _shows[(int)kind.Category].Value; } private static void Unpin(Minimap map, ZDO zdo) { if (Pins.TryGetValue(zdo, out var value)) { map.RemovePin(value); Pins.Remove(zdo); } } private static void Loaded(Component __instance) { if (_failed) { return; } try { ZNetView component = __instance.GetComponent<ZNetView>(); ZDO val = (Object.op_Implicit((Object)(object)component) ? component.GetZDO() : null); if (val != null && ZDOMan.instance != null) { ForgetOtherWorld(); Kind kind = KindOf(val.GetPrefab()); if (kind != null && !Known.ContainsKey(val)) { Known[val] = kind; _timer = float.MaxValue; } } } catch (Exception ex) { Log.LogWarning((object)("a loaded ship or cart was not added, the search finds it: " + ex.Message)); } } private static void ForgetOtherWorld() { if (ZDOMan.instance != _knownFor) { _knownFor = ZDOMan.instance; Known.Clear(); } } private static void Pin(Minimap map, Ship steered, ZDO zdo, Kind kind) { //IL_0001: 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) //IL_0023: 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_0050: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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) Vector3 position = zdo.GetPosition(); PinData value; bool flag = Pins.TryGetValue(zdo, out value); if (Object.op_Implicit((Object)(object)steered) && Vector3.Distance(((Component)steered).transform.position, position) < 0.01f) { if (flag) { map.RemovePin(value); Pins.Remove(zdo); } return; } if (flag) { value.m_pos = position; return; } string text = (string.IsNullOrEmpty(kind.Label) ? null : Localization.instance.Localize(kind.Label)); if (string.IsNullOrEmpty(text) || (kind.Label[0] == '$' && text == "[" + kind.Label.Substring(1) + "]")) { text = kind.FallbackLabel; } value = map.AddPin(position, (PinType)4, text, false, false, 0L, default(PlatformUserID)); if (Object.op_Implicit((Object)(object)kind.Icon)) { value.m_icon = kind.Icon; } value.m_doubleSize = true; Pins.Add(zdo, value); } private static void FitPins(Minimap __instance) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: 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_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) if (Pins.Count == 0) { return; } float num = (((int)__instance.m_mode == 2) ? __instance.m_pinSizeLarge : __instance.m_pinSizeSmall); float num2 = num * _iconSize.Value; float num3 = (num2 - num) * 0.5f + num * 0.1f; LabelRects.Clear(); foreach (PinData value in Pins.Values) { if (!Object.op_Implicit((Object)(object)value.m_uiElement)) { continue; } value.m_uiElement.sizeDelta = new Vector2(num2, num2); PinNameData namePinData = value.m_NamePinData; RectTransform val = ((namePinData != null) ? namePinData.PinNameRectTransform : null); if (Object.op_Implicit((Object)(object)val)) { val.anchoredPosition = value.m_uiElement.anchoredPosition + new Vector2(0f, 0f - num3); } PinNameData namePinData2 = value.m_NamePinData; TMP_Text val2 = ((namePinData2 != null) ? namePinData2.PinNameText : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2)) { bool flag = true; if (_hideOverlappingLabels.Value && ((Component)val).gameObject.activeInHierarchy) { RectTransform rectTransform = val2.rectTransform; Transform parent = ((Transform)val).parent; Rect rect = rectTransform.rect; Vector3 val3 = parent.InverseTransformPoint(((Transform)rectTransform).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center))); float preferredWidth = val2.preferredWidth; rect = rectTransform.rect; float num4 = Math.Min(preferredWidth, ((Rect)(ref rect)).width); Transform parent2 = ((Transform)val).parent; rect = rectTransform.rect; Vector3 val4 = parent2.InverseTransformVector(((Transform)rectTransform).TransformVector(new Vector3(num4, ((Rect)(ref rect)).height, 0f))) * 0.5f; float num5 = num * 0.1f; flag = KeepLabel(new Rect(val3.x - val4.x - num5, val3.y - val4.y - num5, val4.x * 2f + num5 * 2f, val4.y * 2f + num5 * 2f)); } if (((Behaviour)val2).enabled != flag) { ((Behaviour)val2).enabled = flag; } } } } internal static bool KeepLabel(Rect bounds) { //IL_000f: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) foreach (Rect labelRect in LabelRects) { Rect current = labelRect; if (((Rect)(ref current)).Overlaps(bounds)) { return false; } } LabelRects.Add(bounds); return true; } internal static float RowOffset(int index, int count, float bottom, float top, float height) { return top - bottom + 6f + (float)(count - index - 1) * (height + 6f); } internal static float OptionsHeight(int count, float height) { return (float)count * height + (float)(count + 1) * 6f; } internal static bool MenuVisible(bool on, bool large, bool expanded) { return on && large && expanded; } private static void MakeSwitches(Minimap map) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0154: 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_0164: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: 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) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_0233: 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_0074: 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) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Expected O, but got Unknown //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Expected O, but got Unknown //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Expected O, but got Unknown Toggle val = PublicPosition.Invoke(map); if (!Object.op_Implicit((Object)(object)val)) { return; } Transform parent = ((Component)val).transform.parent; RectTransform val2 = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (!Object.op_Implicit((Object)(object)val2)) { return; } Bounds val3 = RectTransformUtility.CalculateRelativeRectTransformBounds(((Transform)val2).parent, (Transform)(object)val2); float num = ((Bounds)(ref val3)).max.y; GameObject val4 = SharedMapHint.Invoke(map); if (Object.op_Implicit((Object)(object)val4)) { float val5 = num; Bounds val6 = RectTransformUtility.CalculateRelativeRectTransformBounds(((Transform)val2).parent, val4.transform); num = Math.Max(val5, ((Bounds)(ref val6)).max.y); } Rect rect = val2.rect; float height = ((Rect)(ref rect)).height; RectTransform val7 = Object.Instantiate<RectTransform>(val2, ((Transform)val2).parent); ((Object)val7).name = "ShipPins Options"; val7.anchoredPosition = val2.anchoredPosition + new Vector2(0f, RowOffset(0, 1, ((Bounds)(ref val3)).min.y, num, height)); Toggle componentInChildren = ((Component)val7).GetComponentInChildren<Toggle>(true); componentInChildren.onValueChanged = new ToggleEvent(); ((Component)componentInChildren).gameObject.SetActive(false); TMP_Text val8 = Object.Instantiate<TMP_Text>(((Component)val).GetComponentInChildren<TMP_Text>(true), (Transform)(object)val7); val8.text = "ShipPins Options"; RectTransform rectTransform = val8.rectTransform; RectTransform rectTransform2 = val8.rectTransform; Vector2 val9 = default(Vector2); ((Vector2)(ref val9))..ctor(1f, 0.5f); rectTransform2.anchorMax = val9; rectTransform.anchorMin = val9; RectTransform rectTransform3 = val8.rectTransform; rectTransform3.anchoredPosition += ((Component)val).GetComponent<RectTransform>().anchoredPosition; _optionsArrow = Object.Instantiate<TMP_Text>(val8, (Transform)(object)val7); ((Object)_optionsArrow).name = "ShipPins options arrow"; _optionsArrow.rectTransform.pivot = new Vector2(0.5f, 0.5f); _optionsArrow.rectTransform.anchoredPosition = ((Component)val).GetComponent<RectTransform>().anchoredPosition; RectTransform rectTransform4 = _optionsArrow.rectTransform; rect = ((Component)val).GetComponent<RectTransform>().rect; rectTransform4.sizeDelta = ((Rect)(ref rect)).size; _optionsArrow.alignment = (TextAlignmentOptions)514; ((Graphic)_optionsArrow).raycastTarget = false; _optionsButton = ((Component)val7).gameObject.AddComponent<Button>(); ((Selectable)_optionsButton).targetGraphic = (Graphic)(object)((Component)val7).GetComponent<Image>(); ((Selectable)_optionsButton).transition = (Transition)0; ((Selectable)_optionsButton).navigation = ((Selectable)val).navigation; ButtonClickedEvent onClick = _optionsButton.onClick; object obj = <>c.<>9__71_0; if (obj == null) { UnityAction val10 = delegate { _optionsOpen = !_optionsOpen; SetSwitchesActive(_enabled.Value && _showMapToggles.Value); }; <>c.<>9__71_0 = val10; obj = (object)val10; } ((UnityEvent)onClick).AddListener((UnityAction)obj); _optionsPanel = Object.Instantiate<RectTransform>(val2, ((Transform)val2).parent); ((Object)_optionsPanel).name = "ShipPins categories"; _optionsPanel.anchoredPosition = val7.anchoredPosition + new Vector2(0f, height + 6f); _optionsPanel.SetSizeWithCurrentAnchors((Axis)1, OptionsHeight(_shows.Length, height)); Toggle componentInChildren2 = ((Component)_optionsPanel).GetComponentInChildren<Toggle>(true); componentInChildren2.onValueChanged = new ToggleEvent(); ((Component)componentInChildren2).gameObject.SetActive(false); _optionsOpen = false; _switches = (Toggle[])(object)new Toggle[_shows.Length]; _switchRows = (RectTransform[])(object)new RectTransform[_shows.Length]; for (int num2 = 0; num2 < _shows.Length; num2++) { RectTransform val11 = Object.Instantiate<RectTransform>(val2, (Transform)(object)_optionsPanel); ((Object)val11).name = "ShipPins " + CategoryLabels[num2]; val11.anchoredPosition = new Vector2(0f, RowOffset(num2, _shows.Length, 0f, 0f, height)); ((Behaviour)((Component)val11).GetComponent<Image>()).enabled = false; Toggle componentInChildren3 = ((Component)val11).GetComponentInChildren<Toggle>(true); ((Object)componentInChildren3).name = "ShipPins " + CategoryLabels[num2]; componentInChildren3.onValueChanged = new ToggleEvent(); SetLabel(((Component)componentInChildren3).gameObject, CategoryLabels[num2]); componentInChildren3.isOn = _shows[num2].Value; int index = num2; ((UnityEvent<bool>)(object)componentInChildren3.onValueChanged).AddListener((UnityAction<bool>)delegate(bool on) { _shows[index].Value = on; _timer = float.MaxValue; }); _switches[num2] = componentInChildren3; _switchRows[num2] = val11; } Log.LogInfo((object)"ShipPins Options opens the category panel, collapsed whenever the map opens"); } private static void SetLabel(GameObject go, string text) { Component[] componentsInChildren = go.GetComponentsInChildren<Component>(true); foreach (Component val in componentsInChildren) { PropertyInfo property = ((object)val).GetType().GetProperty("text"); if (!(property == null) && !(property.PropertyType != typeof(string)) && property.CanWrite) { property.SetValue(val, text, null); break; } } } private static void SetSwitchesActive(bool on) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 bool flag = Object.op_Implicit((Object)(object)_map) && (int)_map.m_mode == 2; _optionsOpen = MenuVisible(on, flag, _optionsOpen); if (Object.op_Implicit((Object)(object)_optionsButton) && ((Component)_optionsButton).gameObject.activeSelf != (on && flag)) { ((Component)_optionsButton).gameObject.SetActive(on && flag); } if (Object.op_Implicit((Object)(object)_optionsPanel) && ((Component)_optionsPanel).gameObject.activeSelf != _optionsOpen) { ((Component)_optionsPanel).gameObject.SetActive(_optionsOpen); } if (Object.op_Implicit((Object)(object)_optionsArrow)) { _optionsArrow.text = (_optionsOpen ? "v" : ">"); } if (_switchRows == null) { return; } RectTransform[] switchRows = _switchRows; foreach (RectTransform val in switchRows) { if (Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.activeSelf != _optionsOpen) { ((Component)val).gameObject.SetActive(_optionsOpen); } } } private static void Clear(Minimap map) { foreach (PinData value in Pins.Values) { map.RemovePin(value); } Pins.Clear(); _timer = float.MaxValue; } private static Kind KindOf(int hash) { if (Kinds.TryGetValue(hash, out var value)) { return value; } if (!Object.op_Implicit((Object)(object)ZNetScene.instance)) { return null; } GameObject prefab = ZNetScene.instance.GetPrefab(hash); if (Object.op_Implicit((Object)(object)prefab) && (Object.op_Implicit((Object)(object)prefab.GetComponent<Ship>()) || Object.op_Implicit((Object)(object)prefab.GetComponent<Vagon>()))) { Piece component = prefab.GetComponent<Piece>(); string value2; bool flag = VanillaLabels.TryGetValue(((Object)prefab).name, out value2); value = new Kind { Label = (Object.op_Implicit((Object)(object)component) ? component.m_name : null), FallbackLabel = (flag ? value2 : ((Object)prefab).name), Icon = (Object.op_Implicit((Object)(object)component) ? component.m_icon : null), Vanilla = flag, Category = CategoryOf(prefab) }; Log.LogInfo((object)$"{((Object)prefab).name} is pinned as {value.Category}"); } Kinds[hash] = value; return value; } private static Category CategoryOf(GameObject prefab) { if (Object.op_Implicit((Object)(object)prefab.GetComponent<Ship>())) { if (!VanillaShipNames.Contains(((Object)prefab).name)) { return Category.ModdedShip; } return Category.VanillaShip; } if (((Object)prefab).name == "Cart") { return Category.VanillaCart; } if (!SiegeNames.Contains(((Object)prefab).name)) { return Category.ModdedCart; } return Category.Siege; } } }