diff --git a/Content.Server/PDA/PDASystem.cs b/Content.Server/PDA/PDASystem.cs index 8a3ced56a6..cfd1ec9b06 100644 --- a/Content.Server/PDA/PDASystem.cs +++ b/Content.Server/PDA/PDASystem.cs @@ -97,7 +97,7 @@ namespace Content.Server.PDA appearance.SetData(PDAVisuals.IDCardInserted, pda.ContainedID != null); } - private void UpdatePDAUserInterface(PDAComponent pda, EntityUid? user = default) + private void UpdatePDAUserInterface(PDAComponent pda, EntityUid? user = null) { var ownerInfo = new PDAIdInfoText { @@ -106,13 +106,39 @@ namespace Content.Server.PDA JobTitle = pda.ContainedID?.JobTitle }; - var hasUplink = EntityManager.HasComponent(pda.Owner); - - if (user is not null) - hasUplink &= _uplinkAccounts.HasAccount(user.Value); - var ui = pda.Owner.GetUIOrNull(PDAUiKey.Key); - ui?.SetState(new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo, hasUplink)); + if (ui == null) + return; + + ui.SetState(new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo, ShouldShowUplink(pda.Owner, ui, user))); + } + + /// + /// Check whether the PDA has an uplink, and ensure that the only person that can see the PDA UI has an + /// uplink account. + /// + public bool ShouldShowUplink(EntityUid uid, BoundUserInterface ui, EntityUid? user = null) + { + // TODO UPLINK RINGTONES/SECRETS This is just a janky placeholder way of hiding uplinks from non syndicate + // players. This should really use a sort of key-code entry system that selects an account which is not directly tied to + // a player entity. + + if (!HasComp(uid)) + return false; + + // If a user is trying to open the UI, make sure that they have an uplink account before showing the UI. + if (user != null && !_uplinkAccounts.HasAccount(user.Value)) + return false; + + // If other users currently have the UI open, check that they too should be allowed to see the button.. + foreach (var session in ui.SubscribedSessions) + { + if (session.AttachedEntity != null && !_uplinkAccounts.HasAccount(session.AttachedEntity.Value)) + return false; + } + + // everyone has an uplink account, show the button. + return true; } private void OnUIMessage(PDAComponent pda, ServerBoundUserInterfaceMessage msg)