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 OopsAllHotdogs.Patches;
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("OopsAllHotdogs")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OopsAllHotdogs")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("56194b1d-2905-4995-bed5-ce782a084f3d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace OopsAllHotdogs
{
[BepInPlugin("bingbongchairsllc.oopsallhotdogs", "Oops All Hotdogs", "0.1.0")]
public class OopsAllHotdogs : BaseUnityPlugin
{
private const string ModGuid = "bingbongchairsllc.oopsallhotdogs";
private const string ModName = "Oops All Hotdogs";
private const string ModVersion = "0.1.0";
internal ManualLogSource ModLogger;
public static GameObject HotdogPrefab;
private Harmony _harmony;
public static OopsAllHotdogs Instance { get; private set; }
private void Awake()
{
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
Instance = this;
ModLogger = ((BaseUnityPlugin)this).Logger;
ModLogger.LogInfo((object)"initializing…");
string text = Path.Combine(((BaseUnityPlugin)Instance).Info.Location.TrimEnd("OopsAllHotdogs.ddl".ToCharArray()), "hotdog");
AssetBundle val = AssetBundle.LoadFromFile(text);
if ((Object)(object)val == (Object)null)
{
ModLogger.LogError((object)("failed to load AssetBundle at " + text));
return;
}
HotdogPrefab = val.LoadAsset<GameObject>("hotdog");
if ((Object)(object)HotdogPrefab == (Object)null)
{
ModLogger.LogError((object)"hotdog not found in bundle");
return;
}
_harmony = new Harmony("bingbongchairsllc.oopsallhotdogs");
_harmony.PatchAll(typeof(EnemyAwakeUniversalHotdogPatch));
ModLogger.LogInfo((object)"Hotdog model loaded, patches applied.");
}
}
}
namespace OopsAllHotdogs.Patches
{
[HarmonyPatch(typeof(Enemy))]
internal class EnemyAwakeUniversalHotdogPatch
{
private const string HotdogInstanceName = "UniversalHotdogReplacement_HotdogInstance";
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void ReplaceVisualsWithHotdog(Enemy __instance)
{
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_0241: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
ManualLogSource modLogger = OopsAllHotdogs.Instance.ModLogger;
if ((Object)(object)__instance == (Object)null || (Object)(object)((Component)__instance).gameObject == (Object)null)
{
modLogger.LogError((object)"Enemy instance or its gameObject is null. Cannot replace model.");
return;
}
Transform transform = ((Component)__instance).transform;
Transform parent = ((Component)__instance).transform.parent;
GameObject hotdogPrefab = OopsAllHotdogs.HotdogPrefab;
if ((Object)(object)hotdogPrefab == (Object)null)
{
modLogger.LogError((object)"HotdogPrefab is null!");
return;
}
if ((Object)(object)parent == (Object)null)
{
modLogger.LogError((object)("Parent of '" + ((Object)transform).name + "' (expected 'Enable') is null. Cannot safely disable original visuals. Aborting for this instance."));
return;
}
GameObject val = Object.Instantiate<GameObject>(hotdogPrefab, transform);
((Object)val).name = "UniversalHotdogReplacement_HotdogInstance";
val.SetActive(true);
Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
Renderer[] array = componentsInChildren;
foreach (Renderer val2 in array)
{
val2.enabled = true;
}
Renderer[] componentsInChildren2 = ((Component)parent).GetComponentsInChildren<Renderer>(true);
Renderer[] array2 = componentsInChildren2;
foreach (Renderer val3 in array2)
{
if (!((Component)val3).transform.IsChildOf(val.transform) && !((Object)(object)((Component)val3).gameObject == (Object)(object)val))
{
val3.enabled = false;
}
}
SkinnedMeshRenderer[] componentsInChildren3 = ((Component)parent).GetComponentsInChildren<SkinnedMeshRenderer>(true);
SkinnedMeshRenderer[] array3 = componentsInChildren3;
foreach (SkinnedMeshRenderer val4 in array3)
{
if (!((Component)val4).transform.IsChildOf(val.transform) && !((Object)(object)((Component)val4).gameObject == (Object)(object)val))
{
((Renderer)val4).enabled = false;
}
}
if ((Object)(object)__instance.CenterTransform != (Object)null)
{
val.transform.localPosition = transform.InverseTransformPoint(__instance.CenterTransform.position);
val.transform.localRotation = Quaternion.Inverse(transform.rotation) * __instance.CenterTransform.rotation;
}
else
{
val.transform.localPosition = Vector3.zero;
val.transform.localRotation = Quaternion.identity;
}
float num = 70f;
Vector3 right = Vector3.right;
Quaternion val5 = Quaternion.AngleAxis(num, right);
Transform transform2 = val.transform;
transform2.localRotation *= val5;
val.transform.localScale = Vector3.one * 85f;
int layer = (val.layer = LayerMask.NameToLayer("Default"));
Transform[] componentsInChildren4 = val.GetComponentsInChildren<Transform>(true);
foreach (Transform val6 in componentsInChildren4)
{
((Component)val6).gameObject.layer = layer;
}
modLogger.LogInfo((object)("Replacement complete for script on '" + ((Object)transform).name + "'. Hotdog parented to it. Visuals under '" + ((Object)parent).name + "' (hopefully) disabled."));
}
}
}