2021-02-17 09:39:31 -03:00
|
|
|
using System.Linq;
|
2021-06-19 13:25:05 +02:00
|
|
|
using Content.Client.Atmos.EntitySystems;
|
|
|
|
|
using Content.Shared.Atmos.Prototypes;
|
2021-02-17 09:39:31 -03:00
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Robust.Client.AutoGenerated;
|
|
|
|
|
using Robust.Client.Console;
|
|
|
|
|
using Robust.Client.Player;
|
|
|
|
|
using Robust.Client.UserInterface.Controls;
|
|
|
|
|
using Robust.Client.UserInterface.CustomControls;
|
2022-11-22 13:12:04 +11:00
|
|
|
using Robust.Shared.Map.Components;
|
2021-02-17 09:39:31 -03:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.Administration.UI.Tabs.AtmosTab
|
2021-02-17 09:39:31 -03:00
|
|
|
{
|
|
|
|
|
[GenerateTypedNameReferences]
|
|
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed partial class AddGasWindow : DefaultWindow
|
2021-02-17 09:39:31 -03:00
|
|
|
{
|
2023-09-11 17:21:52 +12:00
|
|
|
private List<NetEntity>? _gridData;
|
2021-02-17 09:39:31 -03:00
|
|
|
private IEnumerable<GasPrototype>? _gasData;
|
|
|
|
|
|
|
|
|
|
protected override void EnteredTree()
|
|
|
|
|
{
|
|
|
|
|
// Fill out grids
|
2023-07-23 16:03:57 +10:00
|
|
|
var entManager = IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
var playerManager = IoCManager.Resolve<IPlayerManager>();
|
|
|
|
|
|
|
|
|
|
var gridQuery = entManager.AllEntityQueryEnumerator<MapGridComponent>();
|
2023-09-11 17:21:52 +12:00
|
|
|
_gridData ??= new List<NetEntity>();
|
2023-07-23 16:03:57 +10:00
|
|
|
_gridData.Clear();
|
|
|
|
|
|
|
|
|
|
while (gridQuery.MoveNext(out var uid, out _))
|
2021-02-17 09:39:31 -03:00
|
|
|
{
|
2023-09-11 17:21:52 +12:00
|
|
|
_gridData.Add(entManager.GetNetEntity(uid));
|
2024-02-13 22:48:39 +01:00
|
|
|
var player = playerManager.LocalEntity;
|
2023-07-23 16:03:57 +10:00
|
|
|
var playerGrid = entManager.GetComponentOrNull<TransformComponent>(player)?.GridUid;
|
2024-06-22 17:05:33 +04:00
|
|
|
GridOptions.AddItem($"{uid} {(playerGrid == uid ? Loc.GetString("admin-ui-atmos-grid-current") : "")}");
|
2021-02-17 09:39:31 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GridOptions.OnItemSelected += eventArgs => GridOptions.SelectId(eventArgs.Id);
|
|
|
|
|
|
|
|
|
|
// Fill out gases
|
2023-07-23 16:03:57 +10:00
|
|
|
_gasData = entManager.System<AtmosphereSystem>().Gases;
|
|
|
|
|
|
2021-02-17 09:39:31 -03:00
|
|
|
foreach (var gas in _gasData)
|
|
|
|
|
{
|
2022-12-20 23:25:34 +01:00
|
|
|
var gasName = Loc.GetString(gas.Name);
|
|
|
|
|
GasOptions.AddItem($"{gasName} ({gas.ID})");
|
2021-02-17 09:39:31 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GasOptions.OnItemSelected += eventArgs => GasOptions.SelectId(eventArgs.Id);
|
|
|
|
|
|
|
|
|
|
SubmitButton.OnPressed += SubmitButtonOnOnPressed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
|
|
|
|
{
|
|
|
|
|
if (_gridData == null || _gasData == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-07-23 16:03:57 +10:00
|
|
|
var gridIndex = _gridData[GridOptions.SelectedId];
|
2021-02-17 09:39:31 -03:00
|
|
|
|
|
|
|
|
var gasList = _gasData.ToList();
|
|
|
|
|
var gasId = gasList[GasOptions.SelectedId].ID;
|
|
|
|
|
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
|
|
|
|
$"addgas {TileXSpin.Value} {TileYSpin.Value} {gridIndex} {gasId} {AmountSpin.Value}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|