Files
wwdpublic/Content.Server/_EstacaoPirata/OpenTriggeredStorageFill/OpenTriggeredStorageFillSystem.cs
RadsammyT bb612d3ac7 [Port] Playing Cards (#1451)
# Description

This ports Playing Cards from:
Estacao Pirata...
Frontier...
and GoobStation...

More specifically, ports
https://github.com/Goob-Station/Goob-Station/pull/1215 and
https://github.com/Goob-Station/Goob-Station/pull/1311 sequentially.

In short...
 - Adds 3 skins of the playing cards: Nanotrasen, Syndicate, and Black.
- NT can be obtained as an item in your loadout but is locked behind a
command job.
 - Syndicate can be obtained as a pointless item in the uplink for 1 TC.
- Black can be obtained both as an item in your loadout and from the
Games Vendor.

---

# TODO before review

<!--
A list of everything you have to do before this PR is "complete"
You probably won't have to complete everything before merging but it's
good to leave future references
-->

- [X] De-namespace all of (_)EstacaoPirata? (not required, it is an EE
fork)
- [X] **_TO MAINTAINERS/CONTRIBS, NEED YOUR INPUT!!!_**: See
`Content.Client/Inventory/StrippableBoundUserInterface.cs:220`'s "DRAFT
TODO". Basically its me asking how to involve the thieving trait in the
omission of the playing cards in the strip menu. Currently, it does not
take into account the trait and simply obscures. (prolly dont take the
trait into account, obscure regardless)
- [X] Figure out what to do with the Nanotrasen deck variant: should it
remain free like the black deck or restricted like the syndicate? Locked
behind any command job? (prolly this)
- [X] Get media actually filled in

---

<!--
This is default collapsed, readers click to expand it and see all your
media
The PR media section can get very large at times, so this is a good way
to keep it clean
The title is written using HTML tags
The title must be within the <summary> tags or you won't see it
-->

<details><summary><h1>Media</h1></summary>
<p>

![image](https://github.com/user-attachments/assets/66c94a1d-4389-4a65-a547-c11c54efac42)

</p>
</details>

---

# Changelog

<!--
You can add an author after the `🆑` to change the name that appears
in the changelog (ex: `🆑 Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

🆑
- add: Playing Cards. You may get one in the Games Vendor or as an item
in your loadout.

---------

Co-authored-by: VMSolidus <evilexecutive@gmail.com>
(cherry picked from commit 9b5cce20f185d8da3cdddd2fa6cad14ccd38db77)
2025-01-29 20:10:09 +03:00

68 lines
2.5 KiB
C#

using Content.Server.Popups;
using Content.Server.Spawners.Components;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Item;
using Content.Shared.Localizations;
using Content.Shared.Prototypes;
using Content.Shared.Storage;
using Content.Shared.Storage.EntitySystems;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Server._EstacaoPirata.OpenTriggeredStorageFill;
/// <summary>
/// This handles...
/// </summary>
public sealed class OpenTriggeredStorageFillSystem : EntitySystem
{
[Dependency] private readonly SharedStorageSystem _storage = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<OpenTriggeredStorageFillComponent, ActivateInWorldEvent>(OnOpenEvent);
SubscribeLocalEvent<OpenTriggeredStorageFillComponent, ExaminedEvent>(OnExamineEvent);
}
private void OnExamineEvent(EntityUid uid, OpenTriggeredStorageFillComponent component, ExaminedEvent args)
{
args.PushText(Loc.GetString("container-sealed"));
}
//Yes, that's a copy of StorageSystem StorageFill method
private void OnOpenEvent(EntityUid uid, OpenTriggeredStorageFillComponent comp, ActivateInWorldEvent args)
{
Log.Debug($"Processing storage fill trigger for entity {ToPrettyString(uid)}");
var coordinates = Transform(uid).Coordinates;
var spawnItems = EntitySpawnCollection.GetSpawns(comp.Contents);
foreach (var item in spawnItems)
{
DebugTools.Assert(!_prototype.Index<EntityPrototype>(item)
.HasComponent(typeof(RandomSpawnerComponent)));
var ent = Spawn(item, coordinates);
if (!TryComp<ItemComponent>(ent, out var itemComp))
{
Log.Error($"Tried to fill {ToPrettyString(uid)} with non-item {item}.");
Del(ent);
continue;
}
if (!_storage.Insert(uid, ent, out var remainingEnt, out var reason, playSound: false))
{
Log.Error($"Failed to fill {ToPrettyString(uid)} with {ToPrettyString(ent)}. Reason: {reason}");
// Clean up the spawned entity if insertion fails
Del(ent);
}
}
_popup.PopupEntity(Loc.GetString("container-unsealed"), args.Target);
RemComp(uid, comp);
}
}