Skip to content

Commit

Permalink
Move waiting for InitialSync before "Press any button"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jannify committed Nov 14, 2024
1 parent 7dff133 commit a254112
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ public sealed partial class uGUI_SceneIntro_IntroSequence_Patch : NitroxPatch, I
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
return new CodeMatcher(instructions)
// Override AnyKeyDown check
// Replace LargeWorldStreamer.Main.IsWorldSettled() check with IsWorldSettledAndInitialSyncCompleted()
.MatchStartForward(
new CodeMatch(OpCodes.Ldsfld, Reflect.Field(() => LargeWorldStreamer.main)),
new CodeMatch(OpCodes.Callvirt, Reflect.Method((LargeWorldStreamer lws) => lws.IsWorldSettled()))
)
.SetAndAdvance(OpCodes.Call, Reflect.Method(() => IsWorldSettledAndInitialSyncCompleted()))
.RemoveInstruction()
// Replace GameInput.AnyKeyDown() check with AnyKeyDownOrModeCompleted()
.MatchEndForward(
new CodeMatch(OpCodes.Call, Reflect.Method(() => GameInput.AnyKeyDown()))
)
Expand Down Expand Up @@ -75,9 +82,13 @@ public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructio

private static RemotePlayer partner;
private static bool callbackRun;
private static bool readyToSend;
private static bool packetSend;

private static bool IsWorldSettledAndInitialSyncCompleted()
{
return LargeWorldStreamer.main.IsWorldSettled() && Multiplayer.Main && Multiplayer.Main.InitialSyncCompleted;
}

private static bool AnyKeyDownOrModeCompleted()
{
return GameInput.AnyKeyDown() || Resolve<LocalPlayer>().IntroCinematicMode == IntroCinematicMode.COMPLETED;
Expand All @@ -103,13 +114,7 @@ private static bool IsRemoteCinematicReady(uGUI_SceneIntro uGuiSceneIntro)
return false;
}

if (!packetSend && !readyToSend && Multiplayer.Main && Multiplayer.Main.InitialSyncCompleted)
{
readyToSend = true;
return false;
}

if (!packetSend && readyToSend)
if (!packetSend)
{
uGuiSceneIntro.skipHintStartTime = Time.time;
uGuiSceneIntro.mainText.SetText(Language.main.GetFormat("Nitrox_IntroWaitingPartner", uGUI.FormatButton(GameInput.Button.UIMenu)));
Expand Down

0 comments on commit a254112

Please sign in to comment.