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.Configuration;
using HarmonyLib;
using HeavyCFG;
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("SandvichSlayer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SandvichSlayer")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6700ba0d-416a-4cc4-8f01-66ca01f2be00")]
[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 Heavy.Patches
{
[HarmonyPatch]
internal class EnemyTypes
{
public static GameObject HeavyModel;
[HarmonyPatch(typeof(RoundManager), "BeginEnemySpawning")]
[HarmonyPostfix]
public static void HeavyModelTest(RoundManager __instance)
{
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sandvichslayer"));
HeavyModel = val.LoadAsset<GameObject>("assets/sandvichslayer/sandvichslayerdef.prefab");
foreach (SpawnableEnemyWithRarity enemy in RoundManager.Instance.currentLevel.Enemies)
{
if ((Object)(object)enemy.enemyType != (Object)null && (Object)(object)enemy.enemyType.enemyPrefab.GetComponent<FlowermanAI>() != (Object)null)
{
FlowermanAI component = enemy.enemyType.enemyPrefab.GetComponent<FlowermanAI>();
if (!((Object)(object)((Component)component).gameObject.transform.Find("FlowermanModel") != (Object)null))
{
break;
}
Renderer[] componentsInChildren = ((Component)((Component)component).transform.Find("FlowermanModel")).GetComponentsInChildren<Renderer>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].enabled = false;
}
GameObject gameObject = HeavyModel.gameObject;
gameObject.transform.SetParent(enemy.enemyType.enemyPrefab.transform, false);
gameObject.transform.localPosition = new Vector3(0f, 0f, 0f);
if (SandvichslayerConfig.Instance.HideBG.Value)
{
Object.Destroy((Object)(object)((Component)gameObject.transform.Find("background")).gameObject);
}
}
}
}
[HarmonyPatch(typeof(FlowermanAI), "KillEnemy")]
[HarmonyPostfix]
public static void CleanUpHeavy(FlowermanAI __instance)
{
Object.Destroy((Object)(object)((Component)((Component)__instance).transform.Find("SandvichSlayerDef")).gameObject);
}
}
}
namespace HeavyCFG
{
public class SandvichslayerConfig
{
public static SandvichslayerConfig Instance;
public ConfigEntry<bool> HideBG { get; set; }
public SandvichslayerConfig(ConfigFile cfg)
{
HideBG = cfg.Bind<bool>("ModelHide", "HideBG", false, "true: Disable background border ; false: Enable background border");
Instance = this;
}
}
}
namespace SandvichSlayer
{
[BepInPlugin("SandvichSlayer", "SandvichSlayer", "0.0.1")]
internal class Plugin : BaseUnityPlugin
{
public static class PluginInfo
{
public const string GUID = "bugp3tly.SandvichSlayer";
public const string NAME = "SandvichSlayer";
public const string VERSION = "0.0.1";
public const string ASSET_BUNDLE_NAME = "sandvichslayer";
}
public Harmony harmonymain;
private void Awake()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
new SandvichslayerConfig(((BaseUnityPlugin)this).Config);
harmonymain = new Harmony("SandvichSlayer");
harmonymain.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"SandvichSlayer Loaded.");
}
}
}