Skip to content

Commit

Permalink
At the end of old GMHS, return to the entrance in new GMHS instead of…
Browse files Browse the repository at this point in the history
… the start
  • Loading branch information
maddie480 committed Aug 26, 2021
1 parent c7b0530 commit 93ba2c1
Showing 1 changed file with 1 addition and 47 deletions.
48 changes: 1 addition & 47 deletions GrandmasterHeartSideHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ static class GrandmasterHeartSideHelper {
private static Hook hookIsHeartSide;
private static ILHook hookLobbyJournal;
private static ILHook hookOverworldJournal;
private static Hook hookLevelExitToLobby;
private static ILHook hookPoemColors;

public static void Load() {
Expand Down Expand Up @@ -113,13 +112,8 @@ private static void modLevelComplete(ILContext il) {
cursor.Emit(OpCodes.Ldarg_0);
cursor.EmitDelegate<Func<Action, Level, Action>>((orig, self) => {
if (self.Session.Area.GetSID() == "SpringCollab2020/5-Grandmaster/ZZ-HeartSide") {
// "return to lobby" but it actually returns to the new GM heart side.
// "return to lobby" (new GMHS) instead of returning to map.
return () => {
hookLevelExitToLobby = new Hook(
typeof(CollabUtils2.UI.LevelExitToLobby).GetMethod("Begin"),
typeof(GrandmasterHeartSideHelper).GetMethod("modLevelExitToLobby", BindingFlags.NonPublic | BindingFlags.Static));
On.Celeste.LevelEnter.Go += modLevelEnter;

Engine.Scene = new CollabUtils2.UI.LevelExitToLobby(LevelExit.Mode.Completed, self.Session);
};
} else {
Expand All @@ -130,46 +124,6 @@ private static void modLevelComplete(ILContext il) {
}
}

private static void modLevelExitToLobby(Action<CollabUtils2.UI.LevelExitToLobby> orig, CollabUtils2.UI.LevelExitToLobby self) {
// back up return location.
string bakSID = CollabUtils2.CollabModule.Instance.Session.LobbySID;
string bakRoom = CollabUtils2.CollabModule.Instance.Session.LobbyRoom;
float bakX = CollabUtils2.CollabModule.Instance.Session.LobbySpawnPointX;
float bakY = CollabUtils2.CollabModule.Instance.Session.LobbySpawnPointY;

// modify it to the new gmhs.
CollabUtils2.CollabModule.Instance.Session.LobbySID = "SpringCollab2020/5-Grandmaster/ZZ-NewHeartSide";
CollabUtils2.CollabModule.Instance.Session.LobbyRoom = null;
CollabUtils2.CollabModule.Instance.Session.LobbySpawnPointX = 0;
CollabUtils2.CollabModule.Instance.Session.LobbySpawnPointY = 0;

// run collab utils code.
orig(self);

// restore old values.
CollabUtils2.CollabModule.Instance.Session.LobbySID = bakSID;
CollabUtils2.CollabModule.Instance.Session.LobbyRoom = bakRoom;
CollabUtils2.CollabModule.Instance.Session.LobbySpawnPointX = bakX;
CollabUtils2.CollabModule.Instance.Session.LobbySpawnPointY = bakY;

// undo the hook so that future returns to lobby behave normally.
hookLevelExitToLobby?.Dispose();
hookLevelExitToLobby = null;
}

private static void modLevelEnter(On.Celeste.LevelEnter.orig_Go orig, Session session, bool fromSaveData) {
// This hook is only applied when returning from the old GMHS.
// We know we are returning to the start of new GMHS, so set up the session properly for that.
session.FirstLevel = true;
session.StartedFromBeginning = true;
new DynData<Session>(session)["pauseTimerUntilAction"] = false;

orig(session, fromSaveData);

// and undo the hook.
On.Celeste.LevelEnter.Go -= modLevelEnter;
}

private static void renderOldGMHSCompletionStamp(ILContext il) {
ILCursor cursor = new ILCursor(il);

Expand Down

0 comments on commit 93ba2c1

Please sign in to comment.