using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DefenselessCompany.Patches;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DefenselessCompany")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DefenselessCompany")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b6543c70-5011-4f02-82a5-bbf0907c5011")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DefenselessCompany
{
[BepInPlugin("Pulsar.DefenselessCompany", "Defenseless Company", "1.4.1")]
public class DefenselessCompanyModBase : BaseUnityPlugin
{
public const string modGUID = "Pulsar.DefenselessCompany";
private const string modName = "Defenseless Company";
private const string modVersion = "1.4.1";
public static ConfigEntry<bool> disableTurretsConfig;
public static ConfigEntry<bool> disableLandminesConfig;
public static ConfigEntry<bool> disableTurretBerserkConfig;
public static ConfigEntry<float> maxTurretRotationRangeConfig;
public static ConfigEntry<float> maxTurretRotationSpeedConfig;
private readonly Harmony harmony = new Harmony("Pulsar.DefenselessCompany");
public static DefenselessCompanyModBase Instance;
public ManualLogSource mls = Logger.CreateLogSource("Pulsar.DefenselessCompany");
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
disableTurretsConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Turret", "Disable_Turrets", false, "Stop turrets from shooting at you");
disableTurretBerserkConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Turret", "Disable_Turret_Berserk", false, "Stops turret from going into berserk mode");
maxTurretRotationRangeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Turret", "Max_Turret_Range", 45f, "The max range for a turret");
maxTurretRotationSpeedConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Turret", "Max_Turret_Speed_Multiplier", 1f, "Multiplier for the max speed the turret can turn at");
disableLandminesConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Landmine", "Disable_Landmines", false, "Stop landmines from exploding when stopped on");
mls.LogInfo((object)"Defenseless Company mod loaded");
mls.LogWarning((object)("Turret disable config setting: " + disableTurretsConfig.Value));
mls.LogWarning((object)("Turret disable berserk config setting: " + disableTurretBerserkConfig.Value));
mls.LogWarning((object)("Turret max rotation range config setting: " + maxTurretRotationRangeConfig.Value));
mls.LogWarning((object)("Turret max rotation speed config setting: " + maxTurretRotationSpeedConfig.Value));
mls.LogWarning((object)("Landmine disable config setting: " + disableLandminesConfig.Value));
if (disableLandminesConfig.Value)
{
harmony.PatchAll(typeof(disabledLandmines));
}
if (disableTurretsConfig.Value)
{
harmony.PatchAll(typeof(disabledTurrets));
}
if (disableTurretBerserkConfig.Value)
{
harmony.PatchAll(typeof(disableTurretBerserk));
}
harmony.PatchAll(typeof(turretRotationSpeed));
harmony.PatchAll(typeof(turretRotationRange));
}
}
}
namespace DefenselessCompany.Patches
{
[HarmonyPatch(typeof(Landmine))]
internal class disabledLandmines
{
[HarmonyPatch("OnTriggerEnter")]
[HarmonyPrefix]
private static void landmineDisabledPatch(ref bool ___hasExploded)
{
___hasExploded = true;
}
}
[HarmonyPatch(typeof(Turret))]
internal class disabledTurrets
{
[HarmonyPatch("Update")]
[HarmonyPrefix]
private static void turretDisabledPatch(ref bool ___turretActive)
{
___turretActive = false;
}
}
[HarmonyPatch(typeof(Turret))]
internal class disableTurretBerserk
{
[HarmonyPatch("Update")]
[HarmonyPrefix]
private static void disableTurretBerserkPatch(ref float ___berserkTimer)
{
___berserkTimer = 0f;
}
}
[HarmonyPatch(typeof(Turret))]
internal class turretRotationRange
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
private static void turretRotationRangePatch(ref float ___rotationRange)
{
___rotationRange = Mathf.Abs(DefenselessCompanyModBase.maxTurretRotationRangeConfig.Value);
}
}
[HarmonyPatch(typeof(Turret))]
internal class turretRotationSpeed
{
[HarmonyPatch("Update")]
[HarmonyPrefix]
private static void turretRotationSpeedPatch(ref float ___rotationSpeed, ref TurretMode ___turretMode)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected I4, but got Unknown
float num = Mathf.Abs(DefenselessCompanyModBase.maxTurretRotationSpeedConfig.Value);
TurretMode val = ___turretMode;
TurretMode val2 = val;
switch ((int)val2)
{
case 3:
___rotationSpeed = num * 77f;
break;
case 0:
___rotationSpeed = num * 28f;
break;
case 1:
___rotationSpeed = num * 95f;
break;
case 2:
break;
}
}
}
}