Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ZaZaInBellhome v1.2.1
ZazaInBellhome.dll
Decompiled 9 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.ResourceManagement.ResourceProviders; 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("ZazaInBellhome")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ZazaInBellhome")] [assembly: AssemblyTitle("ZazaInBellhome")] [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; } } } namespace Silksong { [BepInPlugin("com.fabbeyond.zaza_in_bellhome", "ZazaInBellHome", "1.2.0")] public class Plugin : BaseUnityPlugin { private GameObject inspect; private HeroController heroController; private int saveFileIdx; private List<ConfigEntry<bool>> zazaTakenConfigs = new List<ConfigEntry<bool>>(); private List<ConfigEntry<bool>> zazaInBellHomeConfigs = new List<ConfigEntry<bool>>(); private List<ConfigEntry<int>> zazaPositionConfigs = new List<ConfigEntry<int>>(); private bool loadedInBellHome = false; private List<string> noNoSceneNames = new List<string> { "Pre_Menu_Loader", "Pre_Menu_Intro", "Menu_Title", "Coral_33" }; private bool coralSceneLoaded = false; private AsyncOperationHandle<SceneInstance> coral_33LoadOp; private void Awake() { SceneManager.sceneLoaded += OnSceneLoaded; for (int i = 0; i < 4; i++) { zazaTakenConfigs.Add(((BaseUnityPlugin)this).Config.Bind<bool>($"Save File {i}", "zazaTaken", false, (ConfigDescription)null)); zazaInBellHomeConfigs.Add(((BaseUnityPlugin)this).Config.Bind<bool>($"Save File {i}", "zazaInBellHome", false, (ConfigDescription)null)); zazaPositionConfigs.Add(((BaseUnityPlugin)this).Config.Bind<int>($"Save File {i}", "zazaPosition", 0, (ConfigDescription)null)); } } private void Update() { if ((Object)(object)heroController == (Object)null) { heroController = HeroController.instance; } } private void OnDisable() { SceneManager.sceneLoaded -= OnSceneLoaded; } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)heroController != (Object)null) { saveFileIdx = heroController.playerData.profileID - 1; } if (((Scene)(ref scene)).name != "Belltown_Room_Spare" && coralSceneLoaded) { Addressables.UnloadSceneAsync(coral_33LoadOp.Result, true); coralSceneLoaded = false; } if (((Scene)(ref scene)).name == "Belltown_Room_Spare" && zazaInBellHomeConfigs[saveFileIdx].Value) { ((MonoBehaviour)this).StartCoroutine(LoadZaza()); } if (!noNoSceneNames.Contains(((Scene)(ref scene)).name) && zazaTakenConfigs[saveFileIdx].Value && !zazaInBellHomeConfigs[saveFileIdx].Value) { zazaInBellHomeConfigs[saveFileIdx].Value = true; ((BaseUnityPlugin)this).Config.Save(); } if (((Scene)(ref scene)).name == "Coral_33" && heroController.playerData.GetBool("garmondBlackThreadDefeated")) { if (!zazaInBellHomeConfigs[saveFileIdx].Value) { ((MonoBehaviour)this).StartCoroutine(ApplyInteractable()); } else if (!loadedInBellHome) { ((MonoBehaviour)this).StartCoroutine(RemoveZaza()); } } } private IEnumerator LoadZaza() { loadedInBellHome = true; AsyncOperationHandle<SceneInstance> handle = Addressables.LoadSceneAsync((object)"Scenes/Coral_33", (LoadSceneMode)1, true, 100, (SceneReleaseMode)0); yield return handle; if ((int)handle.Status == 1) { SceneInstance sceneInstance = handle.Result; coral_33LoadOp = handle; Scene coralScene = ((SceneInstance)(ref sceneInstance)).Scene; yield return null; coralSceneLoaded = true; if (((Scene)(ref coralScene)).IsValid() && ((Scene)(ref coralScene)).isLoaded) { GameObject[] rootGameObjects = ((Scene)(ref coralScene)).GetRootGameObjects(); foreach (GameObject root in rootGameObjects) { Transform zazaTransform = FindChildRecursive(root.transform, "Zaza Sleep NPC"); if ((Object)(object)zazaTransform == (Object)null) { Object.Destroy((Object)(object)root.gameObject); continue; } foreach (Transform componentInChild in ((Component)root.transform.GetChild(1)).gameObject.GetComponentInChildren<Transform>()) { Transform go = componentInChild; if (((Object)((Component)go).gameObject).name != "Garmond Scenes") { Object.Destroy((Object)(object)((Component)go).gameObject); continue; } GameObject zaza = ((Component)((Component)go).transform.GetChild(1).GetChild(1)).gameObject; if (zazaPositionConfigs[saveFileIdx].Value == 0) { zaza.transform.position = new Vector3(21.0599f, 7.002f, 0.0051f); } else if (zazaPositionConfigs[saveFileIdx].Value == 1) { ((tk2dBaseSprite)zaza.GetComponent<tk2dSprite>()).FlipX = true; zaza.transform.position = new Vector3(28.049f, 11.3331f, 0.0051f); zaza.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f); } } } } sceneInstance = default(SceneInstance); coralScene = default(Scene); } loadedInBellHome = false; } private Transform FindChildRecursive(Transform parent, string name) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown if (((Object)parent).name == name) { return parent; } foreach (Transform item in parent) { Transform parent2 = item; Transform val = FindChildRecursive(parent2, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } private IEnumerator RemoveZaza() { yield return (object)new WaitForSeconds(0.1f); GameObject zaza = GameObject.Find("Black Thread States/Black Thread World/Garmond Scenes/Garmond Defeated Scene/Zaza Sleep NPC"); Object.Destroy((Object)(object)zaza); } private IEnumerator ApplyInteractable() { yield return (object)new WaitForSeconds(0.1f); GameObject zaza = GameObject.Find("Black Thread States/Black Thread World/Garmond Scenes/Garmond Defeated Scene/Zaza Sleep NPC"); inspect = Object.Instantiate<GameObject>(new GameObject(), zaza.transform.position, Quaternion.identity); inspect.transform.position = new Vector3(inspect.transform.position.x, 63f, inspect.transform.position.z); BoxCollider2D col = inspect.AddComponent<BoxCollider2D>(); ((Collider2D)col).isTrigger = true; col.size = new Vector2(4f, 2f); InteractEvents ie = inspect.AddComponent<InteractEvents>(); ((InteractableBase)ie).InteractLabel = (PromptLabels)0; ie.Interacted += delegate { heroController.RelinquishControl(); DialogueYesNoBox.Open((Action)delegate { heroController.RegainControl(); YesNoAnswer(answer: true); }, (Action)delegate { heroController.RegainControl(); YesNoAnswer(answer: false); }, true, "Take ZaZa to Bellhome", (SavedItem)null); }; } private void YesNoAnswer(bool answer) { if (answer) { zazaTakenConfigs[saveFileIdx].Value = true; ((BaseUnityPlugin)this).Config.Save(); Object.Destroy((Object)(object)inspect); } } } }