using Content.Server.Labels;
using Content.Server.NameIdentifier;
using Content.Server.Paper;
+using Content.Server.Station.Systems;
using Content.Shared.Cargo;
using Content.Shared.Cargo.Components;
using Content.Shared.Cargo.Prototypes;
var label = Spawn(component.BountyLabelId, Transform(uid).Coordinates);
component.NextPrintTime = _timing.CurTime + component.PrintDelay;
- SetupBountyLabel(label, bounty.Value);
+ SetupBountyLabel(label, station, bounty.Value);
_audio.PlayPvs(component.PrintSound, uid);
}
- public void SetupBountyLabel(EntityUid uid, CargoBountyData bounty, PaperComponent? paper = null, CargoBountyLabelComponent? label = null)
+ public void SetupBountyLabel(EntityUid uid, EntityUid stationId, CargoBountyData bounty, PaperComponent? paper = null, CargoBountyLabelComponent? label = null)
{
if (!Resolve(uid, ref paper, ref label) || !_protoMan.TryIndex<CargoBountyPrototype>(bounty.Bounty, out var prototype))
return;
label.Id = bounty.Id;
+ label.AssociatedStationId = stationId;
var msg = new FormattedMessage();
msg.AddText(Loc.GetString("bounty-manifest-header", ("id", bounty.Id)));
msg.PushNewline();
if (!_container.TryGetContainingContainer(uid, out var container) || container.ID != LabelSystem.ContainerName)
return;
- if (_station.GetOwningStation(uid) is not { } station || !TryComp<StationCargoBountyDatabaseComponent>(station, out var database))
+ if (component.AssociatedStationId is not { } station || !TryComp<StationCargoBountyDatabaseComponent>(station, out var database))
return;
if (database.CheckedBounties.Contains(component.Id))
if (!TryGetBountyLabel(sold, out _, out var component))
continue;
- if (!TryGetBountyFromId(args.Station, component.Id, out var bounty))
+ if (component.AssociatedStationId is not { } station || !TryGetBountyFromId(station, component.Id, out var bounty))
+ {
continue;
+ }
if (!IsBountyComplete(sold, bounty.Value))
+ {
continue;
+ }
- TryRemoveBounty(args.Station, bounty.Value);
- FillBountyDatabase(args.Station);
+ TryRemoveBounty(station, bounty.Value);
+ FillBountyDatabase(station);
_adminLogger.Add(LogType.Action, LogImpact.Low, $"Bounty \"{bounty.Value.Bounty}\" (id:{bounty.Value.Id}) was fulfilled");
}
}
FillBountyDatabase(entity);
}
- public bool IsBountyComplete(EntityUid container, EntityUid? station, out HashSet<EntityUid> bountyEntities)
+ public bool IsBountyComplete(EntityUid container, out HashSet<EntityUid> bountyEntities)
{
if (!TryGetBountyLabel(container, out _, out var component))
{
return false;
}
- station ??= _station.GetOwningStation(container);
+ var station = component.AssociatedStationId;
if (station == null)
{
bountyEntities = new();
return IsBountyComplete(container, data, out _);
}
- public bool IsBountyComplete(EntityUid container, CargoBountyData data, out HashSet<EntityUid> bountyEntities)
+ public bool IsBountyComplete(EntityUid container, CargoBountyData data, out HashSet<EntityUid> bountyEntities)
{
if (!_protoMan.TryIndex(data.Bounty, out var proto))
{
var children = GetBountyEntities(ent);
foreach (var child in children)
{
- entities.Add(child);
+ entities.Add(child);
}
}
}
#region Station
- private bool SellPallets(EntityUid gridUid, EntityUid? station, out double amount)
+ private bool SellPallets(EntityUid gridUid, out double amount)
{
- station ??= _station.GetOwningStation(gridUid);
GetPalletGoods(gridUid, out var toSell, out amount);
Log.Debug($"Cargo sold {toSell.Count} entities for {amount}");
if (toSell.Count == 0)
return false;
- if (station != null)
- {
- var ev = new EntitySoldEvent(station.Value, toSell);
- RaiseLocalEvent(ref ev);
- }
+
+ var ev = new EntitySoldEvent(toSell);
+ RaiseLocalEvent(ref ev);
foreach (var ent in toSell)
{
return false;
}
- var complete = IsBountyComplete(uid, (EntityUid?) null, out var bountyEntities);
+ var complete = IsBountyComplete(uid, out var bountyEntities);
// Recursively check for mobs at any point.
var children = xform.ChildEnumerator;
return;
}
- if (!SellPallets(gridUid, null, out var price))
+ if (!SellPallets(gridUid, out var price))
return;
var stackPrototype = _protoMan.Index<StackPrototype>(component.CashType);
/// deleted but after the price has been calculated.
/// </summary>
[ByRefEvent]
-public readonly record struct EntitySoldEvent(EntityUid Station, HashSet<EntityUid> Sold);
+public readonly record struct EntitySoldEvent(HashSet<EntityUid> Sold);