fix retarded code (#744)

This commit is contained in:
Valtos
2024-10-24 17:15:00 +03:00
committed by GitHub
parent 350ce8e297
commit 64ab042551
4 changed files with 88 additions and 29 deletions

View File

@@ -297,6 +297,9 @@ public sealed partial class StoreSystem
/// </remarks>
private void OnRequestWithdraw(EntityUid uid, StoreComponent component, StoreRequestWithdrawMessage msg)
{
if (msg.Amount <= 0)
return;
//make sure we have enough cash in the bank and we actually support this currency
if (!component.Balance.TryGetValue(msg.Currency, out var currentAmount) || currentAmount < msg.Amount)
return;
@@ -320,7 +323,8 @@ public sealed partial class StoreSystem
var cashId = proto.Cash[value];
var amountToSpawn = (int) MathF.Floor((float) (amountRemaining / value));
var ents = _stack.SpawnMultiple(cashId, amountToSpawn, coordinates);
_hands.PickupOrDrop(buyer, ents.First());
if (ents.FirstOrDefault() is {} ent)
_hands.PickupOrDrop(buyer, ent);
amountRemaining -= value * amountToSpawn;
}