2022-06-23 14:36:47 +10:00
|
|
|
using Content.Server.Cargo.Components;
|
2023-06-16 05:19:02 +00:00
|
|
|
using Content.Server.DeviceLinking.Systems;
|
|
|
|
|
using Content.Server.Popups;
|
|
|
|
|
using Content.Server.Shuttles.Systems;
|
|
|
|
|
using Content.Server.Stack;
|
2022-06-23 14:36:47 +10:00
|
|
|
using Content.Server.Station.Systems;
|
2023-06-16 05:19:02 +00:00
|
|
|
using Content.Shared.Access.Systems;
|
|
|
|
|
using Content.Shared.Administration.Logs;
|
2024-04-18 03:32:21 +03:00
|
|
|
using Content.Server.Radio.EntitySystems;
|
2022-02-15 15:01:45 +11:00
|
|
|
using Content.Shared.Cargo;
|
2024-01-19 22:47:08 -05:00
|
|
|
using Content.Shared.Cargo.Components;
|
2025-04-13 09:22:36 -04:00
|
|
|
using Content.Shared.Cargo.Prototypes;
|
2025-04-22 08:34:53 -04:00
|
|
|
using Content.Shared.CCVar;
|
2022-02-15 15:01:45 +11:00
|
|
|
using Content.Shared.Containers.ItemSlots;
|
2023-07-10 05:24:48 +10:00
|
|
|
using Content.Shared.Mobs.Components;
|
2024-08-04 21:23:23 -07:00
|
|
|
using Content.Shared.Paper;
|
2023-03-10 16:41:22 +11:00
|
|
|
using JetBrains.Annotations;
|
2023-06-16 05:19:02 +00:00
|
|
|
using Robust.Server.GameObjects;
|
2023-11-27 22:12:34 +11:00
|
|
|
using Robust.Shared.Audio.Systems;
|
2025-04-22 08:34:53 -04:00
|
|
|
using Robust.Shared.Configuration;
|
2022-02-15 15:01:45 +11:00
|
|
|
using Robust.Shared.Prototypes;
|
2023-06-16 05:19:02 +00:00
|
|
|
using Robust.Shared.Random;
|
2022-02-15 15:01:45 +11:00
|
|
|
|
2022-06-03 10:56:11 -05:00
|
|
|
namespace Content.Server.Cargo.Systems;
|
2022-02-15 15:01:45 +11:00
|
|
|
|
|
|
|
|
public sealed partial class CargoSystem : SharedCargoSystem
|
|
|
|
|
{
|
2025-04-22 08:34:53 -04:00
|
|
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
2022-02-15 15:01:45 +11:00
|
|
|
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
2023-06-16 05:19:02 +00:00
|
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
|
|
|
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
|
|
|
|
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
|
|
|
|
|
[Dependency] private readonly DeviceLinkSystem _linker = default!;
|
|
|
|
|
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
2022-02-15 15:01:45 +11:00
|
|
|
[Dependency] private readonly ItemSlotsSystem _slots = default!;
|
2023-06-16 05:19:02 +00:00
|
|
|
[Dependency] private readonly PaperSystem _paperSystem = default!;
|
|
|
|
|
[Dependency] private readonly PopupSystem _popup = default!;
|
|
|
|
|
[Dependency] private readonly PricingSystem _pricing = default!;
|
|
|
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
2023-01-10 04:55:59 -05:00
|
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
2023-06-16 05:19:02 +00:00
|
|
|
[Dependency] private readonly StackSystem _stack = default!;
|
|
|
|
|
[Dependency] private readonly StationSystem _station = default!;
|
|
|
|
|
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
2023-07-08 09:02:17 -07:00
|
|
|
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
|
2024-04-18 03:32:21 +03:00
|
|
|
[Dependency] private readonly RadioSystem _radio = default!;
|
2022-02-15 15:01:45 +11:00
|
|
|
|
2023-07-10 05:24:48 +10:00
|
|
|
private EntityQuery<TransformComponent> _xformQuery;
|
|
|
|
|
private EntityQuery<CargoSellBlacklistComponent> _blacklistQuery;
|
|
|
|
|
private EntityQuery<MobStateComponent> _mobQuery;
|
2024-01-19 13:02:28 +11:00
|
|
|
private EntityQuery<TradeStationComponent> _tradeQuery;
|
|
|
|
|
|
|
|
|
|
private HashSet<EntityUid> _setEnts = new();
|
|
|
|
|
private List<EntityUid> _listEnts = new();
|
|
|
|
|
private List<(EntityUid, CargoPalletComponent, TransformComponent)> _pads = new();
|
2022-06-23 14:36:47 +10:00
|
|
|
|
2022-02-15 15:01:45 +11:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2023-07-10 05:24:48 +10:00
|
|
|
|
|
|
|
|
_xformQuery = GetEntityQuery<TransformComponent>();
|
|
|
|
|
_blacklistQuery = GetEntityQuery<CargoSellBlacklistComponent>();
|
|
|
|
|
_mobQuery = GetEntityQuery<MobStateComponent>();
|
2024-01-19 13:02:28 +11:00
|
|
|
_tradeQuery = GetEntityQuery<TradeStationComponent>();
|
2023-07-10 05:24:48 +10:00
|
|
|
|
2022-02-15 15:01:45 +11:00
|
|
|
InitializeConsole();
|
2022-06-23 14:36:47 +10:00
|
|
|
InitializeShuttle();
|
2022-02-15 15:01:45 +11:00
|
|
|
InitializeTelepad();
|
2023-06-22 07:49:33 -04:00
|
|
|
InitializeBounty();
|
2025-04-13 09:22:36 -04:00
|
|
|
InitializeFunds();
|
2022-06-23 14:36:47 +10:00
|
|
|
}
|
|
|
|
|
|
2022-02-15 15:01:45 +11:00
|
|
|
public override void Update(float frameTime)
|
|
|
|
|
{
|
|
|
|
|
base.Update(frameTime);
|
2025-04-13 09:22:36 -04:00
|
|
|
UpdateConsole();
|
2022-02-15 15:01:45 +11:00
|
|
|
UpdateTelepad(frameTime);
|
2023-06-22 07:49:33 -04:00
|
|
|
UpdateBounty();
|
2022-02-15 15:01:45 +11:00
|
|
|
}
|
2022-07-15 09:20:35 -04:00
|
|
|
|
2025-04-17 22:06:29 -04:00
|
|
|
public void UpdateBankAccount(
|
|
|
|
|
Entity<StationBankAccountComponent?> ent,
|
|
|
|
|
int balanceAdded,
|
|
|
|
|
ProtoId<CargoAccountPrototype> account,
|
|
|
|
|
bool dirty = true)
|
|
|
|
|
{
|
|
|
|
|
UpdateBankAccount(
|
|
|
|
|
ent,
|
|
|
|
|
balanceAdded,
|
|
|
|
|
new Dictionary<ProtoId<CargoAccountPrototype>, double> { {account, 1} },
|
|
|
|
|
dirty: dirty);
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-13 09:22:36 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Adds or removes funds from the <see cref="StationBankAccountComponent"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ent">The station.</param>
|
|
|
|
|
/// <param name="balanceAdded">The amount of funds to add or remove.</param>
|
|
|
|
|
/// <param name="accountDistribution">The distribution between individual <see cref="CargoAccountPrototype"/>.</param>
|
2025-04-17 22:06:29 -04:00
|
|
|
/// <param name="dirty">Whether to mark the bank account component as dirty.</param>
|
2023-03-10 16:41:22 +11:00
|
|
|
[PublicAPI]
|
2025-04-13 09:22:36 -04:00
|
|
|
public void UpdateBankAccount(
|
|
|
|
|
Entity<StationBankAccountComponent?> ent,
|
|
|
|
|
int balanceAdded,
|
|
|
|
|
Dictionary<ProtoId<CargoAccountPrototype>, double> accountDistribution,
|
|
|
|
|
bool dirty = true)
|
2022-07-15 09:20:35 -04:00
|
|
|
{
|
2025-03-09 21:50:24 +01:00
|
|
|
if (!Resolve(ent, ref ent.Comp))
|
|
|
|
|
return;
|
|
|
|
|
|
2025-04-13 09:22:36 -04:00
|
|
|
foreach (var (account, percent) in accountDistribution)
|
|
|
|
|
{
|
|
|
|
|
var accountBalancedAdded = (int) Math.Round(percent * balanceAdded);
|
|
|
|
|
ent.Comp.Accounts[account] += accountBalancedAdded;
|
|
|
|
|
}
|
2023-05-31 11:13:02 +10:00
|
|
|
|
2025-04-13 09:22:36 -04:00
|
|
|
var ev = new BankBalanceUpdatedEvent(ent, ent.Comp.Accounts);
|
|
|
|
|
RaiseLocalEvent(ent, ref ev, true);
|
2025-03-09 21:50:24 +01:00
|
|
|
|
2025-04-13 09:22:36 -04:00
|
|
|
if (!dirty)
|
|
|
|
|
return;
|
2023-03-10 16:41:22 +11:00
|
|
|
|
2025-04-13 09:22:36 -04:00
|
|
|
Dirty(ent);
|
2022-07-15 09:20:35 -04:00
|
|
|
}
|
2022-02-15 15:01:45 +11:00
|
|
|
}
|