Decompiled source of DarkFogLimitBreak v0.0.2

DarkFogLimitBreak.dll

Decompiled 5 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DarkFogLimitBreak")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DarkFogLimitBreak")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cc5e2651-5d9c-438d-a65e-8f86b6fea48c")]
[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 DarkFogLimitBreak;

[BepInPlugin("com.orioline.DarkFogLimitBreak", "DarkFogLimitBreak", "0.0.1")]
public class DarkFogLimitBreak : BaseUnityPlugin
{
	public const string PLUGIN_GUID = "com.orioline.DarkFogLimitBreak";

	public const string PLUGIN_NAME = "DarkFogLimitBreak";

	public const string PLUGIN_VERSION = "0.0.1";

	private static Harmony harmony;

	private void Awake()
	{
		ApplyPatches();
	}

	private void Start()
	{
	}

	private void Update()
	{
	}

	private void OnDestroy()
	{
		RevertPatches();
	}

	private void ApplyPatches()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		try
		{
			harmony = new Harmony("com.orioline.DarkFogLimitBreak");
			harmony.PatchAll(typeof(PatchDFLB));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Patches applied!");
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("Patch failed, exception= " + ex.ToString()));
		}
	}

	private void RevertPatches()
	{
		harmony.UnpatchSelf();
	}
}
internal class PatchDFLB
{
	[HarmonyPrefix]
	[HarmonyPatch(typeof(UICombatSettingsDF), "UpdateUIParametersDisplay")]
	public static bool UpdateUIParametersDisplay(ref UICombatSettingsDF __instance)
	{
		//IL_0bc5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bcb: Expected O, but got Unknown
		//IL_0c28: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c2f: Invalid comparison between Unknown and I4
		//IL_0c5b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c60: Unknown result type (might be due to invalid IL or missing references)
		float aggressiveness = __instance.combatSettings.aggressiveness;
		string text = "";
		if (aggressiveness < -0.99f)
		{
			__instance.aggresiveSlider.value = 0f;
		}
		else if (aggressiveness < 0.01f)
		{
			__instance.aggresiveSlider.value = 1f;
		}
		else if (aggressiveness < 0.51f)
		{
			__instance.aggresiveSlider.value = 2f;
		}
		else if (aggressiveness < 1.01f)
		{
			__instance.aggresiveSlider.value = 3f;
		}
		else if (aggressiveness < 2.01f)
		{
			__instance.aggresiveSlider.value = 4f;
		}
		else
		{
			__instance.aggresiveSlider.value = 5f;
		}
		switch ((int)(__instance.aggresiveSlider.value + 0.5f))
		{
		case 0:
			text = Localization.Translate("活靶子");
			break;
		case 1:
			text = Localization.Translate("被动");
			break;
		case 2:
			text = Localization.Translate("消极");
			break;
		case 3:
			text = Localization.Translate("正常");
			break;
		case 4:
			text = Localization.Translate("积极");
			break;
		case 5:
			text = Localization.Translate("狂暴");
			break;
		}
		__instance.aggresiveText.text = text;
		aggressiveness = __instance.combatSettings.initialLevel;
		if (aggressiveness < 0.01f)
		{
			__instance.initLevelSlider.value = 0f;
		}
		else if (aggressiveness < 1.01f)
		{
			__instance.initLevelSlider.value = 1f;
		}
		else if (aggressiveness < 3.01f)
		{
			__instance.initLevelSlider.value = 3f;
		}
		else if (aggressiveness < 6.01f)
		{
			__instance.initLevelSlider.value = 6f;
		}
		else if (aggressiveness < 10.01f)
		{
			__instance.initLevelSlider.value = 10f;
		}
		else if (aggressiveness < 12.01f)
		{
			__instance.initLevelSlider.value = 12f;
		}
		else if (aggressiveness < 15.01f)
		{
			__instance.initLevelSlider.value = 15f;
		}
		else if (aggressiveness < 18.01f)
		{
			__instance.initLevelSlider.value = 18f;
		}
		else if (aggressiveness < 21.01f)
		{
			__instance.initLevelSlider.value = 21f;
		}
		else if (aggressiveness < 24.01f)
		{
			__instance.initLevelSlider.value = 24f;
		}
		else
		{
			__instance.initLevelSlider.value = 30f;
		}
		text = aggressiveness.ToString();
		__instance.initLevelText.text = text;
		aggressiveness = __instance.combatSettings.initialGrowth;
		if (aggressiveness < 0.01f)
		{
			__instance.initGrowthSlider.value = 0f;
		}
		else if (aggressiveness < 0.26f)
		{
			__instance.initGrowthSlider.value = 1f;
		}
		else if (aggressiveness < 0.51f)
		{
			__instance.initGrowthSlider.value = 2f;
		}
		else if (aggressiveness < 0.76f)
		{
			__instance.initGrowthSlider.value = 3f;
		}
		else if (aggressiveness < 1.01f)
		{
			__instance.initGrowthSlider.value = 4f;
		}
		else if (aggressiveness < 1.51f)
		{
			__instance.initGrowthSlider.value = 5f;
		}
		else
		{
			__instance.initGrowthSlider.value = 6f;
		}
		text = aggressiveness * 100f + "%";
		__instance.initGrowthText.text = text;
		aggressiveness = __instance.combatSettings.initialColonize;
		if (aggressiveness < 0.02f)
		{
			__instance.initOccupiedSlider.value = 0f;
		}
		else if (aggressiveness < 0.26f)
		{
			__instance.initOccupiedSlider.value = 1f;
		}
		else if (aggressiveness < 0.51f)
		{
			__instance.initOccupiedSlider.value = 2f;
		}
		else if (aggressiveness < 0.76f)
		{
			__instance.initOccupiedSlider.value = 3f;
		}
		else if (aggressiveness < 1.01f)
		{
			__instance.initOccupiedSlider.value = 4f;
		}
		else if (aggressiveness < 1.51f)
		{
			__instance.initOccupiedSlider.value = 5f;
		}
		else
		{
			__instance.initOccupiedSlider.value = 6f;
		}
		text = aggressiveness * 100f + "%";
		__instance.initOccupiedText.text = text;
		aggressiveness = __instance.combatSettings.maxDensity;
		if (aggressiveness < 1.01f)
		{
			__instance.maxDensitySlider.value = 0f;
		}
		else if (aggressiveness < 2.01f)
		{
			__instance.maxDensitySlider.value = 2f;
		}
		else if (aggressiveness < 3.01f)
		{
			__instance.maxDensitySlider.value = 3f;
		}
		else if (aggressiveness < 4.01f)
		{
			__instance.maxDensitySlider.value = 4f;
		}
		else if (aggressiveness < 5.01f)
		{
			__instance.maxDensitySlider.value = 5f;
		}
		else
		{
			__instance.maxDensitySlider.value = 6f;
		}
		text = aggressiveness + "x";
		__instance.maxDensityText.text = text;
		aggressiveness = __instance.combatSettings.growthSpeedFactor;
		if (aggressiveness < 0.26f)
		{
			__instance.growthSpeedSlider.value = 0f;
		}
		else if (aggressiveness < 0.51f)
		{
			__instance.growthSpeedSlider.value = 1f;
		}
		else if (aggressiveness < 1.01f)
		{
			__instance.growthSpeedSlider.value = 2f;
		}
		else if (aggressiveness < 2.01f)
		{
			__instance.growthSpeedSlider.value = 3f;
		}
		else
		{
			__instance.growthSpeedSlider.value = 4f;
		}
		text = aggressiveness * 100f + "%";
		__instance.growthSpeedText.text = text;
		aggressiveness = __instance.combatSettings.powerThreatFactor;
		if (aggressiveness < 0.02f)
		{
			__instance.powerThreatSlider.value = 0f;
		}
		else if (aggressiveness < 0.11f)
		{
			__instance.powerThreatSlider.value = 1f;
		}
		else if (aggressiveness < 0.21000001f)
		{
			__instance.powerThreatSlider.value = 2f;
		}
		else if (aggressiveness < 0.51f)
		{
			__instance.powerThreatSlider.value = 3f;
		}
		else if (aggressiveness < 1.01f)
		{
			__instance.powerThreatSlider.value = 4f;
		}
		else if (aggressiveness < 2.01f)
		{
			__instance.powerThreatSlider.value = 5f;
		}
		else if (aggressiveness < 5.01f)
		{
			__instance.powerThreatSlider.value = 6f;
		}
		else if (aggressiveness < 8.01f)
		{
			__instance.powerThreatSlider.value = 7f;
		}
		else
		{
			__instance.powerThreatSlider.value = 8f;
		}
		text = aggressiveness * 100f + "%";
		__instance.powerThreatText.text = text;
		aggressiveness = __instance.combatSettings.battleThreatFactor;
		if (aggressiveness < 0.02f)
		{
			__instance.combatThreatSlider.value = 0f;
		}
		else if (aggressiveness < 0.11f)
		{
			__instance.combatThreatSlider.value = 1f;
		}
		else if (aggressiveness < 0.21000001f)
		{
			__instance.combatThreatSlider.value = 2f;
		}
		else if (aggressiveness < 0.51f)
		{
			__instance.combatThreatSlider.value = 3f;
		}
		else if (aggressiveness < 1.01f)
		{
			__instance.combatThreatSlider.value = 4f;
		}
		else if (aggressiveness < 2.01f)
		{
			__instance.combatThreatSlider.value = 5f;
		}
		else if (aggressiveness < 5.01f)
		{
			__instance.combatThreatSlider.value = 6f;
		}
		else if (aggressiveness < 8.01f)
		{
			__instance.combatThreatSlider.value = 7f;
		}
		else
		{
			__instance.combatThreatSlider.value = 8f;
		}
		text = aggressiveness * 100f + "%";
		__instance.combatThreatText.text = text;
		aggressiveness = __instance.combatSettings.battleExpFactor;
		if (aggressiveness < 0.02f)
		{
			__instance.DFExpSlider.value = 0f;
		}
		else if (aggressiveness < 0.11f)
		{
			__instance.DFExpSlider.value = 1f;
		}
		else if (aggressiveness < 0.21000001f)
		{
			__instance.DFExpSlider.value = 2f;
		}
		else if (aggressiveness < 0.51f)
		{
			__instance.DFExpSlider.value = 3f;
		}
		else if (aggressiveness < 1.01f)
		{
			__instance.DFExpSlider.value = 4f;
		}
		else if (aggressiveness < 2.01f)
		{
			__instance.DFExpSlider.value = 5f;
		}
		else if (aggressiveness < 5.01f)
		{
			__instance.DFExpSlider.value = 6f;
		}
		else if (aggressiveness < 8.01f)
		{
			__instance.DFExpSlider.value = 7f;
		}
		else
		{
			__instance.DFExpSlider.value = 8f;
		}
		text = aggressiveness * 100f + "%";
		__instance.DFExpText.text = text;
		GameDesc val = new GameDesc();
		float difficulty = ((CombatSettings)(ref __instance.combatSettings)).difficulty;
		string arg = ((difficulty >= 9.9999f) ? difficulty.ToString("0.00") : difficulty.ToString("0.000"));
		__instance.difficultyText.text = string.Format(Localization.Translate("难度系数值"), arg);
		__instance.difficultTipGroupDF.SetActive(((int)((CombatSettings)(ref __instance.combatSettings)).aggressiveLevel == 40 && difficulty > 4.5f) || difficulty > 6f);
		__instance.gameDesc.CopyTo(val);
		val.combatSettings = __instance.combatSettings;
		__instance.propertyMultiplierText.text = Localization.Translate("元数据生成倍率") + " " + val.propertyMultiplier.ToString("0%");
		return false;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UICombatSettingsDF), "OnMaxDensitySliderChanged")]
	private static bool OnMaxDensitySliderChanged(ref UICombatSettingsDF __instance, float arg0)
	{
		float value = __instance.maxDensitySlider.value;
		if (value < 0.5f)
		{
			__instance.combatSettings.maxDensity = 1f;
		}
		else if (value < 2.5f)
		{
			__instance.combatSettings.maxDensity = 2f;
		}
		else if (value < 3.5f)
		{
			__instance.combatSettings.maxDensity = 3f;
		}
		else if (value < 4.5f)
		{
			__instance.combatSettings.maxDensity = 4f;
		}
		else if (value < 5.5f)
		{
			__instance.combatSettings.maxDensity = 5f;
		}
		else
		{
			__instance.combatSettings.maxDensity = 6f;
		}
		__instance.UpdateUIParametersDisplay();
		return false;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UICombatSettingsDF), "OnInitLevelSliderChanged")]
	private static bool OnInitLevelSliderChanged(ref UICombatSettingsDF __instance, float arg0)
	{
		float value = __instance.initLevelSlider.value;
		if (value < 0.5f)
		{
			__instance.combatSettings.initialLevel = 0f;
		}
		else if (value < 1.5f)
		{
			__instance.combatSettings.initialLevel = 1f;
		}
		else if (value < 3.5f)
		{
			__instance.combatSettings.initialLevel = 3f;
		}
		else if (value < 6.5f)
		{
			__instance.combatSettings.initialLevel = 6f;
		}
		else if (value < 10.5f)
		{
			__instance.combatSettings.initialLevel = 10f;
		}
		else if (value < 12.5f)
		{
			__instance.combatSettings.initialLevel = 12f;
		}
		else if (value < 15.5f)
		{
			__instance.combatSettings.initialLevel = 15f;
		}
		else if (value < 18.5f)
		{
			__instance.combatSettings.initialLevel = 18f;
		}
		else if (value < 21.5f)
		{
			__instance.combatSettings.initialLevel = 21f;
		}
		else if (value < 24.5f)
		{
			__instance.combatSettings.initialLevel = 24f;
		}
		else
		{
			__instance.combatSettings.initialLevel = 30f;
		}
		__instance.UpdateUIParametersDisplay();
		return false;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UICombatSettingsDF), "_OnOpen")]
	public static void _OnOpen(ref UICombatSettingsDF __instance)
	{
		__instance.initLevelSlider.maxValue = 30f;
		__instance.maxDensitySlider.maxValue = 6f;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(StarGen), "CreateStar")]
	[HarmonyPatch(typeof(StarGen), "CreateBirthStar")]
	public static void ClampHiveCount(ref StarData __result)
	{
		__result.maxHiveCount = Mathf.Clamp(__result.maxHiveCount, 0, 8);
		__result.initialHiveCount = Mathf.Clamp(__result.initialHiveCount, 0, 8);
	}
}