Decompiled source of MobileTurretMushroom v1.0.0

BepInEx/plugins/mobileturretmushroom.dll

Decompiled 6 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Items;
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("mobileturretmushroom")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("mobileturretmushroom")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6372bb06-7c3f-4a2e-a33f-50fc48c608a1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[HarmonyPatch(typeof(MushroomBodyBehavior), "FixedUpdate")]
public class MushroomMovePatch
{
	private static void Postfix(MushroomBodyBehavior __instance)
	{
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		if (!(((BaseItemBodyBehavior)__instance).body.baseNameToken != "ENGITURRET_BODY_NAME"))
		{
			object? obj = typeof(MushroomBodyBehavior).GetField("mushroomWardGameObject", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(__instance);
			GameObject val = (GameObject)((obj is GameObject) ? obj : null);
			if ((Object)(object)val != (Object)null)
			{
				val.transform.position = ((BaseItemBodyBehavior)__instance).body.footPosition;
			}
			object? obj2 = typeof(MushroomBodyBehavior).GetField("mushroomHealingWard", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(__instance);
			HealingWard val2 = (HealingWard)((obj2 is HealingWard) ? obj2 : null);
			if ((Object)(object)val2 != (Object)null)
			{
				int stack = ((BaseItemBodyBehavior)__instance).stack;
				float num = (0.045f + 0.0225f * (float)(stack - 1)) * val2.interval;
				float num2 = ((BaseItemBodyBehavior)__instance).body.radius + 1.5f + 1.5f * (float)stack;
				val2.healFraction = num * Plugin.HealMultiplier.Value;
				val2.Networkradius = num2 * Plugin.RadiusMultiplier.Value;
			}
		}
	}
}
[HarmonyPatch(typeof(CharacterBody), "GetNotMoving")]
public class MobileTurretMushroomPatch
{
	private static void Postfix(CharacterBody __instance, ref bool __result)
	{
		if (__instance.baseNameToken == "ENGITURRET_BODY_NAME")
		{
			int itemCount = __instance.inventory.GetItemCount(Items.Mushroom);
			if (itemCount > 0)
			{
				__result = true;
			}
		}
	}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.zhora.mobileturretmushroom", "Mobile Turret Mushroom", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public static ConfigEntry<float> HealMultiplier;

	public static ConfigEntry<float> RadiusMultiplier;

	private void Awake()
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Expected O, but got Unknown
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Expected O, but got Unknown
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Expected O, but got Unknown
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Expected O, but got Unknown
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		HealMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Balance", "HealMultiplier", 0.5f, "Healing multiplier for mobile turret fungus.");
		RadiusMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Balance", "RadiusMultiplier", 0.5f, "Radius multiplier for mobile turret fungus.");
		ModSettingsManager.SetModDescription("Mobile Bustling Fungus support for Engineer mobile turrets.");
		ModSettingsManager.AddOption((BaseOption)new StepSliderOption(HealMultiplier, new StepSliderConfig
		{
			min = 0f,
			max = 1f,
			increment = 0.05f
		}));
		ModSettingsManager.AddOption((BaseOption)new StepSliderOption(RadiusMultiplier, new StepSliderConfig
		{
			min = 0f,
			max = 1f,
			increment = 0.05f
		}));
		new Harmony("com.zhora.mobileturretmushroom").PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Harmony loaded!");
	}
}