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.0.1")]
public class SellCorpsesBase : BaseUnityPlugin
{
private const string modGUID = "SellCorpsesMod";
private const string modName = "Sell corpses mod";
private const string modVersion = "1.0.1";
private const string assetPackageName = "SellCorpses";
private readonly Harmony harmony = new Harmony("SellCorpsesMod");
public static SellCorpsesBase Instance;
public static ManualLogSource mls;
public static Item deadHoardingBug;
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");
NetworkPrefabs.RegisterNetworkPrefab(deadHoardingBug.spawnPrefab);
deadHoardingBug.creditsWorth = 100;
Utilities.FixMixerGroups(deadHoardingBug.spawnPrefab);
Items.RegisterScrap(deadHoardingBug, 0, (LevelTypes)1);
harmony.PatchAll(typeof(SellCorpsesBase));
harmony.PatchAll(typeof(HoardingBugPatch));
}
}
}
namespace SellCorpses.Patches
{
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>());
}
}
}