private void SellPallets(CargoShuttleComponent component, StationBankAccountComponent bank) { double amount = 0; var toSell = new HashSet <EntityUid>(); var xformQuery = GetEntityQuery <TransformComponent>(); foreach (var pallet in GetCargoPallets(component)) { // Containers should already get the sell price of their children so can skip those. foreach (var ent in _lookup.GetEntitiesIntersecting(pallet.Owner, LookupFlags.Anchored)) { // Don't re-sell anything, sell anything anchored (e.g. light fixtures), or anything blacklisted // (e.g. players). if (toSell.Contains(ent) || (xformQuery.TryGetComponent(ent, out var xform) && xform.Anchored)) { continue; } var price = _pricing.GetPrice(ent); if (price == 0) { continue; } toSell.Add(ent); amount += price; } } bank.Balance += (int)amount; _sawmill.Debug($"Cargo sold {toSell.Count} entities for {amount}"); foreach (var ent in toSell) { Del(ent); } }
private void DeductFunds(StationBankAccountComponent component, int amount) { component.Balance = Math.Max(0, component.Balance - amount); Dirty(component); }
// please don't delete this thank you public void UpdateBankAccount(StationBankAccountComponent component, int BalanceAdded) { component.Balance += BalanceAdded; }