Skip to content

Commit

Permalink
Fixed teleportation again, fixed bug with returning to TNH lobby
Browse files Browse the repository at this point in the history
  • Loading branch information
nrgill28 committed Aug 3, 2021
1 parent c888f5d commit b3aaf73
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
8 changes: 2 additions & 6 deletions WurstMod/MappingComponents/Generic/CustomScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion WurstMod/Runtime/Entrypoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}");
}
}

Expand Down
13 changes: 9 additions & 4 deletions WurstMod/Runtime/Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,21 @@ 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;

// Find references
ObjectReferences.FindReferences(scene);

// Load the level
var level = LevelToLoad.Value;
yield return LoadCustomScene(level);
yield return LoadCustomScene(level, sceneLoader);
}

if (IsLoadInProgress && LevelToLoad.HasValue)
Expand All @@ -50,11 +56,10 @@ public static IEnumerator OnSceneLoad(Scene scene)
/// <summary>
/// This method is called to load a custom scene
/// </summary>
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.");
Expand Down

0 comments on commit b3aaf73

Please sign in to comment.