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 RotateTurrets v1.0.0
RotateTurrets.dll
Decompiled 2 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; [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("RotateTurrets")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RotateTurrets")] [assembly: AssemblyTitle("RotateTurrets")] [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 RotateTurrets { [HarmonyPatch(typeof(NetworkManager))] internal static class NetworkPrefabPatch { private static readonly string MOD_GUID = "RotateTurrets"; [HarmonyPostfix] [HarmonyPatch("SetSingleton")] private static void RegisterPrefab() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0018: 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) GameObject val = new GameObject(MOD_GUID + " Prefab"); ((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D); Object.DontDestroyOnLoad((Object)(object)val); NetworkObject obj = val.AddComponent<NetworkObject>(); FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(obj, GetHash(MOD_GUID)); NetworkManager.Singleton.PrefabHandler.AddNetworkPrefab(val); static uint GetHash(string value) { return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0; } } } [BepInPlugin("RotateTurrets", "RotateTurrets", "1.0.0")] [Harmony] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; private static ConfigEntry<float> TotalRotationAmount; private static ConfigEntry<bool> CanTriggerWithShotgun; private static ConfigEntry<bool> CanTriggerWithShotgunEnemy; private static ConfigEntry<bool> CanTriggerWithShotgunGround; private static ConfigEntry<bool> CanTriggerWithShotgunPlayer; private static float RotationOffset => Mathf.Sign(TotalRotationAmount.Value) * (183.9284f % Mathf.Abs(TotalRotationAmount.Value)); private static float RotationAmount => TotalRotationAmount.Value / 9f; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("RotateTurrets"); val.PatchAll(); TotalRotationAmount = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Total Rotation Amount", 120f, new ConfigDescription("How many degrees to rotate the turret while berserk", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-360f, 360f), Array.Empty<object>())); CanTriggerWithShotgun = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Can Trigger With Shotgun", true, "Whether shotgun shots can make turrets berserk"); CanTriggerWithShotgunEnemy = ((BaseUnityPlugin)this).Config.Bind<bool>("Shotgun", "Can Trigger With Enemy Shotgun", false, "Whether enemy shotgun shots can make turrets berserk"); CanTriggerWithShotgunGround = ((BaseUnityPlugin)this).Config.Bind<bool>("Shotgun", "Can Trigger With Grounded Shotgun", true, "Whether grounded shotgun shots can make turrets berserk"); CanTriggerWithShotgunPlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("Shotgun", "Can Trigger With Player Shotgun", true, "Whether player shotgun shots can make turrets berserk"); Logger.LogInfo((object)"Plugin RotateTurrets is loaded!"); } [HarmonyPatch(typeof(Turret), "Update")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> OverrideRotationSpeed(IEnumerable<CodeInstruction> instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.Start(); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)77f, (string)null) }); val.Instruction.opcode = OpCodes.Call; val.Instruction.operand = AccessTools.Method(typeof(Plugin), "BerserkTurretRotationSpeed", (Type[])null, (Type[])null); return val.Instructions(); } private static float BerserkTurretRotationSpeed() { return 77f - RotationAmount; } [HarmonyPatch(typeof(Turret), "Update")] [HarmonyPrefix] private static void GetTurretMode(Turret __instance, ref TurretMode __state) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected I4, but got Unknown __state = (TurretMode)(int)__instance.turretMode; } [HarmonyPatch(typeof(Turret), "Update")] [HarmonyPostfix] private static void RotateTurret(Turret __instance, TurretMode __state) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Invalid comparison between Unknown and I4 //IL_0068: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Invalid comparison between Unknown and I4 //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) if (!__instance.turretActive || ((int)__instance.turretMode != 3 && (int)__state != 3)) { return; } if (__instance.rotatingClockwise && !__instance.enteringBerserkMode) { Transform child = ((Component)__instance).transform.parent.GetChild(1); Transform child2 = child.GetChild(0); child.localEulerAngles = new Vector3(child.localEulerAngles.x, child.localEulerAngles.y - Time.deltaTime * RotationAmount, child.localEulerAngles.z); child2.localEulerAngles = new Vector3(child2.localEulerAngles.x, child2.localEulerAngles.y + Time.deltaTime * RotationAmount, child2.localEulerAngles.z); } if ((int)__instance.turretMode != 3 && (int)__state == 3) { Transform child3 = ((Component)__instance).transform.parent.GetChild(1); Transform child4 = child3.GetChild(0); float num = child3.localEulerAngles.y - RotationOffset; if (num < 0f) { num += 360f; } num /= TotalRotationAmount.Value; num = Mathf.Round(num); num *= TotalRotationAmount.Value; child3.localEulerAngles = new Vector3(child3.localEulerAngles.x, num + RotationOffset, child3.localEulerAngles.z); num = child4.localEulerAngles.y; num /= TotalRotationAmount.Value; num = Mathf.Round(num); num *= TotalRotationAmount.Value; child4.localEulerAngles = new Vector3(child4.localEulerAngles.x, num, child4.localEulerAngles.z); } } [HarmonyPatch(typeof(ShotgunItem), "ShootGun")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> AllowShotgunToTriggerTurrets(IEnumerable<CodeInstruction> instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.Start(); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[10] { new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)5f, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)15f, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_2, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Newobj, (object)null, (string)null) }); val.Insert((CodeInstruction[])(object)new CodeInstruction[4] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldarg_2, (object)null), new CodeInstruction(OpCodes.Ldloc_S, val.Operand), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Plugin), "ShootTurret", (Type[])null, (Type[])null)) }); return val.Instructions(); } private static void ShootTurret(ShotgunItem shotgun, Vector3 shotgunForward, Ray ray) { //IL_0088: 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) if (!CanTriggerWithShotgun.Value || (Object.op_Implicit((Object)(object)shotgun.heldByEnemy) && !CanTriggerWithShotgunEnemy.Value) || (!Object.op_Implicit((Object)(object)((GrabbableObject)shotgun).playerHeldBy) && !CanTriggerWithShotgunGround.Value) || (Object.op_Implicit((Object)(object)((GrabbableObject)shotgun).playerHeldBy) && !CanTriggerWithShotgunPlayer.Value)) { return; } int num = Physics.SphereCastNonAlloc(ray, 5f, shotgun.enemyColliders, 15f, 2097152, (QueryTriggerInteraction)2); Turret val = default(Turret); for (int i = 0; i < num; i++) { if (((Component)((RaycastHit)(ref shotgun.enemyColliders[i])).transform).TryGetComponent<Turret>(ref val)) { ((IHittable)val).Hit(1, shotgunForward, ((GrabbableObject)shotgun).playerHeldBy, true, -1); } } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "RotateTurrets"; public const string PLUGIN_NAME = "RotateTurrets"; public const string PLUGIN_VERSION = "1.0.0"; } }