Decompiled source of liver protection v0.1.1

liver protection Project.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using ABN;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("liver protection Project")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("liver protection Project")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e7c225af-f188-41e0-bef1-ef6eef059385")]
[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 liver_protection_Project;

[BepInPlugin("plugin.LiverProtection", "LiverProtection", "1.0.0")]
public class LiverProtection : BaseUnityPlugin
{
	private static ConfigEntry<double> EnergyMulCfg;

	private static ConfigEntry<int> MinerMulCfg;

	private static ConfigEntry<int> WindMulCfg;

	private static ConfigEntry<int> AddDroneCountCfg;

	private static ConfigEntry<int> AddDroneSpeedCfg;

	private static ConfigEntry<int> DFInitialLevelInc;

	private static ConfigEntry<float> ReplicateSpeedInc;

	private void Awake()
	{
		EnergyMulCfg = ((BaseUnityPlugin)this).Config.Bind<double>("config", "EnergyMul", 10.0, "solar sail energy increase multiplier\n太阳帆能量增强倍率");
		MinerMulCfg = ((BaseUnityPlugin)this).Config.Bind<int>("config", "MinerMul", 20, "新建矿机倍率(所有矿机类型)");
		WindMulCfg = ((BaseUnityPlugin)this).Config.Bind<int>("config", "WindMulCfg", 10, "新建风电倍率");
		AddDroneCountCfg = ((BaseUnityPlugin)this).Config.Bind<int>("config", "AddDroneCountCfg", 2, "开局增加的无人机数量");
		AddDroneSpeedCfg = ((BaseUnityPlugin)this).Config.Bind<int>("config", "AddDroneSpeedCfg", 10, "开局增加的无人机飞行速度");
		DFInitialLevelInc = ((BaseUnityPlugin)this).Config.Bind<int>("config", "DFInitialLevelInc", 20, "黑雾初始等级提高(初始等级=选择的等级+该提高值)");
		ReplicateSpeedInc = ((BaseUnityPlugin)this).Config.Bind<float>("config", "ReplicateSpeedInc", 9f, "手工合成速度增加");
	}

	private void Start()
	{
		Harmony.CreateAndPatchAll(typeof(LiverProtection), (string)null);
		Configs.freeMode.solarSailEnergyPerTick = (long)((double)Configs.freeMode.solarSailEnergyPerTick * EnergyMulCfg.Value);
		Configs.freeMode.dysonNodeEnergyPerTick = (long)((double)Configs.freeMode.dysonNodeEnergyPerTick * EnergyMulCfg.Value);
		Configs.freeMode.dysonFrameEnergyPerTick = (long)((double)Configs.freeMode.dysonFrameEnergyPerTick * EnergyMulCfg.Value);
		Configs.freeMode.dysonShellEnergyPerTick = (long)((double)Configs.freeMode.dysonShellEnergyPerTick * EnergyMulCfg.Value);
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(GameAbnormalityData_0925), "TriggerAbnormality")]
	public static bool MyTriggerAbnormality()
	{
		return false;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(FactorySystem), "NewMinerComponent")]
	public static void fastmining(FactorySystem __instance, int __result)
	{
		__instance.minerPool[__result].period /= MinerMulCfg.Value;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(PowerSystem), "NewGeneratorComponent")]
	public static void BetterWindForced(PowerSystem __instance, int __result)
	{
		if (__instance.genPool[__result].wind)
		{
			__instance.genPool[__result].genEnergyPerTick *= WindMulCfg.Value;
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(ConstructionModuleComponent), "Setup", new Type[] { typeof(ModeConfig) })]
	public static void moreDrone(ConstructionModuleComponent __instance)
	{
		__instance.droneCount += AddDroneCountCfg.Value;
		__instance.droneAliveCount += AddDroneCountCfg.Value;
		__instance.droneIdleCount += AddDroneCountCfg.Value;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(GameHistoryData), "SetForNewGame")]
	public static void betterDrone(GameHistoryData __instance)
	{
		__instance.constructionDroneSpeed += (float)AddDroneSpeedCfg.Value;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(GameHistoryData), "SetForNewGame")]
	public static void highterLevel(GameHistoryData __instance)
	{
		__instance.combatSettings.initialLevel += DFInitialLevelInc.Value;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(Mecha), "SetForNewGame")]
	public static void fasterReplicateSpeed(Mecha __instance)
	{
		__instance.replicateSpeed += ReplicateSpeedInc.Value;
	}
}