using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
[BepInPlugin("com.lexdevies.kitabaeyoh", "LIL BAM LIL BAM LIL BAM", "1.2.9")]
public class KitaBaeYoh : BaseUnityPlugin
{
private static GameObject bamkitaPrefab;
private static GameObject pickupSound;
private static GameObject putdownSound;
private static void CopyItemIdentifier(ItemIdentifier from, ItemIdentifier to)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
Type typeFromHandle = typeof(ItemIdentifier);
BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
FieldInfo[] fields = typeFromHandle.GetFields(bindingAttr);
foreach (FieldInfo fieldInfo in fields)
{
try
{
fieldInfo.SetValue(to, fieldInfo.GetValue(from));
}
catch
{
}
}
to.itemType = (ItemType)6;
to.pickUpSound = pickupSound;
}
private void LogItemIdentifier(ItemIdentifier id)
{
if ((Object)(object)id == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"ItemIdentifier is null!");
return;
}
Type typeFromHandle = typeof(ItemIdentifier);
BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
((BaseUnityPlugin)this).Logger.LogInfo((object)("--- Logging fields for " + ((Object)id).name + " ---"));
FieldInfo[] fields = typeFromHandle.GetFields(bindingAttr);
foreach (FieldInfo fieldInfo in fields)
{
try
{
object value = fieldInfo.GetValue(id);
((BaseUnityPlugin)this).Logger.LogInfo((object)$"Field: {fieldInfo.Name} = {value}");
}
catch
{
}
}
((BaseUnityPlugin)this).Logger.LogInfo((object)("--- Logging properties for " + ((Object)id).name + " ---"));
PropertyInfo[] properties = typeFromHandle.GetProperties(bindingAttr);
foreach (PropertyInfo propertyInfo in properties)
{
try
{
object value2 = propertyInfo.GetValue(id);
((BaseUnityPlugin)this).Logger.LogInfo((object)$"Property: {propertyInfo.Name} = {value2}");
}
catch
{
}
}
}
private void SetAllLayers(GameObject obj, int layer)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
obj.layer = layer;
foreach (Transform item in obj.transform)
{
Transform val = item;
SetAllLayers(((Component)val).gameObject, layer);
}
}
private void MiscLevelSpawn()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: 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_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: 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_0203: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)GameObject.Find("Sandbox Shop") != (Object)null)
{
Vector3 spawnLoc = default(Vector3);
((Vector3)(ref spawnLoc))..ctor(-45f, 0f, 340f);
Quaternion identity = Quaternion.identity;
SpawnBam(spawnLoc, identity);
return;
}
GameObject val = GameObject.Find("Prime FirstRoom");
if ((Object)(object)val != (Object)null)
{
Transform val2 = val.transform.Find("Room");
Transform val3 = ((val2 != null) ? val2.Find("FinalDoor") : null);
if ((Object)(object)val3 != (Object)null)
{
Vector3 spawnLoc2 = val3.position + new Vector3(0.25f, 1.75f, 0f);
Quaternion spawnRot = Quaternion.Euler(0f, 180f, 0f);
SpawnBam(spawnLoc2, spawnRot);
return;
}
}
GameObject val4 = GameObject.Find("FirstRoom Encore");
if ((Object)(object)val4 != (Object)null)
{
Transform val5 = val4.transform.Find("Room");
Transform val6 = ((val5 != null) ? val5.Find("FinalDoor") : null);
if ((Object)(object)val6 != (Object)null)
{
Vector3 spawnLoc3 = val6.position + new Vector3(0.25f, 1.75f, 0f);
Quaternion spawnRot2 = Quaternion.Euler(0f, 180f, 0f);
SpawnBam(spawnLoc3, spawnRot2);
return;
}
}
GameObject val7 = GameObject.Find("FirstRoom Secret");
if ((Object)(object)val7 != (Object)null)
{
Transform val8 = val7.transform.Find("Room");
Transform val9 = ((val8 != null) ? val8.Find("FinalDoor") : null);
if ((Object)(object)val9 != (Object)null)
{
Vector3 spawnLoc4 = val9.position + new Vector3(0.25f, 1.75f, 0f);
Quaternion spawnRot3 = Quaternion.Euler(0f, 180f, 0f);
SpawnBam(spawnLoc4, spawnRot3);
return;
}
}
if (!((Object)(object)GameObject.Find("Main Menu State") != (Object)null) && !((Object)(object)GameObject.Find("Init") != (Object)null))
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"IF YOU'RE IN THE MAIN MENU OR SPLASH SCREEN IGNORE THIS MESSAGE");
((BaseUnityPlugin)this).Logger.LogWarning((object)"whoopsies i guess there's nowhere to spawn lil' bam");
}
}
private void SpawnBam(Vector3 spawnLoc, Quaternion spawnRot)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(bamkitaPrefab, spawnLoc, spawnRot);
((Object)val).name = "your pet bam";
ItemIdentifier from = reserveItemId();
ItemIdentifier to = val.AddComponent<ItemIdentifier>();
CopyItemIdentifier(from, to);
SetAllLayers(val, LayerMask.NameToLayer("Item"));
}
private void Awake()
{
SceneManager.sceneLoaded += OnSceneLoaded;
string[] files = Directory.GetFiles(Paths.PluginPath, "bamkitabundle", SearchOption.AllDirectories);
if (files.Length == 0)
{
((BaseUnityPlugin)this).Logger.LogError((object)"bamkitabundle not found!");
return;
}
string text = files[0];
AssetBundle val = AssetBundle.LoadFromFile(text);
if ((Object)(object)val == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load asset bundle!");
return;
}
bamkitaPrefab = val.LoadAsset<GameObject>("DevPlushie (Bamkita)");
if ((Object)(object)bamkitaPrefab == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load prefab from asset bundle!");
}
pickupSound = val.LoadAsset<GameObject>("BamkitaPickup");
putdownSound = val.LoadAsset<GameObject>("BamkitaPutDown");
}
private static ItemIdentifier reserveItemId()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: 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_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("TempDummy");
ItemIdentifier val2 = val.AddComponent<ItemIdentifier>();
val2.infiniteSource = false;
val2.dropOnHit = false;
val2.pickedUp = true;
val2.beenPickedUp = false;
val2.reverseTransformSettings = true;
val2.putDownPosition = new Vector3(0f, 0f, 0.13f);
val2.putDownRotation = new Vector3(0f, 115f, 90f);
val2.putDownScale = new Vector3(0.5f, 0.5f, 0.5f);
val2.itemType = (ItemType)7;
val2.noHoldingAnimation = false;
val2.hooked = false;
val2.ipz = null;
val2.pickUpSound = null;
val2.onPickUp = null;
val2.onPutDown = null;
return val2;
}
private void huntForPlushies()
{
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
GameObject[] array = Object.FindObjectsOfType<GameObject>();
foreach (GameObject val in array)
{
if (((Object)val).name.Contains("DevPlushie") || ((Object)val).name.Contains("Florp"))
{
((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)val).name + ". YOU ARE NOW LIL BAM."));
GameObject val2 = Object.Instantiate<GameObject>(bamkitaPrefab, val.transform.position, val.transform.rotation);
val2.transform.parent = val.transform.parent;
((Object)val2).name = "(BAMIFIED) " + ((Object)val).name;
ItemIdentifier component = val.GetComponent<ItemIdentifier>();
ItemIdentifier val3 = val2.AddComponent<ItemIdentifier>();
if ((Object)(object)component != (Object)null)
{
CopyItemIdentifier(component, val3);
}
SetAllLayers(val2, LayerMask.NameToLayer("Item"));
val3.pickUpSound = pickupSound;
Object.Destroy((Object)(object)val);
}
}
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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_0084: Unknown result type (might be due to invalid IL or missing references)
huntForPlushies();
GameObject val = GameObject.Find("FirstRoom");
if ((Object)(object)val == (Object)null)
{
MiscLevelSpawn();
return;
}
Transform val2 = val.transform.Find("Room");
Transform val3 = val2.Find("FinalDoor");
Vector3 spawnLoc = val3.position + new Vector3(0.25f, 1.75f, 0f);
Quaternion spawnRot = default(Quaternion);
((Quaternion)(ref spawnRot))..ctor(0f, 180f, 0f, 0f);
SpawnBam(spawnLoc, spawnRot);
}
}