Decompiled source of MoreModifiers v1.0.0

MoreModifiers.dll

Decompiled 23 minutes ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Normal.Realtime;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ClassLibrary")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClassLibrary")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("51d6b1df-2af8-4579-9110-c25fd5881f4c")]
[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 MoreModifiers;

[BepInPlugin("com.natrat4.MoreModifiers.mod", "MoreModifiers", "1.0.0")]
public class MoreModifiersPlugin : BaseUnityPlugin
{
	private Harmony _harmony;

	public static float ThrustMultiplierBonus = 1f;

	public static HashSet<string> ConsumedModifiersThisMatch = new HashSet<string>();

	private void Awake()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"MoreModifiers has successfully loaded");
		_harmony = new Harmony("com.natrat4.MoreModifiers.mod");
		_harmony.PatchAll();
	}

	private void Update()
	{
		if (Keyboard.current != null && ((ButtonControl)Keyboard.current.f1Key).wasPressedThisFrame)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"F1 key pressed good job dork");
		}
	}
}
[HarmonyPatch(typeof(Modifiers), "OnRealtimeModelReplaced")]
public static class Modifiers_OnRealtimeModelReplaced_Patch
{
	public static void Postfix(RealtimeModel currentModel)
	{
		if (currentModel != null && currentModel.isFreshModel)
		{
			MoreModifiersPlugin.ThrustMultiplierBonus = 1f;
			MoreModifiersPlugin.ConsumedModifiersThisMatch.Clear();
			Debug.Log((object)"Reset custom modifier bonuses and consumed pool for a new match.");
		}
	}
}
[HarmonyPatch(typeof(Modifiers), "ApplyModifier")]
public static class Modifiers_ApplyModifier_Patch
{
	public static bool Prefix(Modifiers __instance, Modifier modifier)
	{
		if ((Object)(object)modifier == (Object)null)
		{
			return true;
		}
		switch (((Object)modifier).name)
		{
		case "Zoomies":
			__instance.HorseSpeed *= 4f;
			MoreModifiersPlugin.ConsumedModifiersThisMatch.Add("Zoomies");
			Debug.Log((object)"Applied custom Zoomies modifier!");
			return false;
		case "Erectile Dysfunction":
		{
			Modifiers opponentModifiers = Game.OpponentModifiers;
			opponentModifiers.ToolGravity *= 3f;
			Modifiers opponentModifiers2 = Game.OpponentModifiers;
			opponentModifiers2.ToolDrift *= 3f;
			MoreModifiersPlugin.ConsumedModifiersThisMatch.Add("Erectile Dysfunction");
			Debug.Log((object)"Applied custom Erectile Dysfunction modifier to opponent!");
			return false;
		}
		case "Built like a Wall":
			__instance.ShieldScale *= 6f;
			MoreModifiersPlugin.ConsumedModifiersThisMatch.Add("Built like a Wall");
			Debug.Log((object)"Applied custom Built like a Wall modifier!");
			return false;
		case "Long Reach IV":
		{
			Avatar playerAvatar = Game.PlayerAvatar;
			object obj;
			if (playerAvatar == null)
			{
				obj = null;
			}
			else
			{
				User user = playerAvatar.User;
				obj = ((user != null) ? user.Modifiers : null);
			}
			if ((Object)(object)__instance == (Object)obj)
			{
				MoreModifiersPlugin.ThrustMultiplierBonus *= 4f;
				MoreModifiersPlugin.ConsumedModifiersThisMatch.Add("Long Reach IV");
				Debug.Log((object)"Applied custom Long Reach IV modifier!");
			}
			return false;
		}
		default:
			return true;
		}
	}
}
[HarmonyPatch(typeof(LanceAbility), "ActivateThrust")]
public static class LanceAbility_ActivateThrust_Patch
{
	public static void Prefix(LanceAbility __instance)
	{
		if (!(MoreModifiersPlugin.ThrustMultiplierBonus <= 1f))
		{
			Traverse val = Traverse.Create((object)__instance);
			if (!val.Field("isUsing").GetValue<bool>())
			{
				float value = val.Field("currentRetractDistance").GetValue<float>();
				float num = MoreModifiersPlugin.ThrustMultiplierBonus - 1f;
				val.Field("currentRetractDistance").SetValue((object)(value + num));
			}
		}
	}
}
[HarmonyPatch(typeof(ModifiersMenu), "OnOpen")]
public static class ModifiersMenu_OnOpen_Patch
{
	public static void Prefix()
	{
		Avatar playerAvatar = Game.PlayerAvatar;
		InjectAllCustomModifiers((playerAvatar == null) ? null : playerAvatar.User?.UnusedModifiers);
		Avatar opponentAvatar = Game.OpponentAvatar;
		InjectAllCustomModifiers((opponentAvatar == null) ? null : opponentAvatar.User?.UnusedModifiers);
	}

	private static void InjectAllCustomModifiers(List<Modifier> list)
	{
		if (list != null)
		{
			AddModifierIfMissing(list, "Zoomies", "Zoomies", "Quadruples your horse speed for a round!", isConsumed: true, isDebuff: false);
			AddModifierIfMissing(list, "Erectile Dysfunction", "Erectile Dysfunction", "Makes your OPs flacid...", isConsumed: true, isDebuff: true);
			AddModifierIfMissing(list, "Built like a Wall", "Built like a Wall", "You've never felt this well-guarded before!", isConsumed: true, isDebuff: false);
			AddModifierIfMissing(list, "Long Reach IV", "Long Reach IV", "Quadruples your lance thrust distance!", isConsumed: true, isDebuff: false);
		}
	}

	private static void AddModifierIfMissing(List<Modifier> list, string internalName, string displayName, string dialogue, bool isConsumed, bool isDebuff)
	{
		if (MoreModifiersPlugin.ConsumedModifiersThisMatch.Contains(internalName))
		{
			return;
		}
		foreach (Modifier item in list)
		{
			if ((Object)(object)item != (Object)null && ((Object)item).name == internalName)
			{
				return;
			}
		}
		Modifier val = ScriptableObject.CreateInstance<Modifier>();
		((Object)val).name = internalName;
		val.Name = displayName;
		val.Dialogue = dialogue;
		val.IsConsumed = isConsumed;
		val.IsDebuff = isDebuff;
		list.Add(val);
		Debug.Log((object)("Injected " + internalName + " into modifier pool"));
	}
}