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 MIMO ServerOps v0.2.0
plugins/MIMOServerOps.dll
Decompiled 5 days agousing System; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; 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("MIMOServerOps")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a5b864fbcb59cd71a7696f809259ebda7a27207f")] [assembly: AssemblyProduct("MIMOServerOps")] [assembly: AssemblyTitle("MIMOServerOps")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MIMOServerOps { [BepInPlugin("mimo.serverops", "MIMO ServerOps", "0.2.0")] public sealed class ServerOpsPlugin : BaseUnityPlugin { public const string PluginGuid = "mimo.serverops"; public const string PluginName = "MIMO ServerOps"; public const string PluginVersion = "0.2.0"; private Harmony _harmony; internal static ConfigEntry<bool> SafeEnabled; internal static ConfigEntry<float> CenterX; internal static ConfigEntry<float> CenterZ; internal static ConfigEntry<float> SafeRadius; internal static ConfigEntry<int> ConfigVersion; private void Awake() { //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_012a: Unknown result type (might be due to invalid IL or missing references) SafeEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("MarketSafeZone", "Enabled", true, "Enable Grand Market peace zone."); CenterX = ((BaseUnityPlugin)this).Config.Bind<float>("MarketSafeZone", "Center X", -841.32f, "Market center X."); CenterZ = ((BaseUnityPlugin)this).Config.Bind<float>("MarketSafeZone", "Center Z", 400.26f, "Market center Z."); SafeRadius = ((BaseUnityPlugin)this).Config.Bind<float>("MarketSafeZone", "Radius", 250f, "Peace-zone radius in meters."); ConfigVersion = ((BaseUnityPlugin)this).Config.Bind<int>("MarketSafeZone", "Config Version", 1, "Internal MIMO safe-zone config schema version."); if (ConfigVersion.Value < 2) { if (SafeRadius.Value <= 120.01f) { SafeRadius.Value = 250f; } ConfigVersion.Value = 2; ((BaseUnityPlugin)this).Config.Save(); } _harmony = new Harmony("mimo.serverops"); _harmony.PatchAll(); new ConsoleCommand("market_safezone", "market_safezone [status|on|off|radius <meters>]", new ConsoleEvent(HandleSafeZoneCommand), false, true, true, false, true, false, (ConsoleOptionsFetcher)null, false, true, true); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"ServerOps active. Market safe zone enabled={SafeEnabled.Value} center=({CenterX.Value:F1},{CenterZ.Value:F1}) r={SafeRadius.Value:F1}m"); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } internal static bool Inside(Vector3 p) { //IL_0015: 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) if (SafeEnabled == null || !SafeEnabled.Value) { return false; } float num = p.x - CenterX.Value; float num2 = p.z - CenterZ.Value; return num * num + num2 * num2 <= SafeRadius.Value * SafeRadius.Value; } private static void HandleSafeZoneCommand(ConsoleEventArgs args) { switch ((args.Length <= 1) ? "status" : args[1].ToLowerInvariant()) { case "on": SafeEnabled.Value = true; break; case "off": SafeEnabled.Value = false; break; case "radius": { if (args.Length > 2 && float.TryParse(args[2], NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { SafeRadius.Value = Math.Max(5f, result); } break; } } Console instance = Console.instance; if (instance != null) { instance.Print($"Market safe zone: enabled={SafeEnabled.Value}, center=({CenterX.Value:F1},{CenterZ.Value:F1}), radius={SafeRadius.Value:F1}m"); } } } [HarmonyPatch(typeof(SpawnSystem), "Spawn")] internal static class MarketSpawnBlockPatch { private static bool Prefix(Vector3 spawnPoint) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return !ServerOpsPlugin.Inside(spawnPoint); } } [HarmonyPatch(typeof(BaseAI), "IsEnemy", new Type[] { typeof(Character) })] internal static class MarketIsEnemyInstancePatch { private static bool Prefix(BaseAI __instance, Character other, ref bool __result) { //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) if ((Object)(object)__instance == (Object)null || (Object)(object)other == (Object)null) { return true; } if (!ServerOpsPlugin.Inside(((Component)__instance).transform.position) && !ServerOpsPlugin.Inside(((Component)other).transform.position)) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(BaseAI), "IsEnemy", new Type[] { typeof(Character), typeof(Character) })] internal static class MarketIsEnemyStaticPatch { private static bool Prefix(Character a, Character b, ref bool __result) { //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) if ((Object)(object)a == (Object)null || (Object)(object)b == (Object)null) { return true; } if (!ServerOpsPlugin.Inside(((Component)a).transform.position) && !ServerOpsPlugin.Inside(((Component)b).transform.position)) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(MonsterAI), "SetTarget")] internal static class MarketSetTargetPatch { private static bool Prefix(MonsterAI __instance, Character attacker) { //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) if ((Object)(object)attacker == (Object)null || (Object)(object)__instance == (Object)null) { return true; } if (!ServerOpsPlugin.Inside(((Component)__instance).transform.position)) { return !ServerOpsPlugin.Inside(((Component)attacker).transform.position); } return false; } } [HarmonyPatch(typeof(MonsterAI), "DoAttack")] internal static class MarketDoAttackPatch { private static bool Prefix(MonsterAI __instance, Character target) { //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) if ((Object)(object)__instance == (Object)null || (Object)(object)target == (Object)null) { return true; } if (!ServerOpsPlugin.Inside(((Component)__instance).transform.position)) { return !ServerOpsPlugin.Inside(((Component)target).transform.position); } return false; } } [HarmonyPatch(typeof(MonsterAI), "UpdateAI")] internal static class MarketMonsterUpdatePatch { private static void Prefix(MonsterAI __instance) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance == (Object)null) && ServerOpsPlugin.Inside(((Component)__instance).transform.position)) { AccessTools.Method(typeof(MonsterAI), "SetTarget", (Type[])null, (Type[])null)?.Invoke(__instance, new object[1]); AccessTools.Method(typeof(MonsterAI), "SetAlerted", (Type[])null, (Type[])null)?.Invoke(__instance, new object[1] { false }); } } } }