From b3aaf73bb7c7d1b113c0ea283044a2e66892f4a2 Mon Sep 17 00:00:00 2001 From: Nathan Gill Date: Tue, 3 Aug 2021 15:12:35 -0400 Subject: [PATCH] Fixed teleportation again, fixed bug with returning to TNH lobby --- WurstMod/MappingComponents/Generic/CustomScene.cs | 8 ++------ WurstMod/Runtime/Entrypoint.cs | 3 ++- WurstMod/Runtime/Loader.cs | 13 +++++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/WurstMod/MappingComponents/Generic/CustomScene.cs b/WurstMod/MappingComponents/Generic/CustomScene.cs index 33b3eef..3f05cce 100644 --- a/WurstMod/MappingComponents/Generic/CustomScene.cs +++ b/WurstMod/MappingComponents/Generic/CustomScene.cs @@ -37,12 +37,8 @@ public override void OnExport(ExportErrors err) public void TeleportPlayer(Transform to) { #if !UNITY_EDITOR - FVRMovementManager mm = GM.CurrentMovementManager; - // If the player is currently holding a ladder, break them off it - if (mm.m_activeGrabHand) mm.m_activeGrabHand.CurrentInteractable.EndInteraction(mm.m_activeGrabHand); - - // Then teleport away - mm.TeleportToPoint(to.position, true, to.eulerAngles); + // Proxy to the game's teleport method + GM.CurrentMovementManager.TeleportToPoint(to.position, true, to.eulerAngles); #endif } public void KillPlayer() diff --git a/WurstMod/Runtime/Entrypoint.cs b/WurstMod/Runtime/Entrypoint.cs index 17801c7..c5a3ddf 100644 --- a/WurstMod/Runtime/Entrypoint.cs +++ b/WurstMod/Runtime/Entrypoint.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Reflection; using BepInEx.Configuration; +using BepInEx.Logging; using Deli; using Deli.Setup; using Deli.VFS; @@ -87,7 +88,7 @@ private void LevelLoader(Stage stage, Mod mod, IHandle handle) else { CustomLevelFinder.ArchiveLevels.Add(level.Value); - Debug.Log($"Discovered level {level.Value.SceneName} in {mod}, {handle}"); + Logger.LogInfo($"Discovered level {level.Value.SceneName} in {mod}, {handle}"); } } diff --git a/WurstMod/Runtime/Loader.cs b/WurstMod/Runtime/Loader.cs index d0697d2..51b4d8b 100644 --- a/WurstMod/Runtime/Loader.cs +++ b/WurstMod/Runtime/Loader.cs @@ -30,6 +30,13 @@ public static IEnumerator OnSceneLoad(Scene scene) { if (!IsLoadInProgress && LevelToLoad.HasValue) { + // Check if this scene is the one we wanted to load for this level + var level = LevelToLoad.Value; + var sceneLoader = CustomSceneLoader.GetSceneLoaderForGamemode(level.Gamemode); + + // If either of these are true something is wrong and we shouldn't try to load anything + if (sceneLoader is null || sceneLoader.BaseScene != scene.name) yield break; + // We're loading the base scene for a modded scene IsLoadInProgress = true; @@ -37,8 +44,7 @@ public static IEnumerator OnSceneLoad(Scene scene) ObjectReferences.FindReferences(scene); // Load the level - var level = LevelToLoad.Value; - yield return LoadCustomScene(level); + yield return LoadCustomScene(level, sceneLoader); } if (IsLoadInProgress && LevelToLoad.HasValue) @@ -50,11 +56,10 @@ public static IEnumerator OnSceneLoad(Scene scene) /// /// This method is called to load a custom scene /// - private static IEnumerator LoadCustomScene(LevelInfo level) + private static IEnumerator LoadCustomScene(LevelInfo level, CustomSceneLoader sceneLoader) { // Step 0: Get the loaded scene and find any custom loaders and scene patchers _loadedScene = SceneManager.GetActiveScene(); - var sceneLoader = CustomSceneLoader.GetSceneLoaderForGamemode(level.Gamemode); if (sceneLoader == null) { Debug.LogError($"No SceneLoader found for the gamemode '{level.Gamemode}'! Cannot load level.");