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 PingHeim v0.6.7
plugins/PingHeim.dll
Decompiled 4 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using Splatform; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PingHeim")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a5dfbf1c238ceebb9fe69ad6eb36a8453912b4ec")] [assembly: AssemblyProduct("PingHeim")] [assembly: AssemblyTitle("PingHeim")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 PingHeim { internal static class AggroPing { public static void Use(Player player) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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) if (!PingItem.TryUse(player, start: true)) { return; } float value = PingHeimPlugin.AggroRadius.Value; int num = 0; foreach (Character allCharacter in Character.GetAllCharacters()) { if ((Object)(object)allCharacter == (Object)null || allCharacter.IsPlayer() || allCharacter.IsDead() || allCharacter.IsTamed() || (allCharacter.IsBoss() && !PingHeimPlugin.AggroBosses.Value)) { continue; } Vector3 val = ((Component)allCharacter).transform.position - ((Component)player).transform.position; if (((Vector3)(ref val)).sqrMagnitude > value * value) { continue; } MonsterAI component = ((Component)allCharacter).GetComponent<MonsterAI>(); if (!((Object)(object)component == (Object)null) && BaseAI.IsEnemy(allCharacter, (Character)(object)player)) { if ((Object)(object)allCharacter.m_nview != (Object)null && allCharacter.m_nview.IsValid() && !allCharacter.m_nview.IsOwner()) { allCharacter.m_nview.ClaimOwnership(); } ((BaseAI)component).SetAlerted(true); component.m_targetCreature = (Character)(object)player; ((BaseAI)component).SetHuntPlayer(true); num++; } } PingSound.Play(); PingNet.ShareAggro(player, num); ((Character)player).Message((MessageType)2, (num == 0) ? "Aggro ping: nothing came" : string.Format("Aggro ping! {0} creature{1} heard you", num, (num == 1) ? "" : "s"), 0, (Sprite)null, false); } } [HarmonyPatch(typeof(Humanoid), "StartAttack")] internal static class StoneAttackPatch { private static bool Prefix(Humanoid __instance, ref bool __result) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !PingItem.IsPingStone(__instance.GetRightItem())) { return true; } __result = false; if (!PingOptions.PopupOpen) { PingOptions.OpenPopup(); } return false; } } internal static class BigObjectReport { private static bool _done; private static float _at; public static void Tick() { if (_done || !PingHeimPlugin.LogBigObjects.Value) { return; } if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || (Object)(object)Player.m_localPlayer == (Object)null) { _at = 0f; return; } if (_at == 0f) { _at = Time.time + 40f; } if (Time.time < _at) { return; } _done = true; try { Scan(); } catch (Exception ex) { PingHeimPlugin.Log.LogWarning((object)("Big-object check failed: " + ex.Message)); } } private static void Scan() { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0204: 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_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) FieldInfo fieldInfo = AccessTools.Field(typeof(ZDOExtraData), "s_byteArrays"); IDictionary dictionary = ((fieldInfo != null) ? (fieldInfo.GetValue(null) as IDictionary) : null); if (dictionary == null) { PingHeimPlugin.Log.LogWarning((object)"Big-object check: couldn't find the world's stored data."); return; } List<(long, ZDOID, int)> list = new List<(long, ZDOID, int)>(); long num = 0L; int num2 = 0; foreach (DictionaryEntry item3 in dictionary) { num2++; if (!(item3.Key is ZDOID item) || !(item3.Value is IEnumerable enumerable)) { continue; } foreach (object item4 in enumerable) { Type type = item4.GetType(); PropertyInfo property = type.GetProperty("Key"); PropertyInfo property2 = type.GetProperty("Value"); if (!(property == null) && !(property2 == null) && property2.GetValue(item4, null) is byte[] array) { num += array.Length; int item2 = ((property.GetValue(item4, null) is int num3) ? num3 : 0); list.Add((array.Length, item, item2)); } } } PingHeimPlugin.Log.LogInfo((object)$"Big-object check: {num2} objects hold stored data, {num / 1024} KB in all."); foreach (var item5 in list.OrderByDescending<(long, ZDOID, int), long>(((long size, ZDOID id, int key) r) => r.size).Take(12)) { ZDO val = ((ZDOMan.instance != null) ? ZDOMan.instance.GetZDO(item5.Item2) : null); string text = "unknown"; string text2 = ""; if (val != null) { GameObject val2 = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(val.GetPrefab()) : null); text = (((Object)(object)val2 != (Object)null) ? ((Object)val2).name : ("prefab " + val.GetPrefab() + " (not loaded)")); Vector3 position = val.GetPosition(); text2 = $" at ({position.x:0}, {position.y:0}, {position.z:0})"; } PingHeimPlugin.Log.LogInfo((object)$"Big object: {text}{text2}, {(double)item5.Item1 / 1024.0:0.0} KB (data key {item5.Item3})."); } } } internal enum PingKind { Monster, Trader, Player, Structure, Portal, Spawner } internal static class Marks { private class Record { public PingKind Kind; public Vector3 Position; public string Label = ""; public float Expires; public bool Pinned; public int Tier; public PinData Pin; } private const string PlacesKey = "PingHeim.Places"; private const string PlacesVersionKey = "PingHeim.PlacesVersion"; private const int MaxPlaces = 1500; private static readonly List<Record> Records = new List<Record>(); private static readonly Dictionary<int, Sprite> Sprites = new Dictionary<int, Sprite>(); private static Minimap _forMap; private static Player _forPlayer; private static bool _placesDirty; private static float _nextSave; private static bool _loggedIcons; private static readonly Color[] TierColors = (Color[])(object)new Color[5] { new Color(1f, 0.86f, 0.3f), new Color(1f, 0.6f, 0.2f), new Color(0.93f, 0.22f, 0.18f), new Color(0.72f, 0.04f, 0.22f), new Color(0.72f, 0.32f, 1f) }; private static readonly float[] TierScale = new float[5] { 0.55f, 0.75f, 1f, 1f, 1f }; public static bool IsShown(PingKind kind) { return kind switch { PingKind.Monster => PingHeimPlugin.ShowMobs.Value, PingKind.Trader => PingHeimPlugin.ShowNpcs.Value, PingKind.Player => PingHeimPlugin.ShowPlayers.Value, PingKind.Structure => PingHeimPlugin.ShowStructures.Value, PingKind.Spawner => PingHeimPlugin.ShowSpawners.Value, _ => PingHeimPlugin.ShowPortals.Value, }; } private static bool IsPlace(PingKind kind) { if (kind != PingKind.Structure && kind != PingKind.Portal) { return kind == PingKind.Spawner; } return true; } private static float NewExpiry() { return Time.time + PingHeimPlugin.DotMinutes.Value * 60f; } public static void ClearTemporary() { for (int num = Records.Count - 1; num >= 0; num--) { if (!IsPlace(Records[num].Kind) && !Records[num].Pinned) { RemovePin(Records[num]); Records.RemoveAt(num); } } } public static bool Add(PingKind kind, Vector3 position, string label, float spacing = 0f, int tier = 0) { //IL_00a1: 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_002a: 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) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (IsPlace(kind)) { foreach (Record record in Records) { if (record.Kind != kind) { continue; } Vector3 val = record.Position - position; val.y = 0f; if (!(((Vector3)(ref val)).magnitude >= spacing)) { if (!record.Pinned) { record.Expires = NewExpiry(); } return false; } } if (Records.Count >= 1500) { return false; } } Records.Add(new Record { Kind = kind, Position = position, Label = (label ?? ""), Tier = tier, Expires = NewExpiry() }); return true; } public static bool ToggleAtClick(Minimap map) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)map == (Object)null || !Minimap.IsOpen()) { return false; } PinData closestPin = map.GetClosestPin(map.ScreenToWorldPoint(ZInput.pointerPosition), map.PinInteractRadius, true); if (closestPin == null) { return false; } Record record = null; foreach (Record record2 in Records) { if (record2.Pin == closestPin) { record = record2; } } if (record == null) { return false; } record.Pinned = !record.Pinned; record.Expires = (record.Pinned ? 0f : NewExpiry()); RemovePin(record); _placesDirty = true; Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, record.Pinned ? "Kept on your map. Click it again to let it fade." : $"It will fade in {PingHeimPlugin.DotMinutes.Value:0.#} minutes.", 0, (Sprite)null, false); } return true; } private static void RemovePin(Record record) { if (record.Pin != null) { if ((Object)(object)Minimap.instance != (Object)null) { Minimap.instance.RemovePin(record.Pin); } record.Pin = null; } } private static PinData CreatePin(Minimap map, Record record) { //IL_0028: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_007e: 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_00a1: 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) string text = (record.Pinned ? " (kept)" : ""); PinData val; switch (record.Kind) { case PingKind.Structure: val = map.AddPin(record.Position, PingHeimPlugin.StructureIcon.Value, text.Trim(), false, false, 0L, default(PlatformUserID)); break; case PingKind.Portal: val = map.AddPin(record.Position, PingHeimPlugin.PortalIcon.Value, record.Label + text, false, false, 0L, default(PlatformUserID)); break; default: val = map.AddPin(record.Position, (PinType)3, record.Label + text, false, false, 0L, default(PlatformUserID)); val.m_icon = SpriteFor(record.Kind, record.Tier); val.m_doubleSize = record.Kind == PingKind.Monster && record.Tier >= 3 && PingHeimPlugin.SizeByStrength.Value; break; } return val; } public static void Tick() { Minimap instance = Minimap.instance; if ((Object)(object)instance != (Object)(object)_forMap) { foreach (Record record2 in Records) { record2.Pin = null; } _forMap = instance; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)(object)_forPlayer) { _forPlayer = localPlayer; foreach (Record record3 in Records) { RemovePin(record3); } Records.Clear(); if ((Object)(object)localPlayer != (Object)null) { LoadPlaces(localPlayer); } } if ((Object)(object)instance == (Object)null) { return; } if (!_loggedIcons) { _loggedIcons = true; LogIcons(instance); } bool flag = false; for (int num = Records.Count - 1; num >= 0; num--) { Record record = Records[num]; if (!record.Pinned && record.Expires > 0f && Time.time >= record.Expires) { RemovePin(record); Records.RemoveAt(num); flag = true; } else { bool flag2 = IsShown(record.Kind); if (flag2 && record.Pin == null) { record.Pin = CreatePin(instance, record); flag = true; } else if (!flag2 && record.Pin != null) { RemovePin(record); flag = true; } } } if (flag) { instance.m_pinUpdateRequired = true; } if (_placesDirty && Time.time >= _nextSave && (Object)(object)localPlayer != (Object)null) { _nextSave = Time.time + 2f; _placesDirty = false; SavePlaces(localPlayer); } } private static char Code(PingKind kind) { return kind switch { PingKind.Portal => 'P', PingKind.Spawner => 'N', PingKind.Monster => 'M', PingKind.Trader => 'T', PingKind.Player => 'L', _ => 'S', }; } private static PingKind KindOf(string code) { return code switch { "P" => PingKind.Portal, "N" => PingKind.Spawner, "M" => PingKind.Monster, "T" => PingKind.Trader, "L" => PingKind.Player, _ => PingKind.Structure, }; } private static void SavePlaces(Player player) { StringBuilder stringBuilder = new StringBuilder(); foreach (Record record in Records) { if (record.Pinned) { if (stringBuilder.Length > 0) { stringBuilder.Append(';'); } stringBuilder.Append(Code(record.Kind)).Append('|').Append(record.Position.x.ToString("0.#", CultureInfo.InvariantCulture)) .Append('|') .Append(record.Position.y.ToString("0.#", CultureInfo.InvariantCulture)) .Append('|') .Append(record.Position.z.ToString("0.#", CultureInfo.InvariantCulture)) .Append('|') .Append(record.Label.Replace(';', ' ').Replace('|', ' ')) .Append('|') .Append(record.Tier); } } player.m_customData["PingHeim.Places"] = stringBuilder.ToString(); player.m_customData["PingHeim.PlacesVersion"] = "2"; } private static void LoadPlaces(Player player) { //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) if (!player.m_customData.TryGetValue("PingHeim.Places", out var value) || string.IsNullOrEmpty(value)) { return; } string value2; bool flag = !player.m_customData.TryGetValue("PingHeim.PlacesVersion", out value2) || value2 != "2"; if (flag) { player.m_customData["PingHeim.PlacesVersion"] = "2"; _placesDirty = true; } string[] array = value.Split(';'); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split('|'); if (array2.Length >= 4 && float.TryParse(array2[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array2[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array2[3], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3)) { int result4; int tier = ((array2.Length > 5 && int.TryParse(array2[5], out result4)) ? result4 : 0); Records.Add(new Record { Kind = KindOf(array2[0]), Position = new Vector3(result, result2, result3), Label = ((array2.Length > 4) ? array2[4] : ""), Tier = tier, Pinned = !flag, Expires = (flag ? NewExpiry() : 0f) }); } } } private static void LogIcons(Minimap map) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) try { List<string> list = new List<string>(); foreach (SpriteData icon in map.m_icons) { list.Add(string.Format("{0}={1}", icon.m_name, ((Object)(object)icon.m_icon != (Object)null) ? ((Object)icon.m_icon).name : "none")); } PingHeimPlugin.Log.LogInfo((object)("Map icons: " + string.Join(", ", list))); } catch (Exception ex) { PingHeimPlugin.Log.LogWarning((object)("Couldn't list the map icons: " + ex.Message)); } } public static Color TierColor(int tier) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) return TierColors[Mathf.Clamp(tier, 0, TierColors.Length - 1)]; } private static Sprite SpriteFor(PingKind kind, int tier) { //IL_004c: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) if (kind == PingKind.Monster && !PingHeimPlugin.SizeByStrength.Value) { tier = 2; } int key = ((kind == PingKind.Monster) ? (100 + Mathf.Clamp(tier, 0, 4)) : ((int)kind)); if (Sprites.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } value = (Sprite)(kind switch { PingKind.Monster => MakeSprite(TierColor(tier), paw: true, TierScale[Mathf.Clamp(tier, 0, 4)]), PingKind.Trader => MakeSprite(new Color(1f, 1f, 1f), paw: false, 1f), PingKind.Spawner => MakeSprite(new Color(0.45f, 0.85f, 0.3f), paw: false, 1f, skull: true), _ => MakeSprite(new Color(0.3f, 0.55f, 1f), paw: false, 1f), }); Sprites[key] = value; return value; } public static Color ColorOf(PingKind kind) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_005f: Unknown result type (might be due to invalid IL or missing references) return (Color)(kind switch { PingKind.Monster => new Color(0.95f, 0.35f, 0.32f), PingKind.Trader => Color.white, PingKind.Player => new Color(0.45f, 0.68f, 1f), PingKind.Spawner => new Color(0.55f, 0.88f, 0.4f), _ => new Color(0.85f, 0.85f, 0.85f), }); } private static float Ellipse(float u, float v, float cx, float cy, float rx, float ry) { float num = (u - cx) / rx; float num2 = (v - cy) / ry; return (Mathf.Sqrt(num * num + num2 * num2) - 1f) * Mathf.Min(rx, ry); } private static float Shape(float u, float v, bool paw, bool skull = false) { if (skull) { float num = Ellipse(u, v, 0.5f, 0.58f, 0.3f, 0.28f); float num2 = Mathf.Max(Mathf.Abs(u - 0.5f) - 0.15f, Mathf.Abs(v - 0.27f) - 0.13f); float num3 = Mathf.Min(num, num2); float num4 = Mathf.Min(Ellipse(u, v, 0.38f, 0.58f, 0.075f, 0.085f), Ellipse(u, v, 0.62f, 0.58f, 0.075f, 0.085f)); return Mathf.Max(num3, 0f - num4); } if (paw) { return Mathf.Min(Mathf.Min(Mathf.Min(Mathf.Min(Ellipse(u, v, 0.5f, 0.34f, 0.26f, 0.2f), Ellipse(u, v, 0.18f, 0.6f, 0.09f, 0.12f)), Ellipse(u, v, 0.38f, 0.76f, 0.09f, 0.125f)), Ellipse(u, v, 0.62f, 0.76f, 0.09f, 0.125f)), Ellipse(u, v, 0.82f, 0.6f, 0.09f, 0.12f)); } float num5 = Ellipse(u, v, 0.5f, 0.68f, 0.19f, 0.19f); float num6 = Mathf.Max(Ellipse(u, v, 0.5f, 0.12f, 0.36f, 0.36f), v - 0.43f); return Mathf.Min(num5, num6); } private static Sprite MakeSprite(Color fill, bool paw, float scale, bool skull = false) { //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00d0: 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) Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float u = 0.5f + (((float)j + 0.5f) / 64f - 0.5f) / scale; float v = 0.5f + (((float)i + 0.5f) / 64f - 0.5f) / scale; float num = Shape(u, v, paw, skull) * scale; float num2 = Mathf.Clamp01(0.5f - num * 64f); float num3 = Mathf.Clamp01(0.5f - (num - 0.045f) * 64f); Color val = Color.Lerp(new Color(0f, 0f, 0f, 0.9f), fill, num2); val.a = Mathf.Max(num2, num3 * 0.9f); array[i * 64 + j] = Color32.op_Implicit(val); } } Texture2D val2 = new Texture2D(64, 64, (TextureFormat)4, false) { name = "PingHeimIcon", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; val2.SetPixelData<Color32>(array, 0, 0); val2.Apply(false, false); ((Object)val2).hideFlags = (HideFlags)(((Object)val2).hideFlags | 0x20); Sprite obj = Sprite.Create(val2, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f); ((Object)obj).hideFlags = (HideFlags)(((Object)obj).hideFlags | 0x20); return obj; } } [BepInPlugin("mbaya.PingHeim", "PingHeim", "0.6.7")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class PingHeimPlugin : BaseUnityPlugin { public const string Guid = "mbaya.PingHeim"; public const string Name = "PingHeim"; internal static ConfigEntry<bool> ShareWithPlayers; internal static ConfigEntry<bool> SizeByStrength; internal static ConfigEntry<bool> ShowSpawners; internal static ConfigEntry<bool> LogBigObjects; internal static ConfigEntry<KeyCode> OpenKey; internal static ConfigEntry<float> AggroRadius; internal static ConfigEntry<bool> AggroBosses; internal static ConfigEntry<bool> ReceiveFromPlayers; internal static ConfigEntry<Vector2> PopupPos; internal static ConfigEntry<Vector2> MapBoxPos; public const string Version = "0.6.7"; internal static ManualLogSource Log; internal static ConfigEntry<float> Radius; internal static ConfigEntry<float> CooldownMinutes; internal static ConfigEntry<float> DotMinutes; internal static ConfigEntry<bool> ShowMobs; internal static ConfigEntry<bool> OnlyHostile; internal static ConfigEntry<bool> IncludeTamed; internal static ConfigEntry<bool> ShowNpcs; internal static ConfigEntry<bool> ShowPlayers; internal static ConfigEntry<bool> ShowStructures; internal static ConfigEntry<bool> ShowPortals; internal static ConfigEntry<PinType> StructureIcon; internal static ConfigEntry<PinType> PortalIcon; internal static ConfigEntry<float> StructureCluster; internal static ConfigEntry<bool> MobNames; internal static ConfigEntry<bool> NotifyPlayers; internal static ConfigEntry<float> Volume; internal static PingHeimPlugin Instance; private Harmony _harmony; private void Awake() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Expected O, but got Unknown //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Expected O, but got Unknown //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Instance = this; Radius = ((BaseUnityPlugin)this).Config.Bind<float>("Ping", "Radius", 120f, new ConfigDescription("How far (in meters) a ping reaches around you. The game only knows about things in the areas around you, so what you can detect is capped at roughly 64-128 m, depending on where you stand in your area.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 300f), Array.Empty<object>())); CooldownMinutes = ((BaseUnityPlugin)this).Config.Bind<float>("Ping", "CooldownMinutes", 10f, new ConfigDescription("How long the Ping Stone takes to recharge after use. Takes effect on next game start.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 120f), Array.Empty<object>())); DotMinutes = ((BaseUnityPlugin)this).Config.Bind<float>("Ping", "DotMinutes", 3f, new ConfigDescription("How long everything a ping finds (creatures, traders, players, buildings, portals) stays on the map, unless you click it on the map to keep it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 60f), Array.Empty<object>())); OpenKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Ping", "OpenKey", (KeyCode)112, "While you carry a Ping Stone, this key opens its options (ping, aggro ping, what it shows). The stone can also be clicked when equipped."); LogBigObjects = ((BaseUnityPlugin)this).Config.Bind<bool>("Diagnostics", "LogBigObjects", true, "When you host a world, write the largest stored objects in it to the log once, about 40 seconds in (to help find what makes players' connections fail)."); AggroRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Aggro", "Radius", 60f, new ConfigDescription("How far the aggro ping reaches, in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 150f), Array.Empty<object>())); AggroBosses = ((BaseUnityPlugin)this).Config.Bind<bool>("Aggro", "IncludeBosses", false, "Also call bosses with the aggro ping."); ShowSpawners = ((BaseUnityPlugin)this).Config.Bind<bool>("Detect", "Spawners", true, "Show creature spawners (nests, bone piles and the like) on the map, as a green skull. Also switchable from the box on the map."); SizeByStrength = ((BaseUnityPlugin)this).Config.Bind<bool>("Detect", "SizeByStrength", true, "Show creatures bigger and warmer in colour the bigger and stronger they are (tiny yellow to large crimson, bosses purple)."); ShowMobs = ((BaseUnityPlugin)this).Config.Bind<bool>("Detect", "Monsters", true, "Show creatures (monsters and animals) on the map, as a red paw print. Also switchable from the box on the map."); OnlyHostile = ((BaseUnityPlugin)this).Config.Bind<bool>("Detect", "OnlyHostileMonsters", false, "Show only hostile creatures, not deer, boar and other peaceful animals."); IncludeTamed = ((BaseUnityPlugin)this).Config.Bind<bool>("Detect", "IncludeTamedCreatures", false, "Also show creatures that have been tamed."); ShowNpcs = ((BaseUnityPlugin)this).Config.Bind<bool>("Detect", "Traders", true, "Show vendors (Haldor, Hildir, the Bog Witch) on the map, as a white person. Also switchable from the box on the map."); ShowPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Detect", "Players", true, "Show other players on the map, as a blue person. Also switchable from the box on the map."); ShowStructures = ((BaseUnityPlugin)this).Config.Bind<bool>("Detect", "Structures", true, "Mark player-built buildings on the map with the game's house icon. They are remembered for good. Also switchable from the box on the map."); ShowPortals = ((BaseUnityPlugin)this).Config.Bind<bool>("Detect", "Portals", true, "Mark player-built portals on the map with the game's portal icon and their name. They are remembered for good. Also switchable from the box on the map."); StructureIcon = ((BaseUnityPlugin)this).Config.Bind<PinType>("Icons", "BuildingIcon", (PinType)1, "Which of the game's own map icons marks a building. Icon1 is the house. (The game's icon names are written to the log the first time you open the map.)"); PortalIcon = ((BaseUnityPlugin)this).Config.Bind<PinType>("Icons", "PortalIcon", (PinType)6, "Which of the game's own map icons marks a portal. Icon4 is the portal."); StructureCluster = ((BaseUnityPlugin)this).Config.Bind<float>("Detect", "StructureClusterMeters", 16f, new ConfigDescription("Buildings are grouped into one marker per this many meters, so a base isn't covered in squares.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(4f, 64f), Array.Empty<object>())); MobNames = ((BaseUnityPlugin)this).Config.Bind<bool>("Detect", "LabelMonsters", false, "Put the creature's name beside each red dot."); NotifyPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Detect", "NotifyPlayers", true, "Players your ping detects see a ping where you are, and you show on their map for a few minutes."); ShareWithPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Share", "ShareWithPlayers", true, "When you use a Ping Stone, every other player (who has this mod) hears it and sees what it found on their own map."); ReceiveFromPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Share", "ReceiveFromPlayers", true, "When another player uses a Ping Stone, hear it and show what it found on your map."); PopupPos = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Window", "PopupPosition", new Vector2(-1f, -1f), "Where the Ping Stone options window sits (top-left, pixels). Drag it to move it; -1 = centred."); MapBoxPos = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Window", "MapBoxPosition", new Vector2(-1f, -1f), "Where the filter box on the map sits (top-left, pixels). Drag it to move it; -1 = the default spot on the left."); Volume = ((BaseUnityPlugin)this).Config.Bind<float>("Sound", "PingVolume", 0.8f, new ConfigDescription("Volume of the ping sound.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); PrefabManager.OnVanillaPrefabsAvailable += PingItem.Create; ((MonoBehaviour)this).StartCoroutine(PingSound.Load(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "sounds", "ping.wav"))); _harmony = new Harmony("mbaya.PingHeim"); SafePatch.All(_harmony, typeof(PingHeimPlugin).Assembly, Log); Log.LogInfo((object)"PingHeim 0.6.7 loaded"); } private void Update() { Marks.Tick(); PingKeys.Tick(); } private void OnGUI() { PingOptions.Draw(); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } internal static class PingItem { public const string PrefabName = "PingHeim_PingStone"; private const string BasePrefab = "SurtlingCore"; private const string CooldownEffect = "PingHeim_Recharging"; private static readonly int CooldownHash = StringExtensionMethods.GetStableHashCode("PingHeim_Recharging"); private static readonly Color StoneColor = new Color(0.25f, 0.85f, 1f); public static bool IsPingStone(ItemData item) { if (item != null && (Object)(object)item.m_dropPrefab != (Object)null) { return ((Object)item.m_dropPrefab).name == "PingHeim_PingStone"; } return false; } public static void Create() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00e4: 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) PrefabManager.OnVanillaPrefabsAvailable -= Create; Sprite val = LoadIcon(); ItemConfig val2 = new ItemConfig(); val2.Name = "Ping Stone"; val2.Description = "Equip it (right-click) and click to choose: send a ping across the area around you, or an aggro ping that calls every hostile creature nearby to you. A ping sends a pulse across the area around you. Monsters show as red dots, traders as white, other players as blue, all for a few minutes, and player-built structures are marked in grey for good. Players you reveal see where the ping came from. It then needs time to recharge. The options also say what it shows on your map."; val2.CraftingStation = "forge"; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Bronze", 3, 0, true), new RequirementConfig("FineWood", 5, 0, true), new RequirementConfig("SurtlingCore", 1, 0, true) }; val2.Icons = (Sprite[])(object)((!((Object)(object)val != (Object)null)) ? null : new Sprite[1] { val }); CustomItem val3 = new CustomItem("PingHeim_PingStone", "SurtlingCore", val2); ItemDrop itemDrop = val3.ItemDrop; if ((Object)(object)itemDrop == (Object)null) { PingHeimPlugin.Log.LogError((object)"Could not create the Ping Stone."); return; } SharedData shared = itemDrop.m_itemData.m_shared; shared.m_itemType = (ItemType)19; shared.m_animationState = (AnimationState)1; shared.m_maxStackSize = 1; shared.m_maxQuality = 1; shared.m_weight = 0.5f; shared.m_teleportable = true; shared.m_value = 0; shared.m_equipStatusEffect = null; shared.m_attackStatusEffect = null; Recolour(val3.ItemPrefab); ItemManager.Instance.AddItem(val3); AddRechargeEffect(val); } private static void Recolour(GameObject prefab) { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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) if ((Object)(object)prefab == (Object)null) { return; } try { Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { Material[] sharedMaterials = val.sharedMaterials; for (int j = 0; j < sharedMaterials.Length; j++) { if (!((Object)(object)sharedMaterials[j] == (Object)null)) { Material val2 = new Material(sharedMaterials[j]) { name = ((Object)sharedMaterials[j]).name + "_PingStone" }; if (val2.HasProperty("_Color")) { val2.SetColor("_Color", Color.Lerp(val2.GetColor("_Color"), StoneColor, 0.8f)); } if (val2.HasProperty("_TintColor")) { val2.SetColor("_TintColor", StoneColor); } if (val2.HasProperty("_EmissionColor")) { val2.SetColor("_EmissionColor", StoneColor * 1.6f); } sharedMaterials[j] = val2; } } val.sharedMaterials = sharedMaterials; } Light[] componentsInChildren2 = prefab.GetComponentsInChildren<Light>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].color = StoneColor; } } catch (Exception ex) { PingHeimPlugin.Log.LogWarning((object)("Couldn't recolour the Ping Stone: " + ex.Message)); } } private static void AddRechargeEffect(Sprite icon) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>(); ((Object)val).name = "PingHeim_Recharging"; ((StatusEffect)val).m_name = "Ping Stone recharging"; ((StatusEffect)val).m_tooltip = "The Ping Stone is recharging. It can be used again when this runs out."; ((StatusEffect)val).m_icon = icon; ((StatusEffect)val).m_ttl = PingHeimPlugin.CooldownMinutes.Value * 60f; ((StatusEffect)val).m_cooldownIcon = true; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val, false)); } private static Sprite LoadIcon() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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) try { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("PingHeim.ping_icon.png"); if (stream == null) { return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ImageConversion.LoadImage(val, array); ((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x20); Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); ((Object)obj).hideFlags = (HideFlags)(((Object)obj).hideFlags | 0x20); return obj; } catch (Exception ex) { PingHeimPlugin.Log.LogWarning((object)("Couldn't load the item icon: " + ex.Message)); return null; } } public static bool TryUse(Player player, bool start) { SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan.HaveStatusEffect(CooldownHash)) { StatusEffect statusEffect = sEMan.GetStatusEffect(CooldownHash); float num = (((Object)(object)statusEffect != (Object)null) ? statusEffect.GetRemaningTime() : 0f); ((Character)player).Message((MessageType)2, $"The Ping Stone is recharging ({Mathf.CeilToInt(num / 60f)} min left)", 0, (Sprite)null, false); return false; } if (start && PingHeimPlugin.CooldownMinutes.Value > 0f) { sEMan.AddStatusEffect(CooldownHash, true, 0, 0f, (short)(-1)); } return true; } public static void Use(Player player) { SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan.HaveStatusEffect(CooldownHash)) { StatusEffect statusEffect = sEMan.GetStatusEffect(CooldownHash); float num = (((Object)(object)statusEffect != (Object)null) ? statusEffect.GetRemaningTime() : 0f); ((Character)player).Message((MessageType)2, $"The Ping Stone is recharging ({Mathf.CeilToInt(num / 60f)} min left)", 0, (Sprite)null, false); return; } PingSound.Play(); ScanResult r = Scanner.Run(player); if (PingHeimPlugin.CooldownMinutes.Value > 0f) { sEMan.AddStatusEffect(CooldownHash, true, 0, 0f, (short)(-1)); } string text = Summary(r); ((Character)player).Message((MessageType)2, text, 0, (Sprite)null, false); PingNet.Share(player, text); } private static string Summary(ScanResult r) { string text = "Ping! "; text += string.Format("{0} creature{1}", r.Monsters, (r.Monsters == 1) ? "" : "s"); if (r.Traders > 0) { text += string.Format(", {0} trader{1}", r.Traders, (r.Traders == 1) ? "" : "s"); } if (r.Players > 0) { text += string.Format(", {0} player{1}", r.Players, (r.Players == 1) ? "" : "s"); } if (r.Structures > 0) { text += string.Format(", {0} new building marker{1}", r.Structures, (r.Structures == 1) ? "" : "s"); } if (r.Spawners > 0) { text += string.Format(", {0} spawner{1}", r.Spawners, (r.Spawners == 1) ? "" : "s"); } if (r.Portals > 0) { text += string.Format(", {0} new portal{1}", r.Portals, (r.Portals == 1) ? "" : "s"); } return text; } } [HarmonyPatch(typeof(Humanoid), "UseItem")] internal static class UseItemPatch { private static bool Prefix(Humanoid __instance, Inventory inventory, ItemData item) { if (!PingItem.IsPingStone(item)) { return true; } Player val = (Player)(object)((__instance is Player) ? __instance : null); if ((Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)Player.m_localPlayer) { return true; } if (inventory != null && inventory != ((Humanoid)val).GetInventory()) { return true; } if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) { PingOptions.OpenPopup(); return false; } return true; } } internal static class PingKeys { public static void Tick() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) BigObjectReport.Tick(); Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && !PingOptions.PopupOpen && Input.GetKeyDown(PingHeimPlugin.OpenKey.Value) && !Console.IsVisible() && (!((Object)(object)Chat.instance != (Object)null) || !Chat.instance.HasFocus()) && !TextInput.IsVisible() && !Minimap.IsOpen() && (!((Object)(object)InventoryGui.instance != (Object)null) || !InventoryGui.IsVisible()) && ((Humanoid)localPlayer).GetInventory().GetAllItems().Any(PingItem.IsPingStone)) { PingOptions.OpenPopup(); } } } internal static class PingNet { private const string Pinged = "PingHeim_Pinged"; private const string Shared = "PingHeim_Shared"; private const string AggroRpc = "PingHeim_Aggro"; private static ZRoutedRpc _registeredOn; public static void Register() { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null && instance != _registeredOn) { _registeredOn = instance; instance.Register<Vector3, UserInfo, string>("PingHeim_Pinged", (Action<long, Vector3, UserInfo, string>)RpcPinged); instance.Register<ZPackage>("PingHeim_Shared", (Action<long, ZPackage>)RpcShared); instance.Register<Vector3, UserInfo, string, int>("PingHeim_Aggro", (Method<Vector3, UserInfo, string, int>)RpcAggro); } } public static void Notify(ZDO playerZdo, Vector3 source) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (!PingHeimPlugin.NotifyPlayers.Value || ZRoutedRpc.instance == null) { return; } long owner = playerZdo.GetOwner(); if (owner != 0L && owner != ZDOMan.GetSessionID()) { ZRoutedRpc instance = ZRoutedRpc.instance; object[] obj = new object[3] { source, UserInfo.GetLocalUser(), null }; object obj2; if (!((Object)(object)Game.instance != (Object)null)) { obj2 = ""; } else { Player localPlayer = Player.m_localPlayer; obj2 = ((localPlayer != null) ? localPlayer.GetPlayerName() : null) ?? ""; } obj[2] = obj2; instance.InvokeRoutedRPC(owner, "PingHeim_Pinged", obj); } } public static void Share(Player player, string summary) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) if (!PingHeimPlugin.ShareWithPlayers.Value || ZRoutedRpc.instance == null || (Object)(object)player == (Object)null) { return; } ZPackage val = new ZPackage(); val.Write(player.GetPlayerName() ?? ""); val.Write(((Component)player).transform.position); val.Write(summary ?? ""); UserInfo.GetLocalUser().Serialize(ref val); val.Write(Scanner.LastFound.Count); foreach (Scanner.Found item in Scanner.LastFound) { val.Write((int)item.Kind); val.Write(item.Position); val.Write(item.Label ?? ""); val.Write(item.Spacing); val.Write(item.Tier); } ZRoutedRpc.instance.InvokeRoutedRPC(0L, "PingHeim_Shared", new object[1] { val }); } public static void ShareAggro(Player player, int called) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (PingHeimPlugin.ShareWithPlayers.Value && ZRoutedRpc.instance != null && !((Object)(object)player == (Object)null)) { ZRoutedRpc.instance.InvokeRoutedRPC(0L, "PingHeim_Aggro", new object[4] { ((Component)player).transform.position, UserInfo.GetLocalUser(), player.GetPlayerName() ?? "", called }); } } private static void RpcAggro(long sender, Vector3 position, UserInfo user, string name, int called) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && sender != ZDOMan.GetSessionID() && PingHeimPlugin.ReceiveFromPlayers.Value) { PingSound.Play(); if ((Object)(object)Chat.instance != (Object)null) { Chat.instance.OnNewChatMessage((GameObject)null, sender, position, (Type)3, user, ""); } string text = (string.IsNullOrEmpty(name) ? "Someone" : name); ((Character)localPlayer).Message((MessageType)1, text + " sent an aggro ping" + ((called > 0) ? string.Format(": {0} creature{1} called", called, (called == 1) ? "" : "s") : ""), 0, (Sprite)null, false); } } private static void RpcShared(long sender, ZPackage pkg) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_009f: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || sender == ZDOMan.GetSessionID() || !PingHeimPlugin.ReceiveFromPlayers.Value) { return; } string text = pkg.ReadString(); Vector3 val = pkg.ReadVector3(); string text2 = pkg.ReadString(); UserInfo val2 = new UserInfo(); val2.Deserialize(ref pkg); int num = pkg.ReadInt(); PingSound.Play(); if ((Object)(object)Chat.instance != (Object)null) { Chat.instance.OnNewChatMessage((GameObject)null, sender, val, (Type)3, val2, ""); } Marks.ClearTemporary(); Marks.Add(PingKind.Player, val, text); for (int i = 0; i < num; i++) { PingKind pingKind = (PingKind)pkg.ReadInt(); Vector3 val3 = pkg.ReadVector3(); string label = pkg.ReadString(); float spacing = pkg.ReadSingle(); int tier = pkg.ReadInt(); if (pingKind == PingKind.Player) { Vector3 val4 = val3 - ((Component)localPlayer).transform.position; if (((Vector3)(ref val4)).sqrMagnitude < 4f) { continue; } } Marks.Add(pingKind, val3, label, spacing, tier); } ((Character)localPlayer).Message((MessageType)1, (string.IsNullOrEmpty(text) ? "Someone" : text) + " pinged. " + text2, 0, (Sprite)null, false); } private static void RpcPinged(long sender, Vector3 position, UserInfo user, string name) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { if ((Object)(object)Chat.instance != (Object)null) { Chat.instance.OnNewChatMessage((GameObject)null, sender, position, (Type)3, user, ""); } Marks.Add(PingKind.Player, position, name); ((Character)localPlayer).Message((MessageType)1, (string.IsNullOrEmpty(name) ? "Someone" : name) + " pinged you", 0, (Sprite)null, false); } } } [HarmonyPatch(typeof(Game), "Start")] internal static class GameStartPatch { private static void Postfix() { PingNet.Register(); } } internal static class PingOptions { [CompilerGenerated] private static class <>O { public static WindowFunction <0>__DrawPopupWindow; } private const int WindowId = 37286; private static bool _popup; private static CursorLockMode _lockBefore; private static bool _visibleBefore; private static GUIStyle _title; private static GUIStyle _toggle; private static GUIStyle _small; private static Texture2D _background; private static Rect _mapBox; private static float _mapBoxScale; private static bool _draggingMapBox; private static Vector2 _grab; private static Rect _popupRect; private static bool _popupPlaced; public static bool PopupOpen => _popup; private static float Scale => Mathf.Clamp((float)Screen.height / 1080f, 0.8f, 2.5f); public static void OpenPopup() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!_popup) { _popup = true; _popupPlaced = false; _lockBefore = Cursor.lockState; _visibleBefore = Cursor.visible; } } public static void ClosePopup() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (_popup) { _popup = false; Cursor.lockState = _lockBefore; Cursor.visible = _visibleBefore; } } private static Rect MapRect() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_007c: Unknown result type (might be due to invalid IL or missing references) float scale = Scale; float num = 210f * scale; float num2 = 268f * scale; Vector2 value = PingHeimPlugin.MapBoxPos.Value; if (((Rect)(ref _mapBox)).width <= 0f || _mapBoxScale != scale) { _mapBoxScale = scale; _mapBox = ((value.x < 0f) ? new Rect(16f * scale, (float)Screen.height * 0.3f, num, num2) : new Rect(value.x, value.y, num, num2)); } ((Rect)(ref _mapBox)).width = num; ((Rect)(ref _mapBox)).height = num2; ((Rect)(ref _mapBox)).x = Mathf.Clamp(((Rect)(ref _mapBox)).x, 0f, Mathf.Max(0f, (float)Screen.width - num)); ((Rect)(ref _mapBox)).y = Mathf.Clamp(((Rect)(ref _mapBox)).y, 0f, Mathf.Max(0f, (float)Screen.height - num2)); return _mapBox; } public static bool MouseOverMapBox() { //IL_0009: 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_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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (!Minimap.IsOpen()) { return false; } Vector3 mousePosition = Input.mousePosition; Rect val = MapRect(); return ((Rect)(ref val)).Contains(new Vector2(mousePosition.x, (float)Screen.height - mousePosition.y)); } public static void Draw() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (_popup) { DrawPopup(); } else if (Minimap.IsOpen()) { EnsureStyles(); Rect val = MapRect(); GUI.DrawTexture(val, (Texture)(object)Background()); GUILayout.BeginArea(new Rect(((Rect)(ref val)).x + 10f * Scale, ((Rect)(ref val)).y + 6f * Scale, ((Rect)(ref val)).width - 20f * Scale, ((Rect)(ref val)).height - 12f * Scale)); GUILayout.Label("Ping Stone", _title, Array.Empty<GUILayoutOption>()); DrawToggles(); GUILayout.EndArea(); DragMapBox(val); } } private static void DragMapBox(Rect rect) { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; Vector2 mousePosition = current.mousePosition; if ((int)current.type == 0 && current.button == 0 && ((Rect)(ref rect)).Contains(mousePosition)) { _draggingMapBox = true; _grab = mousePosition - new Vector2(((Rect)(ref rect)).x, ((Rect)(ref rect)).y); } else if ((int)current.type == 3 && _draggingMapBox) { ((Rect)(ref _mapBox)).x = mousePosition.x - _grab.x; ((Rect)(ref _mapBox)).y = mousePosition.y - _grab.y; } else if ((int)current.type == 1 && _draggingMapBox) { _draggingMapBox = false; PingHeimPlugin.MapBoxPos.Value = new Vector2(((Rect)(ref _mapBox)).x, ((Rect)(ref _mapBox)).y); } } private static void DrawPopup() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Invalid comparison between Unknown and I4 //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { ClosePopup(); return; } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; Event current = Event.current; if ((int)current.type == 4 && (int)current.keyCode == 27) { current.Use(); ClosePopup(); return; } EnsureStyles(); float scale = Scale; float num = 400f * scale; float num2 = 410f * scale; if (!_popupPlaced) { Vector2 value = PingHeimPlugin.PopupPos.Value; _popupRect = new Rect((value.x < 0f) ? (((float)Screen.width - num) / 2f) : value.x, (value.y < 0f) ? (((float)Screen.height - num2) / 2f) : value.y, num, num2); _popupPlaced = true; } ((Rect)(ref _popupRect)).width = num; ((Rect)(ref _popupRect)).height = num2; ((Rect)(ref _popupRect)).x = Mathf.Clamp(((Rect)(ref _popupRect)).x, 0f, Mathf.Max(0f, (float)Screen.width - num)); ((Rect)(ref _popupRect)).y = Mathf.Clamp(((Rect)(ref _popupRect)).y, 0f, Mathf.Max(0f, (float)Screen.height - num2)); GUI.DrawTexture(_popupRect, (Texture)(object)Background()); Rect popupRect = _popupRect; object obj = <>O.<0>__DrawPopupWindow; if (obj == null) { WindowFunction val = DrawPopupWindow; <>O.<0>__DrawPopupWindow = val; obj = (object)val; } _popupRect = GUI.Window(37286, popupRect, (WindowFunction)obj, "Ping Stone"); if ((int)Event.current.type == 1) { PingHeimPlugin.PopupPos.Value = new Vector2(((Rect)(ref _popupRect)).x, ((Rect)(ref _popupRect)).y); } } private static void DrawPopupWindow(int id) { float scale = Scale; GUILayout.Space(8f * scale); GUILayout.Label("Choose what a ping shows on your map.", _small, Array.Empty<GUILayoutOption>()); GUILayout.Space(4f * scale); DrawToggles(); GUILayout.FlexibleSpace(); GUILayout.Label("Aggro ping: every hostile creature nearby hears you and comes for you. Click with the stone equipped, or Shift+use it, to open this box.", _small, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Ping now", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f * scale) })) { ClosePopup(); PingItem.Use(Player.m_localPlayer); } if (GUILayout.Button("Aggro ping", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f * scale) })) { ClosePopup(); AggroPing.Use(Player.m_localPlayer); } if (GUILayout.Button("Close (Esc)", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f * scale) })) { ClosePopup(); } GUILayout.EndHorizontal(); GUI.DragWindow(); } private static void DrawToggles() { Row(PingHeimPlugin.ShowMobs, "Creatures", PingKind.Monster); Row(PingHeimPlugin.ShowNpcs, "Traders", PingKind.Trader); Row(PingHeimPlugin.ShowPlayers, "Players", PingKind.Player); Row(PingHeimPlugin.ShowStructures, "Buildings", PingKind.Structure); Row(PingHeimPlugin.ShowPortals, "Portals", PingKind.Portal); Row(PingHeimPlugin.ShowSpawners, "Spawners", PingKind.Spawner); } private static void Row(ConfigEntry<bool> entry, string label, PingKind kind) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) string text = ColorUtility.ToHtmlStringRGB(Marks.ColorOf(kind)); bool flag = GUILayout.Toggle(entry.Value, " <color=#" + text + ">■</color> " + label, _toggle, Array.Empty<GUILayoutOption>()); if (flag != entry.Value) { entry.Value = flag; } } private static Texture2D Background() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_background != (Object)null) { return _background; } _background = new Texture2D(1, 1); _background.SetPixel(0, 0, new Color(0.1f, 0.08f, 0.06f, 0.94f)); _background.Apply(); return _background; } private static void EnsureStyles() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_003c: 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) //IL_004d: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown float scale = Scale; if (_title == null) { _title = new GUIStyle(GUI.skin.label) { fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; _toggle = new GUIStyle(GUI.skin.toggle) { richText = true }; GUIStyleState normal = _toggle.normal; GUIStyleState onNormal = _toggle.onNormal; GUIStyleState hover = _toggle.hover; Color val = (_toggle.onHover.textColor = Color.white); Color val2 = (hover.textColor = val); Color textColor = (onNormal.textColor = val2); normal.textColor = textColor; _small = new GUIStyle(GUI.skin.label) { wordWrap = true }; } _title.fontSize = Mathf.RoundToInt(20f * scale); _toggle.fontSize = Mathf.RoundToInt(18f * scale); _toggle.padding.top = Mathf.RoundToInt(3f * scale); _small.fontSize = Mathf.RoundToInt(14f * scale); GUI.skin.button.fontSize = Mathf.RoundToInt(16f * scale); GUI.skin.window.fontSize = Mathf.RoundToInt(20f * scale); } } [HarmonyPatch(typeof(Player), "TakeInput")] internal static class TakeInputPatch { private static void Postfix(ref bool __result) { if (PingOptions.PopupOpen) { __result = false; } } } [HarmonyPatch(typeof(PlayerController), "TakeInput")] internal static class ControllerTakeInputPatch { private static void Postfix(ref bool __result) { if (PingOptions.PopupOpen) { __result = false; } } } [HarmonyPatch(typeof(Minimap), "OnMapLeftClick")] internal static class MapLeftClickPatch { private static bool Prefix(Minimap __instance) { if (PingOptions.MouseOverMapBox()) { return false; } return !Marks.ToggleAtClick(__instance); } } [HarmonyPatch(typeof(Minimap), "OnMapDblClick")] internal static class MapDoubleClickPatch { private static bool Prefix() { return !PingOptions.MouseOverMapBox(); } } [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] internal static class KeepCursorPatch { private static void Postfix() { if (PingOptions.PopupOpen) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } } internal static class PingSound { private static AudioClip _clip; private static AudioSource _source; public static IEnumerator Load(string path) { if (!File.Exists(path)) { PingHeimPlugin.Log.LogWarning((object)("The ping sound isn't there: " + path)); yield break; } string absoluteUri = new Uri(path).AbsoluteUri; UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(absoluteUri, (AudioType)20); try { yield return request.SendWebRequest(); if ((int)request.result != 1) { PingHeimPlugin.Log.LogWarning((object)("Couldn't load the ping sound: " + request.error)); yield break; } _clip = DownloadHandlerAudioClip.GetContent(request); ((Object)_clip).name = "PingHeimPing"; } finally { ((IDisposable)request)?.Dispose(); } } public static void Play() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown if (!((Object)(object)_clip == (Object)null)) { if ((Object)(object)_source == (Object)null) { GameObject val = new GameObject("PingHeimAudio"); Object.DontDestroyOnLoad((Object)val); _source = val.AddComponent<AudioSource>(); _source.spatialBlend = 0f; _source.playOnAwake = false; _source.ignoreListenerPause = true; } if ((Object)(object)AudioMan.instance != (Object)null) { _source.outputAudioMixerGroup = AudioMan.instance.m_guiMixer; } _source.PlayOneShot(_clip, Mathf.Clamp01(PingHeimPlugin.Volume.Value)); } } } internal static class SafePatch { public static void All(Harmony harmony, Assembly assembly, ManualLogSource log) { Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(assembly); foreach (Type type in typesFromAssembly) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: true).Length != 0) { try { harmony.PatchAll(type); } catch (Exception ex) { log.LogError((object)("Couldn't apply the patch " + type.Name + "; the rest are fine. " + ex.Message)); } } } } } internal struct ScanResult { public int Monsters; public int Traders; public int Players; public int Structures; public int Portals; public int Spawners; } internal static class Scanner { private enum Kind { None, Monster, Trader, Player, Structure, Portal, Spawner } private class Info { public Kind Kind; public bool Hostile; public bool Boss; public float Health; public string Name = ""; } internal struct Found { public PingKind Kind; public Vector3 Position; public string Label; public float Spacing; public int Tier; } private static readonly Dictionary<int, Info> Cache = new Dictionary<int, Info>(); public static readonly List<Found> LastFound = new List<Found>(); private static Info InfoFor(int prefabHash) { //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00f7: Invalid comparison between Unknown and I4 //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Invalid comparison between Unknown and I4 //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Invalid comparison between Unknown and I4 //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Invalid comparison between Unknown and I4 if (Cache.TryGetValue(prefabHash, out var value)) { return value; } Info info = new Info(); GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(prefabHash) : null); if ((Object)(object)val != (Object)null) { if ((Object)(object)val.GetComponent<Player>() != (Object)null) { info.Kind = Kind.Player; } else if ((Object)(object)val.GetComponent<Trader>() != (Object)null) { info.Kind = Kind.Trader; Character component = val.GetComponent<Character>(); if ((Object)(object)component != (Object)null) { info.Name = Localization.instance.Localize(component.m_name); } } else if ((Object)(object)val.GetComponent<Character>() != (Object)null) { Character component2 = val.GetComponent<Character>(); info.Kind = Kind.Monster; info.Name = Localization.instance.Localize(component2.m_name); info.Boss = component2.m_boss; info.Health = component2.m_health; Faction faction = component2.m_faction; info.Hostile = (int)faction != 1 && (int)faction != 0 && (int)faction != 10 && (int)faction != 11 && (int)faction != 12; } else if ((Object)(object)val.GetComponent<SpawnArea>() != (Object)null && ((Object)(object)val.GetComponent<Destructible>() != (Object)null || (Object)(object)val.GetComponent<WearNTear>() != (Object)null)) { info.Kind = Kind.Spawner; info.Name = SpawnerName(val); } else if ((Object)(object)val.GetComponent<TeleportWorld>() != (Object)null) { info.Kind = Kind.Portal; } else if ((Object)(object)val.GetComponent<Piece>() != (Object)null && (Object)(object)val.GetComponent<Plant>() == (Object)null) { info.Kind = Kind.Structure; } } Cache[prefabHash] = info; return info; } private static bool Add(PingKind kind, Vector3 position, string label, float spacing = 0f, int tier = 0) { //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_0046: Unknown result type (might be due to invalid IL or missing references) LastFound.Add(new Found { Kind = kind, Position = position, Label = (label ?? ""), Spacing = spacing, Tier = tier }); return Marks.Add(kind, position, label, spacing, tier); } private static int TierOf(Info info, ZDO zdo) { if (info.Boss) { return 4; } float num = zdo.GetFloat(ZDOVars.s_maxHealth, info.Health); if (!(num < 35f)) { if (!(num < 120f)) { if (!(num < 400f)) { return 3; } return 2; } return 1; } return 0; } private static string SpawnerName(GameObject prefab) { GameObject val = null; SpawnArea component = prefab.GetComponent<SpawnArea>(); if ((Object)(object)component != (Object)null && component.m_prefabs != null && component.m_prefabs.Count > 0) { val = component.m_prefabs[0].m_prefab; } Character val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<Character>() : null); if (!((Object)(object)val2 != (Object)null)) { return "Spawner"; } return Localization.instance.Localize(val2.m_name) + " spawner"; } public static ScanResult Run(Player player) { //IL_002a: 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) //IL_0058: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00d4: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: 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_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: 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_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) LastFound.Clear(); ScanResult result = default(ScanResult); if (ZDOMan.instance == null || (Object)(object)player == (Object)null) { return result; } Vector3 position = ((Component)player).transform.position; float value = PingHeimPlugin.Radius.Value; float num = value * value; ZDOID val = (((Object)(object)((Character)player).m_nview != (Object)null && ((Character)player).m_nview.GetZDO() != null) ? ((Character)player).m_nview.GetZDO().m_uid : ZDOID.None); Marks.ClearTemporary(); Dictionary<long, Vector3> dictionary = new Dictionary<long, Vector3>(); Dictionary<long, int> dictionary2 = new Dictionary<long, int>(); float num2 = Mathf.Max(1f, PingHeimPlugin.StructureCluster.Value); foreach (ZDO value4 in ZDOMan.instance.m_objectsByID.Values) { if (value4 == null) { continue; } Vector3 position2 = value4.GetPosition(); float num3 = position2.x - position.x; float num4 = position2.z - position.z; if (num3 * num3 + num4 * num4 > num) { continue; } Info info = InfoFor(value4.GetPrefab()); switch (info.Kind) { case Kind.Monster: if (!value4.GetBool(ZDOVars.s_dead, false) && (PingHeimPlugin.IncludeTamed.Value || !value4.GetBool(ZDOVars.s_tamed, false)) && (!PingHeimPlugin.OnlyHostile.Value || info.Hostile)) { Add(PingKind.Monster, position2, PingHeimPlugin.MobNames.Value ? info.Name : "", 0f, TierOf(info, value4)); result.Monsters++; } break; case Kind.Trader: Add(PingKind.Trader, position2, info.Name); result.Traders++; break; case Kind.Player: if (!(value4.m_uid == val)) { Add(PingKind.Player, position2, value4.GetString(ZDOVars.s_playerName, "")); result.Players++; PingNet.Notify(value4, position); } break; case Kind.Spawner: if (Add(PingKind.Spawner, position2, info.Name, 3f)) { result.Spawners++; } break; case Kind.Portal: if (value4.GetLong(ZDOVars.s_creator, 0L) != 0L && Add(PingKind.Portal, position2, value4.GetString(ZDOVars.s_tag, ""), 3f)) { result.Portals++; } break; case Kind.Structure: if (value4.GetLong(ZDOVars.s_creator, 0L) != 0L) { long key = ((long)Mathf.FloorToInt(position2.x / num2) << 32) ^ (uint)Mathf.FloorToInt(position2.z / num2); dictionary[key] = (dictionary.TryGetValue(key, out var value2) ? (value2 + position2) : position2); dictionary2[key] = ((!dictionary2.TryGetValue(key, out var value3)) ? 1 : (value3 + 1)); } break; } } foreach (KeyValuePair<long, Vector3> item in dictionary) { Vector3 position3 = item.Value / (float)dictionary2[item.Key]; if (Add(PingKind.Structure, position3, "", num2 * 0.6f)) { result.Structures++; } } return result; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }