Files
Delta-v/Content.Shared/_DV/Shipyard/SharedShipyardConsoleSystem.cs
T
36d634bdff shipyard ui cleanup (#1257)
* small cleanup

* use BankClient for balance updating

* pro

* fixes fixes fixes

* untroll engine

---------

Signed-off-by: deltanedas <39013340+deltanedas@users.noreply.github.com>
Co-authored-by: deltanedas <@deltanedas:kde.org>
Co-authored-by: Tad "Taddy" Johnson <120885811+TadJohnson00@users.noreply.github.com>
Co-authored-by: Milon <milonpl.git@proton.me>
Co-authored-by: Milon <plmilonpl@gmail.com>
2025-01-01 13:47:28 +00:00

53 lines
1.7 KiB
C#

using Content.Shared.Access.Systems;
using Content.Shared.Popups;
using Content.Shared.Shipyard.Prototypes;
using Content.Shared.Whitelist;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Prototypes;
namespace Content.Shared.Shipyard;
/// <summary>
/// Handles shipyard console interaction.
/// <c>ShipyardSystem</c> does the heavy lifting serverside.
/// </summary>
public abstract class SharedShipyardConsoleSystem : EntitySystem
{
[Dependency] private readonly AccessReaderSystem _access = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] protected readonly SharedAudioSystem Audio = default!;
[Dependency] protected readonly SharedPopupSystem Popup = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
public override void Initialize()
{
base.Initialize();
Subs.BuiEvents<ShipyardConsoleComponent>(ShipyardConsoleUiKey.Key,
subs =>
{
subs.Event<ShipyardConsolePurchaseMessage>(OnPurchase);
});
}
private void OnPurchase(Entity<ShipyardConsoleComponent> ent, ref ShipyardConsolePurchaseMessage msg)
{
var user = msg.Actor;
if (!_access.IsAllowed(user, ent.Owner))
{
Popup.PopupClient(Loc.GetString("comms-console-permission-denied"), ent, user);
Audio.PlayPredicted(ent.Comp.DenySound, ent, user);
return;
}
if (!_proto.TryIndex(msg.Vessel, out var vessel) || _whitelistSystem.IsWhitelistFail(vessel.Whitelist, ent))
return;
TryPurchase(ent, user, vessel);
}
protected virtual void TryPurchase(Entity<ShipyardConsoleComponent> ent, EntityUid user, VesselPrototype vessel)
{
}
}