using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace EnergyExchangerTweaks;
[BepInPlugin("com.marvis.energyexchangertweaks", "EnergyExchangerTweaks", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static ConfigEntry<float> ChargeMultiplier;
public static ConfigEntry<float> DischargeMultiplier;
private void Awake()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Expected O, but got Unknown
ChargeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ChargeMultiplier", 2f, new ConfigDescription("充电倍率(1-20,1=原版)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), new object[0]));
DischargeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DischargeMultiplier", 2f, new ConfigDescription("放电倍率(1-20,1=原版)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), new object[0]));
Harmony val = new Harmony("com.marvis.energyexchangertweaks");
val.PatchAll(typeof(Plugin).Assembly);
((BaseUnityPlugin)this).Logger.LogInfo((object)("EnergyExchangerTweaks loaded: Charge x" + ChargeMultiplier.Value + ", Discharge x" + DischargeMultiplier.Value));
}
}
[HarmonyPatch(typeof(PowerExchangerComponent), "CalculateActualEnergyPerTick")]
public static class CalculateActualEnergyPerTickPatch
{
private static void Postfix(bool isOutput, ref long __result)
{
float num = (isOutput ? Plugin.DischargeMultiplier.Value : Plugin.ChargeMultiplier.Value);
if (num > 0f && num != 1f)
{
__result = (long)((float)__result * num);
}
}
}