@@ -62,7 +62,7 @@ namespace Content.Server.Cargo.Systems
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
_audio.PlayPvs(component.ConfirmSound, uid);
|
_audio.PlayPvs(component.ConfirmSound, uid);
|
||||||
UpdateBankAccount(stationUid.Value, bank, (int) price);
|
UpdateBankAccount((stationUid.Value, bank), (int) price);
|
||||||
QueueDel(args.Used);
|
QueueDel(args.Used);
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ namespace Content.Server.Cargo.Systems
|
|||||||
while (stationQuery.MoveNext(out var uid, out var bank))
|
while (stationQuery.MoveNext(out var uid, out var bank))
|
||||||
{
|
{
|
||||||
var balanceToAdd = bank.IncreasePerSecond * Delay;
|
var balanceToAdd = bank.IncreasePerSecond * Delay;
|
||||||
UpdateBankAccount(uid, bank, balanceToAdd);
|
UpdateBankAccount((uid, bank), balanceToAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
var query = EntityQueryEnumerator<CargoOrderConsoleComponent>();
|
var query = EntityQueryEnumerator<CargoOrderConsoleComponent>();
|
||||||
@@ -229,7 +229,7 @@ namespace Content.Server.Cargo.Systems
|
|||||||
$"{ToPrettyString(player):user} approved order [orderId:{order.OrderId}, quantity:{order.OrderQuantity}, product:{order.ProductId}, requester:{order.Requester}, reason:{order.Reason}] with balance at {bank.Balance}");
|
$"{ToPrettyString(player):user} approved order [orderId:{order.OrderId}, quantity:{order.OrderQuantity}, product:{order.ProductId}, requester:{order.Requester}, reason:{order.Reason}] with balance at {bank.Balance}");
|
||||||
|
|
||||||
orderDatabase.Orders.Remove(order);
|
orderDatabase.Orders.Remove(order);
|
||||||
UpdateBankAccount(station.Value, bank, -cost);
|
UpdateBankAccount((station.Value, bank), -cost);
|
||||||
UpdateOrders(station.Value);
|
UpdateOrders(station.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,19 +76,23 @@ public sealed partial class CargoSystem : SharedCargoSystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public void UpdateBankAccount(EntityUid uid, StationBankAccountComponent component, int balanceAdded)
|
public void UpdateBankAccount(Entity<StationBankAccountComponent?> ent, int balanceAdded)
|
||||||
{
|
{
|
||||||
component.Balance += balanceAdded;
|
if (!Resolve(ent, ref ent.Comp))
|
||||||
var query = EntityQueryEnumerator<BankClientComponent, TransformComponent>();
|
return;
|
||||||
|
|
||||||
var ev = new BankBalanceUpdatedEvent(uid, component.Balance);
|
ent.Comp.Balance += balanceAdded;
|
||||||
|
|
||||||
|
var ev = new BankBalanceUpdatedEvent(ent, ent.Comp.Balance);
|
||||||
|
|
||||||
|
var query = EntityQueryEnumerator<BankClientComponent, TransformComponent>();
|
||||||
while (query.MoveNext(out var client, out var comp, out var xform))
|
while (query.MoveNext(out var client, out var comp, out var xform))
|
||||||
{
|
{
|
||||||
var station = _station.GetOwningStation(client, xform);
|
var station = _station.GetOwningStation(client, xform);
|
||||||
if (station != uid)
|
if (station != ent)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
comp.Balance = component.Balance;
|
comp.Balance = ent.Comp.Balance;
|
||||||
Dirty(client, comp);
|
Dirty(client, comp);
|
||||||
RaiseLocalEvent(client, ref ev);
|
RaiseLocalEvent(client, ref ev);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public sealed partial class DeliverySystem : SharedDeliverySystem
|
|||||||
if (!TryComp<StationBankAccountComponent>(ent.Comp.RecipientStation, out var account))
|
if (!TryComp<StationBankAccountComponent>(ent.Comp.RecipientStation, out var account))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_cargo.UpdateBankAccount(ent, account, ent.Comp.SpesoReward);
|
_cargo.UpdateBankAccount((ent.Comp.RecipientStation.Value, account), ent.Comp.SpesoReward);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using Content.Shared.Cargo;
|
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
namespace Content.Shared.Cargo.Components;
|
namespace Content.Shared.Cargo.Components;
|
||||||
@@ -23,4 +22,4 @@ public sealed partial class BankClientComponent : Component
|
|||||||
/// Raised on an entity with <see cref="BankClientComponent"/> when the bank's balance is updated.
|
/// Raised on an entity with <see cref="BankClientComponent"/> when the bank's balance is updated.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ByRefEvent]
|
[ByRefEvent]
|
||||||
public record struct BankBalanceUpdatedEvent(EntityUid Station, int Balance);
|
public readonly record struct BankBalanceUpdatedEvent(EntityUid Station, int Balance);
|
||||||
|
|||||||
Reference in New Issue
Block a user