diff --git a/Content.Server/Store/Components/StoreComponent.cs b/Content.Server/Store/Components/StoreComponent.cs index 063e25fbf9..0b7dbbea09 100644 --- a/Content.Server/Store/Components/StoreComponent.cs +++ b/Content.Server/Store/Components/StoreComponent.cs @@ -78,6 +78,13 @@ public sealed partial class StoreComponent : Component [ViewVariables, DataField] public bool RefundAllowed; + /// + /// Checks if store can be opened by the account owner only. + /// Not meant to be used with uplinks. + /// + [ViewVariables(VVAccess.ReadWrite), DataField] + public bool OwnerOnly; + /// /// The map the store was originally from, used to block refunds if the map is changed /// diff --git a/Content.Server/Store/Systems/StoreSystem.cs b/Content.Server/Store/Systems/StoreSystem.cs index 8ce1f9bb83..56426e0404 100644 --- a/Content.Server/Store/Systems/StoreSystem.cs +++ b/Content.Server/Store/Systems/StoreSystem.cs @@ -10,6 +10,7 @@ using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Shared.Prototypes; using System.Linq; +using Robust.Shared.Utility; namespace Content.Server.Store.Systems; @@ -26,6 +27,7 @@ public sealed partial class StoreSystem : EntitySystem { base.Initialize(); + SubscribeLocalEvent(OnStoreOpenAttempt); SubscribeLocalEvent(OnAfterInteract); SubscribeLocalEvent(BeforeActivatableUiOpen); @@ -65,6 +67,21 @@ public sealed partial class StoreSystem : EntitySystem RaiseLocalEvent(uid, ref ev, true); } + private void OnStoreOpenAttempt(EntityUid uid, StoreComponent component, ActivatableUIOpenAttemptEvent args) + { + if (!component.OwnerOnly) + return; + + component.AccountOwner ??= args.User; + DebugTools.Assert(component.AccountOwner != null); + + if (component.AccountOwner == args.User) + return; + + _popup.PopupEntity(Loc.GetString("store-not-account-owner", ("store", uid)), uid, args.User); + args.Cancel(); + } + private void OnAfterInteract(EntityUid uid, CurrencyComponent component, AfterInteractEvent args) { if (args.Handled || !args.CanReach) diff --git a/Resources/Locale/en-US/store/store.ftl b/Resources/Locale/en-US/store/store.ftl index 7af2b05533..d663cc61f7 100644 --- a/Resources/Locale/en-US/store/store.ftl +++ b/Resources/Locale/en-US/store/store.ftl @@ -6,3 +6,5 @@ store-ui-traitor-flavor = Copyright (C) NT -30643 store-ui-traitor-warning = Operatives must lock their uplinks after use to avoid detection. store-withdraw-button-ui = Withdraw {$currency} + +store-not-account-owner = This {$store} is not bound to you!