Decompiled source of WhiteHoleAbility v1.0.1

WhiteHoleAbility.dll

Decompiled 7 hours ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BoplFixedMath;
using HarmonyLib;
using OctoLib;
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("WhiteHoleAbility")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WhiteHoleAbility")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d6d176f2-c988-46dd-a517-9f7a6543d990")]
[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 WhiteHoleAbility;

[BepInPlugin("com.OctoLab.WhiteHoleAbility", "White Hole Ability", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource Logger;

	public static ConfigEntry<bool> CustomBg;

	public static Assembly ModAssembly;

	private void Awake()
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Expected O, but got Unknown
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		Logger = ((BaseUnityPlugin)this).Logger;
		ModAssembly = Assembly.GetExecutingAssembly();
		CustomBg = ((BaseUnityPlugin)this).Config.Bind<bool>("CustomBg", "CustomBg", false, "Invert Bg for White hole ability");
		Harmony val = new Harmony("com.OctoLab.WhiteHoleAbility");
		Texture2D val2 = Textures.LoadFromAssembly("WhiteHole_Icon", ModAssembly, true);
		Abilities.NewAbilityWithBase("Black hole", "White hole", val2);
		Abilities.AbilitySetCooldown("White hole", (Fix)4L);
		string location = Assembly.GetExecutingAssembly().Location;
		string directoryName = Path.GetDirectoryName(location);
		string text = Path.Combine(directoryName, "WhiteHoleAbility");
		Audio.AddSound("spawnWhiteHole.wav", text, false);
		Localization.AddTranslation("White hole", (Language)9, "Белая дыра");
		Localization.AddTranslation("White hole", (Language)7, "biała dziura");
		if (CustomBg.Value)
		{
			Texture2D val3 = Textures.LoadFromAssembly("InvertAbilityBg", ModAssembly, true);
			Abilities.AbilitySetBackground("White hole", val3);
		}
		val.PatchAll();
		Logger.LogInfo((object)"White Hole Ability loaded!");
	}
}
[HarmonyPatch(typeof(BlackHoleClap), "FireCommon")]
public class WhiteHoleClapInjectionPatch
{
	[HarmonyPrefix]
	public static bool Prefix(BlackHoleClap __instance)
	{
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Expected O, but got Unknown
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Expected O, but got Unknown
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Expected O, but got Unknown
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		Plugin.Logger.LogWarning((object)("BlackHoleClap gameObject.name is " + ((Object)((Component)__instance).gameObject).name));
		if (!((Object)((Component)__instance).gameObject).name.Contains("White hole"))
		{
			return true;
		}
		FieldInfo field = typeof(BlackHoleClap).GetField("blackholeOffset", BindingFlags.Instance | BindingFlags.NonPublic);
		FieldInfo field2 = typeof(BlackHoleClap).GetField("body", BindingFlags.Instance | BindingFlags.NonPublic);
		FieldInfo field3 = typeof(BlackHoleClap).GetField("playerInfo", BindingFlags.Instance | BindingFlags.NonPublic);
		FieldInfo field4 = typeof(BlackHoleClap).GetField("blackHolePrefab", BindingFlags.Instance | BindingFlags.NonPublic);
		FieldInfo field5 = typeof(BlackHoleClap).GetField("ability", BindingFlags.Instance | BindingFlags.NonPublic);
		if (field == null || field2 == null || field3 == null || field4 == null || field5 == null)
		{
			Plugin.Logger.LogError((object)"Failed to get required fields!");
			return true;
		}
		Vec2 val = (Vec2)field.GetValue(__instance);
		PlayerBody val2 = (PlayerBody)field2.GetValue(__instance);
		PlayerInfo val3 = (PlayerInfo)field3.GetValue(__instance);
		BlackHole val4 = (BlackHole)field4.GetValue(__instance);
		Ability val5 = (Ability)field5.GetValue(__instance);
		Vec2 val6 = val;
		ref Fix x = ref val6.x;
		x *= ((((Component)__instance).transform.localScale.x < 0f) ? (-Fix.One) : Fix.One);
		val6 = Vec2.ComplexMul(val2.right, val6);
		Fix val7 = Fix.Clamp(val2.fixtrans.Scale / (Fix)3L, Fix.One, (Fix)2L);
		Vec2 val8 = val2.position + val7 * val6;
		BlackHole val9 = FixTransform.InstantiateFixed<BlackHole>(val4, val8);
		val9.OwnerId = val3.playerId;
		val9.startingMass = (Fix)(-60L);
		FieldInfo field6 = typeof(BlackHole).GetField("mass", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (field6 != null)
		{
			field6.SetValue(val9, (Fix)(-60L));
		}
		FieldInfo field7 = typeof(BlackHole).GetField("targetSize", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (field7 != null)
		{
			field7.SetValue(val9, (Fix)60L);
		}
		AudioManager.Get().Play("spawnWhiteHole");
		val5.isCastable = false;
		return false;
	}
}