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 PingPlus v1.3.0
BepInEx/plugins/PingPlus/PingPlus.dll
Decompiled a month agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using On.RoR2; using On.RoR2.UI; using R2API.Networking; using R2API.Networking.Interfaces; using R2API.Utils; using RoR2; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PingPlus")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0+386250e7c5172763721bcfb91c4716e86ccc7424")] [assembly: AssemblyProduct("PingPlus")] [assembly: AssemblyTitle("PingPlus")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 PingPlus { public sealed class PinnedPingRequestMessage : INetMessage, ISerializableObject { public NetworkInstanceId OwnerId { get; private set; } public NetworkInstanceId TargetId { get; private set; } public Vector3 Origin { get; private set; } public Vector3 Normal { get; private set; } public float Duration { get; private set; } public int Maximum { get; private set; } public PinnedPingRequestMessage() { } public PinnedPingRequestMessage(NetworkInstanceId ownerId, NetworkInstanceId targetId, Vector3 origin, Vector3 normal, float duration, int maximum) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) OwnerId = ownerId; TargetId = targetId; Origin = origin; Normal = normal; Duration = duration; Maximum = maximum; } public void Serialize(NetworkWriter writer) { //IL_0002: 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_001a: 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) writer.Write(OwnerId); writer.Write(TargetId); writer.Write(Origin); writer.Write(Normal); writer.Write(Duration); writer.Write(Maximum); } public void Deserialize(NetworkReader reader) { //IL_0002: 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_001a: 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) OwnerId = reader.ReadNetworkId(); TargetId = reader.ReadNetworkId(); Origin = reader.ReadVector3(); Normal = reader.ReadVector3(); Duration = reader.ReadSingle(); Maximum = reader.ReadInt32(); } public void OnReceived() { Plugin.Instance.ReceivePinnedPingRequest(this); } } public enum PinnedPingOperation : byte { Add, Remove, ClearOwner, ClearAll } public sealed class PinnedPingStateMessage : INetMessage, ISerializableObject { public PinnedPingOperation Operation { get; private set; } public NetworkInstanceId OwnerId { get; private set; } public NetworkInstanceId TargetId { get; private set; } public Vector3 Origin { get; private set; } public Vector3 Normal { get; private set; } public float Duration { get; private set; } public int LabelIndex { get; private set; } public PinnedPingStateMessage() { } public PinnedPingStateMessage(PinnedPingOperation operation, NetworkInstanceId ownerId = default(NetworkInstanceId), NetworkInstanceId targetId = default(NetworkInstanceId), Vector3 origin = default(Vector3), Vector3 normal = default(Vector3), float duration = 0f, int labelIndex = -1) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Operation = operation; OwnerId = ownerId; TargetId = targetId; Origin = origin; Normal = normal; Duration = duration; LabelIndex = labelIndex; } public void Serialize(NetworkWriter writer) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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) writer.Write((byte)Operation); writer.Write(OwnerId); writer.Write(TargetId); writer.Write(Origin); writer.Write(Normal); writer.Write(Duration); writer.Write(LabelIndex); } public void Deserialize(NetworkReader reader) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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) Operation = (PinnedPingOperation)reader.ReadByte(); OwnerId = reader.ReadNetworkId(); TargetId = reader.ReadNetworkId(); Origin = reader.ReadVector3(); Normal = reader.ReadVector3(); Duration = reader.ReadSingle(); LabelIndex = reader.ReadInt32(); } public void OnReceived() { Plugin.Instance.ReceivePinnedPingState(this); } } public sealed class ClearPinnedPingsRequestMessage : INetMessage, ISerializableObject { public NetworkInstanceId OwnerId { get; private set; } public ClearPinnedPingsRequestMessage() { } public ClearPinnedPingsRequestMessage(NetworkInstanceId ownerId) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) OwnerId = ownerId; } public void Serialize(NetworkWriter writer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) writer.Write(OwnerId); } public void Deserialize(NetworkReader reader) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) OwnerId = reader.ReadNetworkId(); } public void OnReceived() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Plugin.Instance.ReceiveClearPinnedPingsRequest(OwnerId); } } public sealed class ItemPingRequestMessage : INetMessage, ISerializableObject { private int _pickupValue; public ItemPingRequestMessage() { } public ItemPingRequestMessage(PickupIndex pickupIndex) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) _pickupValue = pickupIndex.value; } public void Serialize(NetworkWriter writer) { writer.Write(_pickupValue); } public void Deserialize(NetworkReader reader) { _pickupValue = reader.ReadInt32(); } public void OnReceived() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active) { Plugin.Instance.BroadcastItemOwnership(new PickupIndex(_pickupValue)); } } } internal static class PingAppearance { private sealed class RendererState(Color baseColor, Sprite? baseSprite) { public Color BaseColor { get; set; } = baseColor; public Sprite? BaseSprite { get; set; } = baseSprite; public Color CustomColor { get; set; } public Sprite? CustomSprite { get; set; } public bool HasCustomColor { get; set; } public bool HasCustomSprite { get; set; } } private const string ScrapIconResourceName = "PingPlus.Assets.scrap.png"; private static readonly ConditionalWeakTable<SpriteRenderer, RendererState> RendererStates = new ConditionalWeakTable<SpriteRenderer, RendererState>(); private static Texture2D? _scrapTexture; private static Sprite? _scrapSprite; public static void Initialize(ManualLogSource logger) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("PingPlus.Assets.scrap.png"); if (stream == null) { logger.LogWarning((object)"Could not find embedded scrap ping icon PingPlus.Assets.scrap.png."); return; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false) { name = "PingPlusScrapIcon", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; if (!ImageConversion.LoadImage(val, memoryStream.ToArray(), false)) { Object.Destroy((Object)(object)val); logger.LogWarning((object)"Could not decode the embedded scrap ping icon."); } else { _scrapTexture = val; } } public static bool TryApply(PingIndicator indicator) { //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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) RestoreCustomizedRenderers(indicator.interactablePingGameObjects); if (!Object.op_Implicit((Object)(object)indicator.pingTarget) || !TryGetAppearance(indicator.pingTarget, out var color, out var useScrapIcon)) { return false; } SpriteRenderer val = null; GameObject[] interactablePingGameObjects = indicator.interactablePingGameObjects; foreach (GameObject val2 in interactablePingGameObjects) { if (!Object.op_Implicit((Object)(object)val2)) { continue; } if (val == null) { val = val2.GetComponent<SpriteRenderer>(); } SpriteRenderer[] componentsInChildren = val2.GetComponentsInChildren<SpriteRenderer>(true); foreach (SpriteRenderer val3 in componentsInChildren) { if (val == null) { val = val3; } if (color.HasValue) { RendererState rendererState = GetRendererState(val3); Color value = color.Value; value.a = val3.color.a; val3.color = value; rendererState.HasCustomColor = true; rendererState.CustomColor = value; } } } if (useScrapIcon && (Object)(object)val != (Object)null) { Sprite scrapSprite = GetScrapSprite(val.sprite); if (Object.op_Implicit((Object)(object)scrapSprite)) { RendererState rendererState2 = GetRendererState(val); rendererState2.HasCustomSprite = true; rendererState2.CustomSprite = scrapSprite; val.sprite = scrapSprite; } } return true; } public static void SyncTextColorToIcon(PingIndicator indicator) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)indicator.pingText)) { SpriteRenderer val = FindIconRenderer(indicator.defaultPingGameObjects, requireActive: true) ?? FindIconRenderer(indicator.enemyPingGameObjects, requireActive: true) ?? FindIconRenderer(indicator.interactablePingGameObjects, requireActive: true) ?? FindIconRenderer(indicator.defaultPingGameObjects, requireActive: false) ?? FindIconRenderer(indicator.enemyPingGameObjects, requireActive: false) ?? FindIconRenderer(indicator.interactablePingGameObjects, requireActive: false); if (!((Object)(object)val == (Object)null)) { ((TMP_Text)indicator.pingText).overrideColorTags = true; ((Graphic)indicator.pingText).color = val.color; } } } public static bool TryGetPickupIndex(GameObject target, out PickupIndex pickupIndex) { //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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_00bb: 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_00c8: Unknown result type (might be due to invalid IL or missing references) if (IsScrapper(target) || IsShrine(target) || TryGetChestColor(target, out var _)) { pickupIndex = PickupIndex.none; return false; } GenericPickupController componentInParent = target.GetComponentInParent<GenericPickupController>(); if (Object.op_Implicit((Object)(object)componentInParent)) { pickupIndex = componentInParent.pickup.pickupIndex; return ((PickupIndex)(ref pickupIndex)).isValid; } ShopTerminalBehavior componentInParent2 = target.GetComponentInParent<ShopTerminalBehavior>(); if (Object.op_Implicit((Object)(object)componentInParent2)) { pickupIndex = (componentInParent2.pickupIndexIsHidden ? PickupIndex.none : componentInParent2.CurrentPickup().pickupIndex); return ((PickupIndex)(ref pickupIndex)).isValid; } PickupIndexNetworker componentInParent3 = target.GetComponentInParent<PickupIndexNetworker>(); if (Object.op_Implicit((Object)(object)componentInParent3)) { pickupIndex = componentInParent3.pickupState.pickupIndex; return ((PickupIndex)(ref pickupIndex)).isValid; } PickupDisplay componentInParent4 = target.GetComponentInParent<PickupDisplay>(); pickupIndex = (Object.op_Implicit((Object)(object)componentInParent4) ? componentInParent4.GetPickupIndex() : PickupIndex.none); return ((PickupIndex)(ref pickupIndex)).isValid; } private static bool TryGetAppearance(GameObject target, out Color? color, out bool useScrapIcon) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (IsScrapper(target)) { color = null; useScrapIcon = true; return true; } if (IsNewtAltar(target)) { color = GetColor((ColorIndex)4); useScrapIcon = false; return true; } if (TryGetHiddenShopColor(target, out var color2)) { color = color2; useScrapIcon = false; return true; } if (TryGetChestColor(target, out var color3)) { color = color3; useScrapIcon = false; return true; } if (IsShrine(target)) { color = null; useScrapIcon = false; return false; } if (TryGetPickupIndex(target, out var pickupIndex)) { PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); if (pickupDef != null && TryGetPickupAppearance(pickupDef, out var color4, out useScrapIcon)) { color = color4; return true; } } useScrapIcon = false; color = null; return false; } private static bool TryGetHiddenShopColor(GameObject target, out Color color) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00ae: Unknown result type (might be due to invalid IL or missing references) ShopTerminalBehavior componentInParent = target.GetComponentInParent<ShopTerminalBehavior>(); if (!Object.op_Implicit((Object)(object)componentInParent) || !componentInParent.pickupIndexIsHidden) { color = default(Color); return false; } PickupDef pickupDef = PickupCatalog.GetPickupDef(componentInParent.CurrentPickup().pickupIndex); if (pickupDef != null && TryGetPickupAppearance(pickupDef, out color, out var _)) { return true; } string interactableName = GetInteractableName(target); if (interactableName.IndexOf("Large", StringComparison.OrdinalIgnoreCase) >= 0) { color = GetColor((ColorIndex)2); return true; } if (interactableName.IndexOf("Equipment", StringComparison.OrdinalIgnoreCase) >= 0) { color = GetColor((ColorIndex)5); return true; } if (interactableName.IndexOf("Shop", StringComparison.OrdinalIgnoreCase) >= 0 || interactableName.StartsWith("FreeChestTerminal", StringComparison.OrdinalIgnoreCase)) { color = GetColor((ColorIndex)1); return true; } color = default(Color); return false; } private static bool TryGetPickupAppearance(PickupDef pickupDef, out Color color, out bool isScrap) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Invalid comparison between Unknown and I4 //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 //IL_0068: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00c9: Expected I4, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_00d2: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) ItemDef val = (((int)pickupDef.itemIndex != -1) ? ItemCatalog.GetItemDef(pickupDef.itemIndex) : null); isScrap = (Object)(object)val != (Object)null && (val.ContainsTag((ItemTag)10) || val.ContainsTag((ItemTag)14)); if (pickupDef.isLunar || (val != null && (int)val.tier == 3)) { color = GetColor((ColorIndex)4); return true; } if ((int)pickupDef.equipmentIndex != -1) { color = GetColor((ColorIndex)5); return true; } switch ((val != null) ? new ItemTier?(val.tier) : ((ItemTier?)null)) { case (ItemTier)0L: color = GetColor((ColorIndex)1); return true; case (ItemTier)1L: color = GetColor((ColorIndex)2); return true; case (ItemTier)2L: color = GetColor((ColorIndex)3); return true; case (ItemTier)4L: color = GetColor((ColorIndex)13); return true; case (ItemTier)6L: case (ItemTier)7L: case (ItemTier)8L: color = GetColor((ColorIndex)25); return true; default: if ((Object)(object)val != (Object)null) { color = pickupDef.baseColor; return true; } color = default(Color); return false; } } private static bool TryGetChestColor(GameObject target, out Color color) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //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) string interactableName = GetInteractableName(target); if (interactableName.StartsWith("GoldChest", StringComparison.OrdinalIgnoreCase)) { color = GetColor((ColorIndex)3); return true; } if (interactableName.StartsWith("EquipmentBarrel", StringComparison.OrdinalIgnoreCase)) { color = GetColor((ColorIndex)5); return true; } if (interactableName.StartsWith("LunarChest", StringComparison.OrdinalIgnoreCase) || interactableName.StartsWith("LunarPod", StringComparison.OrdinalIgnoreCase)) { color = GetColor((ColorIndex)4); return true; } if (interactableName.StartsWith("VoidChest", StringComparison.OrdinalIgnoreCase) || interactableName.StartsWith("LockboxVoid", StringComparison.OrdinalIgnoreCase)) { color = GetColor((ColorIndex)25); return true; } if (interactableName.StartsWith("CategoryChest2", StringComparison.OrdinalIgnoreCase)) { color = GetColor((ColorIndex)2); return true; } if (interactableName.StartsWith("CategoryChest", StringComparison.OrdinalIgnoreCase)) { color = GetColor((ColorIndex)1); return true; } if (interactableName.StartsWith("Chest2", StringComparison.OrdinalIgnoreCase)) { color = GetColor((ColorIndex)2); return true; } if (interactableName.StartsWith("Chest1", StringComparison.OrdinalIgnoreCase)) { color = GetColor((ColorIndex)1); return true; } color = default(Color); return false; } private static bool IsScrapper(GameObject target) { if (!Object.op_Implicit((Object)(object)(target.GetComponentInParent<ScrapperController>() ?? target.GetComponentInChildren<ScrapperController>()))) { return GetInteractableName(target).StartsWith("Scrapper", StringComparison.OrdinalIgnoreCase); } return true; } private static bool IsNewtAltar(GameObject target) { string interactableName = GetInteractableName(target); if (!interactableName.StartsWith("NewtStatue", StringComparison.OrdinalIgnoreCase)) { return interactableName.StartsWith("NewtAltar", StringComparison.OrdinalIgnoreCase); } return true; } private static bool IsShrine(GameObject target) { return GetInteractableName(target).IndexOf("Shrine", StringComparison.OrdinalIgnoreCase) >= 0; } private static SpriteRenderer? FindIconRenderer(GameObject[] gameObjects, bool requireActive) { foreach (GameObject val in gameObjects) { if (Object.op_Implicit((Object)(object)val) && (!requireActive || val.activeInHierarchy)) { SpriteRenderer val2 = val.GetComponent<SpriteRenderer>() ?? val.GetComponentInChildren<SpriteRenderer>(true); if (Object.op_Implicit((Object)(object)val2)) { return val2; } } } return null; } private static RendererState GetRendererState(SpriteRenderer renderer) { return RendererStates.GetValue(renderer, (SpriteRenderer value) => new RendererState(value.color, value.sprite)); } private static void RestoreCustomizedRenderers(GameObject[] gameObjects) { //IL_004c: 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_008a: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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) foreach (GameObject val in gameObjects) { if (!Object.op_Implicit((Object)(object)val)) { continue; } SpriteRenderer[] componentsInChildren = val.GetComponentsInChildren<SpriteRenderer>(true); foreach (SpriteRenderer val2 in componentsInChildren) { if (!RendererStates.TryGetValue(val2, out RendererState value)) { continue; } if (value.HasCustomColor) { if (HasSameRgb(val2.color, value.CustomColor)) { Color baseColor = value.BaseColor; baseColor.a = val2.color.a; val2.color = baseColor; } else { value.BaseColor = val2.color; } value.HasCustomColor = false; } if (value.HasCustomSprite) { if ((Object)(object)val2.sprite == (Object)(object)value.CustomSprite) { val2.sprite = value.BaseSprite; } else { value.BaseSprite = val2.sprite; } value.HasCustomSprite = false; } } } } private static bool HasSameRgb(Color left, Color right) { //IL_0000: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (Mathf.Approximately(left.r, right.r) && Mathf.Approximately(left.g, right.g)) { return Mathf.Approximately(left.b, right.b); } return false; } private static string GetInteractableName(GameObject target) { ChestBehavior componentInParent = target.GetComponentInParent<ChestBehavior>(); object obj = ((componentInParent != null) ? ((Component)componentInParent).gameObject : null); if (obj == null) { PurchaseInteraction componentInParent2 = target.GetComponentInParent<PurchaseInteraction>(); obj = ((componentInParent2 != null) ? ((Component)componentInParent2).gameObject : null) ?? target; } return ((Object)obj).name; } private static Color GetColor(ColorIndex colorIndex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_000b: 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) Color result = Color32.op_Implicit(ColorCatalog.GetColor(colorIndex)); result.a = 1f; return result; } private static Sprite? GetScrapSprite(Sprite? originalSprite) { //IL_002b: 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_0033: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0054: Unknown result type (might be due to invalid IL or missing references) Texture2D scrapTexture = _scrapTexture; if (Object.op_Implicit((Object)(object)_scrapSprite) || (Object)(object)scrapTexture == (Object)null) { return _scrapSprite; } float num; if ((Object)(object)originalSprite != (Object)null) { Bounds bounds = originalSprite.bounds; if (((Bounds)(ref bounds)).size.x > 0f) { bounds = originalSprite.bounds; num = ((Bounds)(ref bounds)).size.x; goto IL_005e; } } num = 1f; goto IL_005e; IL_005e: float num2 = num; float num3 = (float)((Texture)scrapTexture).width / num2; _scrapSprite = Sprite.Create(scrapTexture, new Rect(0f, 0f, (float)((Texture)scrapTexture).width, (float)((Texture)scrapTexture).height), new Vector2(0.5f, 0.5f), num3); ((Object)_scrapSprite).name = "PingPlusScrapIconSprite"; ((Object)_scrapSprite).hideFlags = (HideFlags)61; scrapTexture.Apply(false, true); return _scrapSprite; } } internal static class PingDistance { private sealed class State { public string BaseText { get; set; } = string.Empty; public string RenderedText { get; set; } = string.Empty; public int LastMeters { get; set; } = int.MinValue; } private const char SuffixMarker = '\u200b'; private static readonly ConditionalWeakTable<PingIndicator, State> States = new ConditionalWeakTable<PingIndicator, State>(); public static void Update(PingIndicator indicator, bool enabled) { //IL_00c0: 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) if (!Object.op_Implicit((Object)(object)indicator.pingText)) { return; } State value = States.GetValue(indicator, (PingIndicator _) => new State()); string text = ((TMP_Text)indicator.pingText).text; if (text != value.RenderedText) { value.BaseText = StripDistance(text); value.LastMeters = int.MinValue; } LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null); if (!enabled || (Object)(object)val == (Object)null) { if (text != value.BaseText) { ((TMP_Text)indicator.pingText).text = value.BaseText; } value.RenderedText = value.BaseText; value.LastMeters = int.MinValue; return; } int num = Mathf.RoundToInt(Vector3.Distance(val.footPosition, ((Component)indicator).transform.position)); if (num != value.LastMeters || !(text == value.RenderedText)) { value.RenderedText = $"{value.BaseText}{'\u200b'}<size=70%> ({num}m)</size>"; value.LastMeters = num; ((TMP_Text)indicator.pingText).text = value.RenderedText; } } private static string StripDistance(string text) { int num = text.IndexOf('\u200b'); if (num < 0) { return text; } return text.Substring(0, num); } } internal static class PingLayout { private const float ScreenPadding = 8f; public static void Update(PingIndicator indicator) { if (Object.op_Implicit((Object)(object)indicator.pingText)) { ((TMP_Text)indicator.pingText).overflowMode = (TextOverflowModes)0; } } public static void ClampToViewport(PingIndicator indicator, Camera camera) { //IL_004b: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0079: 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_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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_016f: 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_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)indicator.positionIndicator) || !Object.op_Implicit((Object)(object)camera)) { return; } if (Object.op_Implicit((Object)(object)indicator.pingText) && ((Behaviour)indicator.pingText).enabled) { ((TMP_Text)indicator.pingText).ForceMeshUpdate(false, false); } Transform transform = indicator.positionIndicator.transform; Vector3 val = camera.WorldToScreenPoint(transform.position); if (!(val.z <= 0f) && TryGetScreenBounds(indicator, camera, out var min, out var max)) { Rect pixelRect = camera.pixelRect; Rect safeArea = Screen.safeArea; float num = Mathf.Max(((Rect)(ref pixelRect)).xMin, ((Rect)(ref safeArea)).xMin) + 8f; float num2 = Mathf.Min(((Rect)(ref pixelRect)).xMax, ((Rect)(ref safeArea)).xMax) - 8f; float num3 = Mathf.Max(((Rect)(ref pixelRect)).yMin, ((Rect)(ref safeArea)).yMin) + 8f; float num4 = Mathf.Min(((Rect)(ref pixelRect)).yMax, ((Rect)(ref safeArea)).yMax) - 8f; Vector2 zero = Vector2.zero; if (min.x < num) { zero.x += num - min.x; } else if (max.x > num2) { zero.x -= max.x - num2; } if (min.y < num3) { zero.y += num3 - min.y; } else if (max.y > num4) { zero.y -= max.y - num4; } if (!(zero == Vector2.zero)) { val.x += zero.x; val.y += zero.y; transform.position = camera.ScreenToWorldPoint(val); } } } private static bool TryGetScreenBounds(PingIndicator indicator, Camera camera, out Vector2 min, out Vector2 max) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) min = new Vector2(float.PositiveInfinity, float.PositiveInfinity); max = new Vector2(float.NegativeInfinity, float.NegativeInfinity); bool result = false; Renderer[] componentsInChildren = ((Component)indicator.positionIndicator).GetComponentsInChildren<Renderer>(true); Vector3 val2 = default(Vector3); foreach (Renderer val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val) || !val.enabled || !((Component)val).gameObject.activeInHierarchy) { continue; } Bounds bounds = val.bounds; for (int j = 0; j < 8; j++) { ((Vector3)(ref val2))..ctor(((j & 1) == 0) ? ((Bounds)(ref bounds)).min.x : ((Bounds)(ref bounds)).max.x, ((j & 2) == 0) ? ((Bounds)(ref bounds)).min.y : ((Bounds)(ref bounds)).max.y, ((j & 4) == 0) ? ((Bounds)(ref bounds)).min.z : ((Bounds)(ref bounds)).max.z); Vector3 val3 = camera.WorldToScreenPoint(val2); if (!(val3.z <= 0f)) { min = Vector2.Min(min, Vector2.op_Implicit(val3)); max = Vector2.Max(max, Vector2.op_Implicit(val3)); result = true; } } } return result; } } internal sealed class PinnedPing { private static readonly string[] Names = new string[20] { "ALPHA", "BETA", "GAMMA", "DELTA", "EPSILON", "ZETA", "ETA", "THETA", "IOTA", "KAPPA", "LAMBDA", "MU", "NU", "XI", "OMICRON", "PI", "RHO", "SIGMA", "TAU", "UPSILON" }; public NetworkInstanceId OwnerId { get; } public NetworkInstanceId TargetId { get; } public PingIndicator Indicator { get; } public int LabelIndex { get; } public PinnedPing(NetworkInstanceId ownerId, NetworkInstanceId targetId, PingIndicator indicator, int labelIndex) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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) OwnerId = ownerId; TargetId = targetId; Indicator = indicator; LabelIndex = labelIndex; } public static string GetDisplayName(int labelIndex) { if (labelIndex < 0 || labelIndex >= Names.Length) { return $"PING {labelIndex + 1}"; } return Names[labelIndex]; } } [BepInPlugin("com.cirillom.pingplus", "Ping Plus", "1.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private sealed class ItemPingReported : MonoBehaviour { } private sealed class ServerPinnedPing(NetworkInstanceId ownerId, NetworkInstanceId targetId, Vector3 origin, Vector3 normal, int labelIndex, float expiresAt) { public NetworkInstanceId OwnerId { get; } = ownerId; public NetworkInstanceId TargetId { get; } = targetId; public Vector3 Origin { get; } = origin; public Vector3 Normal { get; } = normal; public int LabelIndex { get; } = labelIndex; public float ExpiresAt { get; } = expiresAt; } [CompilerGenerated] private static class <>O { public static hook_UpdatePositions <0>__PositionIndicatorUpdatePositions; public static hook_RebuildPing <1>__PingIndicatorRebuildPing; public static hook_Update <2>__PingIndicatorUpdate; public static Func<KeyCode, bool> <3>__GetKey; } private const int MaximumPlayers = 4; private const int SlotsPerPlayer = 5; public const string PluginGuid = "com.cirillom.pingplus"; public const string PluginName = "Ping Plus"; public const string PluginVersion = "1.3.0"; private readonly List<PinnedPing> _pinnedPings = new List<PinnedPing>(); private readonly List<ServerPinnedPing> _serverPinnedPings = new List<ServerPinnedPing>(); private readonly Dictionary<NetworkInstanceId, int> _playerBlocks = new Dictionary<NetworkInstanceId, int>(); private ConfigEntry<float> _duration; private ConfigEntry<int> _maximum; private ConfigEntry<KeyboardShortcut> _pinKey; private ConfigEntry<KeyboardShortcut> _clearKey; private ConfigEntry<bool> _showDistance; internal static Plugin Instance { get; private set; } private void Awake() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown Instance = this; PingAppearance.Initialize(((BaseUnityPlugin)this).Logger); _duration = ((BaseUnityPlugin)this).Config.Bind<float>("Pinned Pings", "PinnedPingDuration", 0f, new ConfigDescription("Pinned ping lifetime in seconds. Use 0 to keep pings until removed or the stage ends.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3600f), Array.Empty<object>())); _maximum = ((BaseUnityPlugin)this).Config.Bind<int>("Pinned Pings", "MaxPinnedPings", 5, new ConfigDescription("Maximum number of pinned pings per player. Creating another removes their oldest.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), Array.Empty<object>())); _pinKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Pinned Pings", "PinKey", new KeyboardShortcut((KeyCode)103, Array.Empty<KeyCode>()), "Key used to create or remove a pinned ping at the crosshair."); _clearKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Pinned Pings", "ClearKey", new KeyboardShortcut((KeyCode)112, Array.Empty<KeyCode>()), "Key used to remove only the pinned pings you created."); _showDistance = ((BaseUnityPlugin)this).Config.Bind<bool>("Ping Display", "ShowDistance", true, "Show the local player's distance to normal and pinned pings."); NetworkingAPI.RegisterMessageType<PinnedPingRequestMessage>(); NetworkingAPI.RegisterMessageType<PinnedPingStateMessage>(); NetworkingAPI.RegisterMessageType<ClearPinnedPingsRequestMessage>(); NetworkingAPI.RegisterMessageType<ItemPingRequestMessage>(); PlayerCharacterMasterController.Update += new hook_Update(PlayerCharacterMasterControllerUpdate); object obj = <>O.<0>__PositionIndicatorUpdatePositions; if (obj == null) { hook_UpdatePositions val = PositionIndicatorUpdatePositions; <>O.<0>__PositionIndicatorUpdatePositions = val; obj = (object)val; } PositionIndicator.UpdatePositions += (hook_UpdatePositions)obj; object obj2 = <>O.<1>__PingIndicatorRebuildPing; if (obj2 == null) { hook_RebuildPing val2 = PingIndicatorRebuildPing; <>O.<1>__PingIndicatorRebuildPing = val2; obj2 = (object)val2; } PingIndicator.RebuildPing += (hook_RebuildPing)obj2; object obj3 = <>O.<2>__PingIndicatorUpdate; if (obj3 == null) { hook_Update val3 = PingIndicatorUpdate; <>O.<2>__PingIndicatorUpdate = val3; obj3 = (object)val3; } PingIndicator.Update += (hook_Update)obj3; Stage.onStageStartGlobal += OnStageStart; NetworkUser.onPostNetworkUserStart += new NetworkUserGenericDelegate(OnPostNetworkUserStart); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Ping Plus loaded! Press {_pinKey.Value} to toggle a shared pinned ping or {_clearKey.Value} to clear your pinned pings."); } private void Update() { _pinnedPings.RemoveAll((PinnedPing ping) => !Object.op_Implicit((Object)(object)ping.Indicator)); if (NetworkServer.active) { UpdateServerPinnedPings(); } } private void PlayerCharacterMasterControllerUpdate(orig_Update orig, PlayerCharacterMasterController self) { //IL_0016: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0037: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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) orig.Invoke(self); if (!self.hasEffectiveAuthority) { return; } if (IsShortcutDown(_clearKey.Value)) { NetworkInstanceId networkId = GetNetworkId(((Component)self).gameObject); if (networkId == default(NetworkInstanceId)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not clear pinned pings because the local player has no network identity."); } else if (NetworkServer.active) { ReceiveClearPinnedPingsRequest(networkId); } else { NetMessageExtensions.Send((INetMessage)(object)new ClearPinnedPingsRequestMessage(networkId), (NetworkDestination)2); } } else { PingInfo val = default(PingInfo); if (!Object.op_Implicit((Object)(object)self.bodyInputs) || !Object.op_Implicit((Object)(object)self.body) || !IsShortcutDown(_pinKey.Value) || !PingerController.GeneratePingInfo(new Ray(self.bodyInputs.aimOrigin, self.bodyInputs.aimDirection), ((Component)self.body).gameObject, ref val) || !Object.op_Implicit((Object)(object)((PingInfo)(ref val)).targetGameObject)) { return; } NetworkInstanceId networkId2 = GetNetworkId(((Component)self).gameObject); if (networkId2 == default(NetworkInstanceId)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not pin ping because the local player has no network identity."); return; } ClearNormalPingForTarget(self, ((PingInfo)(ref val)).targetGameObject); PinnedPingRequestMessage pinnedPingRequestMessage = new PinnedPingRequestMessage(networkId2, GetNetworkId(((PingInfo)(ref val)).targetGameObject), val.origin, val.normal, _duration.Value, _maximum.Value); if (NetworkServer.active) { ReceivePinnedPingRequest(pinnedPingRequestMessage); } else { NetMessageExtensions.Send((INetMessage)(object)pinnedPingRequestMessage, (NetworkDestination)2); } } } private static void PingIndicatorRebuildPing(orig_RebuildPing orig, PingIndicator self) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Invalid comparison between Unknown and I4 //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); PingAppearance.TryApply(self); if (!Object.op_Implicit((Object)(object)self.pingOwner) || !Object.op_Implicit((Object)(object)self.pingTarget) || Object.op_Implicit((Object)(object)((Component)self).GetComponent<ItemPingReported>()) || !HasAuthority(self.pingOwner) || !PingAppearance.TryGetPickupIndex(self.pingTarget, out var pickupIndex)) { return; } PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); if (pickupDef != null && ((int)pickupDef.itemIndex != -1 || (int)pickupDef.equipmentIndex != -1)) { ((Component)self).gameObject.AddComponent<ItemPingReported>(); if (NetworkServer.active) { Instance.BroadcastItemOwnership(pickupIndex); } else { NetMessageExtensions.Send((INetMessage)(object)new ItemPingRequestMessage(pickupIndex), (NetworkDestination)2); } } } private static void PingIndicatorUpdate(orig_Update orig, PingIndicator self) { orig.Invoke(self); if (Object.op_Implicit((Object)(object)self)) { PingDistance.Update(self, Instance._showDistance.Value); PingAppearance.TryApply(self); PingAppearance.SyncTextColorToIcon(self); PingLayout.Update(self); } } internal void BroadcastItemOwnership(PickupIndex pickupIndex) { //IL_0018: 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_0037: Invalid comparison between Unknown and I4 //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Invalid comparison between Unknown and I4 //IL_00b1: 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_00db: Expected O, but got Unknown if (!NetworkServer.active || !((PickupIndex)(ref pickupIndex)).isValid) { return; } PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); if (pickupDef != null && ((int)pickupDef.itemIndex != -1 || (int)pickupDef.equipmentIndex != -1)) { string[] array = (from entry in NetworkUser.readOnlyInstancesList.Select(delegate(NetworkUser user) { CharacterMaster master = user.master; return new { User = user, Count = GetCount((master != null) ? master.inventory : null, pickupDef) }; }) where entry.Count > 0 select $"{Util.EscapeRichTextForTextMeshPro(entry.User.userName)} ×{entry.Count}").ToArray(); if (array.Length != 0) { Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = "<style=cSub>Owned by: " + string.Join(", ", array) + "</style>" }); } } } internal void ReceivePinnedPingRequest(PinnedPingRequestMessage message) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || !IsPlayerOwner(message.OwnerId) || message.TargetId == default(NetworkInstanceId) || !Object.op_Implicit((Object)(object)Util.FindNetworkObject(message.TargetId))) { return; } int num = _serverPinnedPings.FindIndex((ServerPinnedPing ping) => ping.OwnerId == message.OwnerId && ping.TargetId == message.TargetId); if (num >= 0) { RemoveServerPinnedPingAt(num); return; } int orAssignPlayerBlock = GetOrAssignPlayerBlock(message.OwnerId); if (orAssignPlayerBlock < 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)$"Could not pin target for owner {message.OwnerId}: all {4} player label blocks are in use."); return; } int num2 = Mathf.Clamp(message.Maximum, 1, 5); while (_serverPinnedPings.Count((ServerPinnedPing ping) => ping.OwnerId == message.OwnerId) >= num2) { int index = _serverPinnedPings.FindIndex((ServerPinnedPing ping) => ping.OwnerId == message.OwnerId); RemoveServerPinnedPingAt(index); } int num3 = FindAvailableLocalSlot(message.OwnerId); float num4 = Mathf.Clamp(message.Duration, 0f, 3600f); ServerPinnedPing serverPinnedPing = new ServerPinnedPing(message.OwnerId, message.TargetId, message.Origin, message.Normal, orAssignPlayerBlock * 5 + num3, (num4 == 0f) ? float.PositiveInfinity : (Time.time + num4)); _serverPinnedPings.Add(serverPinnedPing); BroadcastPinnedPingState(CreateAddMessage(serverPinnedPing, num4)); } internal void ReceivePinnedPingState(PinnedPingStateMessage message) { if (!NetworkServer.active) { ApplyPinnedPingState(message); } } internal void ReceiveClearPinnedPingsRequest(NetworkInstanceId ownerId) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && IsPlayerOwner(ownerId)) { ClearServerPinnedPings(ownerId, broadcast: true); } } private void ApplyPinnedPingState(PinnedPingStateMessage message) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) switch (message.Operation) { case PinnedPingOperation.Add: ApplyPinnedPing(message); break; case PinnedPingOperation.Remove: RemoveRenderedPinnedPing(message.OwnerId, message.LabelIndex); break; case PinnedPingOperation.ClearOwner: ClearRenderedPinnedPings(message.OwnerId); break; case PinnedPingOperation.ClearAll: ClearRenderedPinnedPings(); break; } } private void ApplyPinnedPing(PinnedPingStateMessage message) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) GameObject val = Util.FindNetworkObject(message.OwnerId); GameObject val2 = Util.FindNetworkObject(message.TargetId); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)$"Could not resolve pinned ping owner {message.OwnerId} or target {message.TargetId}."); return; } RemoveRenderedPinnedPings((PinnedPing ping) => ping.OwnerId == message.OwnerId && (ping.TargetId == message.TargetId || ping.LabelIndex == message.LabelIndex)); GameObject val3 = LegacyResourcesAPI.Load<GameObject>("Prefabs/PingIndicator"); if (!Object.op_Implicit((Object)(object)val3)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not load the vanilla ping indicator prefab."); return; } PingIndicator component = Object.Instantiate<GameObject>(val3).GetComponent<PingIndicator>(); component.pingOwner = val; component.pingOrigin = message.Origin; component.pingNormal = message.Normal; component.pingTarget = val2; component.RebuildPing(); component.fixedTimer = (component.pingDuration = ((message.Duration == 0f) ? float.PositiveInfinity : message.Duration)); PingAppearance.TryApply(component); string displayName = PinnedPing.GetDisplayName(message.LabelIndex); ((TMP_Text)component.pingText).text = "<b>" + displayName + "</b>"; PingAppearance.SyncTextColorToIcon(component); PingLayout.Update(component); _pinnedPings.Add(new PinnedPing(message.OwnerId, message.TargetId, component, message.LabelIndex)); } private static bool HasAuthority(GameObject owner) { NetworkIdentity componentInParent = owner.GetComponentInParent<NetworkIdentity>(); if (Object.op_Implicit((Object)(object)componentInParent)) { return componentInParent.hasAuthority; } return false; } private static void PositionIndicatorUpdatePositions(orig_UpdatePositions orig, UICamera uiCamera) { orig.Invoke(uiCamera); if (!Object.op_Implicit((Object)(object)uiCamera) || !Object.op_Implicit((Object)(object)uiCamera.camera)) { return; } for (int i = 0; i < PingIndicator.instancesList.Count; i++) { PingIndicator val = PingIndicator.instancesList[i]; if (Object.op_Implicit((Object)(object)val)) { PingLayout.ClampToViewport(val, uiCamera.camera); } } } private static void ClearNormalPingForTarget(PlayerCharacterMasterController controller, GameObject target) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) PingerController component = ((Component)controller).GetComponent<PingerController>(); if (Object.op_Implicit((Object)(object)component) && (Object)(object)((PingInfo)(ref component.currentPing)).targetGameObject == (Object)(object)target) { component.SetCurrentPing(PingerController.emptyPing); } } private static bool IsShortcutDown(KeyboardShortcut shortcut) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) if ((int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey)) { return ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey); } return false; } private static NetworkInstanceId GetNetworkId(GameObject? value) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0024: 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 ((Object)(object)value == (Object)null) { return default(NetworkInstanceId); } NetworkIdentity componentInParent = value.GetComponentInParent<NetworkIdentity>(); if (!Object.op_Implicit((Object)(object)componentInParent)) { return default(NetworkInstanceId); } return componentInParent.netId; } private static bool IsPlayerOwner(NetworkInstanceId ownerId) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GameObject val = Util.FindNetworkObject(ownerId); if (Object.op_Implicit((Object)(object)val)) { return Object.op_Implicit((Object)(object)val.GetComponentInParent<PlayerCharacterMasterController>()); } return false; } private int GetOrAssignPlayerBlock(NetworkInstanceId ownerId) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (_playerBlocks.TryGetValue(ownerId, out var value)) { return value; } HashSet<int> hashSet = _playerBlocks.Values.ToHashSet(); for (value = 0; value < 4; value++) { if (!hashSet.Contains(value)) { _playerBlocks.Add(ownerId, value); return value; } } return -1; } private int FindAvailableLocalSlot(NetworkInstanceId ownerId) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) HashSet<int> hashSet = (from ping in _serverPinnedPings where ping.OwnerId == ownerId select ping.LabelIndex % 5).ToHashSet(); for (int num = 0; num < 5; num++) { if (!hashSet.Contains(num)) { return num; } } return 0; } private void UpdateServerPinnedPings() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) NetworkInstanceId[] array = _playerBlocks.Keys.Where((NetworkInstanceId ownerId) => !IsPlayerOwner(ownerId)).ToArray(); foreach (NetworkInstanceId val in array) { ClearServerPinnedPings(val, broadcast: true); _playerBlocks.Remove(val); } for (int num2 = _serverPinnedPings.Count - 1; num2 >= 0; num2--) { ServerPinnedPing serverPinnedPing = _serverPinnedPings[num2]; if (!Object.op_Implicit((Object)(object)Util.FindNetworkObject(serverPinnedPing.TargetId)) || Time.time >= serverPinnedPing.ExpiresAt) { RemoveServerPinnedPingAt(num2); } } } private void RemoveServerPinnedPingAt(int index) { //IL_001c: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0042: Unknown result type (might be due to invalid IL or missing references) ServerPinnedPing serverPinnedPing = _serverPinnedPings[index]; _serverPinnedPings.RemoveAt(index); NetworkInstanceId ownerId = serverPinnedPing.OwnerId; int labelIndex = serverPinnedPing.LabelIndex; BroadcastPinnedPingState(new PinnedPingStateMessage(PinnedPingOperation.Remove, ownerId, default(NetworkInstanceId), default(Vector3), default(Vector3), 0f, labelIndex)); } private void ClearServerPinnedPings(NetworkInstanceId ownerId, bool broadcast) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0044: 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) _serverPinnedPings.RemoveAll((ServerPinnedPing ping) => ping.OwnerId == ownerId); if (broadcast) { BroadcastPinnedPingState(new PinnedPingStateMessage(PinnedPingOperation.ClearOwner, ownerId)); } } private void BroadcastPinnedPingState(PinnedPingStateMessage message) { if (NetworkClient.active) { ApplyPinnedPingState(message); } NetMessageExtensions.Send((INetMessage)(object)message, (NetworkDestination)1); } private static PinnedPingStateMessage CreateAddMessage(ServerPinnedPing ping, float duration) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) return new PinnedPingStateMessage(PinnedPingOperation.Add, ping.OwnerId, ping.TargetId, ping.Origin, ping.Normal, duration, ping.LabelIndex); } private void OnPostNetworkUserStart(NetworkUser networkUser) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || ((NetworkBehaviour)networkUser).connectionToClient == null) { return; } NetMessageExtensions.Send((INetMessage)(object)new PinnedPingStateMessage(PinnedPingOperation.ClearAll), ((NetworkBehaviour)networkUser).connectionToClient); foreach (ServerPinnedPing serverPinnedPing in _serverPinnedPings) { bool num = float.IsPositiveInfinity(serverPinnedPing.ExpiresAt); float num2 = (num ? 0f : (serverPinnedPing.ExpiresAt - Time.time)); if (num || !(num2 <= 0f)) { NetMessageExtensions.Send((INetMessage)(object)CreateAddMessage(serverPinnedPing, num2), ((NetworkBehaviour)networkUser).connectionToClient); } } } private void OnStageStart(Stage _) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0037: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active) { _serverPinnedPings.Clear(); BroadcastPinnedPingState(new PinnedPingStateMessage(PinnedPingOperation.ClearAll)); } else { ClearRenderedPinnedPings(); } } private static int GetCount(Inventory? inventory, PickupDef pickupDef) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)inventory == (Object)null) { return 0; } if ((int)pickupDef.itemIndex != -1) { return inventory.GetItemCountEffective(pickupDef.itemIndex); } if ((int)pickupDef.equipmentIndex == -1 || !inventory.HasEquipment(pickupDef.equipmentIndex)) { return 0; } return 1; } private void RemoveRenderedPinnedPing(NetworkInstanceId ownerId, int labelIndex) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) RemoveRenderedPinnedPings((PinnedPing ping) => ping.OwnerId == ownerId && ping.LabelIndex == labelIndex); } private void ClearRenderedPinnedPings(NetworkInstanceId ownerId) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) RemoveRenderedPinnedPings((PinnedPing ping) => ping.OwnerId == ownerId); } private void RemoveRenderedPinnedPings(Predicate<PinnedPing> predicate) { for (int num = _pinnedPings.Count - 1; num >= 0; num--) { PinnedPing pinnedPing = _pinnedPings[num]; if (predicate(pinnedPing)) { if (Object.op_Implicit((Object)(object)pinnedPing.Indicator)) { Object.Destroy((Object)(object)((Component)pinnedPing.Indicator).gameObject); } _pinnedPings.RemoveAt(num); } } } private void ClearRenderedPinnedPings() { foreach (PinnedPing pinnedPing in _pinnedPings) { if (Object.op_Implicit((Object)(object)pinnedPing.Indicator)) { Object.Destroy((Object)(object)((Component)pinnedPing.Indicator).gameObject); } } _pinnedPings.Clear(); } } }