Decompiled source of Sell Dead Enemies Mod v1.2.0

SellCorpses.dll

Decompiled 10 months ago
using System.Collections.Generic;
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.Logging;
using HarmonyLib;
using LethalLib.Modules;
using SellCorpses;
using SellCorpses.Patches;
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("SellCorpses")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SellCorpses")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d874e430-3aad-4944-bee0-1f37913276e4")]
[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 ViniMod.Patches
{
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
		[HarmonyPrefix]
		public static void spawnYippees(ref List<EnemyAI> ___SpawnedEnemies, ref SelectableLevel newLevel)
		{
			EnemyAI val = null;
			for (int i = 0; i < newLevel.Enemies.Count; i++)
			{
				newLevel.maxEnemyPowerCount = 1000;
				newLevel.Enemies[i].rarity = 0;
				if ((Object)(object)newLevel.Enemies[i].enemyType.enemyPrefab.GetComponent<HoarderBugAI>() != (Object)null)
				{
					newLevel.Enemies[i].rarity = 999;
					val = (EnemyAI)(object)newLevel.Enemies[i].enemyType.enemyPrefab.GetComponent<HoarderBugAI>();
					newLevel.Enemies[i].enemyType.MaxCount = 40;
					SellCorpsesBase.mls.LogDebug((object)("Found a " + ((Object)val).name));
				}
				else
				{
					SellCorpsesBase.mls.LogDebug((object)("Found a " + ((Object)newLevel.Enemies[i].enemyType).name + ":("));
				}
			}
		}
	}
}
namespace SellCorpses
{
	[BepInPlugin("SellCorpsesMod", "Sell corpses mod", "1.2")]
	public class SellCorpsesBase : BaseUnityPlugin
	{
		private const string modGUID = "SellCorpsesMod";

		private const string modName = "Sell corpses mod";

		private const string modVersion = "1.2";

		private const string assetPackageName = "SellCorpses";

		private readonly Harmony harmony = new Harmony("SellCorpsesMod");

		public static SellCorpsesBase Instance;

		public static ManualLogSource mls;

		public static Item deadHoardingBug;

		public static Item deadSpider;

		public static Item deadCentipede;

		public static Item deadEyelessDog;

		public static Item deadThumper;

		public static Item deadNutcracker;

