Skip to content

Commit

Permalink
Fixed server and client part.
Browse files Browse the repository at this point in the history
  • Loading branch information
SkaldetSkaeg committed Feb 12, 2024
1 parent 49dece2 commit f877243
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 32 deletions.
4 changes: 2 additions & 2 deletions Content.Client/SS220/Cargo/UI/UpdatedCargoConsoleMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public UpdatedCargoConsoleMenu(EntityUid owner, IEntityManager entMan, IPrototyp
Categories.OnItemSelected += OnCategoryItemSelected;

AmountOfCashOut.OnTextChanged += e => OnAmountOfCashOutChange(e.Text);
//CashOutButton.OnPressed += CashOutButtonPressed;
//CashOutAllButton.OnPressed += CashOutAllButtonPressed;
CashOutButton.OnPressed += (args) => CashOutButtonPressed?.Invoke(args);
CashOutAllButton.OnPressed += (args) => CashOutAllButtonPressed?.Invoke(args);
}
public string GetAmountOfCashOut()
{
Expand Down
52 changes: 22 additions & 30 deletions Content.Server/SS220/Cargo/CargoCashOutSystem.cs
Original file line number Diff line number Diff line change
@@ -1,66 +1,58 @@
using System.Diagnostics.CodeAnalysis;
using Content.Server.Cargo.Components;
using Content.Server.Labels.Components;
using Content.Server.Paper;
using Content.Server.Station.Components;
using Content.Shared.Cargo;
using Content.Server.Cargo.Systems;
using Content.Shared.Cargo.BUI;
using Content.Shared.Cargo.Components;
using Content.Shared.Cargo.Events;
using Content.Shared.Cargo.Prototypes;
using Content.Shared.Database;
using Content.Shared.Interaction;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using Content.Shared.SS220.Cargo.Events;
using Content.Server.Station.Systems;
using Content.Shared.Cargo;
using Robust.Shared.Audio.Systems;
using Content.Shared.Stacks;
using Content.Server.Stack;
using Robust.Shared.Prototypes;


namespace Content.Server.SS220.Cargo
namespace Content.Server.SS220.Cargо
{
public sealed partial class CargoCashOutSystem : SharedCargoSystem
{
/// <summary>
/// How much time to wait (in seconds) before increasing bank accounts balance.
/// </summary>
private const int Delay = 10;

/// <summary>
/// Keeps track of how much time has elapsed since last balance increase.
/// </summary>
private float _timer;

[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly StackSystem _stack = default!;

private void InitializeConsole()
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CargoOrderConsoleComponent, CargoConsoleCashOutMessage>(CashOut);
}

private void CashOut(EntityUid uid, CargoOrderConsoleComponent component, ref CargoConsoleCashOutMessage arg)
{
var stationUid = _station.GetOwningStation(uid);

if (arg.Amount == 0)
return;

var stationUid = _station.GetOwningStation(arg.Used);

if (!TryComp(stationUid, out StationBankAccountComponent? bank))
return;

if (bank == null)
return;

if (arg.Amount > bank.Balance)
{
_audio.PlayPvs(_audio.GetSound(component.ErrorSound), uid);
return;
}

var cargoSystem = _entitySystemManager.GetEntitySystem<CargoSystem>();
var xform = Transform(uid);
var stackPrototype = _protoMan.Index<StackPrototype>("Credit");
_stack.Spawn(arg.Amount, stackPrototype, xform.Coordinates);

var cargoSystem = _entitySystemManager.GetEntitySystem<CargoSystem>();
cargoSystem.UpdateBankAccount(stationUid.Value, bank, -arg.Amount);
_audio.PlayPvs(component.ConfirmSound, uid);
}
}
}

0 comments on commit f877243

Please sign in to comment.