using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Audio;
using UnityEngine.Events;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DarkFountains")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DarkFountains")]
[assembly: AssemblyTitle("DarkFountains")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Ultrapit;
[BepInPlugin("DarkFountains.draghtnim.ultrakill", "DarkFountains", "1.0")]
public class Plugin : BaseUnityPlugin
{
private AssetBundle terminal;
public static bool IsCustomLevel = false;
private Scene scene;
private GameObject pitobj;
private GameObject newpitobj;
private AssetBundle bundlepit;
private static Plugin _instance;
private static Shader MainShader;
private static string assemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
private static AssetBundle PitBundle = AssetBundle.LoadFromFile(Path.Combine(assemblyLocation, "DATA_PACKAGE.resource"));
private static GameObject[] prefabs = PitBundle.LoadAllAssets<GameObject>();
public static Plugin Instance => _instance;
public static void ReplaceShader(Material mat, Shader shader)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
if ((Object)mat == (Object)null || (Object)mat.shader == (Object)null)
{
return;
}
int renderQueue = mat.renderQueue;
Shader shader2 = mat.shader;
if ((Object)Shader.Find(((Object)shader2).name) != (Object)null)
{
if (((Object)mat.shader).name != "Standard")
{
mat.shader = Shader.Find(((Object)shader2).name);
}
else
{
mat.shader = shader;
}
mat.renderQueue = renderQueue;
}
else if (((Object)shader2).name == ((Object)shader).name)
{
mat.shader = shader;
mat.renderQueue = renderQueue;
}
else
{
mat.renderQueue = renderQueue;
}
}
public static void ReplaceAssets()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: 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_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Expected O, but got Unknown
List<Material> list = new List<Material>();
Dictionary<string, AudioMixer> dictionary = new Dictionary<string, AudioMixer>();
dictionary["AllAudio"] = Addressables.LoadAssetAsync<AudioMixer>((object)"AllAudio").WaitForCompletion();
dictionary["DoorAudio"] = Addressables.LoadAssetAsync<AudioMixer>((object)"DoorAudio").WaitForCompletion();
dictionary["GoreAudio"] = Addressables.LoadAssetAsync<AudioMixer>((object)"GoreAudio").WaitForCompletion();
dictionary["MusicAudio"] = Addressables.LoadAssetAsync<AudioMixer>((object)"MusicAudio").WaitForCompletion();
dictionary["UnfreezeableAudio"] = Addressables.LoadAssetAsync<AudioMixer>((object)"UnfreezeableAudio").WaitForCompletion();
GameObject[] array = PitBundle.LoadAllAssets<GameObject>();
GameObject[] array2 = array;
foreach (GameObject val in array2)
{
if (val.GetComponentsInChildren<AudioSource>(true) == null)
{
continue;
}
AudioSource[] componentsInChildren = val.GetComponentsInChildren<AudioSource>(true);
AudioSource[] array3 = componentsInChildren;
foreach (AudioSource val2 in array3)
{
if ((Object)val2.outputAudioMixerGroup != (Object)null && dictionary.TryGetValue(((Object)val2.outputAudioMixerGroup.audioMixer).name, out var value))
{
val2.outputAudioMixerGroup.audioMixer.outputAudioMixerGroup = value.FindMatchingGroups("Master").FirstOrDefault();
}
}
}
}
public static GameObject FindObjectEvenIfDisabled(string rootName, string objPath = null, int childNum = 0, bool useChildNum = false)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
GameObject val = null;
Scene activeScene = SceneManager.GetActiveScene();
GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects();
bool flag = false;
GameObject[] array = rootGameObjects;
foreach (GameObject val2 in array)
{
if (((Object)val2).name == rootName)
{
val = val2;
flag = true;
}
}
if (flag)
{
GameObject val3 = val;
if (objPath != null)
{
val3 = ((Component)val.transform.Find(objPath)).gameObject;
if (!useChildNum)
{
val = val3;
}
}
if (useChildNum)
{
GameObject gameObject = ((Component)val3.transform.GetChild(childNum)).gameObject;
val = gameObject;
}
}
return val;
}
private void Awake()
{
_instance = this;
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
SceneManager.sceneLoaded += OnSceneLoaded;
}
private void OnDestroy()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
Scene activeScene = SceneManager.GetActiveScene();
logger.LogInfo((object)((Scene)(ref activeScene)).name);
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_01b8: 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_03bc: Unknown result type (might be due to invalid IL or missing references)
//IL_03c6: Expected O, but got Unknown
//IL_0403: Unknown result type (might be due to invalid IL or missing references)
//IL_040d: Expected O, but got Unknown
//IL_044a: Unknown result type (might be due to invalid IL or missing references)
//IL_0454: Expected O, but got Unknown
//IL_05d8: Unknown result type (might be due to invalid IL or missing references)
//IL_0624: Unknown result type (might be due to invalid IL or missing references)
//IL_0682: Unknown result type (might be due to invalid IL or missing references)
//IL_0696: Unknown result type (might be due to invalid IL or missing references)
//IL_069b: Unknown result type (might be due to invalid IL or missing references)
//IL_0721: Unknown result type (might be due to invalid IL or missing references)
//IL_0735: Unknown result type (might be due to invalid IL or missing references)
//IL_073a: Unknown result type (might be due to invalid IL or missing references)
//IL_0772: Unknown result type (might be due to invalid IL or missing references)
//IL_0786: Unknown result type (might be due to invalid IL or missing references)
//IL_078b: Unknown result type (might be due to invalid IL or missing references)
//IL_08ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0938: Unknown result type (might be due to invalid IL or missing references)
//IL_0878: Unknown result type (might be due to invalid IL or missing references)
//IL_0ab3: Unknown result type (might be due to invalid IL or missing references)
//IL_0aff: Unknown result type (might be due to invalid IL or missing references)
//IL_0bb4: Unknown result type (might be due to invalid IL or missing references)
//IL_0bc5: Unknown result type (might be due to invalid IL or missing references)
//IL_0c0c: Unknown result type (might be due to invalid IL or missing references)
//IL_0c16: Expected O, but got Unknown
//IL_0c88: Unknown result type (might be due to invalid IL or missing references)
//IL_0c99: Unknown result type (might be due to invalid IL or missing references)
//IL_0ced: Unknown result type (might be due to invalid IL or missing references)
//IL_0d41: Unknown result type (might be due to invalid IL or missing references)
int num = Random.Range(1, 10);
GameObject[] array = PitBundle.LoadAllAssets<GameObject>();
GameObject val = array[1];
if (SceneHelper.CurrentScene != "Main Menu" || SceneHelper.CurrentScene != "Bootstrap" || SceneHelper.CurrentScene != "Intro")
{
ReplaceAssets();
}
switch (SceneHelper.CurrentScene)
{
case "Level 0-2":
FindObjectEvenIfDisabled("5B - Secret Arena", "5B Nonstuff/Pit (2)").transform.position = new Vector3(0f, 0f, 798f);
FindObjectEvenIfDisabled("5B - Secret Arena", "5B Nonstuff/Pit (3)").transform.position = new Vector3(0f, 0f, 778f);
val = Object.Instantiate<GameObject>(array[7]);
break;
case "Level 0-S":
FindObjectEvenIfDisabled("FinalRoom SecretExit").gameObject.SetActive(false);
val = Object.Instantiate<GameObject>(array[0]);
((Renderer)FindObjectEvenIfDisabled("Hellgate Textless Variant", "DoorLeft").GetComponent<MeshRenderer>()).allowOcclusionWhenDynamic = false;
((Renderer)FindObjectEvenIfDisabled("Hellgate Textless Variant", "DoorRight").GetComponent<MeshRenderer>()).allowOcclusionWhenDynamic = false;
FindObjectEvenIfDisabled("0 - 0-S exit(Clone)", "closedoor").GetComponent<ObjectActivator>().events.toDisActivateObjects[0] = FindObjectEvenIfDisabled("Hellgate Textless Variant", "Opener");
break;
case "Level 1-1":
{
FindObjectEvenIfDisabled("1 - First Field", "1 Stuff/Fountain").gameObject.SetActive(false);
val = Object.Instantiate<GameObject>(array[1]);
((BaseUnityPlugin)this).Logger.LogInfo((object)((Object)FindObjectEvenIfDisabled("1 - Darker_Fountain(Clone)")).name);
((BaseUnityPlugin)this).Logger.LogInfo((object)((Object)FindObjectEvenIfDisabled("1 - Darker_Fountain(Clone)", "fountain")).name);
((BaseUnityPlugin)this).Logger.LogInfo((object)((Object)FindObjectEvenIfDisabled("1 - Darker_Fountain(Clone)", "fountain/muzzles/")).name);
((BaseUnityPlugin)this).Logger.LogInfo((object)((Object)FindObjectEvenIfDisabled("1 - Darker_Fountain(Clone)", "fountain/muzzles/muzzleflash (4)")).name);
((BaseUnityPlugin)this).Logger.LogInfo((object)((Object)FindObjectEvenIfDisabled("StatsManager")).name);
((BaseUnityPlugin)this).Logger.LogInfo((object)FindObjectEvenIfDisabled("1 - Darker_Fountain(Clone)", "fountain/muzzles/muzzleflash (4)").GetComponent<ObjectActivator>().events);
FindObjectEvenIfDisabled("1 - Darker_Fountain(Clone)", "fountain/muzzles/muzzleflash (4)").GetComponent<ObjectActivator>().events.onActivate.AddListener(new UnityAction(FindObjectEvenIfDisabled("StatsManager").GetComponent<StatsManager>().StopTimer));
FindObjectEvenIfDisabled("1 - Darker_Fountain(Clone)", "fountain/Cylinder (1)").GetComponent<CoinActivated>().events.onActivate.AddListener(new UnityAction(FindObjectEvenIfDisabled("FirstRoom", "Room/FinalDoor/DoorLeft").GetComponent<Door>().LockClose));
FindObjectEvenIfDisabled("1 - Darker_Fountain(Clone)", "fountain/Cylinder (1)").GetComponent<CoinActivated>().events.onActivate.AddListener(new UnityAction(FindObjectEvenIfDisabled("FirstRoom", "Room/FinalDoor/DoorRight").GetComponent<Door>().LockClose));
GameObject val2 = FindObjectEvenIfDisabled("1 - Darker_Fountain(Clone)", "nopass");
val2.GetComponent<ObjectActivator>().events.toDisActivateObjects[0] = FindObjectEvenIfDisabled("LargeDoor", "OpenZone (1)");
val2.GetComponent<ObjectActivator>().events.toDisActivateObjects[1] = FindObjectEvenIfDisabled("LargeDoor (12)", "OpenZone (1)");
val.transform.parent = FindObjectEvenIfDisabled("1 - First Field", "1 Stuff").transform;
((BaseUnityPlugin)this).Logger.LogMessage((object)((Object)FindObjectEvenIfDisabled("1 - Darker_Fountain(Clone)", "fountain/Cylinder (1)")).name);
break;
}
case "Level 1-S":
FindObjectEvenIfDisabled("5 - Finale", "FinalRoomSecretExit").gameObject.SetActive(false);
val = Object.Instantiate<GameObject>(array[2]);
FindObjectEvenIfDisabled("5 - Finale", "InteractiveScreenPuzzle5x5 (2)/Canvas/Background").GetComponent<PuzzleController>().toActivate[0] = FindObjectEvenIfDisabled("2 - Witless Fountain(Clone)", "ActivateLimboDoor").gameObject;
break;
case "Level 2-3":
{
FindObjectEvenIfDisabled("Exteriors", "Arch (1)").gameObject.SetActive(false);
FindObjectEvenIfDisabled("2 - Sewer Arena", "2 Nonstuff/Secret Level Entrance/FinalRoom SecretEntrance").gameObject.SetActive(false);
val = Object.Instantiate<GameObject>(array[8]);
GameObject val2 = FindObjectEvenIfDisabled("2 - Sewer Arena", "2 Nonstuff/Secret Level Entrance/FinalRoom SecretEntrance/Pit");
val2.gameObject.SetActive(true);
val2.transform.parent = null;
val2.transform.position = new Vector3(5f, -30f, 800f);
val2 = FindObjectEvenIfDisabled("2 - Sewer Arena", "2 Nonstuff/Secret Level Entrance/FinalRoom SecretEntrance/Pit (2)");
val2.gameObject.SetActive(true);
val2.transform.parent = null;
val2.transform.position = new Vector3(-15f, -30f, 800f);
FindObjectEvenIfDisabled("8 - FountainLust(Clone)", "addmintofix").GetComponent<ObjectActivatorStay>().toDisActivate[0] = FindObjectEvenIfDisabled("MinosBackground");
break;
}
case "Level 4-2":
FindObjectEvenIfDisabled("OOB Stuff").transform.position = FindObjectEvenIfDisabled("OOB Stuff").transform.position - new Vector3(0f, 550f, 0f);
((Collider)FindObjectEvenIfDisabled("FakeMoon").GetComponent<SphereCollider>()).enabled = false;
((Renderer)FindObjectEvenIfDisabled("FakeMoon").GetComponent<MeshRenderer>()).enabled = false;
FindObjectEvenIfDisabled("FakeMoon", "Point Light/Spot Light").gameObject.SetActive(false);
FindObjectEvenIfDisabled("FakeMoon", "FinalRoom SecretEntrance/Pit").transform.position = FindObjectEvenIfDisabled("FakeMoon", "FinalRoom SecretEntrance/Pit").transform.position - new Vector3(0f, 250f, 0f);
FindObjectEvenIfDisabled("FakeMoon", "FinalRoom SecretEntrance/Pit (2)").transform.position = FindObjectEvenIfDisabled("FakeMoon", "FinalRoom SecretEntrance/Pit (2)").transform.position - new Vector3(0f, 250f, 0f);
val = Object.Instantiate<GameObject>(array[12]);
val.transform.parent = FindObjectEvenIfDisabled("FakeMoon").transform;
break;
case "Level 4-S":
FindObjectEvenIfDisabled("4 - Boulder Run", "4 Stuff/FinalRoom SecretExit").gameObject.SetActive(false);
val = Object.Instantiate<GameObject>(array[4]);
val.transform.parent = FindObjectEvenIfDisabled("4 - Boulder Run").transform;
break;
case "Level 5-1":
{
if (num == 6)
{
FindObjectEvenIfDisabled("IntroParent", "Intro/Intro B - First Tunnel/Cube(Clone)").gameObject.SetActive(false);
GameObject val4 = Object.Instantiate<GameObject>(array[6]);
val4.transform.parent = FindObjectEvenIfDisabled("IntroParent", "Intro/Intro B - First Tunnel").transform;
val4.transform.localPosition = new Vector3(-22.6f, 0f, -7.5f);
}
val = Object.Instantiate<GameObject>(array[9]);
FindObjectEvenIfDisabled("2 - Elevator", "2B Secret/FinalRoom SecretEntrance").gameObject.SetActive(false);
GameObject val2 = FindObjectEvenIfDisabled("2 - Elevator", "2B Secret/FinalRoom SecretEntrance/Pit");
val2.gameObject.SetActive(true);
val2.transform.parent = null;
val2.transform.position = new Vector3(5f, -30f, 800f);
val2 = FindObjectEvenIfDisabled("2 - Elevator", "2B Secret/FinalRoom SecretEntrance/Pit (2)");
val2.gameObject.SetActive(true);
val2.transform.parent = null;
val2.transform.position = new Vector3(-15f, -30f, 800f);
break;
}
case "Level 5-S":
FindObjectEvenIfDisabled("FinalRoom SecretExit").gameObject.SetActive(false);
val = Object.Instantiate<GameObject>(array[3]);
break;
case "Level 7-3":
{
num = 3152525;
if (num == 3)
{
GameObject val3 = Object.Instantiate<GameObject>(array[13]);
((BaseUnityPlugin)this).Logger.LogWarning((object)("Importing: " + ((Object)val3.gameObject).name));
FindObjectEvenIfDisabled(((Object)val3.transform).name, SceneHelper.CurrentScene).gameObject.SetActive(true);
}
FindObjectEvenIfDisabled("2 - Garden Maze", "Secret/FinalRoom SecretEntrance").gameObject.SetActive(false);
FindObjectEvenIfDisabled("2 - Garden Maze", "Secret", 3, useChildNum: true).gameObject.SetActive(false);
FindObjectEvenIfDisabled("2 - Garden Maze", "Secret", 4, useChildNum: true).gameObject.SetActive(false);
FindObjectEvenIfDisabled("2 - Garden Maze", "Secret", 5, useChildNum: true).gameObject.SetActive(false);
((Renderer)FindObjectEvenIfDisabled("2 - Garden Maze", "Secret", 6, useChildNum: true).gameObject.GetComponent<MeshRenderer>()).enabled = false;
val = Object.Instantiate<GameObject>(array[11]);
GameObject val2 = FindObjectEvenIfDisabled("2 - Garden Maze", "Secret/FinalRoom SecretEntrance/Pit");
val2.gameObject.SetActive(true);
val2.transform.parent = null;
val2.transform.position = new Vector3(15f, -30f, 800f);
val2 = FindObjectEvenIfDisabled("2 - Garden Maze", "Secret/FinalRoom SecretEntrance/Pit (2)");
val2.gameObject.SetActive(true);
val2.transform.parent = null;
val2.transform.position = new Vector3(-5f, -30f, 800f);
break;
}
case "Level 7-S":
{
FindObjectEvenIfDisabled("Fake Exit").gameObject.SetActive(false);
FindObjectEvenIfDisabled("7-S_Unpaintable", "Interior/Blackout").gameObject.SetActive(false);
FindObjectEvenIfDisabled("7-S_Unpaintable", "Doorways/Door_009").gameObject.SetActive(false);
val = Object.Instantiate<GameObject>(array[5]);
GameObject val2 = FindObjectEvenIfDisabled("Fake Exit", "WasherPickup");
val2.transform.parent = FindObjectEvenIfDisabled("5 - fountainWash(Clone)", "enable/washreplace").transform;
val2.transform.localPosition = new Vector3(0f, 0f, 0f);
val2.transform.rotation = Quaternion.identity;
FindObjectEvenIfDisabled("5 - fountainWash(Clone)", "thumbsuptasque (1)").GetComponent<ObjectActivator>().events.onActivate.AddListener(new UnityAction(FindObjectEvenIfDisabled("Checkpoints", "Checkpoint (2)").GetComponent<CheckPoint>().ReactivateCheckpoint));
FindObjectEvenIfDisabled("Checkpoints", "Checkpoint (2)").GetComponent<CheckPoint>().toActivate = FindObjectEvenIfDisabled("5 - fountainWash(Clone)");
val2 = FindObjectEvenIfDisabled("Fake Exit", "VacuumPickup");
val2.transform.parent = FindObjectEvenIfDisabled("5 - fountainWash(Clone)", "enable/vacreplace").transform;
val2.transform.localPosition = new Vector3(0f, 0f, 0f);
val2.transform.rotation = Quaternion.identity;
val2 = FindObjectEvenIfDisabled("5 - fountainWash(Clone)", "Swatches - parent/swatchLadder");
val2.transform.parent = FindObjectEvenIfDisabled("Interactives", "MainHall/MainHall Stuff/Sliding Ladder/Ladder_Collision/Ladder").transform;
val2.transform.localPosition = new Vector3(0f, -0.8f, 21.35f);
val2 = FindObjectEvenIfDisabled("5 - fountainWash(Clone)", "Swatches - parent/swatchWalk");
val2.transform.parent = FindObjectEvenIfDisabled("7-S_Unpaintable", "Interior/Library Chandelier").transform;
val2.transform.localPosition = new Vector3(0f, -7.66f, 0f);
FindObjectEvenIfDisabled("7-S_Paintable").GetComponent<BloodCheckerManager>().finalDoorOpener = FindObjectEvenIfDisabled("5 - fountainWash(Clone)", "DoorOpenerReplacement");
FindObjectEvenIfDisabled("Interactives", "MainHall/MainHall NonStuff/Altar (Blue Skull) Variant/Cube").GetComponent<ItemPlaceZone>().activateOnSuccess[0] = FindObjectEvenIfDisabled("5 - fountainWash(Clone)", "3 Exit (2)/Open").gameObject;
break;
}
}
try
{
bool flag = true;
GameObject val5 = Object.Instantiate<GameObject>(array[10]);
FindObjectEvenIfDisabled(((Object)val5.transform).name, SceneHelper.CurrentScene).gameObject.SetActive(true);
}
catch (Exception)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"VERY INTERESTING");
}
((BaseUnityPlugin)this).Logger.LogWarning((object)("Importing: " + ((Object)val.gameObject).name));
}
}