Skip to content

Commit

Permalink
Merge branch 'master' into Oninew-horns
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian16199 authored Mar 28, 2024
2 parents 9b874ff + b432789 commit f3f1f68
Show file tree
Hide file tree
Showing 10 changed files with 901 additions and 274 deletions.
10 changes: 9 additions & 1 deletion Content.Server/Cargo/Components/CargoBountyLabelComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Content.Server.Cargo.Components;
using Content.Server.Station.Systems;

namespace Content.Server.Cargo.Components;

/// <summary>
/// This is used for marking containers as
Expand All @@ -17,4 +19,10 @@ public sealed partial class CargoBountyLabelComponent : Component
/// Used to prevent recursion in calculating the price.
/// </summary>
public bool Calculating;

/// <summary>
/// The Station System to check and remove bounties from
/// </summary>
[DataField]
public EntityUid? AssociatedStationId;
}
26 changes: 16 additions & 10 deletions Content.Server/Cargo/Systems/CargoSystem.Bounty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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;
Expand Down Expand Up @@ -65,16 +66,17 @@ private void OnPrintLabelMessage(EntityUid uid, CargoBountyConsoleComponent comp

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();
Expand Down Expand Up @@ -103,7 +105,7 @@ private void OnGetBountyPrice(EntityUid uid, CargoBountyLabelComponent component
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))
Expand Down Expand Up @@ -131,14 +133,18 @@ private void OnSold(ref EntitySoldEvent args)
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");
}
}
Expand Down Expand Up @@ -196,15 +202,15 @@ public void RerollBountyDatabase(Entity<StationCargoBountyDatabaseComponent?> en
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))
{
bountyEntities = new();
return false;
}

station ??= _station.GetOwningStation(container);
var station = component.AssociatedStationId;
if (station == null)
{
bountyEntities = new();
Expand All @@ -225,7 +231,7 @@ public bool IsBountyComplete(EntityUid container, CargoBountyData data)
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))
{
Expand Down Expand Up @@ -314,7 +320,7 @@ private HashSet<EntityUid> GetBountyEntities(EntityUid uid)
var children = GetBountyEntities(ent);
foreach (var child in children)
{
entities.Add(child);
entities.Add(child);
}
}
}
Expand Down
17 changes: 7 additions & 10 deletions Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,21 +254,18 @@ private int GetCargoSpace(EntityUid gridUid)

#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)
{
Expand Down Expand Up @@ -323,7 +320,7 @@ private bool CanSell(EntityUid uid, TransformComponent xform)
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;
Expand Down Expand Up @@ -356,7 +353,7 @@ private void OnPalletSale(EntityUid uid, CargoPalletConsoleComponent component,
return;
}

if (!SellPallets(gridUid, null, out var price))
if (!SellPallets(gridUid, out var price))
return;

var stackPrototype = _protoMan.Index<StackPrototype>(component.CashType);
Expand Down Expand Up @@ -448,4 +445,4 @@ private void SetupTradePost()
/// 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);
2 changes: 1 addition & 1 deletion Content.Server/Cargo/Systems/PriceGunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private void OnAfterInteract(EntityUid uid, PriceGunComponent component, AfterIn
return;

// Check if we're scanning a bounty crate
if (_bountySystem.IsBountyComplete(args.Target.Value, (EntityUid?) null, out _))
if (_bountySystem.IsBountyComplete(args.Target.Value, out _))
{
_popupSystem.PopupEntity(Loc.GetString("price-gun-bounty-complete"), args.User, args.User);
}
Expand Down
7 changes: 7 additions & 0 deletions Resources/Changelog/DeltaVChangelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1960,3 +1960,10 @@
id: 298
time: '2024-03-28T15:27:57.0000000+00:00'
url: https://github.com/DeltaV-Station/Delta-v/pull/1022
- author: FluffiestFloof
changes:
- message: Felinids, Harpies and Vulpkanin should now Weh accordingly.
type: Fix
id: 299
time: '2024-03-28T18:27:42.0000000+00:00'
url: https://github.com/DeltaV-Station/Delta-v/pull/992
16 changes: 8 additions & 8 deletions Resources/Locale/en-US/deltav/navmap-beacons/station-beacons.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ station-beacon-epistemics = Epistemics
station-beacon-mystagogue = Mystagogue
station-beacon-logistics = Logistics
station-beacon-logistics-reception = Logistics Reception
station-beacon-logistics-reception = Logistics
station-beacon-lo = LO
station-beacon-conference-room = Conference Room
station-beacon-virology = Virology
station-beacon-metempsychosis = Metempsychosis
station-beacon-exam = Exam Room
station-beacon-exam = Exam
station-beacon-med-outpost = Med Outpost
station-beacon-psych = Psychologist
station-beacon-psych = Psych
station-beacon-glimmer-prober = Glimmer Prober
station-beacon-forensic-mantis = Forensic Mantis
station-beacon-glimmer-prober = Prober
station-beacon-forensic-mantis = Mantis
station-beacon-mailroom = Mail
station-beacon-engi-outpost = Engi Outpost
station-beacon-janitor-office = Jani Office
station-beacon-janitor-closet = Jani closet
station-beacon-janitor-closet = Jani Closet
station-beacon-reporter = Reporter
station-beacon-camera-servers = Camera Servers
station-beacon-camera-servers = Cameras
station-beacon-boxing-ring = Boxing Ring
station-beacon-boxing-ring = Boxing
station-beacon-park = Park
station-beacon-corpsman = Corpsman
Loading

0 comments on commit f3f1f68

Please sign in to comment.