Decompiled source of MonsterPlushiesOnly v1.0.1

BepInEx/plugins/MonsterPlushiesOnly.dll

Decompiled 12 hours ago
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using MonsterPlushiesOnly.Plushies;
using Unity.Netcode;
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("MonsterPlushiesOnly")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP")]
[assembly: AssemblyProduct("MonsterPlushiesOnly")]
[assembly: AssemblyCopyright("Copyright © HP 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9ca9a9e0-33c1-4ff1-a730-f15690903d54")]
[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 MonsterPlushiesOnly
{
	[BepInPlugin("Windyways.MonsterPlushiesOnly", "Monster Plushies Only", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public enum MonsterEnum
		{
			Null,
			ForestKeeper,
			HoardingBug,
			Masked,
			EyelessDog,
			Maneater,
			KidnapperFox,
			VainShrouds,
			Manticoil,
			TulipSnakes,
			CircuitBees,
			MaskHornets,
			Butler,
			Barber,
			OldBird,
			Thumper,
			CoilHead,
			BaboonHawk,
			EarthLeviathan,
			BunkerSpider,
			Nutcracker,
			Bracken,
			RoamingLocust,
			SnareFlea,
			GhostGirl,
			Hygrodere,
			Jester
		}

		private const string modGUID = "Windyways.MonsterPlushiesOnly";

		private const string modName = "Monster Plushies Only";

		private const string modVersion = "1.0.0";

		public readonly Harmony harmony = new Harmony("Windyways.MonsterPlushiesOnly");

		public static Plugin Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Windyways.MonsterPlushiesOnly");
			mls.LogInfo((object)"Loading Monster Plushies Only...");
			harmony.PatchAll(typeof(Plugin));
		}

		public MonsterEnum GetMonster(EnemyType obj)
		{
			if (obj.enemyName == "Centipede")
			{
				return MonsterEnum.SnareFlea;
			}
			if (obj.enemyName == "Bunker Spider")
			{
				return MonsterEnum.BunkerSpider;
			}
			if (obj.enemyName == "Hoarding bug")
			{
				return MonsterEnum.HoardingBug;
			}
			if (obj.enemyName == "Flowerman")
			{
				return MonsterEnum.Bracken;
			}
			if (obj.enemyName == "Crawler")
			{
				return MonsterEnum.Thumper;
			}
			if (obj.enemyName == "Nutcracker")
			{
				return MonsterEnum.Nutcracker;
			}
			if (obj.enemyName == "Masked")
			{
				return MonsterEnum.Masked;
			}
			if (obj.enemyName == "Butler")
			{
				return MonsterEnum.Butler;
			}
			if (obj.enemyName == "MouthDog")
			{
				return MonsterEnum.EyelessDog;
			}
			if (obj.enemyName == "ForestGiant")
			{
				return MonsterEnum.ForestKeeper;
			}
			if (obj.enemyName == "Baboon hawk")
			{
				return MonsterEnum.BaboonHawk;
			}
			if (obj.enemyName == "Manticoil")
			{
				return MonsterEnum.Manticoil;
			}
			if (obj.enemyName == "Tulip Snake")
			{
				return MonsterEnum.TulipSnakes;
			}
			if (obj.enemyName == "BushWolf")
			{
				return MonsterEnum.KidnapperFox;
			}
			if (obj.enemyName == "Maneater")
			{
				return MonsterEnum.Maneater;
			}
			return MonsterEnum.Null;
		}
	}
}
namespace MonsterPlushiesOnly.Plushies
{
	public class ManagePlushieValues : BaseUnityPlugin
	{
		public static ManagePlushieValues Instance;

		internal ConfigEntry<int> MaskedPlushieMinValue;

		internal ConfigEntry<int> MaskedPlushieMaxValue;

		internal ConfigEntry<int> HoardingBugPlushieMinValue;

		internal ConfigEntry<int> HoardingBugPlushieMaxValue;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Plugin.Instance.harmony.PatchAll(typeof(ManagePlushieValues));
			SetConfig();
		}

		public void SetConfig()
		{
			MaskedPlushieMinValue = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Masked Plushie Min Value", 10, "The minimum scrap value of Masked Plushies obtained via Masked.");
			MaskedPlushieMaxValue = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Masked Plushie Max Value", 70, "The maximum scrap value of Masked Plushies obtained via Masked.");
			HoardingBugPlushieMinValue = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Hoarding Bug Plushie Min Value", 10, "The minimum scrap value of Hoarding Bug Plushies obtained via Hoarding Bugs.");
			HoardingBugPlushieMaxValue = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Hoarding Bug Plushie Max Value", 70, "The maximum scrap value of Hoarding Bug Plushies obtained via Hoarding Bugs.");
		}
	}
}
namespace MonsterPlushiesOnly.Patches.MonsterPatches
{
	internal class HoardingBugPatch
	{
		private static Item _hoardingBugPlushieItem;

