make sure only traitors can see uplink button (#6083)
* make sure only traitors can see uplink button * comments and pda.Owner -> uid
This commit is contained in:
@@ -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<UplinkComponent>(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)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check whether the PDA has an uplink, and ensure that the only person that can see the PDA UI has an
|
||||
/// uplink account.
|
||||
/// </summary>
|
||||
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<UplinkComponent>(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)
|
||||
|
||||
Reference in New Issue
Block a user