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 TurretSettings v1.2.0
TheNameIsTyler.TurretSettings.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; 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; [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("TheNameIsTyler.TurretSettings")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0+ff81ed26bdf454594a322877d457df4840fc82d0")] [assembly: AssemblyProduct("TurretSettings")] [assembly: AssemblyTitle("TheNameIsTyler.TurretSettings")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.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.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] [Microsoft.CodeAnalysis.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] [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 TurretSettings { internal class TurretConfig { public readonly ConfigEntry<int> turretDamage; public readonly ConfigEntry<float> turretFireRate; public readonly ConfigEntry<float> turretWarmupTime; public readonly ConfigEntry<float> turretBerzerkRotationSpeed; public readonly ConfigEntry<float> turretFiringRotationSpeed; public readonly ConfigEntry<float> turretIdleRotationSpeed; public readonly ConfigEntry<float> turretRotationRange; public readonly ConfigEntry<float> turretRotateTimer; public TurretConfig(ConfigFile cfg) { cfg.SaveOnConfigSet = false; turretDamage = cfg.Bind<int>("General", "TurretDamage", 50, "How much damage a Turret deals per hit"); turretFireRate = cfg.Bind<float>("General", "TurretFireRate", 0.21f, "Turret Fire Rate"); turretWarmupTime = cfg.Bind<float>("General", "TurretWarmup", 1.5f, "How long until the turret starts firing after detection"); turretRotateTimer = cfg.Bind<float>("General", "TurretRotationTimer", 7f, "How long until the turret changes direction"); turretRotationRange = cfg.Bind<float>("General", "TurretRotationRange", 45f, "How far the turret can rotate from base position (Dont go beyond 89 or else Turrets will behave weirdly.)"); turretIdleRotationSpeed = cfg.Bind<float>("Rotation", "TurretIdleRotationSpeed", 28f, "How fast the turret rotates when in Idle mode"); turretFiringRotationSpeed = cfg.Bind<float>("Rotation", "TurretFiringRotationSpeed", 95f, "How fast the turret rotates when in Firing mode"); turretBerzerkRotationSpeed = cfg.Bind<float>("Rotation", "TurretBerzerkRotationSpeed", 77f, "How fast the turret rotates when in Berzerk mode"); ClearOrphanedEntries(cfg); cfg.Save(); cfg.SaveOnConfigSet = true; } private static void ClearOrphanedEntries(ConfigFile cfg) { PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries"); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg); dictionary.Clear(); } } [BepInPlugin("TheNameIsTyler.TurretSettings", "TurretSettings", "1.2.0")] public class TurretSettings : BaseUnityPlugin { public static TurretSettings Instance { get; private set; } internal static TurretConfig BoundConfig { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; BoundConfig = new TurretConfig(((BaseUnityPlugin)this).Config); Patch(); Logger.LogInfo((object)"TheNameIsTyler.TurretSettings v1.2.0 has loaded!"); } internal static void Patch() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("TheNameIsTyler.TurretSettings"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "TheNameIsTyler.TurretSettings"; public const string PLUGIN_NAME = "TurretSettings"; public const string PLUGIN_VERSION = "1.2.0"; } } namespace TurretSettings.Patches { [HarmonyPatch(typeof(Turret), "Update")] internal class UpdatePatch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction instruction in instructions) { bool found = false; if (instruction.opcode == OpCodes.Ldc_I4_S || instruction.opcode == OpCodes.Ldc_R4) { string value = instruction.operand.ToString(); if (value == "50") { yield return new CodeInstruction(OpCodes.Ldc_I4_S, (object)TurretSettings.BoundConfig.turretDamage.Value); found = true; } if (value == "0.21") { yield return new CodeInstruction(OpCodes.Ldc_R4, (object)TurretSettings.BoundConfig.turretFireRate.Value); found = true; } if (value == "7") { yield return new CodeInstruction(OpCodes.Ldc_R4, (object)TurretSettings.BoundConfig.turretRotateTimer.Value); found = true; } if (value == "1.5") { yield return new CodeInstruction(OpCodes.Ldc_R4, (object)TurretSettings.BoundConfig.turretWarmupTime.Value); found = true; } if (value == "77") { yield return new CodeInstruction(OpCodes.Ldc_R4, (object)TurretSettings.BoundConfig.turretBerzerkRotationSpeed.Value); found = true; } if (value == "95") { yield return new CodeInstruction(OpCodes.Ldc_R4, (object)TurretSettings.BoundConfig.turretFiringRotationSpeed.Value); found = true; } if (value == "28") { yield return new CodeInstruction(OpCodes.Ldc_R4, (object)TurretSettings.BoundConfig.turretIdleRotationSpeed.Value); found = true; } } if (!found) { yield return instruction; } } } } [HarmonyPatch(typeof(Turret))] internal class RotationRangePatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void SetRotationRange(ref float ___rotationRange) { ___rotationRange = TurretSettings.BoundConfig.turretRotationRange.Value; } } }