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 DroneTargetFilter v0.1.0
plugins/DroneTargetFilter/DroneTargetFilter.dll
Decompiled 9 hours agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [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("saya")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("DroneTargetFilter")] [assembly: AssemblyTitle("DroneTargetFilter")] [assembly: AssemblyVersion("0.1.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 DroneTargetFilter { [HarmonyPatch(typeof(ItemDrone), "Start")] internal static class DroneTargetPatch { [HarmonyPostfix] [HarmonyPriority(0)] internal static void Postfix(ItemDrone __instance, ref ITargetingCondition? ___customTargetingCondition, bool __runOriginal) { if (__runOriginal && Object.op_Implicit((Object)(object)__instance) && !(___customTargetingCondition is NonDroneTargetCondition) && (Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<ItemDroneFeather>()) || Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<ItemDroneZeroGravity>()) || Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<ItemDroneTorque>()))) { ___customTargetingCondition = (ITargetingCondition?)(object)new NonDroneTargetCondition(___customTargetingCondition); } } } internal sealed class NonDroneTargetCondition(ITargetingCondition? original) : ITargetingCondition { public bool CustomTargetingCondition(GameObject target) { if (!Object.op_Implicit((Object)(object)target)) { return false; } if (Plugin.ShouldFilter && Object.op_Implicit((Object)(object)target.GetComponent<ItemDrone>())) { return false; } ITargetingCondition? obj = original; if (obj == null) { return true; } return obj.CustomTargetingCondition(target); } } [BepInPlugin("saya.DroneTargetFilter", "DroneTargetFilter", "0.1.0")] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "saya.DroneTargetFilter"; public const string PluginName = "DroneTargetFilter"; public const string PluginVersion = "0.1.0"; private readonly Harmony _harmony = new Harmony("saya.DroneTargetFilter"); private static bool _active; internal static bool ShouldFilter { get { if (_active && (Object)(object)GameManager.instance != (Object)null) { if (GameManager.Multiplayer()) { return PhotonNetwork.IsMasterClient; } return true; } return false; } } private void Awake() { ((Component)this).transform.SetParent((Transform)null); ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); try { _harmony.PatchAll(typeof(DroneTargetPatch)); _active = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"DroneTargetFilter v0.1.0 loaded. Feather, Zero Gravity and Roll Drones exclude drone targets on the host."); } catch (Exception arg) { _active = false; _harmony.UnpatchSelf(); ((Behaviour)this).enabled = false; ((BaseUnityPlugin)this).Logger.LogError((object)$"DroneTargetFilter initialization failed: {arg}"); } } private void OnDestroy() { _active = false; _harmony.UnpatchSelf(); } } }