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,8 +1,6 @@
|
||||
using Content.Client.Cargo.UI;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.Cargo;
|
||||
using Content.Client.Cargo.UI;
|
||||
using Content.Shared.Cargo.BUI;
|
||||
using Content.Shared.Cargo.Components;
|
||||
using Content.Shared.Cargo.Events;
|
||||
using Content.Shared.Cargo.Prototypes;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
@@ -5,11 +5,8 @@ using Content.Shared.Cargo.Prototypes;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
using static Robust.Client.UserInterface.Controls.BaseButton;
|
||||
|
||||
namespace Content.Client.Cargo.UI
|
||||
|
||||
@@ -154,9 +154,8 @@ namespace Content.Server.Cargo.Systems
|
||||
return;
|
||||
}
|
||||
|
||||
order.Approved = true;
|
||||
_idCardSystem.TryFindIdCard(player, out var idCard);
|
||||
order.Approver = idCard?.FullName ?? string.Empty;
|
||||
order.SetApproverData(idCard);
|
||||
|
||||
|
||||
SoundSystem.Play(component.ConfirmSound.GetSound(), Filter.Pvs(uid, entityManager: EntityManager), uid);
|
||||
@@ -227,7 +226,7 @@ namespace Content.Server.Cargo.Systems
|
||||
|
||||
private CargoOrderData GetOrderData(CargoConsoleAddOrderMessage args, int index)
|
||||
{
|
||||
return new CargoOrderData(index, args.Requester, args.Reason, args.ProductId, args.Amount);
|
||||
return new CargoOrderData(index, args.ProductId, args.Amount, args.Requester, args.Reason);
|
||||
}
|
||||
|
||||
private int GetOrderCount(StationCargoOrderDatabaseComponent component)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Cargo.Components;
|
||||
using Content.Server.Labels.Components;
|
||||
using Content.Server.Paper;
|
||||
@@ -149,15 +148,16 @@ public sealed partial class CargoSystem
|
||||
_paperSystem.SetContent(printed, Loc.GetString(
|
||||
"cargo-console-paper-print-text",
|
||||
("orderNumber", data.OrderNumber),
|
||||
("itemName", prototype.Name),
|
||||
("requester", data.Requester),
|
||||
("reason", data.Reason),
|
||||
("approver", data.Approver)),
|
||||
("approver", data.Approver ?? string.Empty)),
|
||||
paper);
|
||||
|
||||
// attempt to attach the label
|
||||
if (TryComp<PaperLabelComponent>(product, out var label))
|
||||
{
|
||||
_slots.TryInsert(component.Owner, label.LabelSlot, printed, null);
|
||||
_slots.TryInsert(product, label.LabelSlot, printed, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,46 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
using Content.Shared.Access.Components;
|
||||
using System.Text;
|
||||
namespace Content.Shared.Cargo
|
||||
{
|
||||
[NetSerializable, Serializable]
|
||||
public sealed class CargoOrderData
|
||||
{
|
||||
public int OrderNumber;
|
||||
public string ProductId;
|
||||
public int Amount;
|
||||
public string Requester;
|
||||
// public String RequesterRank; // TODO Figure out how to get Character ID card data
|
||||
// public int RequesterId;
|
||||
public string Reason;
|
||||
public string ProductId;
|
||||
public int Amount;
|
||||
public bool Approved;
|
||||
public string Approver = string.Empty;
|
||||
public bool Approved => Approver is not null;
|
||||
public string? Approver;
|
||||
|
||||
public CargoOrderData(int orderNumber, string requester, string reason, string productId, int amount)
|
||||
public CargoOrderData(int orderNumber, string productId, int amount, string requester, string reason)
|
||||
{
|
||||
OrderNumber = orderNumber;
|
||||
Requester = requester;
|
||||
Reason = reason;
|
||||
ProductId = productId;
|
||||
Amount = amount;
|
||||
Requester = requester;
|
||||
Reason = reason;
|
||||
}
|
||||
|
||||
public void SetApproverData(IdCardComponent? idCard)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
if (!string.IsNullOrWhiteSpace(idCard?.FullName))
|
||||
{
|
||||
sb.Append($"{idCard.FullName} ");
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(idCard?.JobTitle))
|
||||
{
|
||||
sb.Append($"({idCard.JobTitle})");
|
||||
}
|
||||
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
Approver = sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ cargo-console-insufficient-funds = Insufficient funds (require {$cost})
|
||||
cargo-console-paper-print-name = Order #{$orderNumber}
|
||||
cargo-console-paper-print-text =
|
||||
Order #{$orderNumber}
|
||||
Item: {$itemName}
|
||||
Requested by: {$requester}
|
||||
Reason: {$reason}
|
||||
Approved by: {$approver}
|
||||
|
||||
Reference in New Issue
Block a user