Order manifests for shuttle orders. Now with item names and approver info. (#9464)
Co-authored-by: Kara <lunarautomaton6@gmail.com>
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Server.Cargo.Components;
|
||||
using Content.Server.GameTicking.Events;
|
||||
using Content.Server.Labels.Components;
|
||||
using Content.Server.Shuttles.Components;
|
||||
using Content.Server.Shuttles.Events;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Server.Paper;
|
||||
using Content.Shared.Cargo;
|
||||
using Content.Shared.Cargo.BUI;
|
||||
using Content.Shared.Cargo.Components;
|
||||
@@ -14,7 +15,7 @@ using Content.Shared.CCVar;
|
||||
using Content.Shared.Dataset;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
using Robust.Server.Maps;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Configuration;
|
||||
@@ -232,8 +233,7 @@ public sealed partial class CargoSystem
|
||||
|
||||
if (cappedAmount < order.Amount)
|
||||
{
|
||||
var reducedOrder = new CargoOrderData(order.OrderNumber, order.Requester, order.Reason, order.ProductId,
|
||||
cappedAmount);
|
||||
var reducedOrder = new CargoOrderData(order.OrderNumber, order.ProductId, cappedAmount, order.Requester, order.Reason);
|
||||
|
||||
orders.Add(reducedOrder);
|
||||
break;
|
||||
@@ -415,8 +415,10 @@ public sealed partial class CargoSystem
|
||||
{
|
||||
var order = orders[i];
|
||||
|
||||
Spawn(_protoMan.Index<CargoProductPrototype>(order.ProductId).Product,
|
||||
new EntityCoordinates(component.Owner, xformQuery.GetComponent(_random.PickAndTake(pads).Owner).LocalPosition));
|
||||
var coordinates = new EntityCoordinates(component.Owner, xformQuery.GetComponent(_random.PickAndTake(pads).Owner).LocalPosition);
|
||||
|
||||
var item = Spawn(_protoMan.Index<CargoProductPrototype>(order.ProductId).Product, coordinates);
|
||||
SpawnAndAttachOrderManifest(item, order, coordinates, component);
|
||||
order.Amount--;
|
||||
|
||||
if (order.Amount == 0)
|
||||
@@ -432,6 +434,41 @@ public sealed partial class CargoSystem
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// In this method we are printing and attaching order manifests to the orders.
|
||||
/// </summary>
|
||||
private void SpawnAndAttachOrderManifest(EntityUid item, CargoOrderData order, EntityCoordinates coordinates, CargoShuttleComponent component)
|
||||
{
|
||||
if (!_protoMan.TryIndex(order.ProductId, out CargoProductPrototype? prototype))
|
||||
return;
|
||||
|
||||
// spawn a piece of paper.
|
||||
var printed = EntityManager.SpawnEntity("Paper", coordinates);
|
||||
|
||||
if (!TryComp<PaperComponent>(printed, out var paper))
|
||||
return;
|
||||
|
||||
// fill in the order data
|
||||
var val = Loc.GetString("cargo-console-paper-print-name", ("orderNumber", order.OrderNumber));
|
||||
|
||||
MetaData(printed).EntityName = val;
|
||||
|
||||
_paperSystem.SetContent(printed, Loc.GetString(
|
||||
"cargo-console-paper-print-text",
|
||||
("orderNumber", order.OrderNumber),
|
||||
("itemName", prototype.Name),
|
||||
("requester", order.Requester),
|
||||
("reason", order.Reason),
|
||||
("approver", order.Approver ?? string.Empty)),
|
||||
paper);
|
||||
|
||||
// attempt to attach the label
|
||||
if (TryComp<PaperLabelComponent>(item, out var label))
|
||||
{
|
||||
_slots.TryInsert(item, label.LabelSlot, printed, null);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanRecallShuttle(EntityUid? uid, [NotNullWhen(false)] out string? reason, TransformComponent? xform = null)
|
||||
{
|
||||
reason = null;
|
||||
|
||||
Reference in New Issue
Block a user