Decompiled source of FrankysHealthModifier v1.1.3

FrankysHealthModifier.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInExPlugin;
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("FrankysHealthModifier (FrankysHealthModifier)")]
[assembly: AssemblyProduct("FrankysHealthModifier")]
[assembly: AssemblyVersion("1.0.0.0")]
[HarmonyPatch(typeof(Health), "Awake")]
public static class HealthOverride
{
	private static void Prefix(Health __instance)
	{
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Invalid comparison between Unknown and I4
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Invalid comparison between Unknown and I4
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Invalid comparison between Unknown and I4
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Invalid comparison between Unknown and I4
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Invalid comparison between Unknown and I4
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Invalid comparison between Unknown and I4
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Invalid comparison between Unknown and I4
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Invalid comparison between Unknown and I4
		//IL_02af: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Invalid comparison between Unknown and I4
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Invalid comparison between Unknown and I4
		Unit val = ((Component)__instance).GetComponent<Unit>() ?? ((Component)__instance).GetComponentInParent<Unit>();
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		FieldInfo fieldInfo = AccessTools.Field(typeof(Health), "_maxHealth");
		FieldInfo fieldInfo2 = AccessTools.Field(typeof(Unit), "_unitType");
		UnitType val2 = (UnitType)fieldInfo2.GetValue(val);
		float value = Plugin.HornetValue.Value;
		float value2 = Plugin.SuperHornetValue.Value;
		float value3 = Plugin.ProwlerValue.Value;
		float value4 = Plugin.HawkeyeValue.Value;
		float value5 = Plugin.OspreyValue.Value;
		float value6 = Plugin.GreyhoundValue.Value;
		float value7 = Plugin.SeahawkValue.Value;
		float value8 = Plugin.ChinookValue.Value;
		float value9 = Plugin.HarrierValue.Value;
		float value10 = Plugin.VikingValue.Value;
		if ((object)fieldInfo == null)
		{
			Debug.LogError((object)"maxHealthField not valid yet");
			return;
		}
		if ((int)val2 == 1)
		{
			fieldInfo.SetValue(__instance, value);
			Debug.Log((object)$"{((Object)val).name} Health Modified to {value}");
		}
		if ((int)val2 == 2)
		{
			fieldInfo.SetValue(__instance, value2);
			Debug.Log((object)$"{((Object)val).name} Health Modified to {value2}");
		}
		if ((int)val2 == 3)
		{
			fieldInfo.SetValue(__instance, value3);
			Debug.Log((object)$"{((Object)val).name} Health Modified to {value3}");
		}
		if ((int)val2 == 4)
		{
			fieldInfo.SetValue(__instance, value4);
			Debug.Log((object)$"{((Object)val).name} Health Modified to {value4}");
		}
		if ((int)val2 == 5)
		{
			fieldInfo.SetValue(__instance, value5);
			Debug.Log((object)$"{((Object)val).name} Health Modified to {value5}");
		}
		if ((int)val2 == 6)
		{
			fieldInfo.SetValue(__instance, value4);
			Debug.Log((object)$"{((Object)val).name} Health Modified to {value6}");
		}
		if ((int)val2 == 7)
		{
			fieldInfo.SetValue(__instance, value7);
			Debug.Log((object)$"{((Object)val).name} Health Modified to {value7}");
		}
		if ((int)val2 == 9)
		{
			fieldInfo.SetValue(__instance, value8);
			Debug.Log((object)$"{((Object)val).name} Health Modified to {value8}");
		}
		if ((int)val2 == 10)
		{
			fieldInfo.SetValue(__instance, value9);
			Debug.Log((object)$"{((Object)val).name} Health Modified to {value9}");
		}
		if ((int)val2 == 11)
		{
			fieldInfo.SetValue(__instance, value10);
			Debug.Log((object)$"{((Object)val).name} Health Modified to {value10}");
		}
	}
}
[HarmonyPatch(typeof(QuickGameModeTemplate), "SetMaxHealth")]
public static class CarrierHealthOverride
{
	private static void Prefix(QuickGameModeTemplate __instance)
	{
		FieldInfo fieldInfo = AccessTools.Field(typeof(QuickGameModeTemplate), "_overrideCarrierHealth");
		bool flag = false;
		if ((object)fieldInfo != null)
		{
			flag = true;
			fieldInfo.SetValue(__instance, true);
			Debug.Log((object)"Override Carrier Health set to True");
		}
		if (!flag)
		{
			Debug.LogError((object)"Override Carrier Health toggle not found");
		}
		FieldInfo fieldInfo2 = AccessTools.Field(typeof(QuickGameModeTemplate), "_overriddenMaxCarrierHealth");
		if ((object)fieldInfo2 == null)
		{
			Debug.LogError((object)"Carrier Health not valid yet");
			return;
		}
		int num = Mathf.RoundToInt((float)Plugin.CarrierValue.Value);
		fieldInfo2.SetValue(__instance, num);
		Debug.Log((object)$"Carrier Health modified to {num}");
	}
}
[HarmonyPatch(typeof(CampaignLevelTemplate), "SetMaxHealth")]
public static class CarrierHealthOverrideCampaign
{
	private static void Prefix(CampaignLevelTemplate __instance)
	{
		FieldInfo fieldInfo = AccessTools.Field(typeof(CampaignLevelTemplate), "_overrideCarrierHealth");
		bool flag = false;
		if ((object)fieldInfo != null)
		{
			flag = true;
			fieldInfo.SetValue(__instance, true);
			Debug.Log((object)"Override Carrier Health set to True");
		}
		if (!flag)
		{
			Debug.LogError((object)"Override Carrier Health toggle not found");
		}
		FieldInfo fieldInfo2 = AccessTools.Field(typeof(CampaignLevelTemplate), "_overriddenMaxCarrierHealth");
		if ((object)fieldInfo2 == null)
		{
			Debug.LogError((object)"Carrier Health not valid yet");
			return;
		}
		int num = Mathf.RoundToInt((float)Plugin.CarrierValue.Value);
		fieldInfo2.SetValue(__instance, num);
		Debug.Log((object)$"Carrier Health modified to {num}");
	}
}
namespace BepInExPlugin;

