Decompiled source of DisableInteractions v0.0.1

DisableInteractions.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using MioGame;
using MioModLoader;
using MioModdingApi;
using On.MioGame;
using On.MioGame.GlobalFunctions.game;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
[assembly: AssemblyCompany("DisableInteractions")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+bf10ee5ebdf10804c7c0bc6fa65fafbc4276a94c")]
[assembly: AssemblyProduct("DisableInteractions")]
[assembly: AssemblyTitle("DisableInteractions")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace DisableInteractions;

public class DisableInteractions : Mod
{
	private static readonly Dictionary<string, string> hittableObjects = new Dictionary<string, string>
	{
		{ "Masocrystal_node", "Energy Crystal" },
		{ "Mana_recipient_node", "Energy Flower" },
		{ "Bomb", "Bomb" },
		{ "Bumper_node", "Spring Flower" },
		{ "Scrap_pile_node", "Junk Pile" },
		{ "Breakable_node", "Breakable Wall" },
		{ "Orb_node", "Splodge crystal" },
		{ "Chocobon", "Crucible Spinner" }
	};

	private static ModMenuPage? modPage;

	private static readonly Dictionary<string, ToggleOption> isHittableOptions = new Dictionary<string, ToggleOption>();

	private static ToggleOption? canHookCrystals;

	private static ToggleOption? canHookEnemies;

	private static ToggleOption? canHookSplodge;

	private static ToggleOption? canBeHitByBombs;

	private static ToggleOption? canSlingshotShields;

	public override void Initialize()
	{
		Hooks();
		ConnectMenus();
	}

	private void Hooks()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		find_hook_shot.Suffix += new suffix_find_hook_shot(Find_hook_shot_suffix);
		combatbox_overlap_test.Suffix += new orig_combatbox_overlap_test(Combatbox_overlap_suffix);
	}

	public void ConnectMenus()
	{
		modPage = ModMenu.RegisterMod((Mod)(object)this, "Boss Refight Mod", "Boss Refight Mod Options");
		foreach (string key in hittableObjects.Keys)
		{
			string text = hittableObjects[key];
			isHittableOptions[key] = modPage.RegisterToggle(key + "-is-hittable", text + " objects are hittable", true, "Control whether this object can be hit by Mio's slashes");
		}
		canHookCrystals = modPage.RegisterToggle("can-hook-crystals", "Hairpin energy crystals", true, "Whether you can hairpin pre-placed energy crystals");
		canHookEnemies = modPage.RegisterToggle("can-hook-enemies", "Hairpin enemies", true, "Whether you can hairpin enemies (doesn't affect bosses)");
		canHookSplodge = modPage.RegisterToggle("can-hook-splodge", "Hairpin splodge crystals", true, "Whether you can hairpin energy crystals spawned by splodge or defrag");
		canBeHitByBombs = modPage.RegisterToggle("can-hit-bombs", "Can be hit by bombs", true, "Whether you can be hit by bombs. Disabling this also disables the ability to dodge bombs for energy refills");
		canSlingshotShields = modPage.RegisterToggle("can-slingshot-shields", "Can slingshot energy shields", true, "Whether slingshot projectiles can hit energy shields");
	}

	private unsafe void Combatbox_overlap_suffix(Combat_system* self, Combat_hit* h)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Invalid comparison between Unknown and I4
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Invalid comparison between Unknown and I4
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if ((int)((Combat_hit)h).result != 0 && (int)((Combat_hit)h).result != 1 && (int)((Combat_hit)h).result != 2)
			{
				return;
			}
			string text = "not a struct";
			string text2 = "not a struct";
			if (((Val_ref)(&((Node2)((Combat_hit)h).attacker_node).data)).is_struct())
			{
				text = Util.MioStringToString(*((Val_ref)(&((Node2)((Combat_hit)h).attacker_node).data)).struct_name());
			}
			if (((Val_ref)(&((Node2)((Combat_hit)h).victim_node).data)).is_struct())
			{
				text2 = Util.MioStringToString(*((Val_ref)(&((Node2)((Combat_hit)h).victim_node).data)).struct_name());
			}
			((Mod)this).LogMessage($"'{text}' just hit '{text2}'");
			if (text == "Explosion_node")
			{
				ToggleOption? obj = canBeHitByBombs;
				if (obj != null && !obj.Value)
				{
					Unsafe.Write(&((Combat_hit)h).result, (Result)3);
					return;
				}
			}
			if (text == "Orb_node" && text2 == "Breakable_node")
			{
				ToggleOption? obj2 = canSlingshotShields;
				if (obj2 != null && !obj2.Value)
				{
					Unsafe.Write(&((Combat_hit)h).result, (Result)3);
					return;
				}
			}
			if (isHittableOptions.TryGetValue(text2, out ToggleOption value) && !value.Value)
			{
				Unsafe.Write(&((Combat_hit)h).result, (Result)3);
			}
		}
		catch (Exception ex)
		{
			((Mod)this).LogMessage("Error in Combatbox_overlap suffix: " + ex.Message);
		}
	}

	private unsafe void Find_hook_shot_suffix(ref bool retBuffer, Mio* mio, Grid* g, Vec_float_2 unused, float max_length, Hook_hit* hit)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (((Hook_hit)hit).node != null)
			{
				string text = Util.MioStringToString(*((Val_ref)(&((Node2)((Hook_hit)hit).node).data)).struct_name());
				((Mod)this).LogMessage("Found hairpin target of type: " + text);
				if (text == "Hookzone_node")
				{
					ToggleOption? obj = canHookCrystals;
					if (obj != null && !obj.Value)
					{
						retBuffer = false;
						return;
					}
				}
				if (text == "Hookpoint_node")
				{
					ToggleOption? obj2 = canHookEnemies;
					if (obj2 != null && !obj2.Value)
					{
						retBuffer = false;
						return;
					}
				}
				if (text == "Orb_node")
				{
					ToggleOption? obj3 = canHookSplodge;
					if (obj3 != null && !obj3.Value)
					{
						retBuffer = false;
					}
				}
			}
			else
			{
				((Mod)this).LogMessage("No hairpin target found");
			}
		}
		catch (Exception ex)
		{
			((Mod)this).LogMessage("Error in Find_hook_shot suffix: " + ex.Message);
		}
	}
}