Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable "First Use Cinematics" on EscapePod #2216

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions NitroxClient/GameLogic/InitialSync/PlayerInitialSyncProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public PlayerInitialSyncProcessor(Items item, ItemContainers itemContainers, Loc
this.itemContainers = itemContainers;
this.localPlayer = localPlayer;

AddStep(sync => SetupEscapePod(sync.FirstTimeConnecting));
AddStep(sync => SetPlayerPermissions(sync.Permissions));
AddStep(sync => SetPlayerIntroCinematicMode(sync.IntroCinematicMode));
AddStep(sync => SetPlayerGameObjectId(sync.PlayerGameObjectId));
Expand Down Expand Up @@ -55,6 +56,25 @@ private void SetPlayerGameObjectId(NitroxId id)
Log.Info($"Received initial sync player GameObject Id: {id}");
}

private void SetupEscapePod(bool firstTimeConnecting)
{
EscapePod escapePod = EscapePod.main;
if (escapePod)
{
Log.Info($"Setting up escape pod, FirstTimeConnecting: {firstTimeConnecting}");

escapePod.bottomHatchUsed = !firstTimeConnecting;
escapePod.topHatchUsed = !firstTimeConnecting;

// Call code we suppressed inside EscapePodFirstUseCinematicsController_OnSceneObjectsLoaded_Patch
EscapePodFirstUseCinematicsController cinematicController = escapePod.GetComponentInChildren<EscapePodFirstUseCinematicsController>(true);
if (cinematicController)
{
cinematicController.Initialize();
}
}
}

private IEnumerator AddStartingItemsToPlayer(bool firstTimeConnecting)
{
if (firstTimeConnecting)
Expand Down
4 changes: 2 additions & 2 deletions NitroxClient/GameLogic/LocalPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public class LocalPlayer : ILocalNitroxPlayer
public ushort? PlayerId => multiplayerSession?.Reservation?.PlayerId;
public PlayerSettings PlayerSettings => multiplayerSession.PlayerSettings;

public Perms Permissions;
public IntroCinematicMode IntroCinematicMode;
public Perms Permissions { get; set; }
public IntroCinematicMode IntroCinematicMode { get; set; }

public LocalPlayer(IMultiplayerSession multiplayerSession, IPacketSender packetSender, ThrottledPacketSender throttledPacketSender)
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Reflection;
using NitroxClient.MonoBehaviours;
using NitroxModel.Helper;

namespace NitroxPatcher.Patches.Persistent;

/// <summary>
/// Patch to disable the EscapePodFirstUseCinematicsController.OnSceneObjectsLoaded method when in multiplayer.
/// Initialize will be called OnSceneLoad to setup cinematics or first use cinematics
/// </summary>
public sealed partial class EscapePodFirstUseCinematicsController_OnSceneObjectsLoaded_Patch : NitroxPatch, IPersistentPatch
{
private static readonly MethodInfo TARGET_METHOD = Reflect.Method((EscapePodFirstUseCinematicsController t) => t.OnSceneObjectsLoaded());

public static bool Prefix(EscapePodFirstUseCinematicsController __instance) => !Multiplayer.Active;
}