[BepInPlugin("FrankysHealthModifier", "FrankysHealthModifier", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public static ConfigEntry<string> CarrierDesc;

	public static ConfigEntry<int> CarrierValue;

	public static ConfigEntry<string> HealthDesc;

	public static ConfigEntry<float> HornetValue;

	public static ConfigEntry<float> SuperHornetValue;

	public static ConfigEntry<float> ProwlerValue;

	public static ConfigEntry<float> HawkeyeValue;

	public static ConfigEntry<float> OspreyValue;

	public static ConfigEntry<float> GreyhoundValue;

	public static ConfigEntry<float> SeahawkValue;

	public static ConfigEntry<float> ChinookValue;

	public static ConfigEntry<float> HarrierValue;

	public static ConfigEntry<float> VikingValue;

	private void Awake()
	{
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Expected O, but got Unknown
		CarrierDesc = ((BaseUnityPlugin)this).Config.Bind<string>("Carrier", "Description", "This section sets the carrier health for both Quick/Survival and the campaign", "Description");
		CarrierValue = ((BaseUnityPlugin)this).Config.Bind<int>("Carrier", "Carrier Health", 10, "Carrier Health");
		HealthDesc = ((BaseUnityPlugin)this).Config.Bind<string>("Aircraft", "Description", "This section sets the aircraft health", "Description");
		HornetValue = ((BaseUnityPlugin)this).Config.Bind<float>("Aircraft", "Hornet Health", 100f, "Hornet");
		SuperHornetValue = ((BaseUnityPlugin)this).Config.Bind<float>("Aircraft", "Super Hornet Health", 100f, "Super Hornet");
		ProwlerValue = ((BaseUnityPlugin)this).Config.Bind<float>("Aircraft", "Prowler Health", 100f, "Prowler");
		HawkeyeValue = ((BaseUnityPlugin)this).Config.Bind<float>("Aircraft", "Hawkeye Health", 100f, "Hawkeye");
		OspreyValue = ((BaseUnityPlugin)this).Config.Bind<float>("Aircraft", "Osprey Health", 100f, "Osprey");
		GreyhoundValue = ((BaseUnityPlugin)this).Config.Bind<float>("Aircraft", "Greyhound Health", 100f, "Greyhound");
		SeahawkValue = ((BaseUnityPlugin)this).Config.Bind<float>("Aircraft", "Seahawk Health", 100f, "Seahawk");
		ChinookValue = ((BaseUnityPlugin)this).Config.Bind<float>("Aircraft", "Chinook Health", 100f, "Chinook");
		HarrierValue = ((BaseUnityPlugin)this).Config.Bind<float>("Aircraft", "Harrier Health", 100f, "Harrier");
		VikingValue = ((BaseUnityPlugin)this).Config.Bind<float>("Aircraft", "Viking Health", 100f, "Viking");
		Harmony val = new Harmony("FrankysHealthModifier");
		val.PatchAll();
		Debug.Log((object)"FrankysHealthModifier loaded");
	}
}
internal static class PluginInfo
{
	public const string PLUGIN_NAME = "FrankysHealthModifier";

	public const string PLUGIN_ID = "FrankysHealthModifier";

	public const string PLUGIN_VERSION = "1.0.0";
}