using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
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("LCOpenDoors")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LCOpenDoors")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("216ef77b-5a62-4e1b-8502-9e3a203e0667")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LCOpenDoors;
[BepInPlugin("Mod.Chris.OpenDoors", "LC Open Doors", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("Mod.Chris.OpenDoors");
internal static Plugin Instance;
internal static ManualLogSource mls;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("Mod.Chris.OpenDoors");
mls.LogInfo((object)"Loaded Succesfully");
harmony.PatchAll(typeof(GamePatcher));
}
}
[HarmonyPatch]
internal class GamePatcher
{
internal static TerminalAccessibleObject[] bigDoors;
[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
[HarmonyPrefix]
private static void HUDPatch(ref HUDManager __instance)
{
try
{
bigDoors = (from obj in Object.FindObjectsOfType<TerminalAccessibleObject>()
where obj.isBigDoor
select obj).ToArray();
if (Utilities.HandleCommand(__instance.chatTextField.text.ToLower()))
{
__instance.chatTextField.text = "";
}
}
catch (Exception ex)
{
Plugin.mls.LogInfo((object)("Unable to handle command: " + ex.Message));
}
}
}
internal class Utilities
{
internal static bool HandleCommand(string command)
{
if (Utility.IsNullOrWhiteSpace(command))
{
return false;
}
if (command == "doors")
{
Plugin.mls.LogInfo((object)$"List of Big Doors on current level ({GamePatcher.bigDoors.Length}):");
TerminalAccessibleObject[] bigDoors = GamePatcher.bigDoors;
foreach (TerminalAccessibleObject val in bigDoors)
{
Plugin.mls.LogInfo((object)val.objectCode);
}
return true;
}
if (command.Length == 2)
{
TerminalAccessibleObject val2 = ((IEnumerable<TerminalAccessibleObject>)GamePatcher.bigDoors).FirstOrDefault((Func<TerminalAccessibleObject, bool>)((TerminalAccessibleObject obj) => obj.objectCode == command));
if ((Object)(object)val2 != (Object)null)
{
val2.SetDoorOpenServerRpc(true);
Plugin.mls.LogInfo((object)("Door '" + command + "' opened"));
return true;
}
Plugin.mls.LogInfo((object)("Door '" + command + "' not in level"));
}
return false;
}
}