-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathPrecursorKeyTerminalTrigger_OnTriggerEnter_Patch.cs
More file actions
35 lines (28 loc) · 1.22 KB
/
PrecursorKeyTerminalTrigger_OnTriggerEnter_Patch.cs
File metadata and controls
35 lines (28 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Reflection;
using NitroxClient.GameLogic.PlayerLogic;
using UnityEngine;
namespace NitroxPatcher.Patches.Dynamic;
/// <summary>
/// Makes precursor key terminal pedestals (tablet pedestals) react to remote players.
/// </summary>
public sealed partial class PrecursorKeyTerminalTrigger_OnTriggerEnter_Patch : NitroxPatch, IDynamicPatch
{
private static readonly MethodInfo TARGET_METHOD = Reflect.Method((PrecursorKeyTerminalTrigger t) => t.OnTriggerEnter(default));
public static bool Prefix(PrecursorKeyTerminalTrigger __instance, Collider col)
{
bool isLocalPlayer = col.gameObject.Equals(Player.main.gameObject);
bool isRemotePlayer = col.GetComponentInParent<RemotePlayerIdentifier>() != null;
if (!isLocalPlayer && !isRemotePlayer)
{
return false;
}
// Track player count for proper exit handling
PrecursorKeyTerminalTrigger_OnTriggerExit_Patch.IncrementPlayerCount(__instance);
// Only send OpenDeck if this is the first player entering
if (PrecursorKeyTerminalTrigger_OnTriggerExit_Patch.GetPlayerCount(__instance) == 1)
{
__instance.SendMessageUpwards("OpenDeck");
}
return false;
}
}