diff --git a/ValensHasThePower/Program.cs b/ValensHasThePower/Program.cs index 53fce37..fa6f093 100644 --- a/ValensHasThePower/Program.cs +++ b/ValensHasThePower/Program.cs @@ -1,12 +1,9 @@ -using System.Collections.Generic; -using BepInEx; -using UnityEngine; +using BepInEx; using EFT.Interactive; +using System.Collections.Generic; using System.Linq; -using EFT; -using EFT.UI; -using Comfort.Common; -using RegexCMD = GClass2285; +using System.Reflection; +using UnityEngine; namespace ValensHasThePower { @@ -20,124 +17,53 @@ namespace ValensHasThePower } } - public class PowerOn + public static class PowerOn { - private static List PowerSwitches = Object.FindObjectsOfType().ToList(); - - private static GameWorld _gameWorld; public static void Start() { - // Adds command to console, type test to enable the script In-Game - // TODO: test with reserve as its the only method currently added to run on command! - ConsoleScreen.Commands.AddCommand(new RegexCMD("test", match => + List PowerSwitches = Object.FindObjectsOfType().ToList(); + + foreach (var switcher in PowerSwitches) { - _gameWorld = Singleton.Instance; - if (_gameWorld == null) + // interchange Power Station + if (switcher.Id == "Shopping_Mall_DesignStuff_00055" && switcher.name == "reserve_electric_switcher_lever") { - string log = "in order to run this command, you have to be in raid"; - PreloaderUI.Instance.Console.AddLog(" " + log, "[Valens HasThePower]:"); - } - else - { - string log = "Enabled!"; - PreloaderUI.Instance.Console.AddLog(" " + log, "[Valens HasThePower]:"); - PowerOn.Reserve(); - } - })); - - //PowerOn.Interchange(); - //PowerOn.Customs(); - //PowerOn.Reserve(); - } - - private static void Interchange() - { - - foreach (var switches in PowerSwitches) // Turn the Power Station switch to On. - { - // Power to Mall - if (switches.Id == "Shopping_Mall_DesignStuff_00055" && switches.name == "reserve_electric_switcher_lever") - { - switches.DoorState = EDoorState.Open; + Debug.LogError($"{switcher.Id} {switcher.enabled}"); + PowerSwitch(switcher); + Debug.LogError($"{switcher.Id} {switcher.enabled}"); } - // Activation of Toilet Key Card Reader in Burger Stop - if (switches.name == "Node_Keycard_Saferoom") + // interchange Secret Container + if (switcher.Id == "Shopping_Mall_DesignStuff_00061" && switcher.Id == "reserve_electric_switcher_lever") { - switches.DoorState = EDoorState.Open; + Debug.LogError($"{switcher.Id} {switcher.enabled}"); + PowerSwitch(switcher); + Debug.LogError($"{switcher.Id} {switcher.enabled}"); } - // Activation of OBJ21 Container - if (switches.Id == "Shopping_Mall_DesignStuff_00061" && switches.Id == "reserve_electric_switcher_lever") + // Customs Power Switch + if (switcher.Id == "custom_DesignStuff_00034" && switcher.name == "reserve_electric_switcher_lever") { - switches.DoorState = EDoorState.Open; + Debug.LogError($"{switcher.Id} {switcher.enabled}"); + PowerSwitch(switcher); + Debug.LogError($"{switcher.Id} {switcher.enabled}"); + } + + // Reserve D2 Switch + if (switcher.Id == "autoId_00000_D2_LEVER" && switcher.name == "reserve_electric_switcher_lever") + { + Debug.LogError($"{switcher.Id} {switcher.enabled}"); + PowerSwitch(switcher); + Debug.LogError($"{switcher.Id} {switcher.enabled}"); } } } - private static void Customs() + private static void PowerSwitch(Switch switcher) { - - foreach (var switches in PowerSwitches) // turns on power on customs - { - if (switches.Id == "custom_DesignStuff_00034" && switches.name == "reserve_electric_switcher_lever") - { - var lamps = switches.Lamps.ToList(); - var exfil = switches.ExfiltrationPoint; - - // turns on lamps - foreach (var lamp in lamps) - { - lamp.Enabled = true; - } - - // turns on power - switches.DoorState = EDoorState.Open; - - // turns on exfil - exfil.Status = EExfiltrationStatus.RegularMode; - } - } - } - - private static void Reserve() - { - foreach (var switches in PowerSwitches) // turns on power on reserve - { - if (switches.Id == "autoId_00000_D2_LEVER" && switches.name == "reserve_electric_switcher_lever") - { - var lamps = switches.Lamps.ToList(); - - // turns on power - switches.DoorState = EDoorState.Open; - - // turns on lamps - foreach (var lamp in lamps) - { - // finds LampControllers attached to Switch - Debug.LogError($"LampController Name: {lamp.name}"); - var lights = lamp.Lights.ToList(); - - // finds all lights attached to the LampControllers - foreach (var light in lights) - { - // enables the lights - Debug.LogError($"BEFORE -- light Name: {light.name} | Enabled? {light.enabled}"); - light.enabled = true; - Debug.LogError($"AFTER -- light Name: {light.name} | Enabled? {light.enabled}"); - // TODO: this currently shows finding all the above and enabling the lights, put once in raid they are still not enabled in UE, so something might be running after - // as per the reason to try a command after load - } - } - } - - // turns on d2 extract button - if (switches.Id == "00453" && switches.name == "Node_GatesButton") - { - switches.DoorState = EDoorState.Shut; - } - } + switcher.GetType().GetMethod("Open", BindingFlags.NonPublic | BindingFlags.Instance) + .Invoke(switcher, new object[0]); } } } \ No newline at end of file