2022-04-12 23:49:45 +01:00
|
|
|
|
using BepInEx;
|
|
|
|
|
using BepInEx.Configuration;
|
|
|
|
|
using EFT.Interactive;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace ValensHasThePower
|
|
|
|
|
{
|
2024-06-06 08:11:02 +01:00
|
|
|
|
[BepInPlugin("com.Valens.HasThePower", "ValensHasThePower", "1.3.0")]
|
2022-04-12 23:49:45 +01:00
|
|
|
|
public class Plugin : BaseUnityPlugin
|
|
|
|
|
{
|
|
|
|
|
public static ConfigEntry<int> configCustoms;
|
|
|
|
|
public static ConfigEntry<int> configInterchange;
|
|
|
|
|
public static ConfigEntry<int> configReserve;
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
/* Example Config
|
|
|
|
|
configGreeting = Config.Bind("General", // The section under which the option is shown
|
|
|
|
|
"GreetingText", // The key of the configuration option in the configuration file
|
|
|
|
|
"Hello, world!", // The default value
|
|
|
|
|
"A greeting text to show when the game is launched"); // Description of the option to show in the config file*/
|
|
|
|
|
|
2022-04-12 18:39:54 -05:00
|
|
|
|
configCustoms = Config.Bind("General.Maps",
|
|
|
|
|
"Customs",
|
2022-04-12 23:49:45 +01:00
|
|
|
|
100,
|
2024-06-06 08:11:02 +01:00
|
|
|
|
"Percentage Chance that Power will be On at Raid Start for the Customs Map." +
|
2022-07-25 15:57:33 -04:00
|
|
|
|
"Default is 100.");
|
2022-04-12 23:49:45 +01:00
|
|
|
|
|
2022-04-12 18:39:54 -05:00
|
|
|
|
configInterchange = Config.Bind("General.Maps",
|
|
|
|
|
"Interchange",
|
2022-04-12 23:49:45 +01:00
|
|
|
|
100,
|
2024-06-06 08:11:02 +01:00
|
|
|
|
"Percentage Chance that Power will be On at Raid Start for the Interchange Map." +
|
2022-07-25 15:57:33 -04:00
|
|
|
|
"Default is 100.");
|
2022-04-12 23:49:45 +01:00
|
|
|
|
|
2022-04-12 18:39:54 -05:00
|
|
|
|
configReserve = Config.Bind("General.Maps",
|
|
|
|
|
"Reserve",
|
2022-04-12 23:49:45 +01:00
|
|
|
|
100,
|
2022-04-12 18:39:54 -05:00
|
|
|
|
"Percentage Chance that Power will be On at Raid Start for the Reserve Map." +
|
2022-07-25 15:57:33 -04:00
|
|
|
|
"Default is 100.");
|
2022-04-12 23:49:45 +01:00
|
|
|
|
|
|
|
|
|
Logger.LogInfo($"Valens...has the POWER!!!");
|
|
|
|
|
new PatchThePower().Enable();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-06 08:11:02 +01:00
|
|
|
|
public class PowerOn : MonoBehaviour
|
2022-04-12 23:49:45 +01:00
|
|
|
|
{
|
2024-06-06 08:11:02 +01:00
|
|
|
|
public void Start()
|
2022-04-12 23:49:45 +01:00
|
|
|
|
{
|
2024-06-06 08:11:02 +01:00
|
|
|
|
List<Switch> PowerSwitches = FindObjectsOfType<Switch>().ToList();
|
2022-04-12 23:49:45 +01:00
|
|
|
|
|
|
|
|
|
foreach (var switcher in PowerSwitches)
|
|
|
|
|
{
|
|
|
|
|
// Customs Power Switch
|
|
|
|
|
if (switcher.Id == "custom_DesignStuff_00034" && switcher.name == "reserve_electric_switcher_lever")
|
|
|
|
|
{
|
2022-04-13 00:25:51 +01:00
|
|
|
|
int percent = RandomGen();
|
|
|
|
|
|
2022-04-12 23:49:45 +01:00
|
|
|
|
if (percent <= Plugin.configCustoms.Value)
|
|
|
|
|
{
|
|
|
|
|
PowerSwitch(switcher);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-06 08:11:02 +01:00
|
|
|
|
// Interchange Power Station
|
2022-04-12 23:49:45 +01:00
|
|
|
|
if (switcher.Id == "Shopping_Mall_DesignStuff_00055" && switcher.name == "reserve_electric_switcher_lever")
|
|
|
|
|
{
|
2022-04-13 00:25:51 +01:00
|
|
|
|
int percent = RandomGen();
|
2022-04-12 23:49:45 +01:00
|
|
|
|
|
2022-04-13 00:25:51 +01:00
|
|
|
|
if (percent <= Plugin.configInterchange.Value)
|
2022-04-12 23:49:45 +01:00
|
|
|
|
{
|
|
|
|
|
PowerSwitch(switcher);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reserve D2 Switch
|
|
|
|
|
if (switcher.Id == "autoId_00000_D2_LEVER" && switcher.name == "reserve_electric_switcher_lever")
|
|
|
|
|
{
|
2022-04-13 00:25:51 +01:00
|
|
|
|
int percent = RandomGen();
|
|
|
|
|
|
|
|
|
|
if (percent <= Plugin.configReserve.Value)
|
2022-04-12 23:49:45 +01:00
|
|
|
|
{
|
|
|
|
|
PowerSwitch(switcher);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-13 00:25:51 +01:00
|
|
|
|
private static int RandomGen()
|
|
|
|
|
{
|
|
|
|
|
System.Random chance = new System.Random();
|
|
|
|
|
int percent = chance.Next(1, 99);
|
|
|
|
|
return percent;
|
|
|
|
|
}
|
2022-04-12 23:49:45 +01:00
|
|
|
|
private static void PowerSwitch(Switch switcher)
|
|
|
|
|
{
|
2024-06-06 08:11:02 +01:00
|
|
|
|
switcher.Open();
|
2022-04-12 23:49:45 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|