Files
Delta-v/Content.Shared/ParcelWrap/Systems/ParcelWrappingSystem.cs
T
a667530e18 Single item cargo orders are delivered in Parcel Wrap instead of crates (#40834)
* - rework a bunch of cargo orders to not send a crate with just one thing
  - instead sends the item, wrapped
- add ability for cargo orders to wrap the item ordered in parcel wrap
- cargo order name and descriptions are now localization strings, but still 99.99% of the time just get that info from the entity they're spawning
- small refactor to how cargo orders move around in cargo code so that the actual order proto is kept around longer
- small rework to certain restock cargo orders to halve the cost and number of items received in one order

* oop

* Suffering

* Arbitrary containers for cargo products

* I ran the tests locally and they passed, github please rerun :)

* massage Slarti's work into this.
Mainly by taking the API wrapping ability out back with the rifle q-q

* testfail fake

* wow `_applyingState` is useful, I wonder where I should've been using that in other PRs before :^)

* pr comments

* tfw the hook doesn't update the submodule

* Update Content.Client/Cargo/UI/CargoConsoleMenu.xaml.cs

Co-authored-by: āda <ss.adasts@gmail.com>

* PR comments

* fixies

* Update Content.Client/Cargo/UI/CargoConsoleMenu.xaml.cs

* Update Content.Shared/ParcelWrap/Systems/ParcelWrappingSystem.WrappedParcel.cs

* fix wrapped parcel entity name + audio

* Actually read PR comments

* Apply suggestions from code review

Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com>

---------

Co-authored-by: āda <ss.adasts@gmail.com>
Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com>
2026-06-29 12:44:06 +02:00

55 lines
2.2 KiB
C#

using Content.Shared.Charges.Systems;
using Content.Shared.DoAfter;
using Content.Shared.Item;
using Content.Shared.ParcelWrap.Components;
using Content.Shared.Popups;
using Content.Shared.Whitelist;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
namespace Content.Shared.ParcelWrap.Systems;
/// <summary>
/// This system handles things related to package wrap, both wrapping items to create parcels, and unwrapping existing
/// parcels.
/// </summary>
/// <seealso cref="ParcelWrapComponent"/>
/// <seealso cref="WrappedParcelComponent"/>
public sealed partial class ParcelWrappingSystem : EntitySystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedChargesSystem _charges = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly SharedItemSystem _item = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
/// <inheritdoc/>
public override void Initialize()
{
base.Initialize();
InitializeParcelWrap();
InitializeWrappedParcel();
}
/// <summary>
/// Returns whether or not <paramref name="wrapper"/> can be used to wrap <paramref name="target"/>.
/// </summary>
/// <param name="wrapper">The entity doing the wrapping.</param>
/// <param name="target">The entity to be wrapped.</param>
/// <returns>True if <paramref name="wrapper"/> can be used to wrap <paramref name="target"/>, false otherwise.</returns>
public bool IsWrappable(Entity<ParcelWrapComponent> wrapper, EntityUid target)
{
return
// Wrapping cannot wrap itself
wrapper.Owner != target &&
// Wrapper should never be empty, but may as well make sure.
!_charges.IsEmpty(wrapper.Owner) &&
_whitelist.CheckBoth(target, wrapper.Comp.Blacklist, wrapper.Comp.Whitelist);
}
}