[ViewVariables, DataField]
public bool RefundAllowed;
+ /// <summary>
+ /// Checks if store can be opened by the account owner only.
+ /// Not meant to be used with uplinks.
+ /// </summary>
+ [ViewVariables(VVAccess.ReadWrite), DataField]
+ public bool OwnerOnly;
+
/// <summary>
/// The map the store was originally from, used to block refunds if the map is changed
/// </summary>
using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;
using System.Linq;
+using Robust.Shared.Utility;
namespace Content.Server.Store.Systems;
{
base.Initialize();
+ SubscribeLocalEvent<StoreComponent, ActivatableUIOpenAttemptEvent>(OnStoreOpenAttempt);
SubscribeLocalEvent<CurrencyComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<StoreComponent, BeforeActivatableUIOpenEvent>(BeforeActivatableUiOpen);
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)