using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
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("ShipDoorsBeGone")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ShipDoorsBeGone")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cb34b092-82ab-40b7-8936-265c216e99a4")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("bubba.shipdoorsbegone", "ShipDoorsBeGone", "1.0.3")]
public class ShipDoorsBeGone : BaseUnityPlugin
{
public static ShipDoorsBeGone Instance;
public static ConfigEntry<bool> Collision;
public static ConfigEntry<bool> Visibility;
private void Awake()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
Collision = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Collision", false, "Should collision for the ship doors be enabled?");
Visibility = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Visibility", false, "Should visibility for the ship doors be enabled?");
new Harmony("bubba.shipdoorsbegone").PatchAll();
Debug.Log((object)$"[SDBG] Using configs: [Collision {Collision.Value}] [Visibility {Visibility.Value}]");
}
}
[HarmonyPatch(typeof(StartOfRound), "Start")]
public static class SDBG_Start
{
public static void Postfix()
{
SDBG_Collision();
SDBG_Visibility();
}
private static string SDBG_GetPath(Transform t)
{
string text = ((Object)t).name;
while ((Object)(object)t.parent != (Object)null)
{
t = t.parent;
text = ((Object)t).name + "/" + text;
}
return text;
}
private static void SDBG_Collision()
{
if (ShipDoorsBeGone.Collision.Value)
{
return;
}
GameObject[] array = Object.FindObjectsOfType<GameObject>();
foreach (GameObject val in array)
{
string text = ((Object)val).name.ToLowerInvariant();
if (!text.Contains("hangardoor") && !text.Contains("shipdoor"))
{
continue;
}
Collider[] componentsInChildren = val.GetComponentsInChildren<Collider>(true);
foreach (Collider val2 in componentsInChildren)
{
string text2 = SDBG_GetPath(((Component)val2).transform);
if (!text2.ToLowerInvariant().Contains("hangardoorbuttonpanel") && !val2.isTrigger && (val2 is BoxCollider || val2 is MeshCollider))
{
val2.enabled = false;
Debug.Log((object)("[SDBG] Disabled collision: " + SDBG_GetPath(((Component)val2).transform) + " (" + ((object)val2).GetType().Name + ")"));
}
}
}
}
private static void SDBG_Visibility()
{
if (ShipDoorsBeGone.Visibility.Value)
{
return;
}
GameObject[] array = Object.FindObjectsOfType<GameObject>();
foreach (GameObject val in array)
{
string text = ((Object)val).name.ToLowerInvariant();
if (text.Contains("hangardoorleft") || text.Contains("hangardoorright"))
{
Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>();
foreach (Renderer val2 in componentsInChildren)
{
val2.enabled = false;
}
Debug.Log((object)("[SDBG] Disabled visibility: " + SDBG_GetPath(val.transform)));
}
}
}
}