Only show the Uplink to players with Uplink Accounts (#6080)

This commit is contained in:
E F R
2022-01-09 08:02:07 +00:00
committed by GitHub
parent d2420e6520
commit e5cb3f74d7
2 changed files with 11 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ using Content.Server.Light.Components;
using Content.Server.Light.EntitySystems; using Content.Server.Light.EntitySystems;
using Content.Server.Light.Events; using Content.Server.Light.Events;
using Content.Server.Traitor.Uplink; using Content.Server.Traitor.Uplink;
using Content.Server.Traitor.Uplink.Account;
using Content.Server.Traitor.Uplink.Components; using Content.Server.Traitor.Uplink.Components;
using Content.Server.UserInterface; using Content.Server.UserInterface;
using Content.Shared.Containers.ItemSlots; using Content.Shared.Containers.ItemSlots;
@@ -17,6 +18,7 @@ namespace Content.Server.PDA
public sealed class PDASystem : SharedPDASystem public sealed class PDASystem : SharedPDASystem
{ {
[Dependency] private readonly UplinkSystem _uplinkSystem = default!; [Dependency] private readonly UplinkSystem _uplinkSystem = default!;
[Dependency] private readonly UplinkAccountsSystem _uplinkAccounts = default!;
[Dependency] private readonly UnpoweredFlashlightSystem _unpoweredFlashlight = default!; [Dependency] private readonly UnpoweredFlashlightSystem _unpoweredFlashlight = default!;
public override void Initialize() public override void Initialize()
@@ -82,6 +84,7 @@ namespace Content.Server.PDA
if (!EntityManager.TryGetComponent(user, out ActorComponent? actor)) if (!EntityManager.TryGetComponent(user, out ActorComponent? actor))
return false; return false;
UpdatePDAUserInterface(pda, user);
var ui = pda.Owner.GetUIOrNull(PDAUiKey.Key); var ui = pda.Owner.GetUIOrNull(PDAUiKey.Key);
ui?.Toggle(actor.PlayerSession); ui?.Toggle(actor.PlayerSession);
@@ -94,7 +97,7 @@ namespace Content.Server.PDA
appearance.SetData(PDAVisuals.IDCardInserted, pda.ContainedID != null); appearance.SetData(PDAVisuals.IDCardInserted, pda.ContainedID != null);
} }
private void UpdatePDAUserInterface(PDAComponent pda) private void UpdatePDAUserInterface(PDAComponent pda, EntityUid? user = default)
{ {
var ownerInfo = new PDAIdInfoText var ownerInfo = new PDAIdInfoText
{ {
@@ -105,6 +108,9 @@ namespace Content.Server.PDA
var hasUplink = EntityManager.HasComponent<UplinkComponent>(pda.Owner); var hasUplink = EntityManager.HasComponent<UplinkComponent>(pda.Owner);
if (user is not null)
hasUplink &= _uplinkAccounts.HasAccount(user.Value);
var ui = pda.Owner.GetUIOrNull(PDAUiKey.Key); var ui = pda.Owner.GetUIOrNull(PDAUiKey.Key);
ui?.SetState(new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo, hasUplink)); ui?.SetState(new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo, hasUplink));
} }
@@ -118,7 +124,7 @@ namespace Content.Server.PDA
switch (msg.Message) switch (msg.Message)
{ {
case PDARequestUpdateInterfaceMessage _: case PDARequestUpdateInterfaceMessage _:
UpdatePDAUserInterface(pda); UpdatePDAUserInterface(pda, playerUid);
break; break;
case PDAToggleFlashlightMessage _: case PDAToggleFlashlightMessage _:
{ {

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Shared.Stacks; using Content.Shared.Stacks;
using Content.Shared.Traitor.Uplink; using Content.Shared.Traitor.Uplink;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -28,6 +29,8 @@ namespace Content.Server.Traitor.Uplink.Account
return _accounts.Add(acc); return _accounts.Add(acc);
} }
public bool HasAccount(EntityUid holder) =>
_accounts.Any(acct => acct.AccountHolder == holder);
/// <summary> /// <summary>
/// Add TC to uplinks account balance /// Add TC to uplinks account balance