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 PermaPings v1.0.4
BepInEx/plugins/PermaPings.dll
Decompiled 6 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using IL.RoR2.UI; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using On.RoR2; using On.RoR2.UI; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PermaPings")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PermaPings")] [assembly: AssemblyTitle("PermaPings")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 PermaPings { internal static class Hooks { [CompilerGenerated] private static class <>O { public static hook_Update <0>__PlayerCharacterMasterController_Update; public static Action<Stage> <1>__ResetPings; public static Manipulator <2>__IL_PingIndicator_Update; public static hook_Update <3>__PingIndicator_Update; } public static void Init() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0074: 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_007f: Expected O, but got Unknown object obj = <>O.<0>__PlayerCharacterMasterController_Update; if (obj == null) { hook_Update val = PlayerCharacterMasterController_Update; <>O.<0>__PlayerCharacterMasterController_Update = val; obj = (object)val; } PlayerCharacterMasterController.Update += (hook_Update)obj; Stage.onServerStageComplete += PermaPingerController.ResetPings; object obj2 = <>O.<2>__IL_PingIndicator_Update; if (obj2 == null) { Manipulator val2 = IL_PingIndicator_Update; <>O.<2>__IL_PingIndicator_Update = val2; obj2 = (object)val2; } PingIndicator.Update += (Manipulator)obj2; object obj3 = <>O.<3>__PingIndicator_Update; if (obj3 == null) { hook_Update val3 = PingIndicator_Update; <>O.<3>__PingIndicator_Update = val3; obj3 = (object)val3; } PingIndicator.Update += (hook_Update)obj3; } private static void PingIndicator_Update(orig_Update orig, PingIndicator self) { orig.Invoke(self); BarrelInteraction val = default(BarrelInteraction); if (Object.op_Implicit((Object)(object)self.pingTarget) && self.pingTarget.TryGetComponent<BarrelInteraction>(ref val) && val.opened) { self.DestroyPing(); } } private static void IL_PingIndicator_Update(ILContext il) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel label = null; val.GotoNext(new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref label), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCall<PingIndicator>(x, "DestroyPing") }); int index = val.Index; val.Index = index + 1; val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<PingIndicator, bool>>((Func<PingIndicator, bool>)delegate(PingIndicator ping) { //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) //IL_001f: 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_0024: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 PurchaseInteraction val2 = default(PurchaseInteraction); if (ping.pingTarget.TryGetComponent<PurchaseInteraction>(ref val2)) { CostTypeIndex costType = val2.costType; if (1 == 0) { } bool result = ((costType - 4 <= 2 || (int)costType == 10) ? true : false); if (1 == 0) { } return result; } return false; }); val.Emit(OpCodes.Brtrue_S, (object)label); } private static void PlayerCharacterMasterController_Update(orig_Update orig, PlayerCharacterMasterController self) { //IL_003d: 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_004d: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); if (self.hasEffectiveAuthority && Object.op_Implicit((Object)(object)self.bodyInputs) && Object.op_Implicit((Object)(object)self.body) && PermaPingsConfig.GetPermaPingKeyDown()) { PermaPingerController.AttemptPing(new Ray(self.bodyInputs.aimOrigin, self.bodyInputs.aimDirection), ((Component)self.body).gameObject, ((Component)self).gameObject); } } } internal static class PermaPingerController { private static List<PingInfo> permapings = new List<PingInfo>(); public static List<PingIndicator> permapingsIndicators = new List<PingIndicator>(); public static void AttemptPing(Ray aimRay, GameObject bodyObject, GameObject owner) { //IL_0007: 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_0061: Unknown result type (might be due to invalid IL or missing references) PingInfo result = default(PingInfo); if (PingerController.GeneratePingInfo(aimRay, bodyObject, ref result) && (Object)(object)result.targetNetworkIdentity != (Object)null) { int num = permapings.FindIndex((PingInfo permaping) => (Object)(object)permaping.targetNetworkIdentity == (Object)(object)result.targetNetworkIdentity); if (num == -1) { permapings.Add(result); BuildPing(result, owner); } else { RemovePing(num); } } } public static void AttemptRemovePing(NetworkIdentity networkIdentity) { int num = permapings.FindIndex((PingInfo permaping) => (Object)(object)permaping.targetNetworkIdentity == (Object)(object)networkIdentity); if (num != -1) { RemovePing(num); } } private static void BuildPing(PingInfo pingInfo, GameObject owner) { //IL_0021: 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_002e: 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_006f: 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_00c9: 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_00ce: 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) GameObject val = Object.Instantiate<GameObject>(LegacyResourcesAPI.Load<GameObject>("Prefabs/PingIndicator")); PingIndicator component = val.GetComponent<PingIndicator>(); component.pingOwner = owner; component.pingOrigin = pingInfo.origin; component.pingNormal = pingInfo.normal; component.pingTarget = ((PingInfo)(ref pingInfo)).targetGameObject; component.RebuildPing(); component.fixedTimer = float.PositiveInfinity; Transform parent = component.interactablePingGameObjects[0].transform.parent; parent.localScale *= PermaPingsConfig.permaPingSize.Value / 100f; Color? itemColor = GetItemColor(((PingInfo)(ref pingInfo)).targetGameObject); SpriteRenderer[] componentsInChildren = ((Component)parent).GetComponentsInChildren<SpriteRenderer>(); foreach (SpriteRenderer val2 in componentsInChildren) { Color color = (Color)(((??)itemColor) ?? val2.color); color.a *= PermaPingsConfig.permaPingAlpha.Value / 100f; val2.color = color; } TextMeshPro pingText = component.pingText; ((TMP_Text)pingText).fontSize = ((TMP_Text)pingText).fontSize * (PermaPingsConfig.permaPingSize.Value / 100f); TextMeshPro pingText2 = component.pingText; ((TMP_Text)pingText2).alpha = ((TMP_Text)pingText2).alpha * (PermaPingsConfig.permaPingAlpha.Value / 100f); permapingsIndicators.Add(component); } private static Color? GetItemColor(GameObject interactable) { //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_0046: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) if (!PermaPingsConfig.permaPingItemTierColor.Value) { return null; } GenericPickupController val = default(GenericPickupController); UniquePickup val2; if (interactable.TryGetComponent<GenericPickupController>(ref val)) { val2 = val.pickup; return ((PickupIndex)(ref val2.pickupIndex)).pickupDef.baseColor; } PickupPickerController val3 = default(PickupPickerController); if ((Object)(object)interactable.GetComponent<ScrapperController>() == (Object)null && interactable.TryGetComponent<PickupPickerController>(ref val3) && val3.options.Length != 0) { return ((PickupIndex)(ref val3.options[0].pickup.pickupIndex)).pickupDef.baseColor; } ShopTerminalBehavior val4 = default(ShopTerminalBehavior); if (interactable.TryGetComponent<ShopTerminalBehavior>(ref val4)) { val2 = val4.CurrentPickup(); return ((PickupIndex)(ref val2.pickupIndex)).pickupDef.baseColor; } return null; } internal static void RemovePing(int index) { permapings.RemoveAt(index); if ((Object)(object)permapingsIndicators[index] != (Object)null && (Object)(object)((Component)permapingsIndicators[index]).gameObject != (Object)null) { PingIndicator obj = permapingsIndicators[index]; Object.Destroy((Object)(object)((obj != null) ? ((Component)obj).gameObject : null)); } permapingsIndicators.RemoveAt(index); } internal static void ResetPings(Stage stage) { permapings = new List<PingInfo>(); permapingsIndicators = new List<PingIndicator>(); } } [BepInPlugin("kyryh.permapings", "PermaPings", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class PermaPings : BaseUnityPlugin { public const string PluginGUID = "kyryh.permapings"; public const string PluginName = "PermaPings"; public const string PluginVersion = "1.0.0"; public static ManualLogSource Log { get; private set; } private void Awake() { Log = ((BaseUnityPlugin)this).Logger; PermaPingsConfig.Init(((BaseUnityPlugin)this).Config); Hooks.Init(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin kyryh.permapings is loaded!"); } public static void LogDebug(object data) { Log.LogDebug(data); } public static void LogError(object data) { Log.LogError(data); } } internal static class PermaPingsConfig { public static ConfigEntry<KeyboardShortcut> permaPingKey; public static ConfigEntry<float> permaPingAlpha; public static ConfigEntry<float> permaPingSize; public static ConfigEntry<bool> permaPingItemTierColor; public static void Init(ConfigFile config) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) permaPingKey = config.Bind<KeyboardShortcut>("Keybinds", "PermaPingButton", new KeyboardShortcut((KeyCode)326, Array.Empty<KeyCode>()), "Which key to use to place a permanent ping"); permaPingAlpha = config.Bind<float>("Visuals", "PermaPingAlpha", 50f, "Alpha value of the perma-ping icon, i.e. how opaque it is\n100 means it's completely visible, 0 means it's completely transparent"); permaPingSize = config.Bind<float>("Visuals", "PermaPingSize", 75f, "Size of the perma-ping icon and text"); permaPingItemTierColor = config.Bind<bool>("Visuals", "PermaPingItemTierColor", true, "Whether to use the pinged item's tier as the ping's color"); if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions")) { AddConfigOptions(); } } public static bool GetPermaPingKeyDown() { //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_0013: Unknown result type (might be due to invalid IL or missing references) IInputSystem current = UnityInput.Current; KeyboardShortcut value = permaPingKey.Value; return current.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static void AddConfigOptions() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new KeyBindOption(permaPingKey)); ModSettingsManager.AddOption((BaseOption)new SliderOption(permaPingAlpha, new SliderConfig { min = 0f, max = 100f })); ModSettingsManager.AddOption((BaseOption)new SliderOption(permaPingSize, new SliderConfig { min = 0f, max = 100f })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(permaPingItemTierColor)); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "PermaPings"; public const string PLUGIN_NAME = "PermaPings"; public const string PLUGIN_VERSION = "1.0.0"; } }