expedition rewards (#16972)
Co-authored-by: deltanedas <@deltanedas:kde.org> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -18,6 +18,8 @@ using Content.Shared.Access.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Cargo.Systems
|
||||
{
|
||||
@@ -33,14 +35,6 @@ namespace Content.Server.Cargo.Systems
|
||||
/// </summary>
|
||||
private float _timer;
|
||||
|
||||
[Dependency] private readonly IdCardSystem _idCardSystem = default!;
|
||||
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
|
||||
[Dependency] private readonly DeviceLinkSystem _linker = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly StationSystem _station = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
|
||||
private void InitializeConsole()
|
||||
{
|
||||
SubscribeLocalEvent<CargoOrderConsoleComponent, CargoConsoleAddOrderMessage>(OnAddOrderMessage);
|
||||
@@ -72,6 +66,8 @@ namespace Content.Server.Cargo.Systems
|
||||
{
|
||||
_timer += frameTime;
|
||||
|
||||
// TODO: Doesn't work with serialization and shouldn't just be updating every delay
|
||||
// client can just interp this just fine on its own.
|
||||
while (_timer > Delay)
|
||||
{
|
||||
_timer -= Delay;
|
||||
@@ -124,7 +120,7 @@ namespace Content.Server.Cargo.Systems
|
||||
}
|
||||
|
||||
// Invalid order
|
||||
if (!_protoMan.TryIndex<CargoProductPrototype>(order.ProductId, out var product))
|
||||
if (!_protoMan.HasIndex<EntityPrototype>(order.ProductId))
|
||||
{
|
||||
ConsolePopup(args.Session, Loc.GetString("cargo-console-invalid-product"));
|
||||
PlayDenySound(uid, component);
|
||||
@@ -152,7 +148,7 @@ namespace Content.Server.Cargo.Systems
|
||||
PlayDenySound(uid, component);
|
||||
}
|
||||
|
||||
var cost = product.PointCost * order.OrderQuantity;
|
||||
var cost = order.Price * order.OrderQuantity;
|
||||
|
||||
// Not enough balance
|
||||
if (cost > bankAccount.Balance)
|
||||
@@ -163,7 +159,7 @@ namespace Content.Server.Cargo.Systems
|
||||
}
|
||||
|
||||
_idCardSystem.TryFindIdCard(player, out var idCard);
|
||||
order.SetApproverData(idCard);
|
||||
order.SetApproverData(idCard?.FullName, idCard?.JobTitle);
|
||||
_audio.PlayPvs(_audio.GetSound(component.ConfirmSound), uid);
|
||||
|
||||
// Log order approval
|
||||
@@ -190,11 +186,20 @@ namespace Content.Server.Cargo.Systems
|
||||
return;
|
||||
|
||||
var bank = GetBankAccount(component);
|
||||
if (bank == null) return;
|
||||
var orderDatabase = GetOrderDatabase(component);
|
||||
if (orderDatabase == null) return;
|
||||
if (bank == null)
|
||||
return;
|
||||
|
||||
var data = GetOrderData(args, GenerateOrderId(orderDatabase));
|
||||
var orderDatabase = GetOrderDatabase(component);
|
||||
if (orderDatabase == null)
|
||||
return;
|
||||
|
||||
if (!_protoMan.TryIndex<CargoProductPrototype>(args.CargoProductId, out var product))
|
||||
{
|
||||
_sawmill.Error($"Tried to add invalid cargo product {args.CargoProductId} as order!");
|
||||
return;
|
||||
}
|
||||
|
||||
var data = GetOrderData(args, product, GenerateOrderId(orderDatabase));
|
||||
|
||||
if (!TryAddOrder(orderDatabase, data))
|
||||
{
|
||||
@@ -239,9 +244,9 @@ namespace Content.Server.Cargo.Systems
|
||||
_audio.PlayPvs(_audio.GetSound(component.ErrorSound), uid);
|
||||
}
|
||||
|
||||
private CargoOrderData GetOrderData(CargoConsoleAddOrderMessage args, int id)
|
||||
private CargoOrderData GetOrderData(CargoConsoleAddOrderMessage args, CargoProductPrototype cargoProduct, int id)
|
||||
{
|
||||
return new CargoOrderData(id, args.ProductId, args.Amount, args.Requester, args.Reason);
|
||||
return new CargoOrderData(id, cargoProduct.Product, cargoProduct.PointCost, args.Amount, args.Requester, args.Reason);
|
||||
}
|
||||
|
||||
public int GetOutstandingOrderCount(StationCargoOrderDatabaseComponent component)
|
||||
@@ -286,21 +291,15 @@ namespace Content.Server.Cargo.Systems
|
||||
}
|
||||
}
|
||||
|
||||
public bool AddAndApproveOrder(StationCargoOrderDatabaseComponent component, string productId, int qty, string sender, string description, string dest)
|
||||
public bool AddAndApproveOrder(StationCargoOrderDatabaseComponent component, string spawnId, int cost, 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;
|
||||
}
|
||||
|
||||
DebugTools.Assert(_protoMan.HasIndex<EntityPrototype>(spawnId));
|
||||
// Make an order
|
||||
var id = GenerateOrderId(component);
|
||||
var order = new CargoOrderData(id, productId, qty, sender, description);
|
||||
var order = new CargoOrderData(id, spawnId, cost, qty, sender, description);
|
||||
|
||||
// Approve it now
|
||||
order.SetApproverData(new IdCardComponent(){FullName = dest, JobTitle = sender});
|
||||
order.SetApproverData(dest, sender);
|
||||
|
||||
// Log order addition
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Low,
|
||||
@@ -368,7 +367,7 @@ namespace Content.Server.Cargo.Systems
|
||||
if (PopFrontOrder(orderDB, out var order))
|
||||
{
|
||||
// Create the item itself
|
||||
var item = Spawn(_protoMan.Index<CargoProductPrototype>(order.ProductId).Product, whereToPutIt);
|
||||
var item = Spawn(order.ProductId, whereToPutIt);
|
||||
|
||||
// Create a sheet of paper to write the order details on
|
||||
var printed = EntityManager.SpawnEntity(paperPrototypeToPrint, whereToPutIt);
|
||||
|
||||
@@ -29,15 +29,6 @@ public sealed partial class CargoSystem
|
||||
* Handles cargo shuttle mechanics.
|
||||
*/
|
||||
|
||||
[Dependency] private readonly IComponentFactory _factory = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||
[Dependency] private readonly PricingSystem _pricing = default!;
|
||||
[Dependency] private readonly ShuttleConsoleSystem _console = default!;
|
||||
[Dependency] private readonly StackSystem _stack = default!;
|
||||
public MapId? CargoMap { get; private set; }
|
||||
|
||||
private void InitializeShuttle()
|
||||
@@ -191,7 +182,7 @@ public sealed partial class CargoSystem
|
||||
// We won't be able to fit the whole order on, so make one
|
||||
// which represents the space we do have left:
|
||||
var reducedOrder = new CargoOrderData(order.OrderId,
|
||||
order.ProductId, spaceRemaining, order.Requester, order.Reason);
|
||||
order.ProductId, order.Price, spaceRemaining, order.Requester, order.Reason);
|
||||
orders.Add(reducedOrder);
|
||||
}
|
||||
else
|
||||
@@ -335,7 +326,7 @@ public sealed partial class CargoSystem
|
||||
}
|
||||
|
||||
SellPallets(gridUid, out var price);
|
||||
var stackPrototype = _prototypeManager.Index<StackPrototype>(component.CashType);
|
||||
var stackPrototype = _protoMan.Index<StackPrototype>(component.CashType);
|
||||
_stack.Spawn((int)price, stackPrototype, uid.ToCoordinates());
|
||||
UpdatePalletConsoleInterface(uid);
|
||||
}
|
||||
|
||||
@@ -12,9 +12,6 @@ namespace Content.Server.Cargo.Systems;
|
||||
|
||||
public sealed partial class CargoSystem
|
||||
{
|
||||
[Dependency] private readonly PaperSystem _paperSystem = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
|
||||
private void InitializeTelepad()
|
||||
{
|
||||
SubscribeLocalEvent<CargoTelepadComponent, ComponentInit>(OnInit);
|
||||
|
||||
@@ -1,17 +1,46 @@
|
||||
using Content.Server.Access.Systems;
|
||||
using Content.Server.Cargo.Components;
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
using Content.Server.Paper;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Shuttles.Systems;
|
||||
using Content.Server.Stack;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Cargo;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Cargo.Systems;
|
||||
|
||||
public sealed partial class CargoSystem : SharedCargoSystem
|
||||
{
|
||||
[Dependency] private readonly IComponentFactory _factory = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
|
||||
[Dependency] private readonly DeviceLinkSystem _linker = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||
[Dependency] private readonly IdCardSystem _idCardSystem = default!;
|
||||
[Dependency] private readonly ItemSlotsSystem _slots = default!;
|
||||
[Dependency] private readonly PaperSystem _paperSystem = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly PricingSystem _pricing = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly ShuttleConsoleSystem _console = default!;
|
||||
[Dependency] private readonly StackSystem _stack = default!;
|
||||
[Dependency] private readonly StationSystem _station = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||
|
||||
private ISawmill _sawmill = default!;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user