* Fix merge conflicts with #4078 Check if the requested cargo order amount exceeds the maximum capacity Check if the maximum order capacity would be exceeded given current capcity and order amount when approved Cap maximum cargo request amount on client-side Play an error sound if a cargo order could not be added or approved * Add back error sound * Cargo orders over the maximum amount do not close the order UI
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Content.Client.UserInterface.Cargo;
|
using System;
|
||||||
|
using Content.Client.UserInterface.Cargo;
|
||||||
using Content.Shared.GameObjects.Components.Cargo;
|
using Content.Shared.GameObjects.Components.Cargo;
|
||||||
using Content.Shared.Prototypes.Cargo;
|
using Content.Shared.Prototypes.Cargo;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
@@ -83,8 +84,10 @@ namespace Content.Client.GameObjects.Components.Cargo
|
|||||||
_menu.OnOrderCanceled += RemoveOrder;
|
_menu.OnOrderCanceled += RemoveOrder;
|
||||||
_orderMenu.SubmitButton.OnPressed += (_) =>
|
_orderMenu.SubmitButton.OnPressed += (_) =>
|
||||||
{
|
{
|
||||||
AddOrder();
|
if (AddOrder())
|
||||||
_orderMenu.Close();
|
{
|
||||||
|
_orderMenu.Close();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_menu.OpenCentered();
|
_menu.OpenCentered();
|
||||||
@@ -131,13 +134,21 @@ namespace Content.Client.GameObjects.Components.Cargo
|
|||||||
_orderMenu?.Dispose();
|
_orderMenu?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddOrder()
|
private bool AddOrder()
|
||||||
{
|
{
|
||||||
|
int orderAmt = _orderMenu?.Amount.Value ?? 0;
|
||||||
|
if (orderAmt < 1 || orderAmt > ShuttleCapacity.MaxCapacity)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
SendMessage(new CargoConsoleAddOrderMessage(
|
SendMessage(new CargoConsoleAddOrderMessage(
|
||||||
_orderMenu?.Requester.Text ?? "",
|
_orderMenu?.Requester.Text ?? "",
|
||||||
_orderMenu?.Reason.Text ?? "",
|
_orderMenu?.Reason.Text ?? "",
|
||||||
_product?.ID ?? "",
|
_product?.ID ?? "",
|
||||||
_orderMenu?.Amount.Value ?? 0));
|
orderAmt));
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveOrder(ButtonEventArgs args)
|
private void RemoveOrder(ButtonEventArgs args)
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ using Content.Shared.GameObjects.Components.Cargo;
|
|||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
using Content.Shared.Prototypes.Cargo;
|
using Content.Shared.Prototypes.Cargo;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -110,7 +112,11 @@ namespace Content.Server.GameObjects.Components.Cargo
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_cargoConsoleSystem.AddOrder(orders.Database.Id, msg.Requester, msg.Reason, msg.ProductId, msg.Amount, _bankAccount.Id);
|
if (!_cargoConsoleSystem.AddOrder(orders.Database.Id, msg.Requester, msg.Reason, msg.ProductId,
|
||||||
|
msg.Amount, _bankAccount.Id))
|
||||||
|
{
|
||||||
|
SoundSystem.Play(Filter.Local(), "/Audio/Effects/error.ogg", Owner, AudioParams.Default);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CargoConsoleRemoveOrderMessage msg:
|
case CargoConsoleRemoveOrderMessage msg:
|
||||||
@@ -131,15 +137,17 @@ namespace Content.Server.GameObjects.Components.Cargo
|
|||||||
if (product == null!)
|
if (product == null!)
|
||||||
break;
|
break;
|
||||||
var capacity = _cargoConsoleSystem.GetCapacity(orders.Database.Id);
|
var capacity = _cargoConsoleSystem.GetCapacity(orders.Database.Id);
|
||||||
if (capacity.CurrentCapacity == capacity.MaxCapacity)
|
if (
|
||||||
|
capacity.CurrentCapacity == capacity.MaxCapacity
|
||||||
|
|| capacity.CurrentCapacity + order.Amount > capacity.MaxCapacity
|
||||||
|
|| !_cargoConsoleSystem.CheckBalance(_bankAccount.Id, (-product.PointCost) * order.Amount)
|
||||||
|
|| !_cargoConsoleSystem.ApproveOrder(orders.Database.Id, msg.OrderNumber)
|
||||||
|
|| !_cargoConsoleSystem.ChangeBalance(_bankAccount.Id, (-product.PointCost) * order.Amount)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SoundSystem.Play(Filter.Local(), "/Audio/Effects/error.ogg", Owner, AudioParams.Default);
|
||||||
break;
|
break;
|
||||||
if (!_cargoConsoleSystem.CheckBalance(_bankAccount.Id, (-product.PointCost) * order.Amount))
|
}
|
||||||
break;
|
|
||||||
if (!_cargoConsoleSystem.ApproveOrder(orders.Database.Id, msg.OrderNumber))
|
|
||||||
break;
|
|
||||||
if (!_cargoConsoleSystem.ChangeBalance(_bankAccount.Id, (-product.PointCost) * order.Amount))
|
|
||||||
break;
|
|
||||||
|
|
||||||
UpdateUIState();
|
UpdateUIState();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,8 +151,11 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
|
|
||||||
public bool AddOrder(int id, string requester, string reason, string productId, int amount, int payingAccountId)
|
public bool AddOrder(int id, string requester, string reason, string productId, int amount, int payingAccountId)
|
||||||
{
|
{
|
||||||
if (amount < 1 || !TryGetOrderDatabase(id, out var database))
|
if (amount < 1 || !TryGetOrderDatabase(id, out var database) || amount > database.MaxOrderSize)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
database.AddOrder(requester, reason, productId, amount, payingAccountId);
|
database.AddOrder(requester, reason, productId, amount, payingAccountId);
|
||||||
SyncComponentsWithId(id);
|
SyncComponentsWithId(id);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user