Skip to content

Commit 93ba2c1

Browse files
committed
At the end of old GMHS, return to the entrance in new GMHS instead of the start
1 parent c7b0530 commit 93ba2c1

File tree

1 file changed

+1
-47
lines changed

1 file changed

+1
-47
lines changed

GrandmasterHeartSideHelper.cs

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ static class GrandmasterHeartSideHelper {
2020
private static Hook hookIsHeartSide;
2121
private static ILHook hookLobbyJournal;
2222
private static ILHook hookOverworldJournal;
23-
private static Hook hookLevelExitToLobby;
2423
private static ILHook hookPoemColors;
2524

2625
public static void Load() {
@@ -113,13 +112,8 @@ private static void modLevelComplete(ILContext il) {
113112
cursor.Emit(OpCodes.Ldarg_0);
114113
cursor.EmitDelegate<Func<Action, Level, Action>>((orig, self) => {
115114
if (self.Session.Area.GetSID() == "SpringCollab2020/5-Grandmaster/ZZ-HeartSide") {
116-
// "return to lobby" but it actually returns to the new GM heart side.
115+
// "return to lobby" (new GMHS) instead of returning to map.
117116
return () => {
118-
hookLevelExitToLobby = new Hook(
119-
typeof(CollabUtils2.UI.LevelExitToLobby).GetMethod("Begin"),
120-
typeof(GrandmasterHeartSideHelper).GetMethod("modLevelExitToLobby", BindingFlags.NonPublic | BindingFlags.Static));
121-
On.Celeste.LevelEnter.Go += modLevelEnter;
122-
123117
Engine.Scene = new CollabUtils2.UI.LevelExitToLobby(LevelExit.Mode.Completed, self.Session);
124118
};
125119
} else {
@@ -130,46 +124,6 @@ private static void modLevelComplete(ILContext il) {
130124
}
131125
}
132126

133-
private static void modLevelExitToLobby(Action<CollabUtils2.UI.LevelExitToLobby> orig, CollabUtils2.UI.LevelExitToLobby self) {
134-
// back up return location.
135-
string bakSID = CollabUtils2.CollabModule.Instance.Session.LobbySID;
136-
string bakRoom = CollabUtils2.CollabModule.Instance.Session.LobbyRoom;
137-
float bakX = CollabUtils2.CollabModule.Instance.Session.LobbySpawnPointX;
138-
float bakY = CollabUtils2.CollabModule.Instance.Session.LobbySpawnPointY;
139-
140-
// modify it to the new gmhs.
141-
CollabUtils2.CollabModule.Instance.Session.LobbySID = "SpringCollab2020/5-Grandmaster/ZZ-NewHeartSide";
142-
CollabUtils2.CollabModule.Instance.Session.LobbyRoom = null;
143-
CollabUtils2.CollabModule.Instance.Session.LobbySpawnPointX = 0;
144-
CollabUtils2.CollabModule.Instance.Session.LobbySpawnPointY = 0;
145-
146-
// run collab utils code.
147-
orig(self);
148-
149-
// restore old values.
150-
CollabUtils2.CollabModule.Instance.Session.LobbySID = bakSID;
151-
CollabUtils2.CollabModule.Instance.Session.LobbyRoom = bakRoom;
152-
CollabUtils2.CollabModule.Instance.Session.LobbySpawnPointX = bakX;
153-
CollabUtils2.CollabModule.Instance.Session.LobbySpawnPointY = bakY;
154-
155-
// undo the hook so that future returns to lobby behave normally.
156-
hookLevelExitToLobby?.Dispose();
157-
hookLevelExitToLobby = null;
158-
}
159-
160-
private static void modLevelEnter(On.Celeste.LevelEnter.orig_Go orig, Session session, bool fromSaveData) {
161-
// This hook is only applied when returning from the old GMHS.
162-
// We know we are returning to the start of new GMHS, so set up the session properly for that.
163-
session.FirstLevel = true;
164-
session.StartedFromBeginning = true;
165-
new DynData<Session>(session)["pauseTimerUntilAction"] = false;
166-
167-
orig(session, fromSaveData);
168-
169-
// and undo the hook.
170-
On.Celeste.LevelEnter.Go -= modLevelEnter;
171-
}
172-
173127
private static void renderOldGMHSCompletionStamp(ILContext il) {
174128
ILCursor cursor = new ILCursor(il);
175129

0 commit comments

Comments
 (0)