using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BepInEx;
using DoomahLevelLoader.UnityComponents;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("DoomahLevelLoader")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+49a54ca2da798d57a0b1984c2939b4f8439ce7a3")]
[assembly: AssemblyProduct("DoomahLevelLoader")]
[assembly: AssemblyTitle("DoomahLevelLoader")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
public class OpenDiscord : MonoBehaviour
{
public void Open()
{
Application.OpenURL("https://discord.gg/RY8J67neJ9");
}
}
public class TriggerZoneBehavior : MonoBehaviour
{
public float delay = 2f;
public float activationDelay = 0.1f;
private bool hasActivated = false;
private List<Transform> ignoreList = new List<Transform>();
private void Start()
{
Collider component = ((Component)this).GetComponent<Collider>();
if ((Object)(object)component != (Object)null)
{
component.isTrigger = true;
}
DelayedInitialization();
}
private void DelayedInitialization()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
foreach (Transform item in ((Component)this).transform)
{
Transform val = item;
((Component)val).gameObject.SetActive(false);
}
}
private IEnumerator ActivateChildrenWithDelay()
{
bool allChildrenActivated;
do
{
allChildrenActivated = true;
foreach (Transform item in ((Component)this).transform)
{
Transform child = item;
if ((Object)(object)child == (Object)null)
{
continue;
}
if (!ignoreList.Contains(child) && !((Object)child).name.Contains("Gore Zone") && !((Component)child).gameObject.activeSelf)
{
allChildrenActivated = false;
if (((Object)child).name != null && (((Object)child).name != "NoPass(Clone)" || (Object)(object)((Component)child).GetComponent<AddressableReplacer>() == (Object)null))
{
yield return (object)new WaitForSeconds(activationDelay);
}
((Component)child).gameObject.SetActive(true);
Debug.Log((object)("Trigger Activated child: " + ((Object)child).name));
}
else
{
ignoreList.Add(child);
}
}
}
while (!allChildrenActivated);
hasActivated = true;
}
private void OnTriggerEnter(Collider other)
{
if (((Object)((Component)other).gameObject).name == "Player" && !hasActivated)
{
((MonoBehaviour)this).StartCoroutine(ActivateChildrenWithDelay());
}
}
}
public class WaveComponent : MonoBehaviour
{
public float checkInterval = 1f;
private float timer = 0f;
private float activationDelay = 0.1f;
private bool hasActivated = false;
private List<Transform> activatedChildren = new List<Transform>();
private List<Transform> ignoreList = new List<Transform>();
private void Start()
{
DisableAllChildren();
}
private void DisableAllChildren()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
foreach (Transform item in ((Component)this).transform)
{
Transform val = item;
((Component)val).gameObject.SetActive(false);
}
}
private void Update()
{
timer += Time.deltaTime;
if (timer >= checkInterval)
{
timer = 0f;
CheckChildren();
}
}
private IEnumerator ActivateChildrenWithDelay(Transform[] childrenToActivate)
{
foreach (Transform child in childrenToActivate)
{
if (((Object)child).name != "NoPass(Clone)" || (Object)(object)((Component)child).GetComponent<AddressableReplacer>() == (Object)null)
{
((Component)child).gameObject.SetActive(true);
yield return (object)new WaitForSeconds(activationDelay);
}
else
{
((Component)child).gameObject.SetActive(true);
}
}
}
private void CheckChildren()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
GameObject gameObject = ((Component)((Component)this).transform.parent).gameObject;
List<GameObject> list = new List<GameObject>();
foreach (Transform item in ((Component)this).transform)
{
Transform val = item;
list.Add(((Component)val).gameObject);
}
List<Transform> list2 = new List<Transform>();
list2.AddRange(gameObject.GetComponentsInChildren<Transform>());
list2.Remove(((Component)this).transform);
List<Transform> list3 = new List<Transform>();
foreach (Transform item2 in list2)
{
EnemyIdentifier component = ((Component)item2).GetComponent<EnemyIdentifier>();
if ((Object)(object)component != (Object)null && !component.dead)
{
list3.Add(item2);
}
else if ((Object)(object)component != (Object)null && component.dead && list3.Contains(item2))
{
list3.Remove(item2);
}
}
Transform[] array = (Transform[])(object)new Transform[list.Count];
for (int i = 0; i < list.Count; i++)
{
array[i] = list[i].transform;
}
if (list3.Count == 0 && !hasActivated)
{
hasActivated = true;
((MonoBehaviour)this).StartCoroutine(ActivateChildrenWithDelay(array));
}
}
}
public static class ShaderManager
{
public class ShaderInfo
{
public string Name { get; set; }
}
public static Dictionary<string, Shader> shaderDictionary = new Dictionary<string, Shader>();
private static HashSet<Material> modifiedMaterials = new HashSet<Material>();
public static IEnumerator LoadShadersAsync()
{
AsyncOperationHandle<IResourceLocator> handle = Addressables.InitializeAsync();
while (!handle.IsDone)
{
yield return null;
}
if ((int)handle.Status == 1)
{
IResourceLocator locator = handle.Result;
foreach (string addressEntry in ((ResourceLocationMap)locator).Keys)
{
if (!addressEntry.EndsWith(".shader"))
{
continue;
}
AsyncOperationHandle<Shader> shaderHandle = Addressables.LoadAssetAsync<Shader>((object)addressEntry);
while (!shaderHandle.IsDone)
{
yield return null;
}
if ((int)shaderHandle.Status == 1)
{
Shader ingameShader = shaderHandle.Result;
if ((Object)(object)ingameShader != (Object)null && ((Object)ingameShader).name != "ULTRAKILL/PostProcessV2" && !shaderDictionary.ContainsKey(((Object)ingameShader).name))
{
shaderDictionary[((Object)ingameShader).name] = ingameShader;
}
}
else
{
Debug.LogError((object)("Failed to load shader: " + shaderHandle.OperationException));
}
}
}
else
{
Debug.LogError((object)("Addressables initialization failed: " + handle.OperationException));
}
}
public static string ModPath()
{
return Assembly.GetExecutingAssembly().Location.Substring(0, Assembly.GetExecutingAssembly().Location.LastIndexOf(Path.DirectorySeparatorChar));
}
public static IEnumerator ApplyShadersAsync(GameObject[] allGameObjects)
{
if (allGameObjects == null)
{
yield break;
}
foreach (GameObject go in allGameObjects)
{
if ((Object)(object)go == (Object)null)
{
continue;
}
Renderer[] meshRenderers = go.GetComponentsInChildren<Renderer>(true);
Renderer[] array = meshRenderers;
foreach (Renderer renderer in array)
{
if ((Object)(object)renderer == (Object)null)
{
continue;
}
Material[] newMaterials = (Material[])(object)new Material[renderer.sharedMaterials.Length];
for (int i = 0; i < renderer.sharedMaterials.Length; i++)
{
Material sharedMat = (newMaterials[i] = renderer.sharedMaterials[i]);
if (!((Object)(object)sharedMat == (Object)null) && !((Object)(object)sharedMat.shader == (Object)null) && !modifiedMaterials.Contains(sharedMat) && !(((Object)sharedMat.shader).name == "ULTRAKILL/PostProcessV2") && shaderDictionary.TryGetValue(((Object)sharedMat.shader).name, out var realShader))
{
newMaterials[i].shader = realShader;
modifiedMaterials.Add(sharedMat);
realShader = null;
}
}
renderer.materials = newMaterials;
}
yield return null;
}
}
public static IEnumerator ApplyShadersAsyncContinuously()
{
GameObject shaderManagerObject = new GameObject("ShaderManagerObject");
ShaderManagerRunner shaderManagerRunner = shaderManagerObject.AddComponent<ShaderManagerRunner>();
shaderManagerRunner.StartApplyingShaders();
yield return null;
}
public static void CreateShaderDictionary()
{
List<ShaderInfo> list = new List<ShaderInfo>();
Shader[] array = Resources.FindObjectsOfTypeAll<Shader>();
foreach (Shader shader in array)
{
if (!list.Any((ShaderInfo s) => s.Name == ((Object)shader).name))
{
list.Add(new ShaderInfo
{
Name = ((Object)shader).name
});
}
}
string contents = JsonConvert.SerializeObject((object)list, (Formatting)1);
File.WriteAllText(Path.Combine(ModPath(), "ShaderList.json"), contents);
}
public static IEnumerator LoadShadersFromDictionaryAsync()
{
string shaderListPath = Path.Combine(ModPath(), "ShaderList.json");
if (!File.Exists(shaderListPath))
{
yield break;
}
Task<string> shaderDataTask = ReadAllTextAsync(shaderListPath);
while (!shaderDataTask.IsCompleted)
{
yield return null;
}
string json = shaderDataTask.Result;
List<ShaderInfo> shaderData = JsonConvert.DeserializeObject<List<ShaderInfo>>(json);
Dictionary<string, Shader> shaderLookup = new Dictionary<string, Shader>();
foreach (ShaderInfo shaderInfo in shaderData)
{
Shader foundShader = Shader.Find(shaderInfo.Name);
if ((Object)(object)foundShader != (Object)null)
{
if (!shaderLookup.ContainsKey(shaderInfo.Name))
{
shaderLookup[shaderInfo.Name] = foundShader;
}
else
{
Debug.LogWarning((object)("Duplicate shader name found: " + shaderInfo.Name));
}
}
}
Material[] array = Resources.FindObjectsOfTypeAll<Material>();
foreach (Material material in array)
{
if (shaderLookup.TryGetValue(((Object)material.shader).name, out var newShader) && (Object)(object)material.shader != (Object)(object)newShader)
{
material.shader = newShader;
}
newShader = null;
}
}
private static async Task<string> ReadAllTextAsync(string path)
{
using StreamReader reader = new StreamReader(path);
return await reader.ReadToEndAsync();
}
}
public class ShaderManagerRunner : MonoBehaviour
{
public void StartApplyingShaders()
{
((MonoBehaviour)this).StartCoroutine(ApplyShadersContinuously());
}
private IEnumerator ApplyShadersContinuously()
{
while (true)
{
yield return (object)new WaitForSeconds(0.15f);
Scene activeScene = SceneManager.GetActiveScene();
yield return ShaderManager.ApplyShadersAsync(((Scene)(ref activeScene)).GetRootGameObjects());
yield return ShaderManager.LoadShadersFromDictionaryAsync();
}
}
}
namespace meshwhatever
{
public static class PluginInfo
{
public const string PLUGIN_GUID = "DoomahLevelLoader";
public const string PLUGIN_NAME = "DoomahLevelLoader";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace DoomahLevelLoader
{
public class ChallengeInfo : MonoBehaviour
{
public string Challenge;
public bool ActiveByDefault;
[HideInInspector]
public GameObject ChallengeText;
public void Awake()
{
ChallengeText = Plugin.FindObjectEvenIfDisabled("Player", "Main Camera/HUD Camera/HUD/FinishCanvas/Panel/Challenge/ChallengeText");
((TMP_Text)ChallengeText.GetComponent<TextMeshProUGUI>()).text = Challenge;
if (ActiveByDefault)
{
MonoSingleton<ChallengeManager>.Instance.challengeFailed = false;
MonoSingleton<ChallengeManager>.Instance.challengeDone = true;
}
else
{
MonoSingleton<ChallengeManager>.Instance.challengeFailed = true;
MonoSingleton<ChallengeManager>.Instance.challengeDone = false;
}
}
}
public class RefreshAndDirectory : MonoBehaviour
{
private static RefreshAndDirectory instance;
public Button Refresh;
public Button Directory;
public static RefreshAndDirectory Instance
{
get
{
if ((Object)(object)instance == (Object)null)
{
instance = Object.FindObjectOfType<RefreshAndDirectory>();
if ((Object)(object)instance == (Object)null)
{
Debug.LogError((object)"RefreshAndDirectory instance not found in the scene.");
}
}
return instance;
}
}
private void Start()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
((UnityEvent)Refresh.onClick).AddListener(new UnityAction(Refreshaction));
((UnityEvent)Directory.onClick).AddListener(new UnityAction(DirectoryOpen));
}
private void Refreshaction()
{
Loaderscene.RefreshLevels();
}
private void DirectoryOpen()
{
Loaderscene.OpenFilesFolder();
}
}
public class EnvyLoaderMenu : MonoBehaviour
{
private static EnvyLoaderMenu instance;
public GameObject ContentStuff;
public GameObject LevelsMenu;
public GameObject LevelsButton;
public GameObject FuckingPleaseWait;
public TextMeshProUGUI MOTDMessage;
private const string motdUrl = "https://raw.githubusercontent.com/SatisfiedBucket/EnvySpiteDownloader/main/MOTD.txt";
public static EnvyLoaderMenu Instance
{
get
{
if ((Object)(object)instance == (Object)null)
{
instance = Object.FindObjectOfType<EnvyLoaderMenu>();
if ((Object)(object)instance == (Object)null)
{
Debug.LogError((object)"EnvyScreen prefab not found or EnvyLoaderMenu instance not initialized.");
return null;
}
}
return instance;
}
}
public void Start()
{
CreateLevels();
((MonoBehaviour)this).StartCoroutine(LoadMOTD());
}
private IEnumerator LoadMOTD()
{
UnityWebRequest webRequest = UnityWebRequest.Get("https://raw.githubusercontent.com/SatisfiedBucket/EnvySpiteDownloader/main/MOTD.txt");
try
{
yield return webRequest.SendWebRequest();
if (webRequest.isNetworkError || webRequest.isHttpError)
{
Debug.LogError((object)("Failed to fetch MOTD: " + webRequest.error));
yield break;
}
string motdText = webRequest.downloadHandler.text;
if (!string.IsNullOrEmpty(motdText))
{
string[] lines = motdText.Split(new char[2] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
string firstLine = ((lines.Length != 0) ? lines[0] : "No MOTD available");
((TMP_Text)MOTDMessage).text = firstLine;
}
}
finally
{
((IDisposable)webRequest)?.Dispose();
}
}
public static void CreateLevels()
{
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
foreach (AssetBundleInfo assetBundle in Loaderscene.AssetBundles)
{
GameObject val = Object.Instantiate<GameObject>(Instance.LevelsButton, Instance.ContentStuff.transform);
LevelButtonScript buttonScript = val.GetComponent<LevelButtonScript>();
Loaderscene.SetLevelButtonScriptProperties(buttonScript, assetBundle);
if (assetBundle.IsCampaign)
{
buttonScript.SceneToLoad = "";
}
((UnityEvent)buttonScript.LevelButtonReal.onClick).AddListener((UnityAction)delegate
{
Loaderscene.LoadScene(buttonScript);
});
}
}
public static void ClearContentStuffChildren()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
if ((Object)(object)Instance == (Object)null)
{
return;
}
foreach (Transform item in Instance.ContentStuff.transform)
{
Transform val = item;
Object.Destroy((Object)(object)((Component)val).gameObject);
}
}
public static IEnumerator UpdateLevelListingCoroutine()
{
Instance.FuckingPleaseWait.SetActive(true);
ClearContentStuffChildren();
CreateLevels();
yield return null;
Instance.FuckingPleaseWait.SetActive(false);
}
public static void UpdateLevelListing()
{
if ((Object)(object)Instance != (Object)null)
{
((MonoBehaviour)Instance).StartCoroutine(UpdateLevelListingCoroutine());
}
}
}
public class DropdownHandler : MonoBehaviour
{
public TMP_Dropdown dropdown;
private const string selectedDifficultyKey = "difficulty";
private string settingsFilePath;
private void Awake()
{
settingsFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "settings.json");
}
private void OnEnable()
{
int value = LoadDifficulty();
dropdown.value = value;
((UnityEvent<int>)(object)dropdown.onValueChanged).AddListener((UnityAction<int>)OnDropdownValueChanged);
}
private int LoadDifficulty()
{
return MonoSingleton<PrefsManager>.Instance.GetInt("difficulty", 0);
}
public void OnDropdownValueChanged(int index)
{
Debug.Log((object)("Difficulty set to " + index));
MonoSingleton<PrefsManager>.Instance.SetInt("difficulty", index);
}
}
public class LevelButtonScript : MonoBehaviour
{
public Image LevelImageButtonThing;
public Button LevelButtonReal;
public TextMeshProUGUI NoLevel;
public TextMeshProUGUI Author;
public TextMeshProUGUI LevelName;
[HideInInspector]
public AssetBundle BundleName;
[HideInInspector]
public byte[] BundleDataToLoad;
[HideInInspector]
public string SceneToLoad;
[HideInInspector]
public bool OpenCamp;
private static LevelButtonScript instance;
public static LevelButtonScript Instance
{
get
{
if (instance == null)
{
instance = Object.FindObjectOfType<LevelButtonScript>();
}
if ((Object)(object)instance == (Object)null)
{
Debug.LogError((object)"LevelButtonScript instance not found in the scene.");
}
return instance;
}
}
}
public class LevelUpdatePopUp : MonoBehaviour
{
private static LevelUpdatePopUp instance;
public static byte[] byteCheck;
public static bool UpdateReady;
public static Scene currentScene;
public static LevelUpdatePopUp Instance
{
get
{
if ((Object)(object)instance == (Object)null)
{
instance = Object.FindObjectOfType<LevelUpdatePopUp>();
if ((Object)(object)instance == (Object)null)
{
Debug.LogError((object)"bongbong bepinex log infestiation");
}
}
return Instance;
}
}
public static GameObject GetInstanceObject()
{
return ((Component)Instance).gameObject;
}
}
public class MenuVisibilityClass : MonoBehaviour
{
private static MenuVisibilityClass instance;
public Button AssignToMenuOpenButton;
public Button AssignToGoBackButton;
public GameObject AssignToFuckingLevels;
public static MenuVisibilityClass Instance
{
get
{
if ((Object)(object)instance == (Object)null)
{
instance = Object.FindObjectOfType<MenuVisibilityClass>();
if ((Object)(object)instance == (Object)null)
{
Debug.LogError((object)"WOWZERS! SOMEONE FORGOT TO FIX THIS!");
}
}
return Instance;
}
}
private void Start()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
((UnityEvent)AssignToMenuOpenButton.onClick).AddListener(new UnityAction(ToggleMenu));
((UnityEvent)AssignToGoBackButton.onClick).AddListener(new UnityAction(ToggleMenu));
}
private void ToggleMenu()
{
if (!AssignToFuckingLevels.activeSelf)
{
AssignToFuckingLevels.SetActive(true);
((Component)AssignToMenuOpenButton).gameObject.SetActive(false);
MainMenuAgony.isAgonyOpen = true;
Debug.Log((object)"open");
}
else
{
AssignToFuckingLevels.SetActive(false);
((Component)AssignToMenuOpenButton).gameObject.SetActive(true);
MainMenuAgony.isAgonyOpen = false;
Debug.Log((object)"close");
}
}
}
public class ScriptWarningUI : MonoBehaviour
{
private static ScriptWarningUI instance;
public Button YesButton;
public Button NoButton;
public TextMeshProUGUI ScriptHashText;
public static ScriptWarningUI Instance
{
get
{
if ((Object)(object)instance == (Object)null)
{
instance = Object.FindObjectOfType<ScriptWarningUI>();
if ((Object)(object)instance == (Object)null)
{
Debug.LogError((object)"EnvyScreen prefab not found or ScriptWarningUI instance not initialized.");
return null;
}
}
return Instance;
}
}
public void Start()
{
}
}
public class SetChallengeStatus : MonoBehaviour
{
public bool Active;
public void Awake()
{
if (Active)
{
MonoSingleton<ChallengeManager>.Instance.challengeFailed = false;
MonoSingleton<ChallengeManager>.Instance.challengeDone = true;
}
else
{
MonoSingleton<ChallengeManager>.Instance.challengeFailed = true;
MonoSingleton<ChallengeManager>.Instance.challengeDone = false;
}
}
}
public class TipOfTheDay : MonoBehaviour
{
public string Tip;
[HideInInspector]
public GameObject TipBox;
public async void Awake()
{
await Task.Delay(150);
try
{
TipBox = Plugin.FindObjectEvenIfDisabled("FirstRoom(Clone)", "Room/Shop/Canvas/TipBox/Panel/TipText");
}
catch (Exception)
{
Debug.Log((object)"This level does not have Tip of the Day setup correctly, please make sure you are using the addressable replacer version of the FirstRoom (the one with no children inside of it, do not take that out of context please) Attempting to deploy temporary fix.");
TipBox = Plugin.FindObjectEvenIfDisabled("FirstRoom", "Room/Shop/Canvas/TipBox/Panel/TipText");
}
if ((Object)(object)TipBox == (Object)null)
{
Debug.Log((object)"Temporary fix failed.");
}
else
{
((TMP_Text)TipBox.GetComponent<TextMeshProUGUI>()).text = Tip;
}
}
}
public static class Loader
{
public static AssetBundle LoadTerminal()
{
try
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string name = "meshwhatever.terminal.bundle";
using Stream stream = executingAssembly.GetManifestResourceStream(name);
if (stream == null)
{
Debug.LogError((object)"Resource 'terminal.bundle' not found in embedded resources.");
return null;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
return AssetBundle.LoadFromMemory(array);
}
catch (Exception ex)
{
Debug.LogError((object)("Error loading terminal: " + ex.Message));
return null;
}
}
}
public static class Merger
{
private static string PartsPath => Plugin.getConfigPath();
public static async Task MergeFiles()
{
string[] partFiles = Directory.GetFiles(PartsPath, "*.part*");
Regex filePattern = new Regex("^(?<basename>.+)\\.part(?<part>\\d+)$");
Dictionary<string, List<string>> fileGroups = new Dictionary<string, List<string>>();
string[] array = partFiles;
foreach (string file in array)
{
Match match = filePattern.Match(Path.GetFileName(file));
if (match.Success)
{
string baseName = match.Groups["basename"].Value;
if (!fileGroups.ContainsKey(baseName))
{
fileGroups[baseName] = new List<string>();
}
fileGroups[baseName].Add(file);
}
}
foreach (KeyValuePair<string, List<string>> group in fileGroups)
{
string baseName2 = group.Key;
List<string> sortedParts = group.Value.OrderBy((string f) => int.Parse(filePattern.Match(Path.GetFileName(f)).Groups["part"].Value)).ToList();
string mergedFilePath = Path.Combine(PartsPath, baseName2);
using (FileStream outputStream = File.Create(mergedFilePath))
{
foreach (string part2 in sortedParts)
{
using FileStream inputStream = File.OpenRead(part2);
await inputStream.CopyToAsync(outputStream);
}
}
foreach (string part in sortedParts)
{
File.Delete(part);
}
Debug.Log((object)("Merged and deleted parts for: " + baseName2 + ", created file: " + baseName2 + ".doomah"));
}
}
}
public static class Loaderscene
{
public static string currentLevelName = null;
public static string currentLevelpath = null;
public static List<AssetBundleInfo> AssetBundles = new List<AssetBundleInfo>();
private static short loadProgress = 0;
private static int loadProgressMax = 0;
public static string LevelsPath => Plugin.getConfigPath();
public static AssetBundle lastUsedBundle { get; private set; }
public static bool isLoadingScene { get; private set; }
public static async Task LoadLevels()
{
string[] files = Directory.GetFiles(LevelsPath, "*.doomah");
GameObject myBlocker = Object.Instantiate<GameObject>(MonoSingleton<SceneHelper>.Instance.loadingBlocker, MonoSingleton<SceneHelper>.Instance.loadingBlocker.transform.parent);
TextMeshProUGUI text = myBlocker.GetComponentInChildren<TextMeshProUGUI>();
((TMP_Text)text).text = "Loading levels...\n<size=60><b>0/" + files.Length + "</b></size>";
myBlocker.SetActive(true);
loadProgress = 0;
loadProgressMax = files.Length;
int fileIndex = 1;
string[] array = files;
foreach (string file in array)
{
try
{
LoadBundlesFromDoomah(file, fileIndex / 2, text);
Debug.Log((object)(file + " loaded!"));
await Task.Delay(16);
}
catch (Exception e)
{
Debug.LogError((object)(file + " failed to load: " + e.ToString()));
}
fileIndex++;
}
Object.Destroy((Object)(object)myBlocker);
EnvyLoaderMenu.UpdateLevelListing();
}
private static async Task LoadBundlesFromDoomah(string doomahFile, int index, TextMeshProUGUI blocker)
{
await Task.Delay(16);
using ZipArchive archive = ZipFile.OpenRead(doomahFile);
foreach (ZipArchiveEntry entry in archive.Entries)
{
if (entry.FullName.EndsWith(".bundle", StringComparison.OrdinalIgnoreCase))
{
Stream s = entry.Open();
byte[] bundleBytes;
using (MemoryStream memstream = new MemoryStream())
{
new StreamReader(s).BaseStream.CopyTo(memstream);
bundleBytes = memstream.ToArray();
}
AssetBundles.Add(new AssetBundleInfo(bundleBytes, archive));
loadProgress++;
((TMP_Text)blocker).text = "Loading levels...\n<size=60><b>" + loadProgress + "/" + loadProgressMax + "</b></size>";
bundleBytes = null;
}
}
}
public static async void RefreshLevels()
{
AssetBundles = new List<AssetBundleInfo>();
await Merger.MergeFiles();
await LoadLevels();
}
public static byte[] ReadFully(Stream input)
{
using BinaryReader binaryReader = new BinaryReader(input);
return binaryReader.ReadBytes((int)input.Length);
}
public static void LoadScene(LevelButtonScript buttonScript)
{
Debug.Log((object)"test 1");
if (isLoadingScene)
{
return;
}
Debug.Log((object)"test 2");
isLoadingScene = true;
Debug.Log((object)"test 3");
SceneHelper.ShowLoadingBlocker();
Debug.Log((object)"test 4");
if (Object.op_Implicit((Object)(object)lastUsedBundle))
{
lastUsedBundle.Unload(true);
}
Debug.Log((object)"test 5");
lastUsedBundle = AssetBundle.LoadFromMemory(buttonScript?.BundleDataToLoad);
Debug.Log((object)"test 6");
buttonScript.BundleName = lastUsedBundle;
Debug.Log((object)"test 7");
buttonScript.SceneToLoad = lastUsedBundle.GetAllScenePaths().FirstOrDefault();
Debug.Log((object)"test 8");
if (!string.IsNullOrEmpty(buttonScript?.SceneToLoad))
{
Debug.Log((object)"test 9");
MonoSingleton<SceneHelper>.Instance.LoadSceneAsync(buttonScript.SceneToLoad, false);
Debug.Log((object)"test 10");
currentLevelpath = buttonScript.SceneToLoad;
Debug.Log((object)"test 11");
currentLevelName = ((TMP_Text)buttonScript.LevelName).text;
Debug.Log((object)"test 12");
SceneManager.LoadSceneAsync(buttonScript.SceneToLoad).completed += delegate
{
SceneHelper.DismissBlockers();
Debug.Log((object)"test 13");
Plugin.Fixorsmth();
Debug.Log((object)"test 14");
isLoadingScene = false;
Debug.Log((object)"test 15");
};
Debug.Log((object)"test 16");
}
}
public static void OpenFilesFolder()
{
Application.OpenURL("file://" + Plugin.getConfigPath().Replace("\\", "/"));
}
public static void SetLevelButtonScriptProperties(LevelButtonScript buttonScript, AssetBundleInfo bundleInfo)
{
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
buttonScript.BundleName = bundleInfo.Bundle;
buttonScript.BundleDataToLoad = bundleInfo.BundleDataToLoad;
buttonScript.SceneToLoad = "";
buttonScript.OpenCamp = bundleInfo.IsCampaign;
((TMP_Text)buttonScript.Author).text = bundleInfo.Author ?? "Unknown";
((TMP_Text)buttonScript.LevelName).text = (bundleInfo.LevelNames.Any() ? bundleInfo.LevelNames.First() : "Unnamed");
Texture2D val = bundleInfo.LevelImages.Values.FirstOrDefault();
if (val != null)
{
if (((Texture)val).width > 2 && ((Texture)val).height > 2)
{
buttonScript.LevelImageButtonThing.sprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero);
((Graphic)buttonScript.LevelImageButtonThing).color = Color.white;
}
else
{
Debug.LogError((object)"Failed to load level image properly.");
((Graphic)buttonScript.LevelImageButtonThing).color = Color.clear;
}
}
else
{
((Graphic)buttonScript.LevelImageButtonThing).color = Color.clear;
}
bool flag = bundleInfo.LevelNames.Any();
((Component)buttonScript.NoLevel).gameObject.SetActive(!flag);
((Component)buttonScript.LevelImageButtonThing).gameObject.SetActive(flag);
}
public static bool IsSceneInAnyAssetBundle(string sceneName)
{
if (Object.op_Implicit((Object)(object)lastUsedBundle))
{
string[] allScenePaths = lastUsedBundle.GetAllScenePaths();
foreach (string path in allScenePaths)
{
if (Path.GetFileNameWithoutExtension(path) == sceneName)
{
return true;
}
}
}
return false;
}
}
public class AssetBundleInfo
{
public AssetBundle Bundle;
public byte[] BundleDataToLoad;
public List<string> ScenePaths;
public List<string> LevelNames;
public Dictionary<string, Texture2D> LevelImages;
public string FileSize;
public string Author;
public bool IsCampaign;
public AssetBundleInfo(byte[] bundleData, ZipArchive archive)
{
BundleDataToLoad = bundleData;
ZipArchiveEntry entry = archive.GetEntry("info.json");
ZipArchiveEntry entry2 = archive.GetEntry("info.txt");
LevelInfo levelInfo = null;
if (entry != null)
{
using StreamReader streamReader = new StreamReader(entry.Open());
levelInfo = LevelInfo.LoadFromJson(streamReader.ReadToEnd());
}
else if (entry2 != null)
{
using StreamReader streamReader2 = new StreamReader(entry2.Open());
levelInfo = LevelInfo.LoadFromText(streamReader2.ReadToEnd());
}
IsCampaign = levelInfo?.IsCampaign ?? false;
LevelNames = levelInfo?.LevelNames ?? new List<string>();
levelInfo.LevelImages = new List<string>();
foreach (ZipArchiveEntry entry4 in archive.Entries)
{
if (Path.GetExtension(entry4.FullName) == ".png")
{
levelInfo?.LevelImages.Add(entry4.FullName);
}
}
LevelImages = LoadLevelImages(levelInfo?.LevelImages, archive);
Author = levelInfo?.Author;
static Dictionary<string, Texture2D> LoadLevelImages(List<string> imagePaths, ZipArchive zipArchive)
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
Dictionary<string, Texture2D> dictionary = new Dictionary<string, Texture2D>();
if (imagePaths == null)
{
return dictionary;
}
foreach (string imagePath in imagePaths)
{
ZipArchiveEntry entry3 = zipArchive.GetEntry(imagePath);
if (entry3 != null)
{
using MemoryStream memoryStream = new MemoryStream();
entry3.Open().CopyTo(memoryStream);
byte[] array = memoryStream.ToArray();
Texture2D val = new Texture2D(2, 2);
if (ImageConversion.LoadImage(val, array))
{
dictionary[imagePath] = val;
}
else
{
Debug.LogError((object)("Failed to load image from path: " + imagePath));
}
}
}
return dictionary;
}
}
}
[Serializable]
public class LevelInfo
{
public string Author;
public string LevelName;
public bool IsCampaign;
public List<string> Scenes = new List<string>();
public List<string> LevelNames = new List<string>();
public List<string> LevelImages = new List<string>();
public static LevelInfo LoadFromJson(string json)
{
return JsonUtility.FromJson<LevelInfo>(json);
}
public static LevelInfo LoadFromText(string text)
{
LevelInfo levelInfo = new LevelInfo();
string[] array = text.Split(new char[2] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
if (array.Length != 0)
{
levelInfo.Author = array[0].Trim();
}
if (array.Length > 1)
{
levelInfo.LevelNames.Add(array[1].Trim());
}
levelInfo.IsCampaign = false;
return levelInfo;
}
}
[HarmonyPatch(typeof(SceneHelper), "RestartScene")]
public static class SceneHelper_RestartScene_Patch
{
[HarmonyPrefix]
public static bool Prefix()
{
if (Plugin.IsCustomLevel)
{
SceneManager.LoadSceneAsync(Loaderscene.currentLevelpath).completed += delegate
{
SceneHelper.DismissBlockers();
Plugin.Fixorsmth();
};
return false;
}
return true;
}
}
[HarmonyPatch(typeof(StatsManager))]
[HarmonyPatch("Start")]
public static class StatsManager_Start_Patch
{
[HarmonyPostfix]
private static void Postfix(StatsManager __instance)
{
if (Plugin.IsCustomLevel)
{
__instance.levelNumber = -1;
Debug.Log((object)__instance.levelNumber);
}
}
}
[HarmonyPatch(typeof(LevelNameFinder))]
[HarmonyPatch("OnEnable")]
public static class LevelNameFinder_Patch
{
private static void Postfix(LevelNameFinder __instance)
{
if (Plugin.IsCustomLevel)
{
__instance.txt2.text = Loaderscene.currentLevelName;
}
}
}
[HarmonyPatch(typeof(FinalRank))]
[HarmonyPatch("LevelChange")]
public static class FinalRank_Patch
{
private static void Prefix(FinalRank __instance)
{
if (Plugin.IsCustomLevel && string.IsNullOrEmpty(__instance.targetLevelName))
{
__instance.targetLevelName = "Main Menu";
}
}
}
[HarmonyPatch(typeof(AdvancedOptions))]
[HarmonyPatch("ResetCyberGrind")]
public static class AdvOpt_Patch
{
private static bool Prefix(AdvancedOptions __instance)
{
return !Plugin.IsCustomLevel;
}
}
[HarmonyPatch(typeof(MusicManager))]
[HarmonyPatch("OnEnable")]
public static class MusicMan_Patch
{
private static void Postfix(MusicManager __instance)
{
((MonoBehaviour)__instance).StartCoroutine(waitForCustom(__instance));
}
private static IEnumerator waitForCustom(MusicManager __instance)
{
yield return (object)new WaitForSeconds(0.25f);
if (!Plugin.IsCustomLevel)
{
yield break;
}
try
{
__instance.battleTheme.outputAudioMixerGroup = MonoSingleton<AudioMixerController>.instance.musicGroup;
__instance.bossTheme.outputAudioMixerGroup = MonoSingleton<AudioMixerController>.instance.musicGroup;
__instance.cleanTheme.outputAudioMixerGroup = MonoSingleton<AudioMixerController>.instance.musicGroup;
__instance.targetTheme.outputAudioMixerGroup = MonoSingleton<AudioMixerController>.instance.musicGroup;
}
catch
{
}
Object[] array = Object.FindObjectsOfTypeAll(typeof(AudioSource));
for (int i = 0; i < array.Length; i++)
{
AudioSource audio = (AudioSource)array[i];
try
{
if (((Object)audio.outputAudioMixerGroup.audioMixer).name == "MusicAudio" || ((Object)audio.outputAudioMixerGroup.audioMixer).name == "MusicAudio_0")
{
audio.outputAudioMixerGroup = MonoSingleton<AudioMixerController>.instance.musicGroup;
}
}
catch
{
}
}
}
}
[BepInPlugin("doomahreal.ultrakill.levelloader", "DoomahLevelLoader", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private AssetBundle terminal;
public static bool IsCustomLevel;
private static Plugin _instance;
public static Plugin Instance => _instance;
public static string getConfigPath()
{
string[] array = new string[1];
string configPath = Paths.ConfigPath;
char directorySeparatorChar = Path.DirectorySeparatorChar;
array[0] = configPath + directorySeparatorChar + "EnvyLevels";
return Path.Combine(array);
}
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 async void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"If you see this, dont panick! because everything is fine :)");
terminal = Loader.LoadTerminal();
_instance = this;
Harmony val = new Harmony("doomahreal.ultrakill.levelloader");
val.PatchAll();
if (!Directory.Exists(getConfigPath()))
{
Directory.CreateDirectory(getConfigPath());
}
await Merger.MergeFiles();
Loaderscene.LoadLevels();
SceneManager.sceneLoaded += OnSceneLoaded;
SceneManager.sceneUnloaded += OnSceneUnloaded;
}
private void OnDestroy()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
SceneManager.sceneUnloaded -= OnSceneUnloaded;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
bool flag = SceneHelper.CurrentScene != "Bootstrap" && SceneHelper.CurrentScene != "Intro";
bool mainMenu = SceneHelper.CurrentScene == "Main Menu";
if (flag)
{
ShaderManager.CreateShaderDictionary();
InstantiateEnvyScreen(mainMenu);
}
if (ShaderManager.shaderDictionary.Count <= 0)
{
((MonoBehaviour)this).StartCoroutine(ShaderManager.LoadShadersAsync());
}
if (!Loaderscene.IsSceneInAnyAssetBundle(((Scene)(ref scene)).name))
{
IsCustomLevel = false;
Loaderscene.currentLevelName = null;
}
else
{
IsCustomLevel = true;
}
}
public static void Fixorsmth()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
SceneHelper.CurrentScene = ((Scene)(ref activeScene)).name;
Camera main = Camera.main;
IsCustomLevel = true;
main.clearFlags = (CameraClearFlags)1;
((MonoBehaviour)_instance).StartCoroutine(ShaderManager.ApplyShadersAsyncContinuously());
}
private void OnSceneUnloaded(Scene scene)
{
if (SceneHelper.CurrentScene == "Main Menu")
{
InstantiateEnvyScreen(mainMenu: true);
ShaderManager.CreateShaderDictionary();
}
}
private void InstantiateEnvyScreen(bool mainMenu)
{
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
GameObject val = terminal.LoadAsset<GameObject>("EnvyScreen.prefab");
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)"EnvyScreen prefab not found in the terminal bundle.");
return;
}
GameObject val2 = GameObject.Find("/Canvas/Main Menu (1)");
if (!mainMenu)
{
val2 = FindObjectEvenIfDisabled("Canvas", "PauseMenu");
}
if (!((Object)(object)val2 == (Object)null))
{
GameObject val3 = Object.Instantiate<GameObject>(val);
val3.transform.SetParent(val2.transform, false);
val3.transform.localPosition = Vector3.zero;
val3.transform.localScale = new Vector3(1f, 1f, 1f);
}
}
}
[HarmonyPatch(typeof(Material))]
internal static class MaterialPatches
{
public static void Process(Material material)
{
if (!((Object)(object)material.shader == (Object)null) && ShaderManager.shaderDictionary.TryGetValue(((Object)material.shader).name, out var value) && !((Object)(object)material.shader == (Object)(object)value))
{
material.shader = value;
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
public static void CtorPatch1(Material __instance)
{
Process(__instance);
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
public static void CtorPatch2(Material __instance)
{
Process(__instance);
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
public static void CtorPatch3(Material __instance)
{
Process(__instance);
}
}
}
namespace DoomahLevelLoader.UnityComponents
{
public class AddressableReplacer : MonoBehaviour
{
public string targetAddress;
public bool oneTime = true;
public bool moveToParent = true;
public bool destroyThis = true;
public bool IsBoss = false;
public string BossName;
public bool IsSanded = false;
public bool IsPuppet = false;
public bool IsRadient = false;
public float RadienceTier;
public float DamageTier;
public float SpeedTier;
public float HealthTier;
internal EnemyIdentifier eid;
private bool _activated = false;
private void OnEnable()
{
Activate();
}
public void Activate()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
if (oneTime && _activated)
{
return;
}
_activated = true;
GameObject val = Addressables.LoadAssetAsync<GameObject>((object)targetAddress).WaitForCompletion();
if ((Object)(object)val == (Object)null)
{
Debug.LogWarning((object)("Tried to load asset at address " + targetAddress + ", but it does not exist"));
((Behaviour)this).enabled = false;
return;
}
GameObject val2 = Object.Instantiate<GameObject>(val, ((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform);
eid = val2.GetComponent<EnemyIdentifier>();
if ((Object)(object)eid == (Object)null && val2.transform.childCount > 0)
{
eid = ((Component)val2.transform.GetChild(0)).GetComponent<EnemyIdentifier>();
}
if (moveToParent)
{
val2.transform.SetParent(((Component)this).transform.parent, true);
}
PostInstantiate(val2);
if ((Object)(object)eid != (Object)null && IsBoss)
{
BossHealthBar val3 = ((Component)eid).gameObject.AddComponent<BossHealthBar>();
if (!string.IsNullOrEmpty(BossName))
{
val3.bossName = BossName;
}
}
if ((Object)(object)eid != (Object)null && IsSanded)
{
eid.Sandify(false);
}
if ((Object)(object)eid != (Object)null && IsPuppet)
{
eid.PuppetSpawn();
eid.puppet = true;
}
if ((Object)(object)eid != (Object)null && IsRadient)
{
eid.radianceTier = RadienceTier;
eid.healthBuffModifier = HealthTier;
eid.speedBuffModifier = SpeedTier;
eid.damageBuffModifier = DamageTier;
eid.BuffAll();
}
if (destroyThis)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
((Component)this).gameObject.SetActive(false);
}
((Behaviour)this).enabled = false;
}
protected virtual void PostInstantiate(GameObject instantiatedObject)
{
}
}
public class CheckpointReplacer : AddressableReplacer
{
protected override void PostInstantiate(GameObject instantiatedObject)
{
Debug.Log((object)"Replacing checkpoint");
CheckPoint componentInParent = ((Component)this).GetComponentInParent<CheckPoint>();
CheckPoint component = instantiatedObject.GetComponent<CheckPoint>();
foreach (Collider item in from col in instantiatedObject.GetComponentsInChildren<Collider>()
where col.isTrigger
select col)
{
Object.Destroy((Object)(object)((Component)item).gameObject);
}
Transform[] array = (from i in Enumerable.Range(0, instantiatedObject.transform.childCount)
select instantiatedObject.transform.GetChild(i)).ToArray();
foreach (Transform val in array)
{
Debug.Log((object)((Object)val).name);
val.SetParent(((Component)this).transform.parent, true);
}
componentInParent.graphic = component.graphic;
componentInParent.activateEffect = component.activateEffect;
}
}
public class ClashTriggerDisable : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
if (((Component)other).gameObject.tag == "Player")
{
MonoSingleton<PlayerTracker>.Instance.ChangeToFPS();
}
}
}
public class ClashTriggerEnable : MonoBehaviour
{
private bool hasenabled = false;
public bool OnlyOnce = false;
private void OnTriggerEnter(Collider other)
{
if (((Component)other).gameObject.tag == "Player" && !hasenabled)
{
MonoSingleton<PlayerTracker>.Instance.ChangeToPlatformer();
if (OnlyOnce)
{
hasenabled = true;
}
}
}
}
public class FinalDoorFixer : MonoBehaviour
{
public bool oneTime = true;
public bool moveToParent = true;
public BoxCollider OpenTrigger;
private FinalDoor FD;
private GameObject instantiatedObject;
private bool isOpened = false;
private bool _activated = false;
private void OnEnable()
{
Activate();
}
public void Activate()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
if (oneTime && _activated)
{
return;
}
_activated = true;
GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"Assets/Prefabs/Levels/Special Rooms/FinalRoom.prefab").WaitForCompletion();
if ((Object)(object)val == (Object)null)
{
Debug.LogWarning((object)"Tried to load asset, but it does not exist");
((Behaviour)this).enabled = false;
return;
}
instantiatedObject = Object.Instantiate<GameObject>(val, ((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform);
if (moveToParent)
{
instantiatedObject.transform.SetParent(((Component)this).transform.parent, true);
}
Debug.Log((object)"FinalDoorFixer: Final door game object loaded successfully.");
Transform obj = instantiatedObject.transform.Find("FinalDoor");
FinalDoor val2 = ((obj != null) ? ((Component)obj).GetComponent<FinalDoor>() : null);
if ((Object)(object)val2 != (Object)null)
{
FD = val2;
Debug.Log((object)"FinalDoorFixer: Final door component found successfully.");
}
else
{
Debug.LogWarning((object)"FinalDoorFixer: Final door component not found.");
}
PostInstantiate(instantiatedObject);
}
protected virtual void PostInstantiate(GameObject instantiatedObject)
{
}
private void OnTriggerEnter(Collider other)
{
if (!isOpened && ((Component)other).CompareTag("Player") && (Object)(object)FD != (Object)null)
{
FD.Open();
isOpened = true;
}
}
}
public class IdolAssigner : MonoBehaviour
{
public AddressableReplacer Target;
public bool oneTime = true;
public bool moveToParent = true;
public bool destroyThis = true;
private bool _activated = false;
private void OnEnable()
{
Activate();
}
public void Activate()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
if (oneTime && _activated)
{
return;
}
_activated = true;
GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"Assets/Prefabs/Enemies/Idol.prefab").WaitForCompletion();
if ((Object)(object)val == (Object)null)
{
Debug.LogWarning((object)"Tried to load asset, but it does not exist");
((Behaviour)this).enabled = false;
return;
}
GameObject val2 = Object.Instantiate<GameObject>(val, ((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform);
if (moveToParent)
{
val2.transform.SetParent(((Component)this).transform.parent, true);
}
Idol component = val2.GetComponent<Idol>();
if ((Object)(object)component != (Object)null && (Object)(object)Target != (Object)null && (Object)(object)Target.eid != (Object)null)
{
component.overrideTarget = Target.eid;
}
PostInstantiate(val2);
if (destroyThis)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
((Component)this).gameObject.SetActive(false);
}
((Behaviour)this).enabled = false;
}
protected virtual void PostInstantiate(GameObject instantiatedObject)
{
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}