@@ -148,20 +148,44 @@ private static void SetupDefaultSceneUniversal()
148148 }
149149
150150 /// <summary>
151- /// <see cref="GameDirector"/> is always present in the `Main` scene, so we use it as entrypoint
151+ /// <see cref="GameDirector"/> is always present in the `Main` scene, so we use it as a base entrypoint
152152 /// </summary>
153153 [ HarmonyPatch ( typeof ( GameDirector ) , nameof ( GameDirector . Start ) ) ]
154154 [ HarmonyPostfix ]
155155 private static void OnStartup ( GameDirector __instance )
156156 {
157157 VRInputSystem . instance . ActivateInput ( ) ;
158-
158+
159159 if ( RunManager . instance . levelCurrent == RunManager . instance . levelMainMenu ||
160- RunManager . instance . levelCurrent == RunManager . instance . levelLobbyMenu ||
161160 RunManager . instance . levelCurrent == RunManager . instance . levelSplashScreen )
162161 OnStartupMainMenu ( ) ;
163- else
164- OnStartupInGame ( ) ;
162+
163+ // We have to do some magic for the Lobby Menu level because of ✨late join✨
164+ }
165+
166+ /// <summary>
167+ /// Special custom entrypoint since we might swap levels shortly after GameDirector startup (Late join)
168+ /// </summary>
169+ [ HarmonyPatch ( typeof ( LobbyMenuOpen ) , nameof ( LobbyMenuOpen . Awake ) ) ]
170+ [ HarmonyPostfix ]
171+ private static void OnStartLobbyMenu ( )
172+ {
173+ if ( RunManager . instance . levelCurrent == RunManager . instance . levelLobbyMenu )
174+ OnStartupMainMenu ( ) ;
175+ }
176+
177+ /// <summary>
178+ /// Use the Truck Start Room module to detect if we are in the actual game
179+ /// </summary>
180+ [ HarmonyPatch ( typeof ( StartRoom ) , nameof ( StartRoom . Start ) ) ]
181+ [ HarmonyPostfix ]
182+ private static void OnStartTruck ( StartRoom __instance )
183+ {
184+ // The menu levels also have the truck so we should just ignore them
185+ if ( __instance . name is "Start Room - Main Menu(Clone)" or "Start Room - Lobby Menu(Clone)" )
186+ return ;
187+
188+ OnStartupInGame ( ) ;
165189 }
166190
167191 [ HarmonyPatch ( typeof ( SplashScreen ) , nameof ( SplashScreen . Start ) ) ]
0 commit comments