Cleaner BoundUserInterfaces (#17736)
This commit is contained in:
@@ -1,12 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Access.Systems;
|
||||
using Content.Server.Cargo.Components;
|
||||
using Content.Server.Labels.Components;
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Cargo;
|
||||
using Content.Shared.Cargo.BUI;
|
||||
using Content.Shared.Cargo.Events;
|
||||
@@ -14,7 +8,6 @@ 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;
|
||||
@@ -49,7 +42,7 @@ namespace Content.Server.Cargo.Systems
|
||||
private void OnInit(EntityUid uid, CargoOrderConsoleComponent orderConsole, ComponentInit args)
|
||||
{
|
||||
var station = _station.GetOwningStation(uid);
|
||||
UpdateOrderState(orderConsole, station);
|
||||
UpdateOrderState(uid, station);
|
||||
}
|
||||
|
||||
private void Reset(RoundRestartCleanupEvent ev)
|
||||
@@ -77,12 +70,13 @@ namespace Content.Server.Cargo.Systems
|
||||
account.Balance += account.IncreasePerSecond * Delay;
|
||||
}
|
||||
|
||||
foreach (var comp in EntityQuery<CargoOrderConsoleComponent>())
|
||||
var query = EntityQueryEnumerator<CargoOrderConsoleComponent>();
|
||||
while (query.MoveNext(out var uid, out var _))
|
||||
{
|
||||
if (!_uiSystem.IsUiOpen(comp.Owner, CargoConsoleUiKey.Orders)) continue;
|
||||
if (!_uiSystem.IsUiOpen(uid, CargoConsoleUiKey.Orders)) continue;
|
||||
|
||||
var station = _station.GetOwningStation(comp.Owner);
|
||||
UpdateOrderState(comp, station);
|
||||
var station = _station.GetOwningStation(uid);
|
||||
UpdateOrderState(uid, station);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,7 +85,7 @@ namespace Content.Server.Cargo.Systems
|
||||
|
||||
private void OnApproveOrderMessage(EntityUid uid, CargoOrderConsoleComponent component, CargoConsoleApproveOrderMessage args)
|
||||
{
|
||||
if (args.Session.AttachedEntity is not {Valid: true} player)
|
||||
if (args.Session.AttachedEntity is not { Valid: true } player)
|
||||
return;
|
||||
|
||||
if (!_accessReaderSystem.IsAllowed(player, uid))
|
||||
@@ -101,11 +95,10 @@ namespace Content.Server.Cargo.Systems
|
||||
return;
|
||||
}
|
||||
|
||||
var orderDatabase = GetOrderDatabase(component);
|
||||
var bankAccount = GetBankAccount(component);
|
||||
var bankAccount = GetBankAccount(uid, component);
|
||||
|
||||
// No station to deduct from.
|
||||
if (orderDatabase == null || bankAccount == null)
|
||||
if (!TryGetOrderDatabase(uid, out var dbUid, out var orderDatabase, component) || bankAccount == null)
|
||||
{
|
||||
ConsolePopup(args.Session, Loc.GetString("cargo-console-station-not-found"));
|
||||
PlayDenySound(uid, component);
|
||||
@@ -113,8 +106,8 @@ namespace Content.Server.Cargo.Systems
|
||||
}
|
||||
|
||||
// Find our order again. It might have been dispatched or approved already
|
||||
var order = orderDatabase.Orders.Find(order => (args.OrderId == order.OrderId) && !order.Approved);
|
||||
if(order == null)
|
||||
var order = orderDatabase.Orders.Find(order => args.OrderId == order.OrderId && !order.Approved);
|
||||
if (order == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -167,30 +160,30 @@ namespace Content.Server.Cargo.Systems
|
||||
$"{ToPrettyString(player):user} approved order [orderId:{order.OrderId}, quantity:{order.OrderQuantity}, product:{order.ProductId}, requester:{order.Requester}, reason:{order.Reason}] with balance at {bankAccount.Balance}");
|
||||
|
||||
DeductFunds(bankAccount, cost);
|
||||
UpdateOrders(orderDatabase);
|
||||
UpdateOrders(dbUid!.Value, orderDatabase);
|
||||
}
|
||||
|
||||
private void OnRemoveOrderMessage(EntityUid uid, CargoOrderConsoleComponent component, CargoConsoleRemoveOrderMessage args)
|
||||
{
|
||||
var orderDatabase = GetOrderDatabase(component);
|
||||
if (orderDatabase == null) return;
|
||||
RemoveOrder(orderDatabase, args.OrderId);
|
||||
if (!TryGetOrderDatabase(uid, out var dbUid, out var orderDatabase, component))
|
||||
return;
|
||||
|
||||
RemoveOrder(dbUid!.Value, args.OrderId, orderDatabase);
|
||||
}
|
||||
|
||||
private void OnAddOrderMessage(EntityUid uid, CargoOrderConsoleComponent component, CargoConsoleAddOrderMessage args)
|
||||
{
|
||||
if (args.Session.AttachedEntity is not {Valid: true} player)
|
||||
if (args.Session.AttachedEntity is not { Valid: true } player)
|
||||
return;
|
||||
|
||||
if (args.Amount <= 0)
|
||||
return;
|
||||
|
||||
var bank = GetBankAccount(component);
|
||||
var bank = GetBankAccount(uid, component);
|
||||
if (bank == null)
|
||||
return;
|
||||
|
||||
var orderDatabase = GetOrderDatabase(component);
|
||||
if (orderDatabase == null)
|
||||
if (!TryGetOrderDatabase(uid, out var dbUid, out var orderDatabase, component))
|
||||
return;
|
||||
|
||||
if (!_protoMan.TryIndex<CargoProductPrototype>(args.CargoProductId, out var product))
|
||||
@@ -201,7 +194,7 @@ namespace Content.Server.Cargo.Systems
|
||||
|
||||
var data = GetOrderData(args, product, GenerateOrderId(orderDatabase));
|
||||
|
||||
if (!TryAddOrder(orderDatabase, data))
|
||||
if (!TryAddOrder(dbUid!.Value, data, orderDatabase))
|
||||
{
|
||||
PlayDenySound(uid, component);
|
||||
return;
|
||||
@@ -216,46 +209,50 @@ namespace Content.Server.Cargo.Systems
|
||||
private void OnOrderUIOpened(EntityUid uid, CargoOrderConsoleComponent component, BoundUIOpenedEvent args)
|
||||
{
|
||||
var station = _station.GetOwningStation(uid);
|
||||
UpdateOrderState(component, station);
|
||||
UpdateOrderState(uid, station);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void UpdateOrderState(CargoOrderConsoleComponent component, EntityUid? station)
|
||||
private void UpdateOrderState(EntityUid consoleUid, EntityUid? station)
|
||||
{
|
||||
if (station == null ||
|
||||
!TryComp<StationCargoOrderDatabaseComponent>(station, out var orderDatabase) ||
|
||||
!TryComp<StationBankAccountComponent>(station, out var bankAccount)) return;
|
||||
|
||||
var state = new CargoConsoleInterfaceState(
|
||||
MetaData(station.Value).EntityName,
|
||||
GetOutstandingOrderCount(orderDatabase),
|
||||
orderDatabase.Capacity,
|
||||
bankAccount.Balance,
|
||||
orderDatabase.Orders);
|
||||
|
||||
_uiSystem.GetUiOrNull(component.Owner, CargoConsoleUiKey.Orders)?.SetState(state);
|
||||
if (_uiSystem.TryGetUi(consoleUid, CargoConsoleUiKey.Orders, out var bui))
|
||||
UserInterfaceSystem.SetUiState(bui, new CargoConsoleInterfaceState(
|
||||
MetaData(station.Value).EntityName,
|
||||
GetOutstandingOrderCount(orderDatabase),
|
||||
orderDatabase.Capacity,
|
||||
bankAccount.Balance,
|
||||
orderDatabase.Orders
|
||||
));
|
||||
}
|
||||
|
||||
private void ConsolePopup(ICommonSession session, string text) => _popup.PopupCursor(text, session);
|
||||
private void ConsolePopup(ICommonSession session, string text)
|
||||
{
|
||||
_popup.PopupCursor(text, session);
|
||||
}
|
||||
|
||||
private void PlayDenySound(EntityUid uid, CargoOrderConsoleComponent component)
|
||||
{
|
||||
_audio.PlayPvs(_audio.GetSound(component.ErrorSound), uid);
|
||||
}
|
||||
|
||||
private CargoOrderData GetOrderData(CargoConsoleAddOrderMessage args, CargoProductPrototype cargoProduct, int id)
|
||||
private static CargoOrderData GetOrderData(CargoConsoleAddOrderMessage args, CargoProductPrototype cargoProduct, int id)
|
||||
{
|
||||
return new CargoOrderData(id, cargoProduct.Product, cargoProduct.PointCost, args.Amount, args.Requester, args.Reason);
|
||||
}
|
||||
|
||||
public int GetOutstandingOrderCount(StationCargoOrderDatabaseComponent component)
|
||||
public static int GetOutstandingOrderCount(StationCargoOrderDatabaseComponent component)
|
||||
{
|
||||
var amount = 0;
|
||||
|
||||
foreach (var order in component.Orders)
|
||||
{
|
||||
if (!order.Approved) continue;
|
||||
if (!order.Approved)
|
||||
continue;
|
||||
amount += order.OrderQuantity - order.NumDispatched;
|
||||
}
|
||||
|
||||
@@ -266,32 +263,41 @@ namespace Content.Server.Cargo.Systems
|
||||
/// Updates all of the cargo-related consoles for a particular station.
|
||||
/// This should be called whenever orders change.
|
||||
/// </summary>
|
||||
private void UpdateOrders(StationCargoOrderDatabaseComponent component)
|
||||
private void UpdateOrders(EntityUid dbUid, StationCargoOrderDatabaseComponent _)
|
||||
{
|
||||
// Order added so all consoles need updating.
|
||||
var orderQuery = AllEntityQuery<CargoOrderConsoleComponent>();
|
||||
|
||||
while (orderQuery.MoveNext(out var uid, out var comp))
|
||||
while (orderQuery.MoveNext(out var uid, out var _))
|
||||
{
|
||||
var station = _station.GetOwningStation(uid);
|
||||
if (station != component.Owner)
|
||||
if (station != dbUid)
|
||||
continue;
|
||||
|
||||
UpdateOrderState(comp, station);
|
||||
UpdateOrderState(uid, station);
|
||||
}
|
||||
|
||||
var consoleQuery = AllEntityQuery<CargoShuttleConsoleComponent>();
|
||||
while (consoleQuery.MoveNext(out var uid, out var comp))
|
||||
while (consoleQuery.MoveNext(out var uid, out var _))
|
||||
{
|
||||
var station = _station.GetOwningStation(uid);
|
||||
if (station != component.Owner)
|
||||
if (station != dbUid)
|
||||
continue;
|
||||
|
||||
UpdateShuttleState(uid, station);
|
||||
}
|
||||
}
|
||||
|
||||
public bool AddAndApproveOrder(StationCargoOrderDatabaseComponent component, string spawnId, int cost, int qty, string sender, string description, string dest)
|
||||
public bool AddAndApproveOrder(
|
||||
EntityUid dbUid,
|
||||
string spawnId,
|
||||
int cost,
|
||||
int qty,
|
||||
string sender,
|
||||
string description,
|
||||
string dest,
|
||||
StationCargoOrderDatabaseComponent component
|
||||
)
|
||||
{
|
||||
DebugTools.Assert(_protoMan.HasIndex<EntityPrototype>(spawnId));
|
||||
// Make an order
|
||||
@@ -306,31 +312,31 @@ namespace Content.Server.Cargo.Systems
|
||||
$"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);
|
||||
return TryAddOrder(dbUid, order, component);
|
||||
}
|
||||
|
||||
private bool TryAddOrder(StationCargoOrderDatabaseComponent component, CargoOrderData data)
|
||||
private bool TryAddOrder(EntityUid dbUid, CargoOrderData data, StationCargoOrderDatabaseComponent component)
|
||||
{
|
||||
component.Orders.Add(data);
|
||||
UpdateOrders(component);
|
||||
UpdateOrders(dbUid, component);
|
||||
return true;
|
||||
}
|
||||
|
||||
private int GenerateOrderId(StationCargoOrderDatabaseComponent orderDB)
|
||||
private static int GenerateOrderId(StationCargoOrderDatabaseComponent orderDB)
|
||||
{
|
||||
// We need an arbitrary unique ID to identify orders, since they may
|
||||
// want to be cancelled later.
|
||||
return ++orderDB.NumOrdersCreated;
|
||||
}
|
||||
|
||||
public void RemoveOrder(StationCargoOrderDatabaseComponent orderDB, int index)
|
||||
public void RemoveOrder(EntityUid dbUid, int index, StationCargoOrderDatabaseComponent orderDB)
|
||||
{
|
||||
var sequenceIdx = orderDB.Orders.FindIndex(order => order.OrderId == index);
|
||||
if (sequenceIdx != -1)
|
||||
{
|
||||
orderDB.Orders.RemoveAt(sequenceIdx);
|
||||
}
|
||||
UpdateOrders(orderDB);
|
||||
UpdateOrders(dbUid, orderDB);
|
||||
}
|
||||
|
||||
public void ClearOrders(StationCargoOrderDatabaseComponent component)
|
||||
@@ -341,7 +347,7 @@ namespace Content.Server.Cargo.Systems
|
||||
Dirty(component);
|
||||
}
|
||||
|
||||
private bool PopFrontOrder(StationCargoOrderDatabaseComponent orderDB, [NotNullWhen(true)] out CargoOrderData? orderOut)
|
||||
private static bool PopFrontOrder(StationCargoOrderDatabaseComponent orderDB, [NotNullWhen(true)] out CargoOrderData? orderOut)
|
||||
{
|
||||
var orderIdx = orderDB.Orders.FindIndex(order => order.Approved);
|
||||
if (orderIdx == -1)
|
||||
@@ -353,7 +359,7 @@ namespace Content.Server.Cargo.Systems
|
||||
orderOut = orderDB.Orders[orderIdx];
|
||||
orderOut.NumDispatched++;
|
||||
|
||||
if(orderOut.NumDispatched >= orderOut.OrderQuantity)
|
||||
if (orderOut.NumDispatched >= orderOut.OrderQuantity)
|
||||
{
|
||||
// Order is complete. Remove from the queue.
|
||||
orderDB.Orders.RemoveAt(orderIdx);
|
||||
@@ -375,7 +381,7 @@ namespace Content.Server.Cargo.Systems
|
||||
{
|
||||
// fill in the order data
|
||||
var val = Loc.GetString("cargo-console-paper-print-name", ("orderNumber", order.OrderId));
|
||||
MetaData(printed).EntityName = val;
|
||||
_metaSystem.SetEntityName(printed, val);
|
||||
|
||||
_paperSystem.SetContent(printed, Loc.GetString(
|
||||
"cargo-console-paper-print-text",
|
||||
@@ -407,20 +413,18 @@ namespace Content.Server.Cargo.Systems
|
||||
|
||||
#region Station
|
||||
|
||||
private StationBankAccountComponent? GetBankAccount(CargoOrderConsoleComponent component)
|
||||
private StationBankAccountComponent? GetBankAccount(EntityUid uid, CargoOrderConsoleComponent _)
|
||||
{
|
||||
var station = _station.GetOwningStation(component.Owner);
|
||||
var station = _station.GetOwningStation(uid);
|
||||
|
||||
TryComp<StationBankAccountComponent>(station, out var bankComponent);
|
||||
return bankComponent;
|
||||
}
|
||||
|
||||
private StationCargoOrderDatabaseComponent? GetOrderDatabase(CargoOrderConsoleComponent component)
|
||||
private bool TryGetOrderDatabase(EntityUid uid, [MaybeNullWhen(false)] out EntityUid? dbUid, [MaybeNullWhen(false)] out StationCargoOrderDatabaseComponent dbComp, CargoOrderConsoleComponent _)
|
||||
{
|
||||
var station = _station.GetOwningStation(component.Owner);
|
||||
|
||||
TryComp<StationCargoOrderDatabaseComponent>(station, out var orderComponent);
|
||||
return orderComponent;
|
||||
dbUid = _station.GetOwningStation(uid);
|
||||
return TryComp(dbUid, out dbComp);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -2,8 +2,6 @@ using System.Linq;
|
||||
using Content.Server.Cargo.Components;
|
||||
using Content.Server.Shuttles.Components;
|
||||
using Content.Server.Shuttles.Events;
|
||||
using Content.Server.Shuttles.Systems;
|
||||
using Content.Server.Stack;
|
||||
using Content.Shared.Stacks;
|
||||
using Content.Shared.Cargo;
|
||||
using Content.Shared.Cargo.BUI;
|
||||
@@ -12,15 +10,13 @@ using Content.Shared.Cargo.Events;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Shared.Coordinates;
|
||||
using Content.Shared.Mobs;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
namespace Content.Server.Cargo.Systems;
|
||||
|
||||
@@ -73,7 +69,7 @@ public sealed partial class CargoSystem
|
||||
|
||||
#region Console
|
||||
|
||||
private void UpdateCargoShuttleConsoles(EntityUid shuttleUid, CargoShuttleComponent component)
|
||||
private void UpdateCargoShuttleConsoles(EntityUid shuttleUid, CargoShuttleComponent _)
|
||||
{
|
||||
// Update pilot consoles that are already open.
|
||||
_console.RefreshDroneConsoles();
|
||||
@@ -81,7 +77,7 @@ public sealed partial class CargoSystem
|
||||
// Update order consoles.
|
||||
var shuttleConsoleQuery = AllEntityQuery<CargoShuttleConsoleComponent>();
|
||||
|
||||
while (shuttleConsoleQuery.MoveNext(out var uid, out _))
|
||||
while (shuttleConsoleQuery.MoveNext(out var uid, out var _))
|
||||
{
|
||||
var stationUid = _station.GetOwningStation(uid);
|
||||
if (stationUid != shuttleUid)
|
||||
@@ -96,12 +92,12 @@ public sealed partial class CargoSystem
|
||||
var bui = _uiSystem.GetUi(uid, CargoPalletConsoleUiKey.Sale);
|
||||
if (Transform(uid).GridUid is not EntityUid gridUid)
|
||||
{
|
||||
_uiSystem.SetUiState(bui,
|
||||
UserInterfaceSystem.SetUiState(bui,
|
||||
new CargoPalletConsoleInterfaceState(0, 0, false));
|
||||
return;
|
||||
}
|
||||
GetPalletGoods(gridUid, out var toSell, out var amount);
|
||||
_uiSystem.SetUiState(bui,
|
||||
UserInterfaceSystem.SetUiState(bui,
|
||||
new CargoPalletConsoleInterfaceState((int) amount, toSell.Count, true));
|
||||
}
|
||||
|
||||
@@ -147,11 +143,12 @@ public sealed partial class CargoSystem
|
||||
var orders = GetProjectedOrders(station ?? EntityUid.Invalid, orderDatabase, shuttle);
|
||||
var shuttleName = orderDatabase?.Shuttle != null ? MetaData(orderDatabase.Shuttle.Value).EntityName : string.Empty;
|
||||
|
||||
_uiSystem.GetUiOrNull(uid, CargoConsoleUiKey.Shuttle)?.SetState(
|
||||
new CargoShuttleConsoleBoundUserInterfaceState(
|
||||
if (_uiSystem.TryGetUi(uid, CargoConsoleUiKey.Shuttle, out var bui))
|
||||
UserInterfaceSystem.SetUiState(bui, new CargoShuttleConsoleBoundUserInterfaceState(
|
||||
station != null ? MetaData(station.Value).EntityName : Loc.GetString("cargo-shuttle-console-station-unknown"),
|
||||
string.IsNullOrEmpty(shuttleName) ? Loc.GetString("cargo-shuttle-console-shuttle-not-found") : shuttleName,
|
||||
orders));
|
||||
orders
|
||||
));
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -172,10 +169,10 @@ public sealed partial class CargoSystem
|
||||
return orders;
|
||||
|
||||
var spaceRemaining = GetCargoSpace(shuttleUid);
|
||||
for( var i = 0; i < component.Orders.Count && spaceRemaining > 0; i++)
|
||||
for (var i = 0; i < component.Orders.Count && spaceRemaining > 0; i++)
|
||||
{
|
||||
var order = component.Orders[i];
|
||||
if(order.Approved)
|
||||
if (order.Approved)
|
||||
{
|
||||
var numToShip = order.OrderQuantity - order.NumDispatched;
|
||||
if (numToShip > spaceRemaining)
|
||||
@@ -311,7 +308,7 @@ public sealed partial class CargoSystem
|
||||
while (pads.Count > 0)
|
||||
{
|
||||
var coordinates = new EntityCoordinates(shuttleUid, xformQuery.GetComponent(_random.PickAndTake(pads).Entity).LocalPosition);
|
||||
if(!FulfillOrder(orderDatabase, coordinates, shuttle.PrinterOutput))
|
||||
if (!FulfillOrder(orderDatabase, coordinates, shuttle.PrinterOutput))
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -328,14 +325,14 @@ public sealed partial class CargoSystem
|
||||
var bui = _uiSystem.GetUi(uid, CargoPalletConsoleUiKey.Sale);
|
||||
if (Transform(uid).GridUid is not EntityUid gridUid)
|
||||
{
|
||||
_uiSystem.SetUiState(bui,
|
||||
UserInterfaceSystem.SetUiState(bui,
|
||||
new CargoPalletConsoleInterfaceState(0, 0, false));
|
||||
return;
|
||||
}
|
||||
|
||||
SellPallets(gridUid, null, out var price);
|
||||
var stackPrototype = _protoMan.Index<StackPrototype>(component.CashType);
|
||||
_stack.Spawn((int)price, stackPrototype, uid.ToCoordinates());
|
||||
_stack.Spawn((int) price, stackPrototype, uid.ToCoordinates());
|
||||
UpdatePalletConsoleInterface(uid);
|
||||
}
|
||||
|
||||
@@ -352,7 +349,7 @@ public sealed partial class CargoSystem
|
||||
}
|
||||
|
||||
AddCargoContents(uid, component, orderDatabase);
|
||||
UpdateOrders(orderDatabase);
|
||||
UpdateOrders(stationUid!.Value, orderDatabase);
|
||||
UpdateCargoShuttleConsoles(uid, component);
|
||||
}
|
||||
|
||||
@@ -397,7 +394,7 @@ public sealed partial class CargoSystem
|
||||
// Shuttle may not have been in the cargo dimension (e.g. on the station map) so need to delete.
|
||||
var query = AllEntityQuery<CargoShuttleComponent>();
|
||||
|
||||
while (query.MoveNext(out var uid, out var comp))
|
||||
while (query.MoveNext(out var uid, out var _))
|
||||
{
|
||||
if (TryComp<StationCargoOrderDatabaseComponent>(uid, out var station))
|
||||
{
|
||||
@@ -427,7 +424,7 @@ public sealed partial class CargoSystem
|
||||
}
|
||||
};
|
||||
|
||||
MetaData(mapUid).EntityName = $"Trading post {_random.Next(1000):000}";
|
||||
_metaSystem.SetEntityName(mapUid, $"Trading post {_random.Next(1000):000}");
|
||||
|
||||
_console.RefreshShuttleConsoles();
|
||||
}
|
||||
|
||||
@@ -65,10 +65,10 @@ public sealed partial class CargoSystem
|
||||
}
|
||||
|
||||
var xform = Transform(uid);
|
||||
if (FulfillOrder(orderDatabase, xform.Coordinates,comp.PrinterOutput))
|
||||
if (FulfillOrder(orderDatabase, xform.Coordinates, comp.PrinterOutput))
|
||||
{
|
||||
_audio.PlayPvs(_audio.GetSound(comp.TeleportSound), uid, AudioParams.Default.WithVolume(-8f));
|
||||
UpdateOrders(orderDatabase);
|
||||
UpdateOrders(station!.Value, orderDatabase);
|
||||
|
||||
comp.CurrentState = CargoTelepadState.Teleporting;
|
||||
_appearance.SetData(uid, CargoTelepadVisuals.State, CargoTelepadState.Teleporting, appearance);
|
||||
|
||||
@@ -43,6 +43,7 @@ public sealed partial class CargoSystem : SharedCargoSystem
|
||||
[Dependency] private readonly StackSystem _stack = default!;
|
||||
[Dependency] private readonly StationSystem _station = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
|
||||
|
||||
private ISawmill _sawmill = default!;
|
||||
|
||||
@@ -76,7 +77,7 @@ public sealed partial class CargoSystem : SharedCargoSystem
|
||||
component.Balance += balanceAdded;
|
||||
var query = EntityQueryEnumerator<CargoOrderConsoleComponent>();
|
||||
|
||||
while (query.MoveNext(out var oUid, out var oComp))
|
||||
while (query.MoveNext(out var oUid, out var _))
|
||||
{
|
||||
if (!_uiSystem.IsUiOpen(oUid, CargoConsoleUiKey.Orders))
|
||||
continue;
|
||||
@@ -85,7 +86,7 @@ public sealed partial class CargoSystem : SharedCargoSystem
|
||||
if (station != uid)
|
||||
continue;
|
||||
|
||||
UpdateOrderState(oComp, station);
|
||||
UpdateOrderState(oUid, station);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user