NanoTrasen might send Gifts to the station via Cargo (#16556)

* Rebase Cargo Gifts

* Remove Chaos values from gifts (for now)

* Translate CargoGifts, rename fields

* Fix gift errors, detect missing products

* Fix order Id, some crate IDs

* Fix get Station. Gifts for Sec, Med, Fire, spacing

* Minimum players for various gifts

# Conflicts:
#	Resources/Prototypes/GameRules/cargo_gifts.yml
This commit is contained in:
Tom Leys
2023-05-23 09:55:27 +12:00
committed by GitHub
parent d45e48b149
commit db81e59013
10 changed files with 514 additions and 6 deletions

View File

@@ -14,6 +14,7 @@ using Content.Shared.Cargo.Prototypes;
using Content.Shared.Database;
using Content.Shared.GameTicking;
using Content.Server.Paper;
using Content.Shared.Access.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Players;
@@ -243,7 +244,7 @@ namespace Content.Server.Cargo.Systems
return new CargoOrderData(id, args.ProductId, args.Amount, args.Requester, args.Reason);
}
private int GetOutstandingOrderCount(StationCargoOrderDatabaseComponent component)
public int GetOutstandingOrderCount(StationCargoOrderDatabaseComponent component)
{
var amount = 0;
@@ -285,7 +286,31 @@ namespace Content.Server.Cargo.Systems
}
}
public bool TryAddOrder(StationCargoOrderDatabaseComponent component, CargoOrderData data)
public bool AddAndApproveOrder(StationCargoOrderDatabaseComponent component, string productId, int qty, string sender, string description, string dest)
{
if (!_prototypeManager.HasIndex<CargoProductPrototype>(productId))
{
_sawmill.Warning($"CargoSystem.Orders could not find CargoProductPrototype for '{productId}' in {description}.");
// Pretend that it worked OK, since we don't want the caller to try again.
return true;
}
// Make an order
var id = GenerateOrderId(component);
var order = new CargoOrderData(id, productId, qty, sender, description);
// Approve it now
order.SetApproverData(new IdCardComponent(){FullName = dest, JobTitle = sender});
// Log order addition
_adminLogger.Add(LogType.Action, LogImpact.Low,
$"AddAndApproveOrder {description} added order [orderId:{order.OrderId}, quantity:{order.OrderQuantity}, product:{order.ProductId}, requester:{order.Requester}, reason:{order.Reason}]");
// Add it to the list
return TryAddOrder(component, order);
}
private bool TryAddOrder(StationCargoOrderDatabaseComponent component, CargoOrderData data)
{
component.Orders.Add(data);
UpdateOrders(component);
@@ -294,7 +319,7 @@ namespace Content.Server.Cargo.Systems
private int GenerateOrderId(StationCargoOrderDatabaseComponent orderDB)
{
// We need an arbitrary unique ID to idenitfy orders, since they may
// We need an arbitrary unique ID to identify orders, since they may
// want to be cancelled later.
return ++orderDB.NumOrdersCreated;
}