Cleaner BoundUserInterfaces (#17736)
This commit is contained in:
@@ -21,7 +21,7 @@ namespace Content.Server.Access.Systems
|
||||
// BUI
|
||||
SubscribeLocalEvent<AgentIDCardComponent, AfterActivatableUIOpenEvent>(AfterUIOpen);
|
||||
SubscribeLocalEvent<AgentIDCardComponent, AgentIDCardNameChangedMessage>(OnNameChanged);
|
||||
SubscribeLocalEvent<AgentIDCardComponent, AgentIDCardJobChangedMessage> (OnJobChanged);
|
||||
SubscribeLocalEvent<AgentIDCardComponent, AgentIDCardJobChangedMessage>(OnJobChanged);
|
||||
}
|
||||
|
||||
private void OnAfterInteract(EntityUid uid, AgentIDCardComponent component, AfterInteractEvent args)
|
||||
@@ -55,14 +55,14 @@ namespace Content.Server.Access.Systems
|
||||
|
||||
private void AfterUIOpen(EntityUid uid, AgentIDCardComponent component, AfterActivatableUIOpenEvent args)
|
||||
{
|
||||
if (!_uiSystem.TryGetUi(component.Owner, AgentIDCardUiKey.Key, out var ui))
|
||||
if (!_uiSystem.TryGetUi(uid, AgentIDCardUiKey.Key, out var ui))
|
||||
return;
|
||||
|
||||
if (!TryComp<IdCardComponent>(uid, out var idCard))
|
||||
return;
|
||||
|
||||
var state = new AgentIDCardBoundUserInterfaceState(idCard.FullName ?? "", idCard.JobTitle ?? "");
|
||||
ui.SetState(state, args.Session);
|
||||
UserInterfaceSystem.SetUiState(ui, state, args.Session);
|
||||
}
|
||||
|
||||
private void OnJobChanged(EntityUid uid, AgentIDCardComponent comp, AgentIDCardJobChangedMessage args)
|
||||
|
||||
@@ -57,7 +57,9 @@ namespace Content.Server.AirlockPainter
|
||||
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
|
||||
return;
|
||||
DirtyUI(uid, component);
|
||||
component.Owner.GetUIOrNull(AirlockPainterUiKey.Key)?.Open(actor.PlayerSession);
|
||||
|
||||
if (_userInterfaceSystem.TryGetUi(uid, AirlockPainterUiKey.Key, out var bui))
|
||||
_userInterfaceSystem.OpenUi(bui, actor.PlayerSession);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace Content.Server.Alert.Click
|
||||
{
|
||||
var entManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (entManager.TryGetComponent(player, out PilotComponent? pilotComponent) &&
|
||||
pilotComponent.Console != null)
|
||||
if (entManager.TryGetComponent(player, out PilotComponent? pilotComponent)
|
||||
&& pilotComponent.Console != null)
|
||||
{
|
||||
entManager.System<ShuttleConsoleSystem>().RemovePilot(player, pilotComponent);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public sealed class AmeControllerSystem : EntitySystem
|
||||
return;
|
||||
|
||||
var state = GetUiState(uid, controller);
|
||||
_userInterfaceSystem.SetUiState(bui, state);
|
||||
UserInterfaceSystem.SetUiState(bui, state);
|
||||
}
|
||||
|
||||
private AmeControllerBoundUserInterfaceState GetUiState(EntityUid uid, AmeControllerComponent controller)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
/// and use this method to update its state so the cartridge loaders state can be added to it.
|
||||
/// </remarks>
|
||||
/// <seealso cref="PDA.PdaSystem.UpdatePdaUserInterface"/>
|
||||
public void UpdateUiState(EntityUid loaderUid, CartridgeLoaderUiState state, IPlayerSession? session = default!, CartridgeLoaderComponent? loader = default!)
|
||||
public void UpdateUiState(EntityUid loaderUid, CartridgeLoaderUiState state, IPlayerSession? session = default!, CartridgeLoaderComponent? loader = default!)
|
||||
{
|
||||
if (!Resolve(loaderUid, ref loader))
|
||||
return;
|
||||
@@ -44,9 +44,8 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
state.ActiveUI = loader.ActiveProgram;
|
||||
state.Programs = GetAvailablePrograms(loaderUid, loader);
|
||||
|
||||
var ui = _userInterfaceSystem.GetUiOrNull(loader.Owner, loader.UiKey);
|
||||
if (ui != null)
|
||||
_userInterfaceSystem.SetUiState(ui, state, session);
|
||||
if (_userInterfaceSystem.TryGetUi(loaderUid, loader.UiKey, out var ui))
|
||||
UserInterfaceSystem.SetUiState(ui, state, session);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -65,9 +64,8 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
if (!Resolve(loaderUid, ref loader))
|
||||
return;
|
||||
|
||||
var ui = _userInterfaceSystem.GetUiOrNull(loader.Owner, loader.UiKey);
|
||||
if (ui != null)
|
||||
_userInterfaceSystem.SetUiState(ui, state, session);
|
||||
if (_userInterfaceSystem.TryGetUi(loaderUid, loader.UiKey, out var ui))
|
||||
UserInterfaceSystem.SetUiState(ui, state, session);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -76,7 +74,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
/// <param name="uid">The cartridge loaders uid</param>
|
||||
/// <param name="loader">The cartridge loader component</param>
|
||||
/// <returns>A list of all the available program entity ids</returns>
|
||||
public List<EntityUid> GetAvailablePrograms(EntityUid uid, CartridgeLoaderComponent? loader = default!)
|
||||
public List<EntityUid> GetAvailablePrograms(EntityUid uid, CartridgeLoaderComponent? loader = default!)
|
||||
{
|
||||
if (!Resolve(uid, ref loader))
|
||||
return new List<EntityUid>();
|
||||
@@ -120,7 +118,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
/// <param name="deinstallable">Whether the program can be deinstalled or not</param>
|
||||
/// <param name="loader">The cartridge loader component</param>
|
||||
/// <returns>Whether installing the cartridge was successful</returns>
|
||||
public bool InstallProgram(EntityUid loaderUid, string prototype, bool deinstallable = true, CartridgeLoaderComponent? loader = default!)
|
||||
public bool InstallProgram(EntityUid loaderUid, string prototype, bool deinstallable = true, CartridgeLoaderComponent? loader = default!)
|
||||
{
|
||||
if (!Resolve(loaderUid, ref loader) || loader.InstalledPrograms.Count >= loader.DiskSpace)
|
||||
return false;
|
||||
@@ -150,7 +148,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
/// <param name="programUid">The uid of the program to be uninstalled</param>
|
||||
/// <param name="loader">The cartridge loader component</param>
|
||||
/// <returns>Whether uninstalling the program was successful</returns>
|
||||
public bool UninstallProgram(EntityUid loaderUid, EntityUid programUid, CartridgeLoaderComponent? loader = default!)
|
||||
public bool UninstallProgram(EntityUid loaderUid, EntityUid programUid, CartridgeLoaderComponent? loader = default!)
|
||||
{
|
||||
if (!Resolve(loaderUid, ref loader) || !ContainsCartridge(programUid, loader, true))
|
||||
return false;
|
||||
@@ -168,7 +166,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
/// <summary>
|
||||
/// Activates a program or cartridge and displays its ui fragment. Deactivates any previously active program.
|
||||
/// </summary>
|
||||
public void ActivateProgram(EntityUid loaderUid, EntityUid programUid, CartridgeLoaderComponent? loader = default!)
|
||||
public void ActivateProgram(EntityUid loaderUid, EntityUid programUid, CartridgeLoaderComponent? loader = default!)
|
||||
{
|
||||
if (!Resolve(loaderUid, ref loader))
|
||||
return;
|
||||
@@ -189,7 +187,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
/// <summary>
|
||||
/// Deactivates the currently active program or cartridge.
|
||||
/// </summary>
|
||||
public void DeactivateProgram(EntityUid loaderUid, EntityUid programUid, CartridgeLoaderComponent? loader = default!)
|
||||
public void DeactivateProgram(EntityUid loaderUid, EntityUid programUid, CartridgeLoaderComponent? loader = default!)
|
||||
{
|
||||
if (!Resolve(loaderUid, ref loader))
|
||||
return;
|
||||
@@ -210,7 +208,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
/// <remarks>
|
||||
/// Programs wanting to use this functionality will have to provide a way to register and unregister themselves as background programs through their ui fragment.
|
||||
/// </remarks>
|
||||
public void RegisterBackgroundProgram(EntityUid loaderUid, EntityUid cartridgeUid, CartridgeLoaderComponent? loader = default!)
|
||||
public void RegisterBackgroundProgram(EntityUid loaderUid, EntityUid cartridgeUid, CartridgeLoaderComponent? loader = default!)
|
||||
{
|
||||
if (!Resolve(loaderUid, ref loader))
|
||||
return;
|
||||
@@ -227,7 +225,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
/// <summary>
|
||||
/// Unregisters the given program as running in the background
|
||||
/// </summary>
|
||||
public void UnregisterBackgroundProgram(EntityUid loaderUid, EntityUid cartridgeUid, CartridgeLoaderComponent? loader = default!)
|
||||
public void UnregisterBackgroundProgram(EntityUid loaderUid, EntityUid cartridgeUid, CartridgeLoaderComponent? loader = default!)
|
||||
{
|
||||
if (!Resolve(loaderUid, ref loader))
|
||||
return;
|
||||
@@ -306,7 +304,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
RaiseLocalEvent(component.ActiveProgram.Value, new CartridgeUiReadyEvent(loaderUid));
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
throw new ArgumentOutOfRangeException($"Unrecognized UI action passed from cartridge loader ui {message.Action}.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,7 +377,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
}
|
||||
}
|
||||
|
||||
private bool ContainsCartridge(EntityUid cartridgeUid, CartridgeLoaderComponent loader , bool onlyInstalled = false)
|
||||
private static bool ContainsCartridge(EntityUid cartridgeUid, CartridgeLoaderComponent loader, bool onlyInstalled = false)
|
||||
{
|
||||
return !onlyInstalled && loader.CartridgeSlot.Item?.Equals(cartridgeUid) == true || loader.InstalledPrograms.Contains(cartridgeUid);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Timing;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Medical.Components;
|
||||
using Content.Server.Cloning.Components;
|
||||
using Content.Server.DeviceLinking.Events;
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Mind.Components;
|
||||
@@ -62,12 +60,12 @@ namespace Content.Server.Cloning
|
||||
TryClone(uid, consoleComponent.CloningPod.Value, consoleComponent.GeneticScanner.Value, consoleComponent: consoleComponent);
|
||||
break;
|
||||
}
|
||||
UpdateUserInterface(consoleComponent);
|
||||
UpdateUserInterface(uid, consoleComponent);
|
||||
}
|
||||
|
||||
private void OnPowerChanged(EntityUid uid, CloningConsoleComponent component, ref PowerChangedEvent args)
|
||||
{
|
||||
UpdateUserInterface(component);
|
||||
UpdateUserInterface(uid, component);
|
||||
}
|
||||
|
||||
private void OnMapInit(EntityUid uid, CloningConsoleComponent component, MapInitEvent args)
|
||||
@@ -115,12 +113,12 @@ namespace Content.Server.Cloning
|
||||
if (args.Port == CloningConsoleComponent.PodPort)
|
||||
component.CloningPod = null;
|
||||
|
||||
UpdateUserInterface(component);
|
||||
UpdateUserInterface(uid, component);
|
||||
}
|
||||
|
||||
private void OnUIOpen(EntityUid uid, CloningConsoleComponent component, AfterActivatableUIOpenEvent args)
|
||||
{
|
||||
UpdateUserInterface(component);
|
||||
UpdateUserInterface(uid, component);
|
||||
}
|
||||
|
||||
private void OnAnchorChanged(EntityUid uid, CloningConsoleComponent component, ref AnchorStateChangedEvent args)
|
||||
@@ -130,27 +128,27 @@ namespace Content.Server.Cloning
|
||||
RecheckConnections(uid, component.CloningPod, component.GeneticScanner, component);
|
||||
return;
|
||||
}
|
||||
UpdateUserInterface(component);
|
||||
UpdateUserInterface(uid, component);
|
||||
}
|
||||
|
||||
public void UpdateUserInterface(CloningConsoleComponent consoleComponent)
|
||||
public void UpdateUserInterface(EntityUid consoleUid, CloningConsoleComponent consoleComponent)
|
||||
{
|
||||
var ui = _uiSystem.GetUiOrNull(consoleComponent.Owner, CloningConsoleUiKey.Key);
|
||||
if (ui == null)
|
||||
if (!_uiSystem.TryGetUi(consoleUid, CloningConsoleUiKey.Key, out var ui))
|
||||
return;
|
||||
if (!_powerReceiverSystem.IsPowered(consoleComponent.Owner))
|
||||
|
||||
if (!_powerReceiverSystem.IsPowered(consoleUid))
|
||||
{
|
||||
_uiSystem.CloseAll(ui);
|
||||
return;
|
||||
}
|
||||
|
||||
var newState = GetUserInterfaceState(consoleComponent);
|
||||
_uiSystem.SetUiState(ui, newState);
|
||||
UserInterfaceSystem.SetUiState(ui, newState);
|
||||
}
|
||||
|
||||
public void TryClone(EntityUid uid, EntityUid cloningPodUid, EntityUid scannerUid, CloningPodComponent? cloningPod = null, MedicalScannerComponent? scannerComp = null, CloningConsoleComponent? consoleComponent = null)
|
||||
{
|
||||
if (!Resolve(uid, ref consoleComponent) || !Resolve(cloningPodUid, ref cloningPod) || !Resolve(scannerUid, ref scannerComp))
|
||||
if (!Resolve(uid, ref consoleComponent) || !Resolve(cloningPodUid, ref cloningPod) || !Resolve(scannerUid, ref scannerComp))
|
||||
return;
|
||||
|
||||
if (!Transform(cloningPodUid).Anchored || !Transform(scannerUid).Anchored)
|
||||
@@ -192,7 +190,7 @@ namespace Content.Server.Cloning
|
||||
consoleComp.CloningPodInRange = podDistance <= consoleComp.MaxDistance;
|
||||
}
|
||||
|
||||
UpdateUserInterface(consoleComp);
|
||||
UpdateUserInterface(console, consoleComp);
|
||||
}
|
||||
private CloningConsoleBoundUserInterfaceState GetUserInterfaceState(CloningConsoleComponent consoleComponent)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,6 @@ using Robust.Shared.Random;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Content.Shared.Humanoid;
|
||||
using Content.Shared.Doors.Components;
|
||||
using Content.Shared.Emag.Systems;
|
||||
using Robust.Shared.Audio;
|
||||
@@ -66,6 +65,7 @@ namespace Content.Server.Cloning
|
||||
[Dependency] private readonly MaterialStorageSystem _material = default!;
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly MindSystem _mindSystem = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
|
||||
|
||||
public readonly Dictionary<Mind.Mind, EntityUid> ClonesWaitingForMind = new();
|
||||
public const float EasyModeCloningCost = 0.7f;
|
||||
@@ -87,7 +87,7 @@ namespace Content.Server.Cloning
|
||||
|
||||
private void OnComponentInit(EntityUid uid, CloningPodComponent clonePod, ComponentInit args)
|
||||
{
|
||||
clonePod.BodyContainer = _containerSystem.EnsureContainer<ContainerSlot>(clonePod.Owner, "clonepod-bodyContainer");
|
||||
clonePod.BodyContainer = _containerSystem.EnsureContainer<ContainerSlot>(uid, "clonepod-bodyContainer");
|
||||
_signalSystem.EnsureSinkPorts(uid, CloningPodComponent.PodPort);
|
||||
}
|
||||
|
||||
@@ -124,12 +124,12 @@ namespace Content.Server.Cloning
|
||||
if (clonedComponent.Parent == EntityUid.Invalid ||
|
||||
!EntityManager.EntityExists(clonedComponent.Parent) ||
|
||||
!TryComp<CloningPodComponent>(clonedComponent.Parent, out var cloningPodComponent) ||
|
||||
clonedComponent.Owner != cloningPodComponent.BodyContainer.ContainedEntity)
|
||||
uid != cloningPodComponent.BodyContainer.ContainedEntity)
|
||||
{
|
||||
EntityManager.RemoveComponent<BeingClonedComponent>(clonedComponent.Owner);
|
||||
EntityManager.RemoveComponent<BeingClonedComponent>(uid);
|
||||
return;
|
||||
}
|
||||
UpdateStatus(CloningPodStatus.Cloning, cloningPodComponent);
|
||||
UpdateStatus(clonedComponent.Parent, CloningPodStatus.Cloning, cloningPodComponent);
|
||||
}
|
||||
|
||||
private void OnPortDisconnected(EntityUid uid, CloningPodComponent pod, PortDisconnectedEvent args)
|
||||
@@ -147,7 +147,7 @@ namespace Content.Server.Cloning
|
||||
_cloningConsoleSystem.RecheckConnections(component.ConnectedConsole.Value, uid, console.GeneticScanner, console);
|
||||
return;
|
||||
}
|
||||
_cloningConsoleSystem.UpdateUserInterface(console);
|
||||
_cloningConsoleSystem.UpdateUserInterface(component.ConnectedConsole.Value, console);
|
||||
}
|
||||
|
||||
private void OnExamined(EntityUid uid, CloningPodComponent component, ExaminedEvent args)
|
||||
@@ -230,11 +230,11 @@ namespace Content.Server.Cloning
|
||||
chance *= failChanceModifier;
|
||||
|
||||
if (cellularDmg > 0 && clonePod.ConnectedConsole != null)
|
||||
_chatSystem.TrySendInGameICMessage(clonePod.ConnectedConsole.Value, Loc.GetString("cloning-console-cellular-warning", ("percent", Math.Round(100 - (chance * 100)))), InGameICChatType.Speak, false);
|
||||
_chatSystem.TrySendInGameICMessage(clonePod.ConnectedConsole.Value, Loc.GetString("cloning-console-cellular-warning", ("percent", Math.Round(100 - chance * 100))), InGameICChatType.Speak, false);
|
||||
|
||||
if (_robustRandom.Prob(chance))
|
||||
{
|
||||
UpdateStatus(CloningPodStatus.Gore, clonePod);
|
||||
UpdateStatus(uid, CloningPodStatus.Gore, clonePod);
|
||||
clonePod.FailedClone = true;
|
||||
AddComp<ActiveCloningPodComponent>(uid);
|
||||
return true;
|
||||
@@ -242,21 +242,21 @@ namespace Content.Server.Cloning
|
||||
}
|
||||
// end of genetic damage checks
|
||||
|
||||
var mob = Spawn(speciesPrototype.Prototype, Transform(clonePod.Owner).MapPosition);
|
||||
var mob = Spawn(speciesPrototype.Prototype, Transform(uid).MapPosition);
|
||||
_humanoidSystem.CloneAppearance(bodyToClone, mob);
|
||||
|
||||
var ev = new CloningEvent(bodyToClone, mob);
|
||||
RaiseLocalEvent(bodyToClone, ref ev);
|
||||
|
||||
if (!ev.NameHandled)
|
||||
MetaData(mob).EntityName = MetaData(bodyToClone).EntityName;
|
||||
_metaSystem.SetEntityName(mob, MetaData(bodyToClone).EntityName);
|
||||
|
||||
var cloneMindReturn = EntityManager.AddComponent<BeingClonedComponent>(mob);
|
||||
cloneMindReturn.Mind = mind;
|
||||
cloneMindReturn.Parent = clonePod.Owner;
|
||||
cloneMindReturn.Parent = uid;
|
||||
clonePod.BodyContainer.Insert(mob);
|
||||
ClonesWaitingForMind.Add(mind, mob);
|
||||
UpdateStatus(CloningPodStatus.NoMind, clonePod);
|
||||
UpdateStatus(uid, CloningPodStatus.NoMind, clonePod);
|
||||
_euiManager.OpenEui(new AcceptCloningEui(mind, this), client);
|
||||
|
||||
AddComp<ActiveCloningPodComponent>(uid);
|
||||
@@ -276,17 +276,18 @@ namespace Content.Server.Cloning
|
||||
return true;
|
||||
}
|
||||
|
||||
public void UpdateStatus(CloningPodStatus status, CloningPodComponent cloningPod)
|
||||
public void UpdateStatus(EntityUid podUid, CloningPodStatus status, CloningPodComponent cloningPod)
|
||||
{
|
||||
cloningPod.Status = status;
|
||||
_appearance.SetData(cloningPod.Owner, CloningPodVisuals.Status, cloningPod.Status);
|
||||
_appearance.SetData(podUid, CloningPodVisuals.Status, cloningPod.Status);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
foreach (var (_, cloning) in EntityManager.EntityQuery<ActiveCloningPodComponent, CloningPodComponent>())
|
||||
var query = EntityQueryEnumerator<ActiveCloningPodComponent, CloningPodComponent>();
|
||||
while (query.MoveNext(out var uid, out var _, out var cloning))
|
||||
{
|
||||
if (!_powerReceiverSystem.IsPowered(cloning.Owner))
|
||||
if (!_powerReceiverSystem.IsPowered(uid))
|
||||
continue;
|
||||
|
||||
if (cloning.BodyContainer.ContainedEntity == null && !cloning.FailedClone)
|
||||
@@ -297,9 +298,9 @@ namespace Content.Server.Cloning
|
||||
continue;
|
||||
|
||||
if (cloning.FailedClone)
|
||||
EndFailedCloning(cloning.Owner, cloning);
|
||||
EndFailedCloning(uid, cloning);
|
||||
else
|
||||
Eject(cloning.Owner, cloning);
|
||||
Eject(uid, cloning);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,14 +322,14 @@ namespace Content.Server.Cloning
|
||||
if (!Resolve(uid, ref clonePod))
|
||||
return;
|
||||
|
||||
if (clonePod.BodyContainer.ContainedEntity is not {Valid: true} entity || clonePod.CloningProgress < clonePod.CloningTime)
|
||||
if (clonePod.BodyContainer.ContainedEntity is not { Valid: true } entity || clonePod.CloningProgress < clonePod.CloningTime)
|
||||
return;
|
||||
|
||||
EntityManager.RemoveComponent<BeingClonedComponent>(entity);
|
||||
clonePod.BodyContainer.Remove(entity);
|
||||
clonePod.CloningProgress = 0f;
|
||||
clonePod.UsedBiomass = 0;
|
||||
UpdateStatus(CloningPodStatus.Idle, clonePod);
|
||||
UpdateStatus(uid, CloningPodStatus.Idle, clonePod);
|
||||
RemCompDeferred<ActiveCloningPodComponent>(uid);
|
||||
}
|
||||
|
||||
@@ -336,7 +337,7 @@ namespace Content.Server.Cloning
|
||||
{
|
||||
clonePod.FailedClone = false;
|
||||
clonePod.CloningProgress = 0f;
|
||||
UpdateStatus(CloningPodStatus.Idle, clonePod);
|
||||
UpdateStatus(uid, CloningPodStatus.Idle, clonePod);
|
||||
var transform = Transform(uid);
|
||||
var indices = _transformSystem.GetGridOrMapTilePosition(uid);
|
||||
|
||||
@@ -350,7 +351,7 @@ namespace Content.Server.Cloning
|
||||
|
||||
Solution bloodSolution = new();
|
||||
|
||||
int i = 0;
|
||||
var i = 0;
|
||||
while (i < 1)
|
||||
{
|
||||
tileMix?.AdjustMoles(Gas.Miasma, 6f);
|
||||
@@ -362,7 +363,7 @@ namespace Content.Server.Cloning
|
||||
|
||||
if (!HasComp<EmaggedComponent>(uid))
|
||||
{
|
||||
_material.SpawnMultipleFromMaterial(_robustRandom.Next(1, (int) (clonePod.UsedBiomass / 2.5)), clonePod.RequiredMaterial, Transform(uid).Coordinates);
|
||||
_material.SpawnMultipleFromMaterial(_robustRandom.Next(1, (int) (clonePod.UsedBiomass / 2.5)), clonePod.RequiredMaterial, Transform(uid).Coordinates);
|
||||
}
|
||||
|
||||
clonePod.UsedBiomass = 0;
|
||||
@@ -386,7 +387,8 @@ namespace Content.Server.Cloning
|
||||
public readonly EntityUid Source;
|
||||
public readonly EntityUid Target;
|
||||
|
||||
public CloningEvent(EntityUid source, EntityUid target) {
|
||||
public CloningEvent(EntityUid source, EntityUid target)
|
||||
{
|
||||
Source = source;
|
||||
Target = target;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace Content.Server.Communications
|
||||
[Dependency] private readonly StationSystem _stationSystem = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||
|
||||
private const int MaxMessageLength = 256;
|
||||
private const int MaxMessageNewlines = 2;
|
||||
@@ -46,7 +47,7 @@ namespace Content.Server.Communications
|
||||
{
|
||||
// All events that refresh the BUI
|
||||
SubscribeLocalEvent<AlertLevelChangedEvent>(OnAlertLevelChanged);
|
||||
SubscribeLocalEvent<CommunicationsConsoleComponent, ComponentInit>((_, comp, _) => UpdateCommsConsoleInterface(comp));
|
||||
SubscribeLocalEvent<CommunicationsConsoleComponent, ComponentInit>((uid, comp, _) => UpdateCommsConsoleInterface(uid, comp));
|
||||
SubscribeLocalEvent<RoundEndSystemChangedEvent>(_ => OnGenericBroadcastEvent());
|
||||
SubscribeLocalEvent<AlertLevelDelayFinishedEvent>(_ => OnGenericBroadcastEvent());
|
||||
|
||||
@@ -59,7 +60,8 @@ namespace Content.Server.Communications
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
foreach (var comp in EntityQuery<CommunicationsConsoleComponent>())
|
||||
var query = EntityQueryEnumerator<CommunicationsConsoleComponent>();
|
||||
while (query.MoveNext(out var uid, out var comp))
|
||||
{
|
||||
// TODO refresh the UI in a less horrible way
|
||||
if (comp.AnnouncementCooldownRemaining >= 0f)
|
||||
@@ -74,8 +76,8 @@ namespace Content.Server.Communications
|
||||
|
||||
comp.UIUpdateAccumulator -= UIUpdateInterval;
|
||||
|
||||
if (comp.UserInterface is {} ui && ui.SubscribedSessions.Count > 0)
|
||||
UpdateCommsConsoleInterface(comp);
|
||||
if (comp.UserInterface is { } ui && ui.SubscribedSessions.Count > 0)
|
||||
UpdateCommsConsoleInterface(uid, comp);
|
||||
}
|
||||
|
||||
base.Update(frameTime);
|
||||
@@ -86,9 +88,10 @@ namespace Content.Server.Communications
|
||||
/// </summary>
|
||||
private void OnGenericBroadcastEvent()
|
||||
{
|
||||
foreach (var comp in EntityQuery<CommunicationsConsoleComponent>())
|
||||
var query = EntityQueryEnumerator<CommunicationsConsoleComponent>();
|
||||
while (query.MoveNext(out var uid, out var comp))
|
||||
{
|
||||
UpdateCommsConsoleInterface(comp);
|
||||
UpdateCommsConsoleInterface(uid, comp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,13 +101,12 @@ namespace Content.Server.Communications
|
||||
/// <param name="args">Alert level changed event arguments</param>
|
||||
private void OnAlertLevelChanged(AlertLevelChangedEvent args)
|
||||
{
|
||||
foreach (var comp in EntityQuery<CommunicationsConsoleComponent>(true))
|
||||
var query = EntityQueryEnumerator<CommunicationsConsoleComponent>();
|
||||
while (query.MoveNext(out var uid, out var comp))
|
||||
{
|
||||
var entStation = _stationSystem.GetOwningStation(comp.Owner);
|
||||
var entStation = _stationSystem.GetOwningStation(uid);
|
||||
if (args.Station == entStation)
|
||||
{
|
||||
UpdateCommsConsoleInterface(comp);
|
||||
}
|
||||
UpdateCommsConsoleInterface(uid, comp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,9 +115,10 @@ namespace Content.Server.Communications
|
||||
/// </summary>
|
||||
public void UpdateCommsConsoleInterface()
|
||||
{
|
||||
foreach (var comp in EntityQuery<CommunicationsConsoleComponent>())
|
||||
var query = EntityQueryEnumerator<CommunicationsConsoleComponent>();
|
||||
while (query.MoveNext(out var uid, out var comp))
|
||||
{
|
||||
UpdateCommsConsoleInterface(comp);
|
||||
UpdateCommsConsoleInterface(uid, comp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,10 +126,8 @@ namespace Content.Server.Communications
|
||||
/// Updates the UI for a particular comms console.
|
||||
/// </summary>
|
||||
/// <param name="comp"></param>
|
||||
public void UpdateCommsConsoleInterface(CommunicationsConsoleComponent comp)
|
||||
public void UpdateCommsConsoleInterface(EntityUid uid, CommunicationsConsoleComponent comp)
|
||||
{
|
||||
var uid = comp.Owner;
|
||||
|
||||
var stationUid = _stationSystem.GetOwningStation(uid);
|
||||
List<string>? levels = null;
|
||||
string currentLevel = default!;
|
||||
@@ -154,19 +155,18 @@ namespace Content.Server.Communications
|
||||
}
|
||||
}
|
||||
|
||||
comp.UserInterface?.SetState(
|
||||
new CommunicationsConsoleInterfaceState(
|
||||
if (comp.UserInterface is not null)
|
||||
UserInterfaceSystem.SetUiState(comp.UserInterface, new CommunicationsConsoleInterfaceState(
|
||||
CanAnnounce(comp),
|
||||
CanCallOrRecall(comp),
|
||||
levels,
|
||||
currentLevel,
|
||||
currentDelay,
|
||||
_roundEndSystem.ExpectedCountdownEnd
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
private bool CanAnnounce(CommunicationsConsoleComponent comp)
|
||||
private static bool CanAnnounce(CommunicationsConsoleComponent comp)
|
||||
{
|
||||
return comp.AnnouncementCooldownRemaining <= 0f;
|
||||
}
|
||||
@@ -207,7 +207,7 @@ namespace Content.Server.Communications
|
||||
|
||||
private void OnSelectAlertLevelMessage(EntityUid uid, CommunicationsConsoleComponent comp, CommunicationsConsoleSelectAlertLevelMessage message)
|
||||
{
|
||||
if (message.Session.AttachedEntity is not {Valid: true} mob) return;
|
||||
if (message.Session.AttachedEntity is not { Valid: true } mob) return;
|
||||
if (!CanUse(mob, uid))
|
||||
{
|
||||
_popupSystem.PopupCursor(Loc.GetString("comms-console-permission-denied"), message.Session, PopupType.Medium);
|
||||
@@ -224,7 +224,8 @@ namespace Content.Server.Communications
|
||||
private void OnAnnounceMessage(EntityUid uid, CommunicationsConsoleComponent comp,
|
||||
CommunicationsConsoleAnnounceMessage message)
|
||||
{
|
||||
var msgChars = (message.Message.Length <= MaxMessageLength ? message.Message.Trim() : $"{message.Message.Trim().Substring(0, MaxMessageLength)}...").ToCharArray();
|
||||
var msgWords = message.Message.Trim();
|
||||
var msgChars = (msgWords.Length <= MaxMessageLength ? msgWords : $"{msgWords[0..MaxMessageLength]}...").ToCharArray();
|
||||
|
||||
var newlines = 0;
|
||||
for (var i = 0; i < msgChars.Length; i++)
|
||||
@@ -240,7 +241,7 @@ namespace Content.Server.Communications
|
||||
|
||||
var msg = new string(msgChars);
|
||||
var author = Loc.GetString("comms-console-announcement-unknown-sender");
|
||||
if (message.Session.AttachedEntity is {Valid: true} mob)
|
||||
if (message.Session.AttachedEntity is { Valid: true } mob)
|
||||
{
|
||||
if (!CanAnnounce(comp))
|
||||
{
|
||||
@@ -260,7 +261,7 @@ namespace Content.Server.Communications
|
||||
}
|
||||
|
||||
comp.AnnouncementCooldownRemaining = comp.DelayBetweenAnnouncements;
|
||||
UpdateCommsConsoleInterface(comp);
|
||||
UpdateCommsConsoleInterface(uid, comp);
|
||||
|
||||
// allow admemes with vv
|
||||
Loc.TryGetString(comp.AnnouncementDisplayName, out var title);
|
||||
@@ -285,7 +286,7 @@ namespace Content.Server.Communications
|
||||
private void OnCallShuttleMessage(EntityUid uid, CommunicationsConsoleComponent comp, CommunicationsConsoleCallEmergencyShuttleMessage message)
|
||||
{
|
||||
if (!CanCallOrRecall(comp)) return;
|
||||
if (message.Session.AttachedEntity is not {Valid: true} mob) return;
|
||||
if (message.Session.AttachedEntity is not { Valid: true } mob) return;
|
||||
if (!CanUse(mob, uid))
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("comms-console-permission-denied"), uid, message.Session);
|
||||
@@ -298,7 +299,7 @@ namespace Content.Server.Communications
|
||||
private void OnRecallShuttleMessage(EntityUid uid, CommunicationsConsoleComponent comp, CommunicationsConsoleRecallEmergencyShuttleMessage message)
|
||||
{
|
||||
if (!CanCallOrRecall(comp)) return;
|
||||
if (message.Session.AttachedEntity is not {Valid: true} mob) return;
|
||||
if (message.Session.AttachedEntity is not { Valid: true } mob) return;
|
||||
if (!CanUse(mob, uid))
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("comms-console-permission-denied"), uid, message.Session);
|
||||
|
||||
@@ -43,7 +43,7 @@ public sealed class ConfigurationSystem : EntitySystem
|
||||
private void UpdateUi(EntityUid uid, ConfigurationComponent component)
|
||||
{
|
||||
if (_uiSystem.TryGetUi(uid, ConfigurationUiKey.Key, out var ui))
|
||||
ui.SetState(new ConfigurationBoundUserInterfaceState(component.Config));
|
||||
UserInterfaceSystem.SetUiState(ui, new ConfigurationBoundUserInterfaceState(component.Config));
|
||||
}
|
||||
|
||||
private void OnUpdate(EntityUid uid, ConfigurationComponent component, ConfigurationUpdatedMessage args)
|
||||
|
||||
@@ -4,7 +4,6 @@ using Content.Server.Administration.Logs;
|
||||
using Content.Server.Decals;
|
||||
using Content.Server.Nutrition.EntitySystems;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Crayon;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Decals;
|
||||
@@ -13,15 +12,15 @@ using Content.Shared.Interaction.Events;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Crayon;
|
||||
|
||||
public sealed class CrayonSystem : SharedCrayonSystem
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly DecalSystem _decals = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
@@ -33,8 +32,8 @@ public sealed class CrayonSystem : SharedCrayonSystem
|
||||
SubscribeLocalEvent<CrayonComponent, ComponentInit>(OnCrayonInit);
|
||||
SubscribeLocalEvent<CrayonComponent, CrayonSelectMessage>(OnCrayonBoundUI);
|
||||
SubscribeLocalEvent<CrayonComponent, CrayonColorMessage>(OnCrayonBoundUIColor);
|
||||
SubscribeLocalEvent<CrayonComponent, UseInHandEvent>(OnCrayonUse, before: new []{ typeof(FoodSystem) });
|
||||
SubscribeLocalEvent<CrayonComponent, AfterInteractEvent>(OnCrayonAfterInteract, after: new []{ typeof(FoodSystem) });
|
||||
SubscribeLocalEvent<CrayonComponent, UseInHandEvent>(OnCrayonUse, before: new[] { typeof(FoodSystem) });
|
||||
SubscribeLocalEvent<CrayonComponent, AfterInteractEvent>(OnCrayonAfterInteract, after: new[] { typeof(FoodSystem) });
|
||||
SubscribeLocalEvent<CrayonComponent, DroppedEvent>(OnCrayonDropped);
|
||||
SubscribeLocalEvent<CrayonComponent, ComponentGetState>(OnCrayonGetState);
|
||||
}
|
||||
@@ -67,11 +66,11 @@ public sealed class CrayonSystem : SharedCrayonSystem
|
||||
return;
|
||||
}
|
||||
|
||||
if(!_decals.TryAddDecal(component.SelectedState, args.ClickLocation.Offset(new Vector2(-0.5f,-0.5f)), out _, component.Color, cleanable: true))
|
||||
if (!_decals.TryAddDecal(component.SelectedState, args.ClickLocation.Offset(new Vector2(-0.5f, -0.5f)), out _, component.Color, cleanable: true))
|
||||
return;
|
||||
|
||||
if (component.UseSound != null)
|
||||
_audio.PlayPvs(component.UseSound, uid, AudioHelpers.WithVariation(0.125f));
|
||||
_audio.PlayPvs(component.UseSound, uid, AudioParams.Default.WithVariation(0.125f));
|
||||
|
||||
// Decrease "Ammo"
|
||||
component.Charges--;
|
||||
@@ -100,7 +99,7 @@ public sealed class CrayonSystem : SharedCrayonSystem
|
||||
if (component.UserInterface?.SubscribedSessions.Contains(actor.PlayerSession) == true)
|
||||
{
|
||||
// Tell the user interface the selected stuff
|
||||
_uiSystem.SetUiState(component.UserInterface, new CrayonBoundUserInterfaceState(component.SelectedState, component.SelectableColor, component.Color));
|
||||
UserInterfaceSystem.SetUiState(component.UserInterface, new CrayonBoundUserInterfaceState(component.SelectedState, component.SelectableColor, component.Color));
|
||||
}
|
||||
|
||||
args.Handled = true;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Content.Server.DeviceLinking.Components;
|
||||
using Content.Server.Interaction;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.MachineLinking;
|
||||
@@ -17,7 +16,6 @@ public sealed class SignalTimerSystem : EntitySystem
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||
[Dependency] private readonly AccessReaderSystem _accessReader = default!;
|
||||
[Dependency] private readonly InteractionSystem _interaction = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -42,7 +40,7 @@ public sealed class SignalTimerSystem : EntitySystem
|
||||
|
||||
if (_ui.TryGetUi(uid, SignalTimerUiKey.Key, out var bui))
|
||||
{
|
||||
_ui.SetUiState(bui, new SignalTimerBoundUserInterfaceState(component.Label,
|
||||
UserInterfaceSystem.SetUiState(bui, new SignalTimerBoundUserInterfaceState(component.Label,
|
||||
TimeSpan.FromSeconds(component.Delay).Minutes.ToString("D2"),
|
||||
TimeSpan.FromSeconds(component.Delay).Seconds.ToString("D2"),
|
||||
component.CanEditLabel,
|
||||
@@ -62,7 +60,7 @@ public sealed class SignalTimerSystem : EntitySystem
|
||||
|
||||
if (_ui.TryGetUi(uid, SignalTimerUiKey.Key, out var bui))
|
||||
{
|
||||
_ui.SetUiState(bui, new SignalTimerBoundUserInterfaceState(signalTimer.Label,
|
||||
UserInterfaceSystem.SetUiState(bui, new SignalTimerBoundUserInterfaceState(signalTimer.Label,
|
||||
TimeSpan.FromSeconds(signalTimer.Delay).Minutes.ToString("D2"),
|
||||
TimeSpan.FromSeconds(signalTimer.Delay).Seconds.ToString("D2"),
|
||||
signalTimer.CanEditLabel,
|
||||
@@ -115,7 +113,7 @@ public sealed class SignalTimerSystem : EntitySystem
|
||||
if (!IsMessageValid(uid, args))
|
||||
return;
|
||||
|
||||
component.Label = args.Text[..Math.Min(5,args.Text.Length)];
|
||||
component.Label = args.Text[..Math.Min(5, args.Text.Length)];
|
||||
_appearanceSystem.SetData(uid, TextScreenVisuals.ScreenText, component.Label);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,15 +68,13 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
foreach (var component in EntityManager.EntityQuery<NetworkConfiguratorComponent>())
|
||||
var query = EntityQueryEnumerator<NetworkConfiguratorComponent>();
|
||||
while (query.MoveNext(out var uid, out var component))
|
||||
{
|
||||
var uid = component.Owner;
|
||||
|
||||
if (component.ActiveDeviceList != null && EntityManager.EntityExists(component.ActiveDeviceList.Value) &&
|
||||
_interactionSystem.InRangeUnobstructed(uid, component.ActiveDeviceList.Value))
|
||||
{
|
||||
if (component.ActiveDeviceList != null
|
||||
&& EntityManager.EntityExists(component.ActiveDeviceList.Value)
|
||||
&& _interactionSystem.InRangeUnobstructed(uid, component.ActiveDeviceList.Value))
|
||||
continue;
|
||||
}
|
||||
|
||||
//The network configurator is a handheld device. There can only ever be an ui session open for the player holding the device.
|
||||
_uiSystem.TryCloseAll(uid, NetworkConfiguratorUiKey.Configure);
|
||||
@@ -95,10 +93,10 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
if (!Resolve(configuratorUid, ref configurator))
|
||||
return;
|
||||
|
||||
TryAddNetworkDevice(targetUid, userUid, configurator);
|
||||
TryAddNetworkDevice(configuratorUid, targetUid, userUid, configurator);
|
||||
}
|
||||
|
||||
private void TryAddNetworkDevice(EntityUid? targetUid, EntityUid userUid, NetworkConfiguratorComponent configurator, DeviceNetworkComponent? device = null)
|
||||
private void TryAddNetworkDevice(EntityUid configuratorUid, EntityUid? targetUid, EntityUid userUid, NetworkConfiguratorComponent configurator, DeviceNetworkComponent? device = null)
|
||||
{
|
||||
if (!targetUid.HasValue || !Resolve(targetUid.Value, ref device, false))
|
||||
return;
|
||||
@@ -122,7 +120,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
return;
|
||||
}
|
||||
|
||||
address = $"UID: {targetUid.Value.ToString()}";
|
||||
address = $"UID: {targetUid.Value}";
|
||||
}
|
||||
|
||||
if (configurator.Devices.ContainsValue(targetUid.Value))
|
||||
@@ -135,7 +133,6 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
_popupSystem.PopupCursor(Loc.GetString("network-configurator-device-saved", ("address", device.Address), ("device", targetUid)),
|
||||
userUid, PopupType.Medium);
|
||||
|
||||
var configuratorUid = configurator.Owner;
|
||||
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low, $"{ToPrettyString(userUid):actor} saved {ToPrettyString(targetUid.Value):subject} to {ToPrettyString(configuratorUid):tool}");
|
||||
|
||||
UpdateListUiState(configuratorUid, configurator);
|
||||
@@ -167,11 +164,11 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
|| HasComp<DeviceLinkSinkComponent>(target) && HasComp<DeviceLinkSinkComponent>(configurator.ActiveDeviceLink))
|
||||
return;
|
||||
|
||||
_popupSystem.PopupEntity(Loc.GetString("network-configurator-link-mode-started", ("device", Name(target.Value))), target.Value, user);
|
||||
_popupSystem.PopupEntity(Loc.GetString("network-configurator-link-mode-started", ("device", Name(target.Value))), target.Value, user);
|
||||
configurator.ActiveDeviceLink = target;
|
||||
}
|
||||
|
||||
private void TryLinkDefaults(EntityUid uid, NetworkConfiguratorComponent configurator, EntityUid? targetUid, EntityUid user)
|
||||
private void TryLinkDefaults(EntityUid _, NetworkConfiguratorComponent configurator, EntityUid? targetUid, EntityUid user)
|
||||
{
|
||||
if (!configurator.LinkModeActive || !configurator.ActiveDeviceLink.HasValue
|
||||
|| !targetUid.HasValue || configurator.ActiveDeviceLink == targetUid)
|
||||
@@ -297,11 +294,11 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
|
||||
if (!HasComp<DeviceListComponent>(target))
|
||||
{
|
||||
TryAddNetworkDevice(target, user, configurator);
|
||||
TryAddNetworkDevice(uid, target, user, configurator);
|
||||
return;
|
||||
}
|
||||
|
||||
OpenDeviceListUi(target, user, configurator);
|
||||
OpenDeviceListUi(uid, target, user, configurator);
|
||||
}
|
||||
|
||||
private void DetermineMode(EntityUid configuratorUid, NetworkConfiguratorComponent configurator, EntityUid? target, EntityUid userUid)
|
||||
@@ -382,7 +379,8 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
return;
|
||||
}
|
||||
|
||||
if (configurator is {LinkModeActive: true, ActiveDeviceLink: { }} && (HasComp<DeviceLinkSinkComponent>(args.Target) || HasComp<DeviceLinkSourceComponent>(args.Target)))
|
||||
if (configurator is { LinkModeActive: true, ActiveDeviceLink: { } }
|
||||
&& (HasComp<DeviceLinkSinkComponent>(args.Target) || HasComp<DeviceLinkSourceComponent>(args.Target)))
|
||||
{
|
||||
AlternativeVerb verb = new()
|
||||
{
|
||||
@@ -460,7 +458,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
/// <summary>
|
||||
/// Opens the config ui. It can be used to modify the devices in the targets device list.
|
||||
/// </summary>
|
||||
private void OpenDeviceListUi(EntityUid? targetUid, EntityUid userUid, NetworkConfiguratorComponent configurator)
|
||||
private void OpenDeviceListUi(EntityUid configuratorUid, EntityUid? targetUid, EntityUid userUid, NetworkConfiguratorComponent configurator)
|
||||
{
|
||||
if (Delay(configurator))
|
||||
return;
|
||||
@@ -470,13 +468,15 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
|
||||
configurator.ActiveDeviceList = targetUid;
|
||||
Dirty(configurator);
|
||||
_uiSystem.GetUiOrNull(configurator.Owner, NetworkConfiguratorUiKey.Configure)?.Open(actor.PlayerSession);
|
||||
_uiSystem.TrySetUiState(
|
||||
configurator.Owner,
|
||||
NetworkConfiguratorUiKey.Configure,
|
||||
new DeviceListUserInterfaceState(
|
||||
|
||||
if (!_uiSystem.TryGetUi(configuratorUid, NetworkConfiguratorUiKey.Configure, out var bui))
|
||||
return;
|
||||
|
||||
if (_uiSystem.OpenUi(bui, actor.PlayerSession))
|
||||
UserInterfaceSystem.SetUiState(bui, new DeviceListUserInterfaceState(
|
||||
_deviceListSystem.GetDeviceList(configurator.ActiveDeviceList.Value)
|
||||
.Select(v => (v.Key, MetaData(v.Value).EntityName)).ToHashSet()));
|
||||
.Select(v => (v.Key, MetaData(v.Value).EntityName)).ToHashSet()
|
||||
));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -504,7 +504,8 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
component.Devices.Remove(invalidDevice);
|
||||
}
|
||||
|
||||
_uiSystem.GetUiOrNull(uid, NetworkConfiguratorUiKey.List)?.SetState(new NetworkConfiguratorUserInterfaceState(devices));
|
||||
if (_uiSystem.TryGetUi(uid, NetworkConfiguratorUiKey.List, out var bui))
|
||||
UserInterfaceSystem.SetUiState(bui, new NetworkConfiguratorUserInterfaceState(devices));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -4,7 +4,6 @@ using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Disposal.Unit.EntitySystems;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Disposal;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -178,7 +177,7 @@ public sealed class MailingUnitSystem : EntitySystem
|
||||
|
||||
var state = new MailingUnitBoundUserInterfaceState(component.DisposalUnitInterfaceState, component.Target, component.TargetList, component.Tag);
|
||||
if (_userInterfaceSystem.TryGetUi(uid, MailingUnitUiKey.Key, out var bui))
|
||||
_userInterfaceSystem.SetUiState(bui, state);
|
||||
UserInterfaceSystem.SetUiState(bui, state);
|
||||
}
|
||||
|
||||
private void OnTargetSelected(EntityUid uid, MailingUnitComponent component, TargetSelectedMessage args)
|
||||
|
||||
@@ -326,7 +326,7 @@ namespace Content.Server.Disposal.Tube
|
||||
}
|
||||
|
||||
if (_uiSystem.TryGetUi(uid, SharedDisposalTaggerComponent.DisposalTaggerUiKey.Key, out var bui))
|
||||
_uiSystem.SetUiState(bui, new SharedDisposalTaggerComponent.DisposalTaggerUserInterfaceState(tagger.Tag));
|
||||
UserInterfaceSystem.SetUiState(bui, new SharedDisposalTaggerComponent.DisposalTaggerUserInterfaceState(tagger.Tag));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -339,7 +339,7 @@ namespace Content.Server.Disposal.Tube
|
||||
if (router.Tags.Count <= 0)
|
||||
{
|
||||
if (bui is not null)
|
||||
_uiSystem.SetUiState(bui, new SharedDisposalTaggerComponent.DisposalTaggerUserInterfaceState(""));
|
||||
UserInterfaceSystem.SetUiState(bui, new SharedDisposalTaggerComponent.DisposalTaggerUserInterfaceState(""));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ namespace Content.Server.Disposal.Tube
|
||||
taglist.Remove(taglist.Length - 2, 2);
|
||||
|
||||
if (bui is not null)
|
||||
_uiSystem.SetUiState(bui, new SharedDisposalTaggerComponent.DisposalTaggerUserInterfaceState(taglist.ToString()));
|
||||
UserInterfaceSystem.SetUiState(bui, new SharedDisposalTaggerComponent.DisposalTaggerUserInterfaceState(taglist.ToString()));
|
||||
}
|
||||
|
||||
private void OnAnchorChange(EntityUid uid, DisposalTubeComponent component, ref AnchorStateChangedEvent args)
|
||||
|
||||
@@ -198,7 +198,9 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
|
||||
|
||||
// Just in case
|
||||
Clean((instrument).Owner);
|
||||
instrument.UserInterface?.CloseAll();
|
||||
|
||||
if (instrument.UserInterface is not null)
|
||||
_userInterfaceSystem.CloseAll(instrument.UserInterface);
|
||||
}
|
||||
|
||||
instrument.Timer += frameTime;
|
||||
@@ -217,7 +219,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
var ui = uid.GetUIOrNull(InstrumentUiKey.Key);
|
||||
ui?.Toggle(session);
|
||||
if (_userInterfaceSystem.TryGetUi(uid, InstrumentUiKey.Key, out var bui))
|
||||
_userInterfaceSystem.ToggleUi(bui, session);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,14 +50,14 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
|
||||
SubscribeLocalEvent<MicrowaveComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<MicrowaveComponent, SolutionChangedEvent>(OnSolutionChange);
|
||||
SubscribeLocalEvent<MicrowaveComponent, InteractUsingEvent>(OnInteractUsing, after: new[]{typeof(AnchorableSystem)});
|
||||
SubscribeLocalEvent<MicrowaveComponent, InteractUsingEvent>(OnInteractUsing, after: new[] { typeof(AnchorableSystem) });
|
||||
SubscribeLocalEvent<MicrowaveComponent, BreakageEventArgs>(OnBreak);
|
||||
SubscribeLocalEvent<MicrowaveComponent, PowerChangedEvent>(OnPowerChanged);
|
||||
SubscribeLocalEvent<MicrowaveComponent, SuicideEvent>(OnSuicide);
|
||||
SubscribeLocalEvent<MicrowaveComponent, RefreshPartsEvent>(OnRefreshParts);
|
||||
SubscribeLocalEvent<MicrowaveComponent, UpgradeExamineEvent>(OnUpgradeExamine);
|
||||
|
||||
SubscribeLocalEvent<MicrowaveComponent, MicrowaveStartCookMessage>((u,c,m) => Wzhzhzh(u,c,m.Session.AttachedEntity));
|
||||
SubscribeLocalEvent<MicrowaveComponent, MicrowaveStartCookMessage>((u, c, m) => Wzhzhzh(u, c, m.Session.AttachedEntity));
|
||||
SubscribeLocalEvent<MicrowaveComponent, MicrowaveEjectMessage>(OnEjectMessage);
|
||||
SubscribeLocalEvent<MicrowaveComponent, MicrowaveEjectSolidIndexedMessage>(OnEjectIndex);
|
||||
SubscribeLocalEvent<MicrowaveComponent, MicrowaveSelectCookTimeMessage>(OnSelectTime);
|
||||
@@ -70,7 +70,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
{
|
||||
if (!TryComp<MicrowaveComponent>(uid, out var microwaveComponent))
|
||||
return;
|
||||
SetAppearance(microwaveComponent, MicrowaveVisualState.Cooking);
|
||||
SetAppearance(uid, MicrowaveVisualState.Cooking, microwaveComponent);
|
||||
|
||||
microwaveComponent.PlayingStream =
|
||||
_audio.PlayPvs(microwaveComponent.LoopingSound, uid, AudioParams.Default.WithLoop(true).WithMaxDistance(5));
|
||||
@@ -80,7 +80,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
{
|
||||
if (!TryComp<MicrowaveComponent>(uid, out var microwaveComponent))
|
||||
return;
|
||||
SetAppearance(microwaveComponent, MicrowaveVisualState.Idle);
|
||||
SetAppearance(uid, MicrowaveVisualState.Idle, microwaveComponent);
|
||||
|
||||
microwaveComponent.PlayingStream?.Stop();
|
||||
}
|
||||
@@ -175,7 +175,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
|
||||
private void OnInit(EntityUid uid, MicrowaveComponent component, ComponentInit ags)
|
||||
{
|
||||
component.Storage = _container.EnsureContainer<Container>(uid,"microwave_entity_container");
|
||||
component.Storage = _container.EnsureContainer<Container>(uid, "microwave_entity_container");
|
||||
}
|
||||
|
||||
private void OnSuicide(EntityUid uid, MicrowaveComponent component, SuicideEvent args)
|
||||
@@ -227,7 +227,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
|
||||
private void OnInteractUsing(EntityUid uid, MicrowaveComponent component, InteractUsingEvent args)
|
||||
{
|
||||
if(args.Handled)
|
||||
if (args.Handled)
|
||||
return;
|
||||
if (!(TryComp<ApcPowerReceiverComponent>(uid, out var apc) && apc.Powered))
|
||||
{
|
||||
@@ -255,7 +255,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
private void OnBreak(EntityUid uid, MicrowaveComponent component, BreakageEventArgs args)
|
||||
{
|
||||
component.Broken = true;
|
||||
SetAppearance(component, MicrowaveVisualState.Broken);
|
||||
SetAppearance(uid, MicrowaveVisualState.Broken, component);
|
||||
RemComp<ActiveMicrowaveComponent>(uid);
|
||||
_sharedContainer.EmptyContainer(component.Storage);
|
||||
UpdateUserInterfaceState(uid, component);
|
||||
@@ -265,7 +265,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
{
|
||||
if (!args.Powered)
|
||||
{
|
||||
SetAppearance(component, MicrowaveVisualState.Idle);
|
||||
SetAppearance(uid, MicrowaveVisualState.Idle, component);
|
||||
RemComp<ActiveMicrowaveComponent>(uid);
|
||||
_sharedContainer.EmptyContainer(component.Storage);
|
||||
}
|
||||
@@ -288,22 +288,22 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
var ui = _userInterface.GetUiOrNull(uid, MicrowaveUiKey.Key);
|
||||
if (ui == null)
|
||||
return;
|
||||
var state = new MicrowaveUpdateUserInterfaceState(
|
||||
|
||||
UserInterfaceSystem.SetUiState(ui, new MicrowaveUpdateUserInterfaceState(
|
||||
component.Storage.ContainedEntities.ToArray(),
|
||||
HasComp<ActiveMicrowaveComponent>(uid),
|
||||
component.CurrentCookTimeButtonIndex,
|
||||
component.CurrentCookTimerTime
|
||||
);
|
||||
_userInterface.SetUiState(ui, state);
|
||||
));
|
||||
}
|
||||
|
||||
public void SetAppearance(MicrowaveComponent component, MicrowaveVisualState state)
|
||||
public void SetAppearance(EntityUid uid, MicrowaveVisualState state, MicrowaveComponent component)
|
||||
{
|
||||
var display = component.Broken ? MicrowaveVisualState.Broken : state;
|
||||
_appearance.SetData(component.Owner, PowerDeviceVisuals.VisualState, display);
|
||||
_appearance.SetData(uid, PowerDeviceVisuals.VisualState, display);
|
||||
}
|
||||
|
||||
public bool HasContents(MicrowaveComponent component)
|
||||
public static bool HasContents(MicrowaveComponent component)
|
||||
{
|
||||
return component.Storage.ContainedEntities.Any();
|
||||
}
|
||||
@@ -338,7 +338,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
if (_tag.HasTag(item, "MicrowaveMachineUnsafe") || _tag.HasTag(item, "Metal"))
|
||||
{
|
||||
component.Broken = true;
|
||||
SetAppearance(component, MicrowaveVisualState.Broken);
|
||||
SetAppearance(uid, MicrowaveVisualState.Broken, component);
|
||||
_audio.PlayPvs(component.ItemBreakSound, uid);
|
||||
return;
|
||||
}
|
||||
@@ -390,11 +390,11 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
UpdateUserInterfaceState(uid, component);
|
||||
}
|
||||
|
||||
public (FoodRecipePrototype, int) CanSatisfyRecipe(MicrowaveComponent component, FoodRecipePrototype recipe, Dictionary<string, int> solids, Dictionary<string, FixedPoint2> reagents)
|
||||
public static (FoodRecipePrototype, int) CanSatisfyRecipe(MicrowaveComponent component, FoodRecipePrototype recipe, Dictionary<string, int> solids, Dictionary<string, FixedPoint2> reagents)
|
||||
{
|
||||
var portions = 0;
|
||||
|
||||
if(component.CurrentCookTimerTime % recipe.CookTime != 0)
|
||||
if (component.CurrentCookTimerTime % recipe.CookTime != 0)
|
||||
{
|
||||
//can't be a multiple of this recipe
|
||||
return (recipe, 0);
|
||||
@@ -427,13 +427,15 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
}
|
||||
|
||||
//cook only as many of those portions as time allows
|
||||
return (recipe, (int)Math.Min(portions, component.CurrentCookTimerTime / recipe.CookTime));
|
||||
return (recipe, (int) Math.Min(portions, component.CurrentCookTimerTime / recipe.CookTime));
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
foreach (var (active, microwave) in EntityManager.EntityQuery<ActiveMicrowaveComponent, MicrowaveComponent>())
|
||||
|
||||
var query = EntityQueryEnumerator<ActiveMicrowaveComponent, MicrowaveComponent>();
|
||||
while (query.MoveNext(out var uid, out var active, out var microwave))
|
||||
{
|
||||
//check if there's still cook time left
|
||||
active.CookTimeRemaining -= frameTime;
|
||||
@@ -445,7 +447,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
|
||||
if (active.PortionedRecipe.Item1 != null)
|
||||
{
|
||||
var coords = Transform(microwave.Owner).Coordinates;
|
||||
var coords = Transform(uid).Coordinates;
|
||||
for (var i = 0; i < active.PortionedRecipe.Item2; i++)
|
||||
{
|
||||
SubtractContents(microwave, active.PortionedRecipe.Item1);
|
||||
@@ -454,9 +456,9 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
}
|
||||
|
||||
_sharedContainer.EmptyContainer(microwave.Storage);
|
||||
UpdateUserInterfaceState(microwave.Owner, microwave);
|
||||
EntityManager.RemoveComponentDeferred<ActiveMicrowaveComponent>(active.Owner);
|
||||
_audio.PlayPvs(microwave.FoodDoneSound, microwave.Owner, AudioParams.Default.WithVolume(-1));
|
||||
UpdateUserInterfaceState(uid, microwave);
|
||||
EntityManager.RemoveComponentDeferred<ActiveMicrowaveComponent>(uid);
|
||||
_audio.PlayPvs(microwave.FoodDoneSound, uid, AudioParams.Default.WithVolume(-1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Content.Server.Lathe
|
||||
SubscribeLocalEvent<LatheComponent, LatheQueueRecipeMessage>(OnLatheQueueRecipeMessage);
|
||||
SubscribeLocalEvent<LatheComponent, LatheSyncRequestMessage>(OnLatheSyncRequestMessage);
|
||||
|
||||
SubscribeLocalEvent<LatheComponent, BeforeActivatableUIOpenEvent>((u,c,_) => UpdateUserInterfaceState(u,c));
|
||||
SubscribeLocalEvent<LatheComponent, BeforeActivatableUIOpenEvent>((u, c, _) => UpdateUserInterfaceState(u, c));
|
||||
SubscribeLocalEvent<LatheComponent, MaterialAmountChangedEvent>(OnMaterialAmountChanged);
|
||||
|
||||
SubscribeLocalEvent<TechnologyDatabaseComponent, LatheGetRecipesEvent>(OnGetRecipes);
|
||||
@@ -55,12 +55,12 @@ namespace Content.Server.Lathe
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
var query = EntityQueryEnumerator<LatheProducingComponent, LatheComponent>();
|
||||
while(query.MoveNext(out var uid, out var comp, out var lathe))
|
||||
while (query.MoveNext(out var uid, out var comp, out var lathe))
|
||||
{
|
||||
if (lathe.CurrentRecipe == null)
|
||||
continue;
|
||||
|
||||
if ( _timing.CurTime - comp.StartTime >= comp.ProductionLength)
|
||||
if (_timing.CurTime - comp.StartTime >= comp.ProductionLength)
|
||||
FinishProducing(uid, lathe);
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ namespace Content.Server.Lathe
|
||||
if (args.Storage != uid)
|
||||
return;
|
||||
var materialWhitelist = new List<string>();
|
||||
var recipes = GetAllBaseRecipes(component);
|
||||
var recipes = GetAllBaseRecipes(component);
|
||||
foreach (var id in recipes)
|
||||
{
|
||||
if (!_proto.TryIndex<LatheRecipePrototype>(id, out var proto))
|
||||
@@ -108,7 +108,7 @@ namespace Content.Server.Lathe
|
||||
return ev.Recipes;
|
||||
}
|
||||
|
||||
public List<string> GetAllBaseRecipes(LatheComponent component)
|
||||
public static List<string> GetAllBaseRecipes(LatheComponent component)
|
||||
{
|
||||
return component.StaticRecipes.Union(component.DynamicRecipes).ToList();
|
||||
}
|
||||
@@ -186,7 +186,7 @@ namespace Content.Server.Lathe
|
||||
var producing = component.CurrentRecipe ?? component.Queue.FirstOrDefault();
|
||||
|
||||
var state = new LatheUpdateState(GetAvailableRecipes(uid, component), component.Queue, producing);
|
||||
_uiSys.SetUiState(ui, state);
|
||||
UserInterfaceSystem.SetUiState(ui, state);
|
||||
}
|
||||
|
||||
private void OnGetRecipes(EntityUid uid, TechnologyDatabaseComponent component, LatheGetRecipesEvent args)
|
||||
|
||||
@@ -2,7 +2,6 @@ using System.Linq;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.DeviceLinking.Components;
|
||||
using Content.Server.MachineLinking.Components;
|
||||
using Content.Server.MachineLinking.Events;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Tools;
|
||||
using Content.Shared.DeviceLinking.Events;
|
||||
@@ -246,9 +245,9 @@ namespace Content.Server.MachineLinking.System
|
||||
return;
|
||||
}
|
||||
|
||||
if (TryGetOrOpenUI(actor, linker, out var bui))
|
||||
if (TryGetOrOpenUI(args.Used, out var bui, actor))
|
||||
{
|
||||
TryUpdateUI(linker, transmitter, receiver, bui);
|
||||
TryUpdateUI(args.Used, uid, linker.SavedReceiver!.Value, bui, transmitter, receiver);
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
@@ -275,26 +274,29 @@ namespace Content.Server.MachineLinking.System
|
||||
return;
|
||||
}
|
||||
|
||||
if (TryGetOrOpenUI(actor, linker, out var bui))
|
||||
if (TryGetOrOpenUI(args.Used, out var bui, actor))
|
||||
{
|
||||
TryUpdateUI(linker, transmitter, receiver, bui);
|
||||
TryUpdateUI(args.Used, linker.SavedTransmitter!.Value, uid, bui, transmitter, receiver);
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryGetOrOpenUI(ActorComponent actor, SignalLinkerComponent linker, [NotNullWhen(true)] out BoundUserInterface? bui)
|
||||
private bool TryGetOrOpenUI(EntityUid linkerUid, [NotNullWhen(true)] out BoundUserInterface? bui, ActorComponent actor)
|
||||
{
|
||||
if (_userInterfaceSystem.TryGetUi(linker.Owner, SignalLinkerUiKey.Key, out bui))
|
||||
if (_userInterfaceSystem.TryGetUi(linkerUid, SignalLinkerUiKey.Key, out bui))
|
||||
{
|
||||
bui.Open(actor.PlayerSession);
|
||||
_userInterfaceSystem.OpenUi(bui, actor.PlayerSession);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool TryUpdateUI(SignalLinkerComponent linker, SignalTransmitterComponent transmitter, SignalReceiverComponent receiver, BoundUserInterface? bui = null)
|
||||
private bool TryUpdateUI(EntityUid linkerUid, EntityUid transmitterUid, EntityUid receiverUid, BoundUserInterface? bui = null, SignalTransmitterComponent? transmitter = null, SignalReceiverComponent? receiver = null)
|
||||
{
|
||||
if (bui == null && !_userInterfaceSystem.TryGetUi(linker.Owner, SignalLinkerUiKey.Key, out bui))
|
||||
if (!Resolve(transmitterUid, ref transmitter) || !Resolve(receiverUid, ref receiver))
|
||||
return false;
|
||||
|
||||
if (bui == null && !_userInterfaceSystem.TryGetUi(linkerUid, SignalLinkerUiKey.Key, out bui))
|
||||
return false;
|
||||
|
||||
var outKeys = transmitter.Outputs.Keys.ToList();
|
||||
@@ -304,24 +306,30 @@ namespace Content.Server.MachineLinking.System
|
||||
{
|
||||
foreach (var re in transmitter.Outputs[outKeys[i]])
|
||||
{
|
||||
if (re.Uid == receiver.Owner)
|
||||
if (re.Uid == receiverUid)
|
||||
links.Add((i, inKeys.IndexOf(re.Port)));
|
||||
}
|
||||
}
|
||||
|
||||
bui.SetState(new SignalPortsState($"{Name(transmitter.Owner)} ({transmitter.Owner})", outKeys,
|
||||
$"{Name(receiver.Owner)} ({receiver.Owner})", inKeys, links));
|
||||
UserInterfaceSystem.SetUiState(bui, new SignalPortsState(
|
||||
$"{Name(transmitterUid)} ({transmitterUid})",
|
||||
outKeys,
|
||||
$"{Name(receiverUid)} ({receiverUid})",
|
||||
inKeys,
|
||||
links
|
||||
));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private bool TryLink(SignalTransmitterComponent transmitter, SignalReceiverComponent receiver, SignalPortSelected args, EntityUid? user, bool quiet = false, bool checkRange = true)
|
||||
private bool TryLink(EntityUid transmitterUid, EntityUid receiverUid, SignalPortSelected args, EntityUid? user, bool quiet = false, bool checkRange = true, SignalTransmitterComponent? transmitter = null, SignalReceiverComponent? receiver = null)
|
||||
{
|
||||
if (!transmitter.Outputs.TryGetValue(args.TransmitterPort, out var linkedReceivers) ||
|
||||
!receiver.Inputs.TryGetValue(args.ReceiverPort, out var linkedTransmitters))
|
||||
{
|
||||
if (!Resolve(transmitterUid, ref transmitter) || !Resolve(receiverUid, ref receiver))
|
||||
return false;
|
||||
|
||||
if (!transmitter.Outputs.TryGetValue(args.TransmitterPort, out var linkedReceivers)
|
||||
|| !receiver.Inputs.TryGetValue(args.ReceiverPort, out var linkedTransmitters))
|
||||
return false;
|
||||
}
|
||||
|
||||
quiet |= !user.HasValue;
|
||||
|
||||
@@ -329,11 +337,11 @@ namespace Content.Server.MachineLinking.System
|
||||
// transmitter ports.
|
||||
foreach (var identifier in linkedTransmitters)
|
||||
{
|
||||
if (identifier.Uid == transmitter.Owner && identifier.Port == args.TransmitterPort)
|
||||
if (identifier.Uid == transmitterUid && identifier.Port == args.TransmitterPort)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkRange && !IsInRange(transmitter, receiver))
|
||||
if (checkRange && !IsInRange(transmitterUid, receiverUid, transmitter, receiver))
|
||||
{
|
||||
if (!quiet)
|
||||
_popupSystem.PopupCursor(Loc.GetString("signal-linker-component-out-of-range"), user!.Value);
|
||||
@@ -341,35 +349,35 @@ namespace Content.Server.MachineLinking.System
|
||||
}
|
||||
|
||||
// allow other systems to refuse the connection
|
||||
var linkAttempt = new LinkAttemptEvent(user, transmitter.Owner, args.TransmitterPort, receiver.Owner, args.ReceiverPort);
|
||||
RaiseLocalEvent(transmitter.Owner, linkAttempt, true);
|
||||
var linkAttempt = new LinkAttemptEvent(user, transmitterUid, args.TransmitterPort, receiverUid, args.ReceiverPort);
|
||||
RaiseLocalEvent(transmitterUid, linkAttempt, true);
|
||||
if (linkAttempt.Cancelled)
|
||||
{
|
||||
if (!quiet)
|
||||
_popupSystem.PopupCursor(Loc.GetString("signal-linker-component-connection-refused", ("machine", transmitter.Owner)), user!.Value);
|
||||
_popupSystem.PopupCursor(Loc.GetString("signal-linker-component-connection-refused", ("machine", transmitterUid)), user!.Value);
|
||||
return false;
|
||||
}
|
||||
RaiseLocalEvent(receiver.Owner, linkAttempt, true);
|
||||
RaiseLocalEvent(receiverUid, linkAttempt, true);
|
||||
if (linkAttempt.Cancelled)
|
||||
{
|
||||
if (!quiet)
|
||||
_popupSystem.PopupCursor(Loc.GetString("signal-linker-component-connection-refused", ("machine", receiver.Owner)), user!.Value);
|
||||
_popupSystem.PopupCursor(Loc.GetString("signal-linker-component-connection-refused", ("machine", receiverUid)), user!.Value);
|
||||
return false;
|
||||
}
|
||||
|
||||
linkedReceivers.Add(new(receiver.Owner, args.ReceiverPort));
|
||||
linkedTransmitters.Add(new(transmitter.Owner, args.TransmitterPort));
|
||||
linkedReceivers.Add(new(receiverUid, args.ReceiverPort));
|
||||
linkedTransmitters.Add(new(transmitterUid, args.TransmitterPort));
|
||||
if (!quiet)
|
||||
{
|
||||
_popupSystem.PopupCursor(Loc.GetString("signal-linker-component-linked-port",
|
||||
("machine1", transmitter.Owner), ("port1", PortName<TransmitterPortPrototype>(args.TransmitterPort)),
|
||||
("machine2", receiver.Owner), ("port2", PortName<ReceiverPortPrototype>(args.ReceiverPort))),
|
||||
("machine1", transmitterUid), ("port1", PortName<TransmitterPortPrototype>(args.TransmitterPort)),
|
||||
("machine2", receiverUid), ("port2", PortName<ReceiverPortPrototype>(args.ReceiverPort))),
|
||||
user!.Value, PopupType.Medium);
|
||||
}
|
||||
|
||||
var newLink = new NewLinkEvent(user, transmitter.Owner, args.TransmitterPort, receiver.Owner, args.ReceiverPort);
|
||||
RaiseLocalEvent(receiver.Owner, newLink);
|
||||
RaiseLocalEvent(transmitter.Owner, newLink);
|
||||
var newLink = new NewLinkEvent(user, transmitterUid, args.TransmitterPort, receiverUid, args.ReceiverPort);
|
||||
RaiseLocalEvent(receiverUid, newLink);
|
||||
RaiseLocalEvent(transmitterUid, newLink);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -382,22 +390,25 @@ namespace Content.Server.MachineLinking.System
|
||||
!receiver.Inputs.TryGetValue(args.ReceiverPort, out var transmitters))
|
||||
return;
|
||||
|
||||
if (args.Session.AttachedEntity is not { Valid: true} attached)
|
||||
if (args.Session.AttachedEntity is not { Valid: true } attached)
|
||||
return;
|
||||
|
||||
if (receivers.Contains(new(receiver.Owner, args.ReceiverPort)) ||
|
||||
transmitters.Contains(new(transmitter.Owner, args.TransmitterPort)))
|
||||
var receiverUid = linker.SavedReceiver.Value;
|
||||
var transmitterUid = linker.SavedTransmitter.Value;
|
||||
|
||||
if (receivers.Contains(new(receiverUid, args.ReceiverPort)) ||
|
||||
transmitters.Contains(new(transmitterUid, args.TransmitterPort)))
|
||||
{
|
||||
// link already exists, remove it
|
||||
if (receivers.Remove(new(receiver.Owner, args.ReceiverPort)) &&
|
||||
transmitters.Remove(new(transmitter.Owner, args.TransmitterPort)))
|
||||
if (receivers.Remove(new(receiverUid, args.ReceiverPort)) &&
|
||||
transmitters.Remove(new(transmitterUid, args.TransmitterPort)))
|
||||
{
|
||||
RaiseLocalEvent(receiver.Owner, new PortDisconnectedEvent(args.ReceiverPort), true);
|
||||
RaiseLocalEvent(transmitter.Owner, new PortDisconnectedEvent(args.TransmitterPort), true);
|
||||
RaiseLocalEvent(receiverUid, new PortDisconnectedEvent(args.ReceiverPort), true);
|
||||
RaiseLocalEvent(transmitterUid, new PortDisconnectedEvent(args.TransmitterPort), true);
|
||||
|
||||
_popupSystem.PopupCursor(Loc.GetString("signal-linker-component-unlinked-port",
|
||||
("machine1", transmitter.Owner), ("port1", PortName<TransmitterPortPrototype>(args.TransmitterPort)),
|
||||
("machine2", receiver.Owner), ("port2", PortName<ReceiverPortPrototype>(args.ReceiverPort))),
|
||||
("machine1", transmitterUid), ("port1", PortName<TransmitterPortPrototype>(args.TransmitterPort)),
|
||||
("machine2", receiverUid), ("port2", PortName<ReceiverPortPrototype>(args.ReceiverPort))),
|
||||
attached, PopupType.Medium);
|
||||
}
|
||||
else
|
||||
@@ -407,10 +418,10 @@ namespace Content.Server.MachineLinking.System
|
||||
}
|
||||
else
|
||||
{
|
||||
TryLink(transmitter, receiver, args, attached);
|
||||
TryLink(transmitterUid, receiverUid, args, attached, transmitter: transmitter, receiver: receiver);
|
||||
}
|
||||
|
||||
TryUpdateUI(linker, transmitter, receiver);
|
||||
TryUpdateUI(uid, transmitterUid, receiverUid, transmitter: transmitter, receiver: receiver);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -432,19 +443,22 @@ namespace Content.Server.MachineLinking.System
|
||||
!TryComp(linker.SavedReceiver, out SignalReceiverComponent? receiver))
|
||||
return;
|
||||
|
||||
var transmitterUid = linker.SavedTransmitter.Value;
|
||||
var receiverUid = linker.SavedReceiver.Value;
|
||||
|
||||
foreach (var (port, receivers) in transmitter.Outputs)
|
||||
{
|
||||
if (receivers.RemoveAll(id => id.Uid == receiver.Owner) > 0)
|
||||
RaiseLocalEvent(transmitter.Owner, new PortDisconnectedEvent(port), true);
|
||||
if (receivers.RemoveAll(id => id.Uid == receiverUid) > 0)
|
||||
RaiseLocalEvent(transmitterUid, new PortDisconnectedEvent(port), true);
|
||||
}
|
||||
|
||||
foreach (var (port, transmitters) in receiver.Inputs)
|
||||
{
|
||||
if (transmitters.RemoveAll(id => id.Uid == transmitter.Owner) > 0)
|
||||
RaiseLocalEvent(receiver.Owner, new PortDisconnectedEvent(port), true);
|
||||
if (transmitters.RemoveAll(id => id.Uid == transmitterUid) > 0)
|
||||
RaiseLocalEvent(receiverUid, new PortDisconnectedEvent(port), true);
|
||||
}
|
||||
|
||||
TryUpdateUI(linker, transmitter, receiver);
|
||||
TryUpdateUI(uid, transmitterUid, receiverUid, transmitter: transmitter, receiver: receiver);
|
||||
}
|
||||
|
||||
private void OnLinkerLinkDefaultSelected(EntityUid uid, SignalLinkerComponent linker, LinkerLinkDefaultSelected args)
|
||||
@@ -456,8 +470,11 @@ namespace Content.Server.MachineLinking.System
|
||||
if (args.Session.AttachedEntity is not { Valid: true } user)
|
||||
return;
|
||||
|
||||
TryLinkDefaults(linker.SavedReceiver!.Value, linker.SavedTransmitter!.Value, user, receiver, transmitter);
|
||||
TryUpdateUI(linker, transmitter, receiver);
|
||||
var transmitterUid = linker.SavedTransmitter!.Value;
|
||||
var receiverUid = linker.SavedReceiver!.Value;
|
||||
|
||||
TryLinkDefaults(receiverUid, transmitterUid, user, receiver, transmitter);
|
||||
TryUpdateUI(uid, transmitterUid, receiverUid, transmitter: transmitter, receiver: receiver);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -470,7 +487,7 @@ namespace Content.Server.MachineLinking.System
|
||||
if (!Resolve(receiverUid, ref receiver, false) || !Resolve(transmitterUid, ref transmitter, false))
|
||||
return false;
|
||||
|
||||
if (!IsInRange(transmitter, receiver))
|
||||
if (!IsInRange(transmitterUid, receiverUid, transmitter, receiver))
|
||||
return false;
|
||||
|
||||
var allLinksSucceeded = true;
|
||||
@@ -478,14 +495,14 @@ namespace Content.Server.MachineLinking.System
|
||||
// First, disconnect existing links.
|
||||
foreach (var (port, receivers) in transmitter.Outputs)
|
||||
{
|
||||
if (receivers.RemoveAll(id => id.Uid == receiver.Owner) > 0)
|
||||
RaiseLocalEvent(transmitter.Owner, new PortDisconnectedEvent(port), true);
|
||||
if (receivers.RemoveAll(id => id.Uid == receiverUid) > 0)
|
||||
RaiseLocalEvent(transmitterUid, new PortDisconnectedEvent(port), true);
|
||||
}
|
||||
|
||||
foreach (var (port, transmitters) in receiver.Inputs)
|
||||
{
|
||||
if (transmitters.RemoveAll(id => id.Uid == transmitter.Owner) > 0)
|
||||
RaiseLocalEvent(receiver.Owner, new PortDisconnectedEvent(port), true);
|
||||
if (transmitters.RemoveAll(id => id.Uid == transmitterUid) > 0)
|
||||
RaiseLocalEvent(receiverUid, new PortDisconnectedEvent(port), true);
|
||||
}
|
||||
|
||||
// Then make any valid default connections.
|
||||
@@ -498,7 +515,7 @@ namespace Content.Server.MachineLinking.System
|
||||
foreach (var inPort in prototype.DefaultLinks)
|
||||
{
|
||||
if (receiver.Inputs.ContainsKey(inPort))
|
||||
allLinksSucceeded &= TryLink(transmitter, receiver, new(outPort, inPort), user, quiet: true, checkRange: false);
|
||||
allLinksSucceeded &= TryLink(transmitterUid, receiverUid, new(outPort, inPort), user, quiet: true, checkRange: false, transmitter: transmitter, receiver: receiver);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,16 +528,16 @@ namespace Content.Server.MachineLinking.System
|
||||
component.SavedReceiver = null;
|
||||
}
|
||||
|
||||
private bool IsInRange(SignalTransmitterComponent transmitterComponent, SignalReceiverComponent receiverComponent)
|
||||
private bool IsInRange(EntityUid transmitterUid, EntityUid receiverUid, SignalTransmitterComponent transmitterComponent, SignalReceiverComponent _)
|
||||
{
|
||||
if (TryComp(transmitterComponent.Owner, out ApcPowerReceiverComponent? transmitterPower) &&
|
||||
TryComp(receiverComponent.Owner, out ApcPowerReceiverComponent? receiverPower) &&
|
||||
if (TryComp(transmitterUid, out ApcPowerReceiverComponent? transmitterPower) &&
|
||||
TryComp(receiverUid, out ApcPowerReceiverComponent? receiverPower) &&
|
||||
transmitterPower.Provider?.Net == receiverPower.Provider?.Net)
|
||||
return true;
|
||||
|
||||
// TODO: As elsewhere don't use mappos inrange.
|
||||
return Comp<TransformComponent>(transmitterComponent.Owner).MapPosition.InRange(
|
||||
Comp<TransformComponent>(receiverComponent.Owner).MapPosition, transmitterComponent.TransmissionRange);
|
||||
return Comp<TransformComponent>(transmitterUid).MapPosition.InRange(
|
||||
Comp<TransformComponent>(receiverUid).MapPosition, transmitterComponent.TransmissionRange);
|
||||
}
|
||||
|
||||
private bool IsLinkerInteractable(EntityUid uid, SignalLinkerComponent linkerComponent)
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Linq;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Mech.Components;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.DoAfter;
|
||||
@@ -33,6 +34,7 @@ public sealed class MechSystem : SharedMechSystem
|
||||
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly BatterySystem _batterySystem = default!;
|
||||
|
||||
private ISawmill _sawmill = default!;
|
||||
|
||||
@@ -69,7 +71,7 @@ public sealed class MechSystem : SharedMechSystem
|
||||
#endregion
|
||||
}
|
||||
|
||||
private void OnMechCanMoveEvent(EntityUid uid, MechComponent component , UpdateCanMoveEvent args)
|
||||
private void OnMechCanMoveEvent(EntityUid uid, MechComponent component, UpdateCanMoveEvent args)
|
||||
{
|
||||
if (component.Broken || component.Integrity <= 0 || component.Energy <= 0)
|
||||
args.Cancel();
|
||||
@@ -300,7 +302,7 @@ public sealed class MechSystem : SharedMechSystem
|
||||
EquipmentStates = ev.States
|
||||
};
|
||||
var ui = _ui.GetUi(uid, MechUiKey.Key);
|
||||
_ui.SetUiState(ui, state);
|
||||
UserInterfaceSystem.SetUiState(ui, state);
|
||||
}
|
||||
|
||||
public override bool TryInsert(EntityUid uid, EntityUid? toInsert, MechComponent? component = null)
|
||||
@@ -318,7 +320,7 @@ public sealed class MechSystem : SharedMechSystem
|
||||
{
|
||||
var tile = grid.GetTileRef(coordinates);
|
||||
|
||||
if (_atmosphere.GetTileMixture(tile.GridUid, null, tile.GridIndices, true) is {} environment)
|
||||
if (_atmosphere.GetTileMixture(tile.GridUid, null, tile.GridIndices, true) is { } environment)
|
||||
{
|
||||
_atmosphere.Merge(mechAir.Air, environment.RemoveVolume(MechAirComponent.GasMixVolume));
|
||||
}
|
||||
@@ -342,7 +344,7 @@ public sealed class MechSystem : SharedMechSystem
|
||||
{
|
||||
var tile = grid.GetTileRef(coordinates);
|
||||
|
||||
if (_atmosphere.GetTileMixture(tile.GridUid, null, tile.GridIndices, true) is {} environment)
|
||||
if (_atmosphere.GetTileMixture(tile.GridUid, null, tile.GridIndices, true) is { } environment)
|
||||
{
|
||||
_atmosphere.Merge(environment, mechAir.Air);
|
||||
mechAir.Air.Clear();
|
||||
@@ -376,7 +378,7 @@ public sealed class MechSystem : SharedMechSystem
|
||||
if (!TryComp<BatteryComponent>(battery, out var batteryComp))
|
||||
return false;
|
||||
|
||||
batteryComp.CurrentCharge = batteryComp.CurrentCharge + delta.Float();
|
||||
_batterySystem.SetCharge(battery!.Value, batteryComp.CurrentCharge + delta.Float(), batteryComp);
|
||||
if (batteryComp.CurrentCharge != component.Energy) //if there's a discrepency, we have to resync them
|
||||
{
|
||||
_sawmill.Debug($"Battery charge was not equal to mech charge. Battery {batteryComp.CurrentCharge}. Mech {component.Energy}");
|
||||
|
||||
@@ -1,23 +1,17 @@
|
||||
using System.Linq;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Medical.SuitSensors;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Medical.CrewMonitoring;
|
||||
using Robust.Shared.Map;
|
||||
using Content.Shared.Medical.SuitSensor;
|
||||
using Robust.Shared.Timing;
|
||||
using Content.Server.PowerCell;
|
||||
using Content.Shared.Medical.CrewMonitoring;
|
||||
using Content.Shared.Medical.SuitSensor;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
namespace Content.Server.Medical.CrewMonitoring
|
||||
{
|
||||
public sealed class CrewMonitoringConsoleSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SuitSensorSystem _sensors = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _xform = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly PowerCellSystem _cell = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -60,14 +54,12 @@ namespace Content.Server.Medical.CrewMonitoring
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
var ui = component.Owner.GetUIOrNull(CrewMonitoringUIKey.Key);
|
||||
if (ui == null)
|
||||
if (!_uiSystem.TryGetUi(uid, CrewMonitoringUIKey.Key, out var bui))
|
||||
return;
|
||||
|
||||
// update all sensors info
|
||||
var allSensors = component.ConnectedSensors.Values.ToList();
|
||||
var uiState = new CrewMonitoringState(allSensors, component.Snap, component.Precision);
|
||||
ui.SetState(uiState);
|
||||
UserInterfaceSystem.SetUiState(bui, new CrewMonitoringState(allSensors, component.Snap, component.Precision));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace Content.Server.Medical
|
||||
!CanScannerInsert(uid, args.Using.Value, component))
|
||||
return;
|
||||
|
||||
string name = "Unknown";
|
||||
var name = "Unknown";
|
||||
if (TryComp<MetaDataComponent>(args.Using.Value, out var metadata))
|
||||
name = metadata.EntityName;
|
||||
|
||||
@@ -109,11 +109,13 @@ namespace Content.Server.Medical
|
||||
// Eject verb
|
||||
if (IsOccupied(component))
|
||||
{
|
||||
AlternativeVerb verb = new();
|
||||
verb.Act = () => EjectBody(uid, component);
|
||||
verb.Category = VerbCategory.Eject;
|
||||
verb.Text = Loc.GetString("medical-scanner-verb-noun-occupant");
|
||||
verb.Priority = 1; // Promote to top to make ejecting the ALT-click action
|
||||
AlternativeVerb verb = new()
|
||||
{
|
||||
Act = () => EjectBody(uid, component),
|
||||
Category = VerbCategory.Eject,
|
||||
Text = Loc.GetString("medical-scanner-verb-noun-occupant"),
|
||||
Priority = 1 // Promote to top to make ejecting the ALT-click action
|
||||
};
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
@@ -122,9 +124,11 @@ namespace Content.Server.Medical
|
||||
CanScannerInsert(uid, args.User, component) &&
|
||||
_blocker.CanMove(args.User))
|
||||
{
|
||||
AlternativeVerb verb = new();
|
||||
verb.Act = () => InsertBody(uid, args.User, component);
|
||||
verb.Text = Loc.GetString("medical-scanner-verb-enter");
|
||||
AlternativeVerb verb = new()
|
||||
{
|
||||
Act = () => InsertBody(uid, args.User, component),
|
||||
Text = Loc.GetString("medical-scanner-verb-enter")
|
||||
};
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
}
|
||||
@@ -154,7 +158,7 @@ namespace Content.Server.Medical
|
||||
_cloningConsoleSystem.RecheckConnections(component.ConnectedConsole.Value, console.CloningPod, uid, console);
|
||||
return;
|
||||
}
|
||||
_cloningConsoleSystem.UpdateUserInterface(console);
|
||||
_cloningConsoleSystem.UpdateUserInterface(component.ConnectedConsole.Value, console);
|
||||
}
|
||||
private MedicalScannerStatus GetStatus(EntityUid uid, MedicalScannerComponent scannerComponent)
|
||||
{
|
||||
@@ -174,7 +178,7 @@ namespace Content.Server.Medical
|
||||
return MedicalScannerStatus.Off;
|
||||
}
|
||||
|
||||
public bool IsOccupied(MedicalScannerComponent scannerComponent)
|
||||
public static bool IsOccupied(MedicalScannerComponent scannerComponent)
|
||||
{
|
||||
return scannerComponent.BodyContainer.ContainedEntity != null;
|
||||
}
|
||||
@@ -212,7 +216,7 @@ namespace Content.Server.Medical
|
||||
_updateDif -= UpdateRate;
|
||||
|
||||
var query = EntityQueryEnumerator<MedicalScannerComponent>();
|
||||
while(query.MoveNext(out var uid, out var scanner))
|
||||
while (query.MoveNext(out var uid, out var scanner))
|
||||
{
|
||||
UpdateAppearance(uid, scanner);
|
||||
}
|
||||
@@ -238,7 +242,7 @@ namespace Content.Server.Medical
|
||||
if (!Resolve(uid, ref scannerComponent))
|
||||
return;
|
||||
|
||||
if (scannerComponent.BodyContainer.ContainedEntity is not {Valid: true} contained)
|
||||
if (scannerComponent.BodyContainer.ContainedEntity is not { Valid: true } contained)
|
||||
return;
|
||||
|
||||
scannerComponent.BodyContainer.Remove(contained);
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Content.Server.Nuke
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _xformSystem = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Used to calculate when the nuke song should start playing for maximum kino with the nuke sfx
|
||||
@@ -82,16 +83,16 @@ namespace Content.Server.Nuke
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var query = EntityQuery<NukeComponent>();
|
||||
foreach (var nuke in query)
|
||||
var query = EntityQueryEnumerator<NukeComponent>();
|
||||
while (query.MoveNext(out var uid, out var nuke))
|
||||
{
|
||||
switch (nuke.Status)
|
||||
{
|
||||
case NukeStatus.ARMED:
|
||||
TickTimer(nuke.Owner, frameTime, nuke);
|
||||
TickTimer(uid, frameTime, nuke);
|
||||
break;
|
||||
case NukeStatus.COOLDOWN:
|
||||
TickCooldown(nuke.Owner, frameTime, nuke);
|
||||
TickCooldown(uid, frameTime, nuke);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -180,8 +181,11 @@ namespace Content.Server.Nuke
|
||||
|
||||
// manually set transform anchor (bypassing anchorable)
|
||||
// todo: it will break pullable system
|
||||
transform.Coordinates = transform.Coordinates.SnapToGrid();
|
||||
transform.Anchored = !transform.Anchored;
|
||||
_xformSystem.SetCoordinates(uid, transform, transform.Coordinates.SnapToGrid());
|
||||
if (transform.Anchored)
|
||||
_xformSystem.Unanchor(uid, transform);
|
||||
else
|
||||
_xformSystem.AnchorEntity(uid, transform);
|
||||
|
||||
UpdateUserInterface(uid, component);
|
||||
}
|
||||
@@ -243,7 +247,7 @@ namespace Content.Server.Nuke
|
||||
|
||||
private void OnDoAfter(EntityUid uid, NukeComponent component, DoAfterEvent args)
|
||||
{
|
||||
if(args.Handled || args.Cancelled)
|
||||
if (args.Handled || args.Cancelled)
|
||||
return;
|
||||
|
||||
DisarmBomb(uid, component);
|
||||
@@ -317,7 +321,6 @@ namespace Content.Server.Nuke
|
||||
component.Status = NukeStatus.AWAIT_CODE;
|
||||
break;
|
||||
case NukeStatus.AWAIT_CODE:
|
||||
{
|
||||
if (!component.DiskSlot.HasItem)
|
||||
{
|
||||
component.Status = NukeStatus.AWAIT_DISK;
|
||||
@@ -339,7 +342,6 @@ namespace Content.Server.Nuke
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case NukeStatus.AWAIT_ARM:
|
||||
// do nothing, wait for arm button to be pressed
|
||||
break;
|
||||
@@ -378,7 +380,7 @@ namespace Content.Server.Nuke
|
||||
CooldownTime = (int) component.CooldownTime
|
||||
};
|
||||
|
||||
_ui.SetUiState(ui, state);
|
||||
UserInterfaceSystem.SetUiState(ui, state);
|
||||
}
|
||||
|
||||
private void PlayNukeKeypadSound(EntityUid uid, int number, NukeComponent? component = null)
|
||||
@@ -444,7 +446,7 @@ namespace Content.Server.Nuke
|
||||
if (stationUid != null)
|
||||
_alertLevel.SetLevel(stationUid.Value, component.AlertLevelOnActivate, true, true, true, true);
|
||||
|
||||
var pos = nukeXform.MapPosition;
|
||||
var pos = nukeXform.MapPosition;
|
||||
var x = (int) pos.X;
|
||||
var y = (int) pos.Y;
|
||||
var posText = $"({x}, {y})";
|
||||
@@ -458,7 +460,7 @@ namespace Content.Server.Nuke
|
||||
_soundSystem.PlayGlobalOnStation(uid, _audio.GetSound(component.ArmSound));
|
||||
|
||||
_itemSlots.SetLock(uid, component.DiskSlot, true);
|
||||
nukeXform.Anchored = true;
|
||||
_xformSystem.AnchorEntity(uid, nukeXform);
|
||||
component.Status = NukeStatus.ARMED;
|
||||
UpdateUserInterface(uid, component);
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace Content.Server.PDA.Ringer
|
||||
private void UpdateRingerUserInterface(EntityUid uid, RingerComponent ringer)
|
||||
{
|
||||
if (_ui.TryGetUi(uid, RingerUiKey.Key, out var bui))
|
||||
_ui.SetUiState(bui, new RingerUpdateState(HasComp<ActiveRingerComponent>(uid), ringer.Ringtone));
|
||||
UserInterfaceSystem.SetUiState(bui, new RingerUpdateState(HasComp<ActiveRingerComponent>(uid), ringer.Ringtone));
|
||||
}
|
||||
|
||||
public bool ToggleRingerUI(EntityUid uid, IPlayerSession session)
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Content.Server.Paper
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
|
||||
public override void Initialize()
|
||||
@@ -88,7 +89,7 @@ namespace Content.Server.Paper
|
||||
|
||||
if (paperComp.StampedBy.Count > 0)
|
||||
{
|
||||
string commaSeparated = string.Join(", ", paperComp.StampedBy);
|
||||
var commaSeparated = string.Join(", ", paperComp.StampedBy);
|
||||
args.PushMarkup(
|
||||
Loc.GetString(
|
||||
"paper-component-examine-detail-stamped-by", ("paper", uid), ("stamps", commaSeparated))
|
||||
@@ -115,10 +116,11 @@ namespace Content.Server.Paper
|
||||
if (TryComp<StampComponent>(args.Used, out var stampComp) && TryStamp(uid, stampComp.StampedName, stampComp.StampState, paperComp))
|
||||
{
|
||||
// successfully stamped, play popup
|
||||
var stampPaperOtherMessage = Loc.GetString("paper-component-action-stamp-paper-other", ("user", Identity.Entity(args.User, EntityManager)),("target", Identity.Entity(args.Target, EntityManager)),("stamp", args.Used));
|
||||
_popupSystem.PopupEntity(stampPaperOtherMessage, args.User, Filter.PvsExcept(args.User, entityManager: EntityManager), true);
|
||||
var stampPaperSelfMessage = Loc.GetString("paper-component-action-stamp-paper-self", ("target", Identity.Entity(args.Target, EntityManager)),("stamp", args.Used));
|
||||
_popupSystem.PopupEntity(stampPaperSelfMessage, args.User, args.User);
|
||||
var stampPaperOtherMessage = Loc.GetString("paper-component-action-stamp-paper-other", ("user", Identity.Entity(args.User, EntityManager)), ("target", Identity.Entity(args.Target, EntityManager)), ("stamp", args.Used));
|
||||
_popupSystem.PopupEntity(stampPaperOtherMessage, args.User, Filter.PvsExcept(args.User, entityManager: EntityManager), true);
|
||||
|
||||
var stampPaperSelfMessage = Loc.GetString("paper-component-action-stamp-paper-self", ("target", Identity.Entity(args.Target, EntityManager)), ("stamp", args.Used));
|
||||
_popupSystem.PopupEntity(stampPaperSelfMessage, args.User, args.User);
|
||||
|
||||
_audio.PlayPvs(stampComp.Sound, uid);
|
||||
|
||||
@@ -140,7 +142,7 @@ namespace Content.Server.Paper
|
||||
_appearance.SetData(uid, PaperVisuals.Status, PaperStatus.Written, appearance);
|
||||
|
||||
if (TryComp<MetaDataComponent>(uid, out var meta))
|
||||
meta.EntityDescription = "";
|
||||
_metaSystem.SetEntityDescription(uid, "", meta);
|
||||
|
||||
if (args.Session.AttachedEntity != null)
|
||||
_adminLogger.Add(LogType.Chat, LogImpact.Low,
|
||||
@@ -198,8 +200,8 @@ namespace Content.Server.Paper
|
||||
if (!Resolve(uid, ref paperComp))
|
||||
return;
|
||||
|
||||
var state = new PaperBoundUserInterfaceState(paperComp.Content, paperComp.StampedBy, paperComp.Mode);
|
||||
_uiSystem.TrySetUiState(uid, PaperUiKey.Key, state, session);
|
||||
if (_uiSystem.TryGetUi(uid, PaperUiKey.Key, out var bui))
|
||||
UserInterfaceSystem.SetUiState(bui, new PaperBoundUserInterfaceState(paperComp.Content, paperComp.StampedBy, paperComp.Mode), session);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.ParticleAccelerator.Components;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Singularity.Components;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Utility;
|
||||
using System.Diagnostics;
|
||||
|
||||
@@ -69,7 +69,7 @@ public sealed partial class ParticleAcceleratorSystem
|
||||
if (comp.Enabled || !comp.CanBeEnabled)
|
||||
return;
|
||||
|
||||
if (user?.AttachedEntity is {} player)
|
||||
if (user?.AttachedEntity is { } player)
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(player):player} has turned {ToPrettyString(uid)} on");
|
||||
|
||||
comp.Enabled = true;
|
||||
@@ -89,7 +89,7 @@ public sealed partial class ParticleAcceleratorSystem
|
||||
if (!comp.Enabled)
|
||||
return;
|
||||
|
||||
if (user?.AttachedEntity is {} player)
|
||||
if (user?.AttachedEntity is { } player)
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(player):player} has turned {ToPrettyString(uid)} off");
|
||||
|
||||
comp.Enabled = false;
|
||||
@@ -146,7 +146,7 @@ public sealed partial class ParticleAcceleratorSystem
|
||||
if (strength == comp.SelectedStrength)
|
||||
return;
|
||||
|
||||
if (user?.AttachedEntity is {} player)
|
||||
if (user?.AttachedEntity is { } player)
|
||||
{
|
||||
var impact = strength switch
|
||||
{
|
||||
@@ -221,7 +221,7 @@ public sealed partial class ParticleAcceleratorSystem
|
||||
receive = powerConsumer.ReceivedPower;
|
||||
}
|
||||
|
||||
_uiSystem.SetUiState(bui, new ParticleAcceleratorUIState(
|
||||
UserInterfaceSystem.SetUiState(bui, new ParticleAcceleratorUIState(
|
||||
comp.Assembled,
|
||||
comp.Enabled,
|
||||
comp.SelectedStrength,
|
||||
|
||||
@@ -11,8 +11,6 @@ using Content.Shared.Shuttles.Systems;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.Physics.Controllers
|
||||
{
|
||||
@@ -20,8 +18,9 @@ namespace Content.Server.Physics.Controllers
|
||||
{
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly ThrusterSystem _thruster = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _xformSystem = default!;
|
||||
|
||||
private Dictionary<ShuttleComponent, List<(PilotComponent, InputMoverComponent, TransformComponent)>> _shuttlePilots = new();
|
||||
private Dictionary<EntityUid, (ShuttleComponent, List<(EntityUid, PilotComponent, InputMoverComponent, TransformComponent)>)> _shuttlePilots = new();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -165,7 +164,8 @@ namespace Content.Server.Physics.Controllers
|
||||
|
||||
protected override void HandleShuttleInput(EntityUid uid, ShuttleButtons button, ushort subTick, bool state)
|
||||
{
|
||||
if (!TryComp<PilotComponent>(uid, out var pilot) || pilot.Console == null) return;
|
||||
if (!TryComp<PilotComponent>(uid, out var pilot) || pilot.Console == null)
|
||||
return;
|
||||
|
||||
ResetSubtick(pilot);
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace Content.Server.Physics.Controllers
|
||||
pilot.HeldButtons = buttons;
|
||||
}
|
||||
|
||||
private void ApplyTick(PilotComponent component, float fraction)
|
||||
private static void ApplyTick(PilotComponent component, float fraction)
|
||||
{
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
@@ -248,12 +248,14 @@ namespace Content.Server.Physics.Controllers
|
||||
|
||||
private void HandleShuttleMovement(float frameTime)
|
||||
{
|
||||
var newPilots = new Dictionary<ShuttleComponent, List<(PilotComponent Pilot, InputMoverComponent Mover, TransformComponent ConsoleXform)>>();
|
||||
var newPilots = new Dictionary<EntityUid, (ShuttleComponent Shuttle, List<(EntityUid PilotUid, PilotComponent Pilot, InputMoverComponent Mover, TransformComponent ConsoleXform)>)>();
|
||||
|
||||
// We just mark off their movement and the shuttle itself does its own movement
|
||||
foreach (var (pilot, mover) in EntityManager.EntityQuery<PilotComponent, InputMoverComponent>())
|
||||
var activePilotQuery = EntityQueryEnumerator<PilotComponent, InputMoverComponent>();
|
||||
var shuttleQuery = GetEntityQuery<ShuttleComponent>();
|
||||
while (activePilotQuery.MoveNext(out var uid, out var pilot, out var mover))
|
||||
{
|
||||
var consoleEnt = pilot.Console?.Owner;
|
||||
var consoleEnt = pilot.Console;
|
||||
|
||||
// TODO: This is terrible. Just make a new mover and also make it remote piloting + device networks
|
||||
if (TryComp<DroneConsoleComponent>(consoleEnt, out var cargoConsole))
|
||||
@@ -265,23 +267,25 @@ namespace Content.Server.Physics.Controllers
|
||||
|
||||
var gridId = xform.GridUid;
|
||||
// This tries to see if the grid is a shuttle and if the console should work.
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid) ||
|
||||
!EntityManager.TryGetComponent(grid.Owner, out ShuttleComponent? shuttleComponent) ||
|
||||
!shuttleComponent.Enabled) continue;
|
||||
if (!_mapManager.TryGetGrid(gridId, out var _) ||
|
||||
!shuttleQuery.TryGetComponent(gridId, out var shuttleComponent) ||
|
||||
!shuttleComponent.Enabled)
|
||||
continue;
|
||||
|
||||
if (!newPilots.TryGetValue(shuttleComponent, out var pilots))
|
||||
if (!newPilots.TryGetValue(gridId!.Value, out var pilots))
|
||||
{
|
||||
pilots = new List<(PilotComponent, InputMoverComponent, TransformComponent)>();
|
||||
newPilots[shuttleComponent] = pilots;
|
||||
pilots = (shuttleComponent, new List<(EntityUid, PilotComponent, InputMoverComponent, TransformComponent)>());
|
||||
newPilots[gridId.Value] = pilots;
|
||||
}
|
||||
|
||||
pilots.Add((pilot, mover, xform));
|
||||
pilots.Item2.Add((uid, pilot, mover, xform));
|
||||
}
|
||||
|
||||
// Reset inputs for non-piloted shuttles.
|
||||
foreach (var (shuttle, _) in _shuttlePilots)
|
||||
foreach (var (shuttleUid, (shuttle, _)) in _shuttlePilots)
|
||||
{
|
||||
if (newPilots.ContainsKey(shuttle) || CanPilot(shuttle)) continue;
|
||||
if (newPilots.ContainsKey(shuttleUid) || CanPilot(shuttleUid))
|
||||
continue;
|
||||
|
||||
_thruster.DisableLinearThrusters(shuttle);
|
||||
}
|
||||
@@ -290,35 +294,37 @@ namespace Content.Server.Physics.Controllers
|
||||
|
||||
// Collate all of the linear / angular velocites for a shuttle
|
||||
// then do the movement input once for it.
|
||||
foreach (var (shuttle, pilots) in _shuttlePilots)
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
foreach (var (shuttleUid, (shuttle, pilots)) in _shuttlePilots)
|
||||
{
|
||||
if (Paused(shuttle.Owner) || CanPilot(shuttle) || !TryComp(shuttle.Owner, out PhysicsComponent? body)) continue;
|
||||
if (Paused(shuttleUid) || CanPilot(shuttleUid) || !TryComp<PhysicsComponent>(shuttleUid, out var body))
|
||||
continue;
|
||||
|
||||
var shuttleNorthAngle = Transform(body.Owner).WorldRotation;
|
||||
var shuttleNorthAngle = _xformSystem.GetWorldRotation(shuttleUid, xformQuery);
|
||||
|
||||
// Collate movement linear and angular inputs together
|
||||
var linearInput = Vector2.Zero;
|
||||
var brakeInput = 0f;
|
||||
var angularInput = 0f;
|
||||
|
||||
foreach (var (pilot, _, consoleXform) in pilots)
|
||||
foreach (var (pilotUid, pilot, _, consoleXform) in pilots)
|
||||
{
|
||||
var pilotInput = GetPilotVelocityInput(pilot);
|
||||
var (strafe, rotation, brakes) = GetPilotVelocityInput(pilot);
|
||||
|
||||
if (pilotInput.Brakes > 0f)
|
||||
if (brakes > 0f)
|
||||
{
|
||||
brakeInput += pilotInput.Brakes;
|
||||
brakeInput += brakes;
|
||||
}
|
||||
|
||||
if (pilotInput.Strafe.Length() > 0f)
|
||||
if (strafe.Length() > 0f)
|
||||
{
|
||||
var offsetRotation = consoleXform.LocalRotation;
|
||||
linearInput += offsetRotation.RotateVec(pilotInput.Strafe);
|
||||
linearInput += offsetRotation.RotateVec(strafe);
|
||||
}
|
||||
|
||||
if (pilotInput.Rotation != 0f)
|
||||
if (rotation != 0f)
|
||||
{
|
||||
angularInput += pilotInput.Rotation;
|
||||
angularInput += rotation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,7 +396,7 @@ namespace Content.Server.Physics.Controllers
|
||||
if (impulse.Length() > maxVelocity)
|
||||
impulse = impulse.Normalized() * maxVelocity;
|
||||
|
||||
PhysicsSystem.ApplyForce(shuttle.Owner, impulse, body: body);
|
||||
PhysicsSystem.ApplyForce(shuttleUid, impulse, body: body);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -413,7 +419,7 @@ namespace Content.Server.Physics.Controllers
|
||||
|
||||
if (!torque.Equals(0f))
|
||||
{
|
||||
PhysicsSystem.ApplyTorque(shuttle.Owner, torque, body: body);
|
||||
PhysicsSystem.ApplyTorque(shuttleUid, torque, body: body);
|
||||
_thruster.SetAngularThrust(shuttle, true);
|
||||
}
|
||||
}
|
||||
@@ -425,14 +431,14 @@ namespace Content.Server.Physics.Controllers
|
||||
|
||||
if (linearInput.Length().Equals(0f))
|
||||
{
|
||||
PhysicsSystem.SetSleepingAllowed(shuttle.Owner, body, true);
|
||||
PhysicsSystem.SetSleepingAllowed(shuttleUid, body, true);
|
||||
|
||||
if (brakeInput.Equals(0f))
|
||||
_thruster.DisableLinearThrusters(shuttle);
|
||||
}
|
||||
else
|
||||
{
|
||||
PhysicsSystem.SetSleepingAllowed(shuttle.Owner, body, false);
|
||||
PhysicsSystem.SetSleepingAllowed(shuttleUid, body, false);
|
||||
var angle = linearInput.ToWorldAngle();
|
||||
var linearDir = angle.GetDir();
|
||||
var dockFlag = linearDir.AsFlag();
|
||||
@@ -478,7 +484,7 @@ namespace Content.Server.Physics.Controllers
|
||||
force.X -= thrust;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
throw new ArgumentOutOfRangeException($"Attempted to apply thrust to shuttle {shuttleUid} along invalid dir {dir}.");
|
||||
}
|
||||
|
||||
_thruster.EnableLinearThrustDirection(shuttle, dir);
|
||||
@@ -497,20 +503,20 @@ namespace Content.Server.Physics.Controllers
|
||||
if (totalForce.Length() > maxVelocity)
|
||||
totalForce = totalForce.Normalized() * maxVelocity;
|
||||
|
||||
PhysicsSystem.ApplyForce(shuttle.Owner, totalForce, body: body);
|
||||
PhysicsSystem.ApplyForce(shuttleUid, totalForce, body: body);
|
||||
}
|
||||
}
|
||||
|
||||
if (MathHelper.CloseTo(angularInput, 0f))
|
||||
{
|
||||
PhysicsSystem.SetSleepingAllowed(shuttle.Owner, body, true);
|
||||
PhysicsSystem.SetSleepingAllowed(shuttleUid, body, true);
|
||||
|
||||
if (brakeInput <= 0f)
|
||||
_thruster.SetAngularThrust(shuttle, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
PhysicsSystem.SetSleepingAllowed(shuttle.Owner, body, false);
|
||||
PhysicsSystem.SetSleepingAllowed(shuttleUid, body, false);
|
||||
var torque = shuttle.AngularThrust * -angularInput;
|
||||
|
||||
// Need to cap the velocity if 1 tick of input brings us over cap so we don't continuously
|
||||
@@ -523,18 +529,18 @@ namespace Content.Server.Physics.Controllers
|
||||
|
||||
if (!torque.Equals(0f))
|
||||
{
|
||||
PhysicsSystem.ApplyTorque(shuttle.Owner, torque, body: body);
|
||||
PhysicsSystem.ApplyTorque(shuttleUid, torque, body: body);
|
||||
_thruster.SetAngularThrust(shuttle, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool CanPilot(ShuttleComponent shuttle)
|
||||
private bool CanPilot(EntityUid shuttleUid)
|
||||
{
|
||||
return TryComp<FTLComponent>(shuttle.Owner, out var ftl) &&
|
||||
(ftl.State & (FTLState.Starting | FTLState.Travelling | FTLState.Arriving)) != 0x0 ||
|
||||
HasComp<PreventPilotComponent>(shuttle.Owner);
|
||||
return TryComp<FTLComponent>(shuttleUid, out var ftl)
|
||||
&& (ftl.State & (FTLState.Starting | FTLState.Travelling | FTLState.Arriving)) != 0x0
|
||||
|| HasComp<PreventPilotComponent>(shuttleUid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ internal sealed class PowerMonitoringConsoleSystem : EntitySystem
|
||||
private float _updateTimer = 0.0f;
|
||||
private const float UpdateTime = 1.0f;
|
||||
|
||||
[Dependency] private UserInterfaceSystem _userInterfaceSystem = default!;
|
||||
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!;
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
@@ -24,9 +24,11 @@ internal sealed class PowerMonitoringConsoleSystem : EntitySystem
|
||||
if (_updateTimer >= UpdateTime)
|
||||
{
|
||||
_updateTimer -= UpdateTime;
|
||||
foreach (var component in EntityQuery<PowerMonitoringConsoleComponent>())
|
||||
|
||||
var query = EntityQueryEnumerator<PowerMonitoringConsoleComponent>();
|
||||
while (query.MoveNext(out var uid, out var component))
|
||||
{
|
||||
UpdateUIState(component.Owner, component);
|
||||
UpdateUIState(uid, component);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,8 +54,7 @@ internal sealed class PowerMonitoringConsoleSystem : EntitySystem
|
||||
if (!_nodeContainer.TryGetNode<Node>(ncComp, "hv", out var node))
|
||||
return;
|
||||
|
||||
var netQ = node.NodeGroup as PowerNet;
|
||||
if (netQ != null)
|
||||
if (node.NodeGroup is PowerNet netQ)
|
||||
{
|
||||
foreach (PowerConsumerComponent pcc in netQ.Consumers)
|
||||
{
|
||||
@@ -92,9 +93,10 @@ internal sealed class PowerMonitoringConsoleSystem : EntitySystem
|
||||
// Sort
|
||||
loads.Sort(CompareLoadOrSources);
|
||||
sources.Sort(CompareLoadOrSources);
|
||||
|
||||
// Actually set state.
|
||||
var state = new PowerMonitoringConsoleBoundInterfaceState(totalSources, totalLoads, sources.ToArray(), loads.ToArray());
|
||||
_userInterfaceSystem.GetUiOrNull(target, PowerMonitoringConsoleUiKey.Key)?.SetState(state);
|
||||
if (_userInterfaceSystem.TryGetUi(target, PowerMonitoringConsoleUiKey.Key, out var bui))
|
||||
UserInterfaceSystem.SetUiState(bui, new PowerMonitoringConsoleBoundInterfaceState(totalSources, totalLoads, sources.ToArray(), loads.ToArray()));
|
||||
}
|
||||
|
||||
private int CompareLoadOrSources(PowerMonitoringConsoleEntry x, PowerMonitoringConsoleEntry y)
|
||||
|
||||
@@ -290,16 +290,14 @@ public sealed partial class SalvageSystem
|
||||
{
|
||||
// send it to cargo, no rewards otherwise.
|
||||
if (!TryComp<StationCargoOrderDatabaseComponent>(comp.Station, out var cargoDb))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var reward in comp.Rewards)
|
||||
{
|
||||
var sender = Loc.GetString("cargo-gift-default-sender");
|
||||
var desc = Loc.GetString("salvage-expedition-reward-description");
|
||||
var dest = Loc.GetString("cargo-gift-default-dest");
|
||||
_cargo.AddAndApproveOrder(cargoDb, reward, 0, 1, sender, desc, dest);
|
||||
_cargo.AddAndApproveOrder(comp.Station, reward, 0, 1, sender, desc, dest, cargoDb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Content.Server.Shuttles.Components
|
||||
public sealed class ShuttleConsoleComponent : SharedShuttleConsoleComponent
|
||||
{
|
||||
[ViewVariables]
|
||||
public readonly List<PilotComponent> SubscribedPilots = new();
|
||||
public readonly List<EntityUid> SubscribedPilots = new();
|
||||
|
||||
/// <summary>
|
||||
/// How much should the pilot's eye be zoomed by when piloting using this console?
|
||||
|
||||
@@ -10,6 +10,7 @@ using Content.Shared.Popups;
|
||||
using Content.Shared.Shuttles.BUIStates;
|
||||
using Content.Shared.Shuttles.Events;
|
||||
using Content.Shared.Shuttles.Systems;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
@@ -264,7 +265,8 @@ public sealed partial class EmergencyShuttleSystem
|
||||
}
|
||||
|
||||
// TODO: This is fucking bad
|
||||
if (!component.AuthorizedEntities.Remove(MetaData(idCard.Owner).EntityName)) return;
|
||||
if (!component.AuthorizedEntities.Remove(MetaData(idCard.Owner).EntityName))
|
||||
return;
|
||||
|
||||
_logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle early launch REPEAL by {args.Session:user}");
|
||||
var remaining = component.AuthorizationsRequired - component.AuthorizedEntities.Count;
|
||||
@@ -276,7 +278,8 @@ public sealed partial class EmergencyShuttleSystem
|
||||
private void OnEmergencyAuthorize(EntityUid uid, EmergencyShuttleConsoleComponent component, EmergencyShuttleAuthorizeMessage args)
|
||||
{
|
||||
var player = args.Session.AttachedEntity;
|
||||
if (player == null) return;
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if (!_idSystem.TryFindIdCard(player.Value, out var idCard) || !_reader.IsAllowed(idCard.Owner, uid))
|
||||
{
|
||||
@@ -285,7 +288,8 @@ public sealed partial class EmergencyShuttleSystem
|
||||
}
|
||||
|
||||
// TODO: This is fucking bad
|
||||
if (!component.AuthorizedEntities.Add(MetaData(idCard.Owner).EntityName)) return;
|
||||
if (!component.AuthorizedEntities.Add(MetaData(idCard.Owner).EntityName))
|
||||
return;
|
||||
|
||||
_logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle early launch AUTH by {args.Session:user}");
|
||||
var remaining = component.AuthorizationsRequired - component.AuthorizedEntities.Count;
|
||||
@@ -296,7 +300,7 @@ public sealed partial class EmergencyShuttleSystem
|
||||
playSound: false, colorOverride: DangerColor);
|
||||
|
||||
if (!CheckForLaunch(component))
|
||||
SoundSystem.Play("/Audio/Misc/notice1.ogg", Filter.Broadcast());
|
||||
_audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), recordReplay: true);
|
||||
|
||||
UpdateAllEmergencyConsoles();
|
||||
}
|
||||
@@ -317,9 +321,10 @@ public sealed partial class EmergencyShuttleSystem
|
||||
|
||||
private void UpdateAllEmergencyConsoles()
|
||||
{
|
||||
foreach (var comp in EntityQuery<EmergencyShuttleConsoleComponent>(true))
|
||||
var query = AllEntityQuery<EmergencyShuttleConsoleComponent>();
|
||||
while (query.MoveNext(out var uid, out var comp))
|
||||
{
|
||||
UpdateConsoleState(comp.Owner, comp);
|
||||
UpdateConsoleState(uid, comp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,12 +337,16 @@ public sealed partial class EmergencyShuttleSystem
|
||||
auths.Add(auth);
|
||||
}
|
||||
|
||||
_uiSystem.GetUiOrNull(uid, EmergencyConsoleUiKey.Key)?.SetState(new EmergencyConsoleBoundUserInterfaceState()
|
||||
{
|
||||
EarlyLaunchTime = EarlyLaunchAuthorized ? _timing.CurTime + TimeSpan.FromSeconds(_consoleAccumulator) : null,
|
||||
Authorizations = auths,
|
||||
AuthorizationsRequired = component.AuthorizationsRequired,
|
||||
});
|
||||
if (_uiSystem.TryGetUi(uid, EmergencyConsoleUiKey.Key, out var bui))
|
||||
UserInterfaceSystem.SetUiState(
|
||||
bui,
|
||||
new EmergencyConsoleBoundUserInterfaceState()
|
||||
{
|
||||
EarlyLaunchTime = EarlyLaunchAuthorized ? _timing.CurTime + TimeSpan.FromSeconds(_consoleAccumulator) : null,
|
||||
Authorizations = auths,
|
||||
AuthorizationsRequired = component.AuthorizationsRequired,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private bool CheckForLaunch(EmergencyShuttleConsoleComponent component)
|
||||
@@ -375,7 +384,7 @@ public sealed partial class EmergencyShuttleSystem
|
||||
playSound: false,
|
||||
colorOverride: DangerColor);
|
||||
|
||||
SoundSystem.Play("/Audio/Misc/notice1.ogg", Filter.Broadcast());
|
||||
_audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), recordReplay: true);
|
||||
}
|
||||
|
||||
public bool DelayEmergencyRoundEnd()
|
||||
|
||||
@@ -20,36 +20,36 @@ public sealed class RadarConsoleSystem : SharedRadarConsoleSystem
|
||||
|
||||
private void OnRadarStartup(EntityUid uid, RadarConsoleComponent component, ComponentStartup args)
|
||||
{
|
||||
UpdateState(component);
|
||||
UpdateState(uid, component);
|
||||
}
|
||||
|
||||
protected override void UpdateState(RadarConsoleComponent component)
|
||||
protected override void UpdateState(EntityUid uid, RadarConsoleComponent component)
|
||||
{
|
||||
var xform = Transform(component.Owner);
|
||||
var xform = Transform(uid);
|
||||
var onGrid = xform.ParentUid == xform.GridUid;
|
||||
EntityCoordinates? coordinates = onGrid ? xform.Coordinates : null;
|
||||
Angle? angle = onGrid ? xform.LocalRotation : null;
|
||||
|
||||
// Use ourself I guess.
|
||||
if (TryComp<IntrinsicUIComponent>(component.Owner, out var intrinsic))
|
||||
if (TryComp<IntrinsicUIComponent>(uid, out var intrinsic))
|
||||
{
|
||||
foreach (var uiKey in intrinsic.UIs)
|
||||
{
|
||||
if (uiKey.Key?.Equals(RadarConsoleUiKey.Key) == true)
|
||||
{
|
||||
coordinates = new EntityCoordinates(component.Owner, Vector2.Zero);
|
||||
coordinates = new EntityCoordinates(uid, Vector2.Zero);
|
||||
angle = Angle.Zero;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var radarState = new RadarConsoleBoundInterfaceState(
|
||||
component.MaxRange,
|
||||
coordinates,
|
||||
angle,
|
||||
new List<DockingInterfaceState>());
|
||||
|
||||
_uiSystem.GetUiOrNull(component.Owner, RadarConsoleUiKey.Key)?.SetState(radarState);
|
||||
if (_uiSystem.TryGetUi(uid, RadarConsoleUiKey.Key, out var bui))
|
||||
UserInterfaceSystem.SetUiState(bui, new RadarConsoleBoundInterfaceState(
|
||||
component.MaxRange,
|
||||
coordinates,
|
||||
angle,
|
||||
new List<DockingInterfaceState>()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
RefreshShuttleConsoles();
|
||||
}
|
||||
|
||||
public void RefreshShuttleConsoles(EntityUid uid)
|
||||
public void RefreshShuttleConsoles(EntityUid _)
|
||||
{
|
||||
// TODO: Should really call this per shuttle in some instances.
|
||||
RefreshShuttleConsoles();
|
||||
@@ -149,7 +149,7 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
var docks = GetAllDocks();
|
||||
var query = AllEntityQuery<ShuttleConsoleComponent>();
|
||||
|
||||
while (query.MoveNext(out var uid, out var comp))
|
||||
while (query.MoveNext(out var uid, out var _))
|
||||
{
|
||||
UpdateState(uid, docks);
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
/// </summary>
|
||||
private void OnConsoleUIClose(EntityUid uid, ShuttleConsoleComponent component, BoundUIClosedEvent args)
|
||||
{
|
||||
if ((ShuttleConsoleUiKey)args.UiKey != ShuttleConsoleUiKey.Key ||
|
||||
if ((ShuttleConsoleUiKey) args.UiKey != ShuttleConsoleUiKey.Key ||
|
||||
args.Session.AttachedEntity is not { } user)
|
||||
{
|
||||
return;
|
||||
@@ -211,19 +211,18 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
{
|
||||
RemovePilot(user, pilotComponent);
|
||||
|
||||
if (console == component)
|
||||
{
|
||||
// This feels backwards; is this intended to be a toggle?
|
||||
if (console == uid)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
AddPilot(user, component);
|
||||
AddPilot(uid, user, component);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OnGetState(EntityUid uid, PilotComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new PilotComponentState(component.Console?.Owner);
|
||||
args.State = new PilotComponentState(component.Console);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -328,15 +327,16 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
|
||||
docks ??= GetAllDocks();
|
||||
|
||||
_ui.GetUiOrNull(consoleUid, ShuttleConsoleUiKey.Key)
|
||||
?.SetState(new ShuttleConsoleBoundInterfaceState(
|
||||
if (_ui.TryGetUi(consoleUid, ShuttleConsoleUiKey.Key, out var bui))
|
||||
UserInterfaceSystem.SetUiState(bui, new ShuttleConsoleBoundInterfaceState(
|
||||
ftlState,
|
||||
ftlTime,
|
||||
destinations,
|
||||
range,
|
||||
consoleXform?.Coordinates,
|
||||
consoleXform?.LocalRotation,
|
||||
docks));
|
||||
docks
|
||||
));
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
@@ -351,7 +351,7 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
if (comp.Console == null)
|
||||
continue;
|
||||
|
||||
if (!_blocker.CanInteract(uid, comp.Console.Owner))
|
||||
if (!_blocker.CanInteract(uid, comp.Console))
|
||||
{
|
||||
toRemove.Add((uid, comp));
|
||||
}
|
||||
@@ -395,21 +395,21 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
ClearPilots(component);
|
||||
}
|
||||
|
||||
public void AddPilot(EntityUid entity, ShuttleConsoleComponent component)
|
||||
public void AddPilot(EntityUid uid, EntityUid entity, ShuttleConsoleComponent component)
|
||||
{
|
||||
if (!EntityManager.TryGetComponent(entity, out PilotComponent? pilotComponent) ||
|
||||
component.SubscribedPilots.Contains(pilotComponent))
|
||||
if (!EntityManager.TryGetComponent(entity, out PilotComponent? pilotComponent)
|
||||
|| component.SubscribedPilots.Contains(entity))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_eyeSystem.SetZoom(entity, component.Zoom, ignoreLimits:true);
|
||||
_eyeSystem.SetZoom(entity, component.Zoom, ignoreLimits: true);
|
||||
|
||||
component.SubscribedPilots.Add(pilotComponent);
|
||||
component.SubscribedPilots.Add(entity);
|
||||
|
||||
_alertsSystem.ShowAlert(entity, AlertType.PilotingShuttle);
|
||||
|
||||
pilotComponent.Console = component;
|
||||
pilotComponent.Console = uid;
|
||||
ActionBlockerSystem.UpdateCanMove(entity);
|
||||
pilotComponent.Position = EntityManager.GetComponent<TransformComponent>(entity).Coordinates;
|
||||
Dirty(pilotComponent);
|
||||
@@ -419,14 +419,14 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
{
|
||||
var console = pilotComponent.Console;
|
||||
|
||||
if (console is not ShuttleConsoleComponent helmsman)
|
||||
if (!TryComp<ShuttleConsoleComponent>(console, out var helm))
|
||||
return;
|
||||
|
||||
pilotComponent.Console = null;
|
||||
pilotComponent.Position = null;
|
||||
_eyeSystem.ResetZoom(pilotUid);
|
||||
|
||||
if (!helmsman.SubscribedPilots.Remove(pilotComponent))
|
||||
if (!helm.SubscribedPilots.Remove(pilotUid))
|
||||
return;
|
||||
|
||||
_alertsSystem.ClearAlert(pilotUid, AlertType.PilotingShuttle);
|
||||
@@ -447,9 +447,11 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
|
||||
public void ClearPilots(ShuttleConsoleComponent component)
|
||||
{
|
||||
var query = GetEntityQuery<PilotComponent>();
|
||||
while (component.SubscribedPilots.TryGetValue(0, out var pilot))
|
||||
{
|
||||
RemovePilot(pilot.Owner, pilot);
|
||||
if (query.TryGetComponent(pilot, out var pilotComponent))
|
||||
RemovePilot(pilot, pilotComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Server.Solar.Components;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Solar;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
namespace Content.Server.Solar.EntitySystems
|
||||
{
|
||||
@@ -11,7 +12,8 @@ namespace Content.Server.Solar.EntitySystems
|
||||
[UsedImplicitly]
|
||||
internal sealed class PowerSolarControlConsoleSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private PowerSolarSystem _powerSolarSystem = default!;
|
||||
[Dependency] private readonly PowerSolarSystem _powerSolarSystem = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Timer used to avoid updating the UI state every frame (which would be overkill)
|
||||
@@ -32,9 +34,10 @@ namespace Content.Server.Solar.EntitySystems
|
||||
{
|
||||
_updateTimer -= 1;
|
||||
var state = new SolarControlConsoleBoundInterfaceState(_powerSolarSystem.TargetPanelRotation, _powerSolarSystem.TargetPanelVelocity, _powerSolarSystem.TotalPanelPower, _powerSolarSystem.TowardsSun);
|
||||
foreach (var component in EntityManager.EntityQuery<SolarControlConsoleComponent>())
|
||||
var query = EntityQueryEnumerator<SolarControlConsoleComponent, ServerUserInterfaceComponent>();
|
||||
while (query.MoveNext(out var uid, out var _, out var uiComp))
|
||||
{
|
||||
component.Owner.GetUIOrNull(SolarControlConsoleUiKey.Key)?.SetState(state);
|
||||
_uiSystem.TrySetUiState(uid, SolarControlConsoleUiKey.Key, state, ui: uiComp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,17 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Anomaly;
|
||||
using Content.Server.Cargo.Components;
|
||||
using Content.Server.Cargo.Systems;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Server.StationEvents.Components;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Cargo;
|
||||
using Content.Shared.Cargo.Prototypes;
|
||||
using Content.Shared.Database;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.StationEvents.Events;
|
||||
|
||||
public sealed class CargoGiftsRule : StationEventSystem<CargoGiftsRuleComponent>
|
||||
{
|
||||
[Dependency] private readonly CargoSystem _cargoSystem = default!;
|
||||
[Dependency] private readonly StationSystem _stationSystem = default!;
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly GameTicker _ticker = default!;
|
||||
|
||||
@@ -61,7 +50,7 @@ public sealed class CargoGiftsRule : StationEventSystem<CargoGiftsRuleComponent>
|
||||
}
|
||||
|
||||
// Add some presents
|
||||
int outstanding = _cargoSystem.GetOutstandingOrderCount(cargoDb);
|
||||
var outstanding = CargoSystem.GetOutstandingOrderCount(cargoDb);
|
||||
while (outstanding < cargoDb.Capacity - component.OrderSpaceToLeave && component.Gifts.Count > 0)
|
||||
{
|
||||
// I wish there was a nice way to pop this
|
||||
@@ -71,13 +60,15 @@ public sealed class CargoGiftsRule : StationEventSystem<CargoGiftsRuleComponent>
|
||||
var product = _prototypeManager.Index<CargoProductPrototype>(productId);
|
||||
|
||||
if (!_cargoSystem.AddAndApproveOrder(
|
||||
cargoDb,
|
||||
station!.Value,
|
||||
product.Product,
|
||||
product.PointCost,
|
||||
qty,
|
||||
Loc.GetString(component.Sender),
|
||||
Loc.GetString(component.Description),
|
||||
Loc.GetString(component.Dest)))
|
||||
Loc.GetString(component.Dest),
|
||||
cargoDb
|
||||
))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -99,9 +99,7 @@ public sealed class GeneralStationRecordConsoleSystem : EntitySystem
|
||||
|
||||
private void SetStateForInterface(EntityUid uid, GeneralStationRecordConsoleState newState)
|
||||
{
|
||||
_userInterface
|
||||
.GetUiOrNull(uid, GeneralStationRecordConsoleKey.Key)
|
||||
?.SetState(newState);
|
||||
_userInterface.TrySetUiState(uid, GeneralStationRecordConsoleKey.Key, newState);
|
||||
}
|
||||
|
||||
private bool IsSkippedRecord(GeneralStationRecordsFilter filter,
|
||||
|
||||
@@ -23,7 +23,6 @@ using Content.Shared.Storage;
|
||||
using Content.Shared.Storage.Components;
|
||||
using Content.Shared.Timing;
|
||||
using Content.Shared.Verbs;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.Containers;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
@@ -33,7 +32,6 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using static Content.Shared.Storage.SharedStorageComponent;
|
||||
|
||||
@@ -43,6 +41,7 @@ namespace Content.Server.Storage.EntitySystems
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IAdminManager _admin = default!;
|
||||
[Dependency] private readonly ILogManager _logManager = default!;
|
||||
[Dependency] private readonly ContainerSystem _containerSystem = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _entityLookupSystem = default!;
|
||||
@@ -68,7 +67,7 @@ namespace Content.Server.Storage.EntitySystems
|
||||
SubscribeLocalEvent<ServerStorageComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<ServerStorageComponent, GetVerbsEvent<ActivationVerb>>(AddOpenUiVerb);
|
||||
SubscribeLocalEvent<ServerStorageComponent, GetVerbsEvent<UtilityVerb>>(AddTransferVerbs);
|
||||
SubscribeLocalEvent<ServerStorageComponent, InteractUsingEvent>(OnInteractUsing, after: new []{ typeof(ItemSlotsSystem)} );
|
||||
SubscribeLocalEvent<ServerStorageComponent, InteractUsingEvent>(OnInteractUsing, after: new[] { typeof(ItemSlotsSystem) });
|
||||
SubscribeLocalEvent<ServerStorageComponent, ActivateInWorldEvent>(OnActivate);
|
||||
SubscribeLocalEvent<ServerStorageComponent, OpenStorageImplantEvent>(OnImplantActivate);
|
||||
SubscribeLocalEvent<ServerStorageComponent, AfterInteractEvent>(AfterInteract);
|
||||
@@ -98,7 +97,7 @@ namespace Content.Server.Storage.EntitySystems
|
||||
|
||||
private void AddOpenUiVerb(EntityUid uid, ServerStorageComponent component, GetVerbsEvent<ActivationVerb> args)
|
||||
{
|
||||
bool silent = false;
|
||||
var silent = false;
|
||||
if (!args.CanAccess || !args.CanInteract || TryComp<LockComponent>(uid, out var lockComponent) && lockComponent.Locked)
|
||||
{
|
||||
// we allow admins to open the storage anyways
|
||||
@@ -115,7 +114,7 @@ namespace Content.Server.Storage.EntitySystems
|
||||
return;
|
||||
|
||||
// Does this player currently have the storage UI open?
|
||||
bool uiOpen = _uiSystem.SessionHasOpenUi(uid, StorageUiKey.Key, actor.PlayerSession);
|
||||
var uiOpen = _uiSystem.SessionHasOpenUi(uid, StorageUiKey.Key, actor.PlayerSession);
|
||||
|
||||
ActivationVerb verb = new()
|
||||
{
|
||||
@@ -125,13 +124,13 @@ namespace Content.Server.Storage.EntitySystems
|
||||
{
|
||||
verb.Text = Loc.GetString("verb-common-close-ui");
|
||||
verb.Icon = new SpriteSpecifier.Texture(
|
||||
new ("/Textures/Interface/VerbIcons/close.svg.192dpi.png"));
|
||||
new("/Textures/Interface/VerbIcons/close.svg.192dpi.png"));
|
||||
}
|
||||
else
|
||||
{
|
||||
verb.Text = Loc.GetString("verb-common-open-ui");
|
||||
verb.Icon = new SpriteSpecifier.Texture(
|
||||
new ("/Textures/Interface/VerbIcons/open.svg.192dpi.png"));
|
||||
new("/Textures/Interface/VerbIcons/open.svg.192dpi.png"));
|
||||
}
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
@@ -169,7 +168,8 @@ namespace Content.Server.Storage.EntitySystems
|
||||
if (args.Handled || !storageComp.ClickInsert || TryComp(uid, out LockComponent? lockComponent) && lockComponent.Locked)
|
||||
return;
|
||||
|
||||
Logger.DebugS(storageComp.LoggerName, $"Storage (UID {uid}) attacked by user (UID {args.User}) with entity (UID {args.Used}).");
|
||||
_logManager.GetSawmill(storageComp.LoggerName)
|
||||
.Debug($"Storage (UID {uid}) attacked by user (UID {args.User}) with entity (UID {args.Used}).");
|
||||
|
||||
if (HasComp<PlaceableSurfaceComponent>(uid))
|
||||
return;
|
||||
@@ -253,7 +253,7 @@ namespace Content.Server.Storage.EntitySystems
|
||||
// Pick up the clicked entity
|
||||
if (storageComp.QuickInsert)
|
||||
{
|
||||
if (args.Target is not {Valid: true} target)
|
||||
if (args.Target is not { Valid: true } target)
|
||||
return;
|
||||
|
||||
if (_containerSystem.IsEntityInContainer(target)
|
||||
@@ -267,7 +267,9 @@ namespace Content.Server.Storage.EntitySystems
|
||||
|
||||
var position = EntityCoordinates.FromMap(
|
||||
parent.IsValid() ? parent : uid,
|
||||
transformEnt.MapPosition);
|
||||
transformEnt.MapPosition,
|
||||
_transform
|
||||
);
|
||||
|
||||
if (PlayerInsertEntityInWorld(uid, args.User, target, storageComp))
|
||||
{
|
||||
@@ -307,8 +309,9 @@ namespace Content.Server.Storage.EntitySystems
|
||||
|
||||
var position = EntityCoordinates.FromMap(
|
||||
xform.ParentUid.IsValid() ? xform.ParentUid : uid,
|
||||
new MapCoordinates(_transform.GetWorldPosition(targetXform, xformQuery),
|
||||
targetXform.MapID), EntityManager);
|
||||
new MapCoordinates(_transform.GetWorldPosition(targetXform, xformQuery), targetXform.MapID),
|
||||
_transform
|
||||
);
|
||||
|
||||
if (PlayerInsertEntityInWorld(uid, args.Args.User, entity, component))
|
||||
{
|
||||
@@ -353,7 +356,7 @@ namespace Content.Server.Storage.EntitySystems
|
||||
|
||||
if (!Exists(args.InteractedItemUID))
|
||||
{
|
||||
Logger.Error($"Player {args.Session} interacted with non-existent item {args.InteractedItemUID} stored in {ToPrettyString(uid)}");
|
||||
Log.Error($"Player {args.Session} interacted with non-existent item {args.InteractedItemUID} stored in {ToPrettyString(uid)}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -605,29 +608,6 @@ namespace Content.Server.Storage.EntitySystems
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool CanCombineStacks(
|
||||
ServerStorageComponent storageComp,
|
||||
StackComponent stack)
|
||||
{
|
||||
if (storageComp.Storage == null)
|
||||
return false;
|
||||
|
||||
var stackQuery = GetEntityQuery<StackComponent>();
|
||||
var countLeft = stack.Count;
|
||||
foreach (var ent in storageComp.Storage.ContainedEntities)
|
||||
{
|
||||
if (!stackQuery.TryGetComponent(ent, out var destStack))
|
||||
continue;
|
||||
|
||||
if (destStack.StackTypeId != stack.StackTypeId)
|
||||
continue;
|
||||
|
||||
countLeft -= _stack.GetAvailableSpace(stack);
|
||||
}
|
||||
|
||||
return countLeft <= 0;
|
||||
}
|
||||
|
||||
// REMOVE: remove and drop on the ground
|
||||
public bool RemoveAndDrop(EntityUid uid, EntityUid removeEnt, ServerStorageComponent? storageComp = null)
|
||||
{
|
||||
@@ -705,7 +685,8 @@ namespace Content.Server.Storage.EntitySystems
|
||||
_useDelay.BeginDelay(uid, useDelay);
|
||||
}
|
||||
|
||||
Logger.DebugS(storageComp.LoggerName, $"Storage (UID {uid}) \"used\" by player session (UID {player.PlayerSession.AttachedEntity}).");
|
||||
_logManager.GetSawmill(storageComp.LoggerName)
|
||||
.Debug($"Storage (UID {uid}) \"used\" by player session (UID {player.PlayerSession.AttachedEntity}).");
|
||||
|
||||
var bui = _uiSystem.GetUiOrNull(uid, StorageUiKey.Key);
|
||||
if (bui != null)
|
||||
@@ -750,10 +731,10 @@ namespace Content.Server.Storage.EntitySystems
|
||||
|
||||
var bui = _uiSystem.GetUiOrNull(uid, StorageUiKey.Key);
|
||||
if (bui != null)
|
||||
_uiSystem.SetUiState(bui, state);
|
||||
UserInterfaceSystem.SetUiState(bui, state);
|
||||
}
|
||||
|
||||
private void Popup(EntityUid uid, EntityUid player, string message, ServerStorageComponent storageComp)
|
||||
private void Popup(EntityUid _, EntityUid player, string message, ServerStorageComponent storageComp)
|
||||
{
|
||||
if (!storageComp.ShowPopup)
|
||||
return;
|
||||
@@ -761,8 +742,7 @@ namespace Content.Server.Storage.EntitySystems
|
||||
_popupSystem.PopupEntity(Loc.GetString(message), player, player);
|
||||
}
|
||||
|
||||
private void PopupEnt(EntityUid uid, EntityUid player, string message, EntityUid entityUid,
|
||||
ServerStorageComponent storageComp)
|
||||
private void PopupEnt(EntityUid _, EntityUid player, string message, EntityUid entityUid, ServerStorageComponent storageComp)
|
||||
{
|
||||
if (!storageComp.ShowPopup)
|
||||
return;
|
||||
|
||||
@@ -98,7 +98,7 @@ public sealed partial class StoreSystem
|
||||
// only tell operatives to lock their uplink if it can be locked
|
||||
var showFooter = HasComp<RingerUplinkComponent>(store);
|
||||
var state = new StoreUpdateState(component.LastAvailableListings, allCurrency, showFooter);
|
||||
_ui.SetUiState(ui, state);
|
||||
UserInterfaceSystem.SetUiState(ui, state);
|
||||
}
|
||||
|
||||
private void OnRequestUpdate(EntityUid uid, StoreComponent component, StoreRequestUpdateInterfaceMessage args)
|
||||
@@ -119,7 +119,7 @@ public sealed partial class StoreSystem
|
||||
var listing = component.Listings.FirstOrDefault(x => x.Equals(msg.Listing));
|
||||
if (listing == null) //make sure this listing actually exists
|
||||
{
|
||||
Logger.Debug("listing does not exist");
|
||||
Log.Debug("listing does not exist");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ public sealed partial class StoreSystem
|
||||
if (proto.Cash == null || !proto.CanWithdraw)
|
||||
return;
|
||||
|
||||
if (msg.Session.AttachedEntity is not { Valid: true} buyer)
|
||||
if (msg.Session.AttachedEntity is not { Valid: true } buyer)
|
||||
return;
|
||||
|
||||
FixedPoint2 amountRemaining = msg.Amount;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.PDA.Ringer;
|
||||
using Content.Server.Store.Components;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.FixedPoint;
|
||||
@@ -185,7 +183,7 @@ public sealed partial class StoreSystem : EntitySystem
|
||||
var ui = _ui.GetUiOrNull(uid, StoreUiKey.Key);
|
||||
if (ui != null)
|
||||
{
|
||||
_ui.SetUiState(ui, new StoreInitializeState(preset.StoreName));
|
||||
UserInterfaceSystem.SetUiState(ui, new StoreInitializeState(preset.StoreName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,13 +137,12 @@ public sealed class SurveillanceCameraRouterSystem : EntitySystem
|
||||
|
||||
private void OpenSetupInterface(EntityUid uid, EntityUid player, SurveillanceCameraRouterComponent? camera = null, ActorComponent? actor = null)
|
||||
{
|
||||
if (!Resolve(uid, ref camera)
|
||||
|| !Resolve(player, ref actor))
|
||||
{
|
||||
if (!Resolve(uid, ref camera) || !Resolve(player, ref actor))
|
||||
return;
|
||||
if (!_userInterface.TryGetUi(uid, SurveillanceCameraSetupUiKey.Router, out var bui))
|
||||
return;
|
||||
}
|
||||
|
||||
_userInterface.GetUiOrNull(uid, SurveillanceCameraSetupUiKey.Router)!.Open(actor.PlayerSession);
|
||||
_userInterface.OpenUi(bui, actor.PlayerSession);
|
||||
UpdateSetupInterface(uid, camera);
|
||||
}
|
||||
|
||||
|
||||
@@ -197,13 +197,12 @@ public sealed class SurveillanceCameraSystem : EntitySystem
|
||||
|
||||
private void OpenSetupInterface(EntityUid uid, EntityUid player, SurveillanceCameraComponent? camera = null, ActorComponent? actor = null)
|
||||
{
|
||||
if (!Resolve(uid, ref camera)
|
||||
|| !Resolve(player, ref actor))
|
||||
{
|
||||
if (!Resolve(uid, ref camera) || !Resolve(player, ref actor))
|
||||
return;
|
||||
if (!_userInterface.TryGetUi(uid, SurveillanceCameraSetupUiKey.Camera, out var bui))
|
||||
return;
|
||||
}
|
||||
|
||||
_userInterface.GetUiOrNull(uid, SurveillanceCameraSetupUiKey.Camera)!.Open(actor.PlayerSession);
|
||||
_userInterface.OpenUi(bui, actor.PlayerSession);
|
||||
UpdateSetupInterface(uid, camera);
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ public sealed partial class ActivatableUISystem : EntitySystem
|
||||
RaiseLocalEvent((aui).Owner, bae, false);
|
||||
|
||||
SetCurrentSingleUser((aui).Owner, actor.PlayerSession, aui);
|
||||
ui.Toggle(actor.PlayerSession);
|
||||
_uiSystem.ToggleUi(ui, actor.PlayerSession);
|
||||
|
||||
//Let the component know a user opened it so it can do whatever it needs to do
|
||||
var aae = new AfterActivatableUIOpenEvent(user, actor.PlayerSession);
|
||||
@@ -167,8 +167,12 @@ public sealed partial class ActivatableUISystem : EntitySystem
|
||||
|
||||
public void CloseAll(EntityUid uid, ActivatableUIComponent? aui = null)
|
||||
{
|
||||
if (!Resolve(uid, ref aui, false)) return;
|
||||
aui.UserInterface?.CloseAll();
|
||||
if (!Resolve(uid, ref aui, false))
|
||||
return;
|
||||
if (aui.UserInterface is null)
|
||||
return;
|
||||
|
||||
_uiSystem.CloseAll(aui.UserInterface);
|
||||
}
|
||||
|
||||
private void OnHandDeselected(EntityUid uid, ActivatableUIComponent? aui, HandDeselectedEvent args)
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace Content.Server.UserInterface;
|
||||
public sealed class IntrinsicUISystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ActionsSystem _actionsSystem = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -54,7 +55,7 @@ public sealed class IntrinsicUISystem : EntitySystem
|
||||
if (attempt.Cancelled)
|
||||
return false;
|
||||
|
||||
ui.Toggle(actor.PlayerSession);
|
||||
_uiSystem.ToggleUi(ui, actor.PlayerSession);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,8 @@ using Content.Shared.Actions;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.Verbs;
|
||||
using Content.Shared.VoiceMask;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.VoiceMask;
|
||||
|
||||
@@ -71,11 +69,11 @@ public sealed partial class VoiceMaskSystem : EntitySystem
|
||||
private void OpenUI(EntityUid player, ActorComponent? actor = null)
|
||||
{
|
||||
if (!Resolve(player, ref actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!_uiSystem.TryGetUi(player, VoiceMaskUIKey.Key, out var bui))
|
||||
return;
|
||||
|
||||
_uiSystem.GetUiOrNull(player, VoiceMaskUIKey.Key)?.Open(actor.PlayerSession);
|
||||
_uiSystem.OpenUi(bui, actor.PlayerSession);
|
||||
UpdateUI(player);
|
||||
}
|
||||
|
||||
@@ -86,7 +84,8 @@ public sealed partial class VoiceMaskSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
_uiSystem.GetUiOrNull(owner, VoiceMaskUIKey.Key)?.SetState(new VoiceMaskBuiState(component.VoiceName));
|
||||
if (_uiSystem.TryGetUi(owner, VoiceMaskUIKey.Key, out var bui))
|
||||
UserInterfaceSystem.SetUiState(bui, new VoiceMaskBuiState(component.VoiceName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Construction;
|
||||
using Content.Server.DeviceLinking.Events;
|
||||
using Content.Server.MachineLinking.Components;
|
||||
using Content.Server.Paper;
|
||||
using Content.Server.Power.Components;
|
||||
@@ -41,6 +40,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
|
||||
[Dependency] private readonly ArtifactSystem _artifact = default!;
|
||||
[Dependency] private readonly PaperSystem _paper = default!;
|
||||
[Dependency] private readonly ResearchSystem _research = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize()
|
||||
@@ -66,11 +66,11 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
|
||||
SubscribeLocalEvent<AnalysisConsoleComponent, AnalysisConsolePrintButtonPressedMessage>(OnPrintButton);
|
||||
SubscribeLocalEvent<AnalysisConsoleComponent, AnalysisConsoleExtractButtonPressedMessage>(OnExtractButton);
|
||||
|
||||
SubscribeLocalEvent<AnalysisConsoleComponent, ResearchClientServerSelectedMessage>((e,c,_) => UpdateUserInterface(e,c),
|
||||
after: new []{typeof(ResearchSystem)});
|
||||
SubscribeLocalEvent<AnalysisConsoleComponent, ResearchClientServerDeselectedMessage>((e,c,_) => UpdateUserInterface(e,c),
|
||||
after: new []{typeof(ResearchSystem)});
|
||||
SubscribeLocalEvent<AnalysisConsoleComponent, BeforeActivatableUIOpenEvent>((e,c,_) => UpdateUserInterface(e,c));
|
||||
SubscribeLocalEvent<AnalysisConsoleComponent, ResearchClientServerSelectedMessage>((e, c, _) => UpdateUserInterface(e, c),
|
||||
after: new[] { typeof(ResearchSystem) });
|
||||
SubscribeLocalEvent<AnalysisConsoleComponent, ResearchClientServerDeselectedMessage>((e, c, _) => UpdateUserInterface(e, c),
|
||||
after: new[] { typeof(ResearchSystem) });
|
||||
SubscribeLocalEvent<AnalysisConsoleComponent, BeforeActivatableUIOpenEvent>((e, c, _) => UpdateUserInterface(e, c));
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
@@ -83,7 +83,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
|
||||
if (scan.Console != null)
|
||||
UpdateUserInterface(scan.Console.Value);
|
||||
|
||||
if (_timing.CurTime - active.StartTime < (scan.AnalysisDuration * scan.AnalysisDurationMulitplier))
|
||||
if (_timing.CurTime - active.StartTime < scan.AnalysisDuration * scan.AnalysisDurationMulitplier)
|
||||
continue;
|
||||
|
||||
FinishScan(uid, scan, active);
|
||||
@@ -222,7 +222,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
|
||||
canScan, canPrint, msg, scanning, remaining, totalTime, points);
|
||||
|
||||
var bui = _ui.GetUi(uid, ArtifactAnalzyerUiKey.Key);
|
||||
_ui.SetUiState(bui, state);
|
||||
UserInterfaceSystem.SetUiState(bui, state);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -277,7 +277,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
|
||||
analyzer.ReadyToPrint = false;
|
||||
|
||||
var report = Spawn(component.ReportEntityId, Transform(uid).Coordinates);
|
||||
MetaData(report).EntityName = Loc.GetString("analysis-report-title", ("id", analyzer.LastAnalyzedNode.Id));
|
||||
_metaSystem.SetEntityName(report, Loc.GetString("analysis-report-title", ("id", analyzer.LastAnalyzedNode.Id)));
|
||||
|
||||
var msg = GetArtifactScanMessage(analyzer);
|
||||
if (msg == null)
|
||||
|
||||
Reference in New Issue
Block a user