106 lines
4.0 KiB
C#
106 lines
4.0 KiB
C#
using BepInEx;
|
|
using BepInEx.Configuration;
|
|
using EFT.Interactive;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using UnityEngine;
|
|
|
|
namespace ValensHasThePower
|
|
{
|
|
[BepInPlugin("com.Valens.HasThePower", "ValensHasThePower", "1.2.1")]
|
|
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*/
|
|
|
|
configCustoms = Config.Bind("General.Maps",
|
|
"Customs",
|
|
100,
|
|
"Percentage Chance that Power will be On at Raid Start for the Customs Map." +
|
|
"Default is 100.");
|
|
|
|
configInterchange = Config.Bind("General.Maps",
|
|
"Interchange",
|
|
100,
|
|
"Percentage Chance that Power will be On at Raid Start for the Interchange Map." +
|
|
"Default is 100.");
|
|
|
|
configReserve = Config.Bind("General.Maps",
|
|
"Reserve",
|
|
100,
|
|
"Percentage Chance that Power will be On at Raid Start for the Reserve Map." +
|
|
"Default is 100.");
|
|
|
|
Logger.LogInfo($"Valens...has the POWER!!!");
|
|
new PatchThePower().Enable();
|
|
}
|
|
}
|
|
|
|
public static class PowerOn
|
|
{
|
|
public static void Start()
|
|
{
|
|
List<Switch> PowerSwitches = UnityEngine.Object.FindObjectsOfType<Switch>().ToList();
|
|
|
|
foreach (var switcher in PowerSwitches)
|
|
{
|
|
// Customs Power Switch
|
|
if (switcher.Id == "custom_DesignStuff_00034" && switcher.name == "reserve_electric_switcher_lever")
|
|
{
|
|
int percent = RandomGen();
|
|
|
|
if (percent <= Plugin.configCustoms.Value)
|
|
{
|
|
PowerSwitch(switcher);
|
|
}
|
|
}
|
|
|
|
// Interchange Power Station
|
|
if (switcher.Id == "Shopping_Mall_DesignStuff_00055" && switcher.name == "reserve_electric_switcher_lever")
|
|
{
|
|
int percent = RandomGen();
|
|
|
|
if (percent <= Plugin.configInterchange.Value)
|
|
{
|
|
PowerSwitch(switcher);
|
|
}
|
|
}
|
|
|
|
// Reserve D2 Switch
|
|
if (switcher.Id == "autoId_00000_D2_LEVER" && switcher.name == "reserve_electric_switcher_lever")
|
|
{
|
|
int percent = RandomGen();
|
|
|
|
if (percent <= Plugin.configReserve.Value)
|
|
{
|
|
PowerSwitch(switcher);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private static int RandomGen()
|
|
{
|
|
System.Random chance = new System.Random();
|
|
int percent = chance.Next(1, 99);
|
|
return percent;
|
|
}
|
|
private static void PowerSwitch(Switch switcher)
|
|
{
|
|
switcher.GetType().GetMethod("Open", BindingFlags.NonPublic | BindingFlags.Instance)
|
|
.Invoke(switcher, new object[0]);
|
|
}
|
|
}
|
|
} |