		public static Item deadBaboonHawk;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("SellCorpsesMod");
			mls.LogDebug((object)"ViniMod has awoken!");
			mls.LogDebug((object)"Config has awoken!");
			mls = ((BaseUnityPlugin)this).Logger;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "SellCorpses");
			mls.LogDebug((object)File.Exists(text));
			AssetBundle val = AssetBundle.LoadFromFile(text);
			deadHoardingBug = val.LoadAsset<Item>("Assets/ViniStuffs/DeadHoarderBugItem.asset");
			deadBaboonHawk = val.LoadAsset<Item>("Assets/ViniStuffs/DeadBaboonHawkItem.asset");
			deadCentipede = val.LoadAsset<Item>("Assets/ViniStuffs/DeadCentipedeItem.asset");
			deadThumper = val.LoadAsset<Item>("Assets/ViniStuffs/DeadCrawlerItem.asset");
			deadEyelessDog = val.LoadAsset<Item>("Assets/ViniStuffs/DeadEyelessDogItem.asset");
			deadNutcracker = val.LoadAsset<Item>("Assets/ViniStuffs/DeadNutcrackerItem.asset");
			deadSpider = val.LoadAsset<Item>("Assets/ViniStuffs/DeadSandSpiderItem.asset");
			NetworkPrefabs.RegisterNetworkPrefab(deadHoardingBug.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(deadBaboonHawk.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(deadCentipede.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(deadThumper.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(deadEyelessDog.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(deadNutcracker.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(deadSpider.spawnPrefab);
			Utilities.FixMixerGroups(deadHoardingBug.spawnPrefab);
			Utilities.FixMixerGroups(deadBaboonHawk.spawnPrefab);
			Utilities.FixMixerGroups(deadCentipede.spawnPrefab);
			Utilities.FixMixerGroups(deadThumper.spawnPrefab);
			Utilities.FixMixerGroups(deadEyelessDog.spawnPrefab);
			Utilities.FixMixerGroups(deadSpider.spawnPrefab);
			Utilities.FixMixerGroups(deadNutcracker.spawnPrefab);
			Items.RegisterScrap(deadHoardingBug, 0, (LevelTypes)1);
			Items.RegisterScrap(deadBaboonHawk, 0, (LevelTypes)1);
			Items.RegisterScrap(deadCentipede, 0, (LevelTypes)1);
			Items.RegisterScrap(deadThumper, 0, (LevelTypes)1);
			Items.RegisterScrap(deadEyelessDog, 0, (LevelTypes)1);
			Items.RegisterScrap(deadNutcracker, 0, (LevelTypes)1);
			Items.RegisterScrap(deadSpider, 0, (LevelTypes)1);
			harmony.PatchAll(typeof(SellCorpsesBase));
			harmony.PatchAll(typeof(HoardingBugPatch));
			harmony.PatchAll(typeof(BaboonHawkPatch));
			harmony.PatchAll(typeof(CentipedePatch));
			harmony.PatchAll(typeof(EyelessDogPatch));
			harmony.PatchAll(typeof(NutcrackerPatch));
			harmony.PatchAll(typeof(SandSpiderPatch));
			harmony.PatchAll(typeof(ThumperPatch));
		}
	}
}
namespace SellCorpses.Patches
{
	internal class ThumperPatch
	{
		[HarmonyPatch(typeof(CrawlerAI), "KillEnemy")]
		[HarmonyPostfix]
		public static void spawnDeadBody(CrawlerAI __instance)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(SellCorpsesBase.deadThumper.spawnPrefab, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
			GrabbableObject component = val.GetComponent<GrabbableObject>();
			((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation);
			component.fallTime = 0f;
			component.scrapValue = 100;
			NetworkObject component2 = val.GetComponent<NetworkObject>();
			component2.Spawn(false);
			Debug.Log((object)"Despawn network object in kill enemy called!");
			RoundManager.Instance.DespawnEnemyOnServer(((Component)__instance).GetComponent<NetworkObject>());
		}
	}
	internal class CentipedePatch
	{
		[HarmonyPatch(typeof(CentipedeAI), "KillEnemy")]
		[HarmonyPostfix]
		public static void spawnDeadBody(CentipedeAI __instance)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(SellCorpsesBase.deadCentipede.spawnPrefab, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
			GrabbableObject component = val.GetComponent<GrabbableObject>();
			((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation);
			component.fallTime = 0f;
			component.scrapValue = 40;
			NetworkObject component2 = val.GetComponent<NetworkObject>();
			component2.Spawn(false);
			Debug.Log((object)"Despawn network object in kill enemy called!");
			RoundManager.Instance.DespawnEnemyOnServer(((Component)__instance).GetComponent<NetworkObject>());
		}
	}
	internal class BaboonHawkPatch
	{
		[HarmonyPatch(typeof(BaboonBirdAI), "KillEnemy")]
		[HarmonyPostfix]
		public static void spawnDeadBody(BaboonBirdAI __instance)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(SellCorpsesBase.deadBaboonHawk.spawnPrefab, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
			GrabbableObject component = val.GetComponent<GrabbableObject>();
			((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation);
			component.fallTime = 0f;
			component.scrapValue = 80;
			NetworkObject component2 = val.GetComponent<NetworkObject>();
			component2.Spawn(false);
			Debug.Log((object)"Despawn network object in kill enemy called!");
			RoundManager.Instance.DespawnEnemyOnServer(((Component)__instance).GetComponent<NetworkObject>());
		}
	}
	internal class SandSpiderPatch
	{
		[HarmonyPatch(typeof(SandSpiderAI), "KillEnemy")]
		[HarmonyPostfix]
		public static void spawnDeadBody(SandSpiderAI __instance)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(SellCorpsesBase.deadSpider.spawnPrefab, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
			GrabbableObject component = val.GetComponent<GrabbableObject>();
			((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation);
			component.fallTime = 0f;
			component.scrapValue = 160;
			NetworkObject component2 = val.GetComponent<NetworkObject>();
			component2.Spawn(false);
			Debug.Log((object)"Despawn network object in kill enemy called!");
			RoundManager.Instance.DespawnEnemyOnServer(((Component)__instance).GetComponent<NetworkObject>());
		}
	}
	internal class EyelessDogPatch
	{
		[HarmonyPatch(typeof(MouthDogAI), "KillEnemy")]
		[HarmonyPostfix]
		public static void spawnDeadBody(MouthDogAI __instance)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(SellCorpsesBase.deadEyelessDog.spawnPrefab, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
			GrabbableObject component = val.GetComponent<GrabbableObject>();
			((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation);
			component.fallTime = 0f;
			component.scrapValue = 180;
			NetworkObject component2 = val.GetComponent<NetworkObject>();
			component2.Spawn(false);
			Debug.Log((object)"Despawn network object in kill enemy called!");
			RoundManager.Instance.DespawnEnemyOnServer(((Component)__instance).GetComponent<NetworkObject>());
		}
	}
	internal class NutcrackerPatch
	{
		[HarmonyPatch(typeof(NutcrackerEnemyAI), "SpawnShotgunShells")]
		[HarmonyPostfix]
		public static void spawnDeadBody(NutcrackerEnemyAI __instance)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(SellCorpsesBase.deadNutcracker.spawnPrefab, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
			GrabbableObject component = val.GetComponent<GrabbableObject>();
			((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation);
			component.fallTime = 0f;
			component.scrapValue = 100;
			NetworkObject component2 = val.GetComponent<NetworkObject>();
			component2.Spawn(false);
			Debug.Log((object)"Despawn network object in kill enemy called!");
			RoundManager.Instance.DespawnEnemyOnServer(((Component)__instance).GetComponent<NetworkObject>());
		}
	}
	internal class HoardingBugPatch
	{
		[HarmonyPatch(typeof(HoarderBugAI), "KillEnemy")]
		[HarmonyPostfix]
		public static void spawnDeadBody(HoarderBugAI __instance)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(SellCorpsesBase.deadHoardingBug.spawnPrefab, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
			GrabbableObject component = val.GetComponent<GrabbableObject>();
			((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation);
			component.fallTime = 0f;
			component.scrapValue = 60;
			NetworkObject component2 = val.GetComponent<NetworkObject>();
			component2.Spawn(false);
			Debug.Log((object)"Despawn network object in kill enemy called!");
			RoundManager.Instance.DespawnEnemyOnServer(((Component)__instance).GetComponent<NetworkObject>());
		}
	}
}