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("Dead By Doorlight")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Dead By Doorlight")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d48ed7c4-fea0-4032-b5bd-f2a43eb39914")]
[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")]
namespace Dead_By_Doorlight;
[HarmonyPatch(typeof(HUDManager))]
[HarmonyPatch(typeof(TerminalAccessibleObject))]
internal class Patches
{
public static List<TerminalAccessibleObject> objects = new List<TerminalAccessibleObject>();
private static List<string> doorCodes = new List<string>();
public static ManualLogSource mls = Logger.CreateLogSource("DeadByDoorlight.LCMod");
private static string recentMessage = "";
public static List<string> getDoorCodes()
{
mls.LogDebug((object)"The Action Has Been Successfully Called");
TerminalAccessibleObject[] array = Object.FindObjectsOfType<TerminalAccessibleObject>();
if (array == null || array.Length == 0)
{
return null;
}
objects = array.ToList();
mls.LogInfo((object)objects.ToString());
List<TerminalAccessibleObject> list = new List<TerminalAccessibleObject>();
foreach (TerminalAccessibleObject @object in objects)
{
if (((Object)((Component)@object).gameObject).name.Contains("BigDoor"))
{
list.Add(@object);
}
}
objects = list;
foreach (TerminalAccessibleObject object2 in objects)
{
doorCodes.Add(object2.objectCode);
mls.Log((LogLevel)16, (object)object2.objectCode);
}
return doorCodes;
}
[HarmonyPatch(typeof(HUDManager), "AddPlayerChatMessageClientRpc")]
[HarmonyPostfix]
public static void AddPlayerChatMessageClientRpcPostfix(HUDManager __instance, string chatMessage, int playerId)
{
recentMessage = chatMessage.ToLower();
mls.Log((LogLevel)16, (object)recentMessage);
doorCodes = getDoorCodes();
mls.LogInfo((object)doorCodes);
if (HUDManager.Instance.playersManager.allPlayerScripts[playerId].isPlayerDead)
{
foreach (string doorCode in doorCodes)
{
foreach (TerminalAccessibleObject @object in objects)
{
if (recentMessage.Equals("open"))
{
if (@object.objectCode.Equals(doorCode))
{
@object.SetDoorOpen(true);
mls.LogInfo((object)("door " + doorCode + " has been affected"));
}
}
else if (recentMessage.Equals("close") && @object.objectCode.Equals(doorCode))
{
@object.SetDoorOpen(false);
mls.LogInfo((object)("door " + doorCode + " has been affected"));
}
}
}
return;
}
mls.LogInfo((object)"Currently Player is not currently dead");
}
}
[BepInPlugin("DeadByDoorlight.LCMod", "Dead By Doorlight", "1.0.0.0")]
public class ModBase : BaseUnityPlugin
{
private const string modGUID = "DeadByDoorlight.LCMod";
private const string modName = "Dead By Doorlight";
private const string modVersion = "1.0.0.0";
private readonly Harmony harmony = new Harmony("DeadByDoorlight.LCMod");
private static ModBase Instance;
internal ManualLogSource mls;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("DeadByDoorlight.LCMod");
harmony.PatchAll(typeof(ModBase));
harmony.PatchAll(typeof(Patches));
}
}