mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 05:59:03 +03:00
# Description Showing some love to our hard-working couriers. This cherry-picks the following PRs from delta-v: - https://github.com/DeltaV-Station/Delta-v/pull/1472 - Adds a MailMetrics PDA cartridge for couriers and the LO - https://github.com/DeltaV-Station/Delta-v/pull/1652 - Ports mail tweaks from frontier to delta-v, adding large packages, RPDs (mail cannons), and more mail - https://github.com/DeltaV-Station/Delta-v/pull/1788 - Adding a couple more packages - https://github.com/DeltaV-Station/Delta-v/pull/1925 - Fixing the non-functional "last known location" part of mail descriptions Some mail items, such as the opporozidone syringe and rainbow joints/blunts, had to be disabled because we don't have them (yet?) <details><summary><h1>Media</h1></summary> <p>       </p> </details> --- # Changelog 🆑 - add: The Courier and Logistics Officer now have a new program in their PDA for tracking mail delivery performance, including earnings and percent of packages opened, damaged, or expired. - add: The list of possible mail packages has been greately expanded, and now includes large parcels. - add: The CourierDrobe now offers a rapid mail delivery device, along with capsules for it. --------- Signed-off-by: Adeinitas <147965189+adeinitas@users.noreply.github.com> Co-authored-by: portfiend <109661617+portfiend@users.noreply.github.com> Co-authored-by: byte <50130120+huckleton@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: Adeinitas <147965189+adeinitas@users.noreply.github.com> Co-authored-by: ErhardSteinhauer <65374927+ErhardSteinhauer@users.noreply.github.com> Co-authored-by: Dvir <dvirf01@gmail.com> Co-authored-by: Dvir <39403717+dvir001@users.noreply.github.com> Co-authored-by: Whatstone <166147148+whatston3@users.noreply.github.com> Co-authored-by: Whatstone <whatstone3@gmail.com> Co-authored-by: Danger Revolution! <142105406+DangerRevolution@users.noreply.github.com> Co-authored-by: Milon <plmilonpl@gmail.com> # Conflicts: # Resources/Prototypes/Entities/Objects/Weapons/Guns/Launchers/launchers.yml
83 lines
2.7 KiB
C#
83 lines
2.7 KiB
C#
using Content.Server.Cargo.Components;
|
|
using Content.Server.Cargo.Systems;
|
|
using Content.Server.Mail.Components;
|
|
using Content.Server.Station.Systems;
|
|
using Content.Shared.CartridgeLoader;
|
|
using Content.Shared.CartridgeLoader.Cartridges;
|
|
|
|
namespace Content.Server.CartridgeLoader.Cartridges;
|
|
|
|
public sealed class MailMetricsCartridgeSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly CartridgeLoaderSystem _cartridgeLoader = default!;
|
|
[Dependency] private readonly StationSystem _station = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<MailMetricsCartridgeComponent, CartridgeUiReadyEvent>(OnUiReady);
|
|
SubscribeLocalEvent<LogisticStatsUpdatedEvent>(OnLogisticsStatsUpdated);
|
|
SubscribeLocalEvent<MailComponent, MapInitEvent>(OnMapInit);
|
|
}
|
|
|
|
private void OnUiReady(Entity<MailMetricsCartridgeComponent> ent, ref CartridgeUiReadyEvent args)
|
|
{
|
|
UpdateUI(ent, args.Loader);
|
|
}
|
|
|
|
private void OnLogisticsStatsUpdated(LogisticStatsUpdatedEvent args)
|
|
{
|
|
UpdateAllCartridges(args.Station);
|
|
}
|
|
|
|
private void OnMapInit(EntityUid uid, MailComponent mail, MapInitEvent args)
|
|
{
|
|
if (_station.GetOwningStation(uid) is { } station)
|
|
UpdateAllCartridges(station);
|
|
}
|
|
|
|
private void UpdateAllCartridges(EntityUid station)
|
|
{
|
|
var query = EntityQueryEnumerator<MailMetricsCartridgeComponent, CartridgeComponent>();
|
|
while (query.MoveNext(out var uid, out var comp, out var cartridge))
|
|
{
|
|
if (cartridge.LoaderUid is not { } loader || comp.Station != station)
|
|
continue;
|
|
UpdateUI((uid, comp), loader);
|
|
}
|
|
}
|
|
|
|
private void UpdateUI(Entity<MailMetricsCartridgeComponent> ent, EntityUid loader)
|
|
{
|
|
if (_station.GetOwningStation(loader) is { } station)
|
|
ent.Comp.Station = station;
|
|
|
|
if (!TryComp<StationLogisticStatsComponent>(ent.Comp.Station, out var logiStats))
|
|
return;
|
|
|
|
// Get station's logistic stats
|
|
var unopenedMailCount = GetUnopenedMailCount(ent.Comp.Station);
|
|
|
|
// Send logistic stats to cartridge client
|
|
var state = new MailMetricUiState(logiStats.Metrics, unopenedMailCount);
|
|
_cartridgeLoader.UpdateCartridgeUiState(loader, state);
|
|
}
|
|
|
|
|
|
private int GetUnopenedMailCount(EntityUid? station)
|
|
{
|
|
var unopenedMail = 0;
|
|
|
|
var query = EntityQueryEnumerator<MailComponent>();
|
|
|
|
while (query.MoveNext(out var uid, out var comp))
|
|
{
|
|
if (comp.IsLocked && _station.GetOwningStation(uid) == station)
|
|
unopenedMail++;
|
|
}
|
|
|
|
return unopenedMail;
|
|
}
|
|
}
|