Please disclose if your mod was created primarily 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 LandminesForAll v1.0.1
LC_LandminesForAll.dll
Decompiled 2 years 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; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using LC_LandminesForAll.Patches; using LC_LandminesForAll.Utils; using Microsoft.CodeAnalysis; 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("LC_LandminesForAll")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Templete")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+d2a1d9af8893c2a3098c4da244d009911438c0a4")] [assembly: AssemblyProduct("LC_LandminesForAll")] [assembly: AssemblyTitle("LC_LandminesForAll")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.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 LC_LandminesForAll { public class MyPluginInfo { public const string PLUGIN_GUID = "sakura.lc.landminesforall"; public const string PLUGIN_NAME = "LandminesForAll"; public const string PLUGIN_VERSION = "1.0.1"; } [BepInPlugin("sakura.lc.landminesforall", "LandminesForAll", "1.0.1")] public class Plugin : BaseUnityPlugin { private Harmony _harmony; internal static ManualLogSource Logger; public static string ThisPluginFolder => Path.Combine(Paths.PluginPath, "Sakura-LandminesForAll"); private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("sakura.lc.landminesforall"); _harmony.PatchAll(typeof(LandminePatch)); Logger.LogInfo((object)"Plugin sakura.lc.landminesforall is loaded!"); } } public static class PluginInfo { public const string PLUGIN_GUID = "LC_LandminesForAll"; public const string PLUGIN_NAME = "LC_LandminesForAll"; public const string PLUGIN_VERSION = "1.0.1"; } } namespace LC_LandminesForAll.Utils { internal static class ReflectionUtils { public static void SetPrivateField<T>(this T instance, string fieldName, object value) { typeof(T).GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic).SetValue(instance, value); } public static void SetPrivateProperty<T>(this T instance, string propertyName, object value) { typeof(T).GetProperty(propertyName, BindingFlags.Instance | BindingFlags.NonPublic).SetValue(instance, value); } public static void SetPrivateStaticField<T>(string fieldName, object value) { typeof(T).GetField(fieldName, BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, value); } public static void SetPrivateStaticProperty<T>(string propertyName, object value) { typeof(T).GetProperty(propertyName, BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, value); } public static T GetPrivateField<T>(this object instance, string fieldName) { return (T)instance.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic).GetValue(instance); } public static T GetPrivateProperty<T>(this object instance, string propertyName) { return (T)instance.GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.NonPublic).GetValue(instance); } public static T GetPrivateStaticField<T>(string fieldName) { return (T)typeof(T).GetField(fieldName, BindingFlags.Static | BindingFlags.NonPublic).GetValue(null); } public static T GetPrivateStaticProperty<T>(string propertyName) { return (T)typeof(T).GetProperty(propertyName, BindingFlags.Static | BindingFlags.NonPublic).GetValue(null); } public static void InvokePrivateMethod<T>(this T instance, string methodName, params object[] parameters) { instance.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic).Invoke(instance, parameters); } public static void InvokePrivateStaticMethod<T>(string methodName, params object[] parameters) { typeof(T).GetMethod(methodName, BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, parameters); } public static T CreatePrivateInstance<T>(params object[] parameters) { return (T)Activator.CreateInstance(typeof(T), BindingFlags.Instance | BindingFlags.NonPublic, null, parameters, null); } public static T CreatePrivateStaticInstance<T>(params object[] parameters) { return (T)Activator.CreateInstance(typeof(T), BindingFlags.Static | BindingFlags.NonPublic, null, parameters, null); } } } namespace LC_LandminesForAll.Patches { [HarmonyPatch(typeof(Landmine))] internal class LandminePatch { private const int LineOfSightLayer = 18; private const int EnemyLayer = 19; [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start(Landmine __instance) { //IL_006d: 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_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_0044: Unknown result type (might be due to invalid IL or missing references) BoxCollider val = ((IEnumerable<BoxCollider>)((Component)__instance).GetComponents<BoxCollider>()).FirstOrDefault((Func<BoxCollider, bool>)((BoxCollider x) => ((Collider)x).isTrigger)); if ((Object)(object)val == (Object)null) { Plugin.Logger.LogError((object)$"Could not find mine trigger collider on mine at {((Component)__instance).transform.position}"); return; } BoxCollider obj = ((Component)__instance).gameObject.AddComponent<BoxCollider>(); ((Collider)obj).isTrigger = true; obj.size = val.size * 2f; obj.center = val.center; ((Collider)obj).enabled = true; ((Collider)obj).includeLayers = LayerMask.op_Implicit(524288); } private static void TriggerDebounce(Landmine __instance) { //IL_0017: 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_0032: 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) Transform closestEnemyForLogging = GetClosestEnemyForLogging(__instance); Plugin.Logger.LogDebug((object)$"Triggering debounce on mine at {((Component)__instance).transform.position} with closest enemy at {closestEnemyForLogging.position} at {Vector3.Distance(((Component)__instance).transform.position, ((Component)closestEnemyForLogging).transform.position)} units away."); __instance.SetPrivateField<Landmine>("pressMineDebounceTimer", 0.5f); __instance.PressMineServerRpc(); } private static void TriggerMineExplosion(Landmine __instance) { //IL_0017: 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_0032: 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) Transform closestEnemyForLogging = GetClosestEnemyForLogging(__instance); Plugin.Logger.LogDebug((object)$"Triggering debounce on mine at {((Component)__instance).transform.position} with closest enemy at {closestEnemyForLogging.position} at {Vector3.Distance(((Component)__instance).transform.position, ((Component)closestEnemyForLogging).transform.position)} units away."); __instance.InvokePrivateMethod<Landmine>("TriggerMineOnLocalClientByExiting", Array.Empty<object>()); } private static Transform GetClosestEnemyForLogging(Landmine __instance) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_001b: 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_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_0061: 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) LayerMask val = LayerMask.op_Implicit(524288); RaycastHit[] array = Physics.SphereCastAll(((Component)__instance).transform.position, 10000f, Vector3.up, 0f, LayerMask.op_Implicit(val)); Transform result = null; float num = float.MaxValue; RaycastHit[] array2 = array; for (int i = 0; i < array2.Length; i++) { RaycastHit val2 = array2[i]; if (((Component)((RaycastHit)(ref val2)).collider).CompareTag("Enemy")) { float num2 = Vector3.Distance(((Component)__instance).transform.position, ((RaycastHit)(ref val2)).transform.position); if (num2 < num) { num = num2; result = ((RaycastHit)(ref val2)).transform; } } } return result; } [HarmonyPatch("OnTriggerEnter")] [HarmonyPrefix] private static bool OnTriggerEnter(Landmine __instance, Collider other) { if (__instance.hasExploded || __instance.GetPrivateField<float>("pressMineDebounceTimer") > 0f) { return true; } if (((Component)other).CompareTag("Enemy")) { TriggerDebounce(__instance); return false; } return true; } [HarmonyPatch("OnTriggerExit")] [HarmonyPrefix] private static bool OnTriggerExit(Landmine __instance, Collider other) { if (__instance.hasExploded || __instance.GetPrivateField<float>("pressMineDebounceTimer") > 0f) { return true; } if (((Component)other).CompareTag("Enemy")) { TriggerMineExplosion(__instance); return false; } return true; } } }