Skip to content

Commit 5ea1158

Browse files
committed
Add ModInterop methods for returning to lobby
1 parent 2174f9b commit 5ea1158

File tree

3 files changed

+48
-23
lines changed

3 files changed

+48
-23
lines changed

Entities/MiniHeart.cs

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -105,28 +105,9 @@ private IEnumerator SmashRoutine(Player player, Level level) {
105105
Audio.SetMusic(null);
106106
Audio.SetAmbience(null);
107107

108-
// display an endscreen if enabled in mod options AND speedrun timer is enabled (or else the endscreen won't show anything anyway).
109-
if (CollabModule.Instance.Settings.DisplayEndScreenForAllMaps && Settings.Instance.SpeedrunClock != SpeedrunType.Off) {
110-
Scene.Add(new AreaCompleteInfoInLevel());
111-
112-
// force the player to wait a bit, so that the info shows up
113-
yield return 0.5f;
114-
115-
// wait for an input
116-
while (!Input.MenuConfirm.Pressed && !Input.MenuCancel.Pressed) {
117-
yield return null;
118-
}
119-
} else {
120-
// wait 1 second max
121-
float timer = 0f;
122-
while (!Input.MenuConfirm.Pressed && !Input.MenuCancel.Pressed && timer <= 1f) {
123-
yield return null;
124-
timer += Engine.DeltaTime;
125-
}
126-
}
127-
128-
// get out of here, back to the lobby
129-
level.DoScreenWipe(false, () => Engine.Scene = new LevelExitToLobby(LevelExit.Mode.Completed, level.Session));
108+
// display the end screen and get out of here!
109+
yield return new SwapImmediately(ReturnToLobbyHelper.DisplayCollabMapEndScreenIfEnabled());
110+
ReturnToLobbyHelper.TriggerReturnToLobby();
130111
}
131112

132113
public override void Update() {

UI/ReturnToLobbyHelper.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,33 @@ private static void onLevelLoaderStartLevel(On.Celeste.LevelLoader.orig_StartLev
464464
orig(self);
465465
}
466466

467+
public static IEnumerator DisplayCollabMapEndScreenIfEnabled() {
468+
// display an endscreen if enabled in mod options AND speedrun timer is enabled (or else the endscreen won't show anything anyway).
469+
if (CollabModule.Instance.Settings.DisplayEndScreenForAllMaps && Settings.Instance.SpeedrunClock != SpeedrunType.Off) {
470+
Engine.Scene.Add(new AreaCompleteInfoInLevel());
471+
472+
// force the player to wait a bit, so that the info shows up
473+
yield return 0.5f;
474+
475+
// wait for an input
476+
while (!Input.MenuConfirm.Pressed && !Input.MenuCancel.Pressed) {
477+
yield return null;
478+
}
479+
} else {
480+
// wait 1 second max
481+
float timer = 0f;
482+
while (!Input.MenuConfirm.Pressed && !Input.MenuCancel.Pressed && timer <= 1f) {
483+
yield return null;
484+
timer += Engine.DeltaTime;
485+
}
486+
}
487+
}
488+
489+
public static void TriggerReturnToLobby() {
490+
Level level = (Level) Engine.Scene;
491+
level.DoScreenWipe(false, () => Engine.Scene = new LevelExitToLobby(LevelExit.Mode.Completed, level.Session));
492+
}
493+
467494
// ModInterop exports
468495

469496
[ModExportName("CollabUtils2.ReturnToLobbyHelper")]
@@ -526,6 +553,23 @@ public static void TeleportToMapWithReturnToLobbyAndGym(string mapSID, string ch
526553
OnSessionCreated();
527554
}
528555
}
556+
557+
/// <summary>
558+
/// Displays the endscreen of the individual collab map if the player enabled it, pauses for up to 1 second otherwise.
559+
/// This is the same behavior as mini hearts.
560+
/// </summary>
561+
/// <returns>A coroutine that should be run through in order to show the endscreen and wait for user input</returns>
562+
public static IEnumerator DisplayCollabMapEndScreenIfEnabled() {
563+
return ReturnToLobbyHelper.DisplayCollabMapEndScreenIfEnabled();
564+
}
565+
566+
/// <summary>
567+
/// Triggers the transition that sends the player back to the lobby from an individual collab map,
568+
/// like mini hearts do.
569+
/// </summary>
570+
public static void TriggerReturnToLobby() {
571+
ReturnToLobbyHelper.TriggerReturnToLobby();
572+
}
529573
}
530574
}
531575
}

everest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
- Name: CollabUtils2
2-
Version: 1.11.0
2+
Version: 1.11.1
33
DLL: bin/Release/net452/CollabUtils2.dll
44
Dependencies:
55
- Name: Everest

0 commit comments

Comments
 (0)