		private static Item HoardingBugPlushieItem
		{
			get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				if ((Object)_hoardingBugPlushieItem == (Object)null)
				{
					_hoardingBugPlushieItem = StartOfRound.Instance.allItemsList.itemsList.First((Item i) => ((Object)i).name == "TragedyMask");
				}
				return _hoardingBugPlushieItem;
			}
		}

		[HarmonyPatch(typeof(EnemyAI))]
		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		private static void KillEnemyPatch(EnemyAI __instance)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			EnemyType enemyType = __instance.enemyType;
			Plugin.MonsterEnum monster = Plugin.Instance.GetMonster(enemyType);
			if (monster != Plugin.MonsterEnum.HoardingBug)
			{
				return;
			}
			Item hoardingBugPlushieItem = HoardingBugPlushieItem;
			if (NetworkManager.Singleton.IsServer)
			{
				Vector3 val = ((Component)__instance).transform.position + new Vector3(0f, 2.5f, 0f);
				Vector3 val2 = val + new Vector3(0f, -2.5f, 0f);
				HauntedMaskItem component = Object.Instantiate<GameObject>(hoardingBugPlushieItem.spawnPrefab, val, Quaternion.identity).GetComponent<HauntedMaskItem>();
				component.maskIsHaunted = true;
				NetworkObject component2 = ((Component)component).GetComponent<NetworkObject>();
				if ((Object)component2 != (Object)null)
				{
					component2.Spawn(false);
				}
				((Component)component).GetComponentInChildren<GrabbableObject>().SetScrapValue(Random.Range(ManagePlushieValues.Instance.HoardingBugPlushieMinValue.Value, ManagePlushieValues.Instance.HoardingBugPlushieMaxValue.Value));
			}
		}
	}
	[HarmonyPatch(typeof(MaskedPlayerEnemy))]
	internal class MaskedPatch
	{
		private static Item _maskedPlushieItem;

		private static Item MaskedPlushieItem
		{
			get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				if ((Object)_maskedPlushieItem == (Object)null)
				{
					_maskedPlushieItem = StartOfRound.Instance.allItemsList.itemsList.First((Item i) => ((Object)i).name == "TragedyMask");
				}
				return _maskedPlushieItem;
			}
		}

		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		internal static void DropMaskOnDeath(MaskedPlayerEnemy __instance)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			Item maskedPlushieItem = MaskedPlushieItem;
			if (NetworkManager.Singleton.IsServer)
			{
				Vector3 val = ((Component)__instance).transform.position + new Vector3(0f, 2.5f, 0f);
				Vector3 val2 = val + new Vector3(0f, -2.5f, 0f);
				HauntedMaskItem component = Object.Instantiate<GameObject>(maskedPlushieItem.spawnPrefab, val, Quaternion.identity).GetComponent<HauntedMaskItem>();
				component.maskIsHaunted = true;
				NetworkObject component2 = ((Component)component).GetComponent<NetworkObject>();
				if ((Object)component2 != (Object)null)
				{
					component2.Spawn(false);
				}
				((Component)component).GetComponentInChildren<GrabbableObject>().SetScrapValue(Random.Range(ManagePlushieValues.Instance.MaskedPlushieMinValue.Value, ManagePlushieValues.Instance.MaskedPlushieMaxValue.Value));
			}
		}
	}
}