Files
OldThink/Content.Client/Borer/BorerScannerUIController.cs
Ogunefu ff26505b11 Мозговой Червь (#17)
* - add: Added Cortic Borer.

* - fix: Removed unnecessary imports, unused fields, variables, methods.

* - fix: Изменён принцип вселения: теперь не создаётся новый энтити с переходом разума, вместо этого хост хранит в себе контейнер для червя, в который последний и погружается

* - fix: Убрано использование устаревших методов и полей, исправлена ошибка, из-за которой при вселении в носителя уровень сахара не проверялся

* - fix: Изменено тестировочное значение добавления очков химикатов

* - fix: Borer can't speak now

* - fix: Some bug and shitcode fixes

* - fix: Some bug and shitcode fixes

* - fix: Added cooldown after releasing the humanoid's body

* - fix: fix

* - add: Added russian localization

* - add: Убрал использование метода _chatManager.ChatMessageToOne в некоторых местах, т.к. popup включает в себя вывод сообщения в чат.

* - fix: fix

* - fix: fix
2024-02-03 17:31:56 +00:00

61 lines
1.7 KiB
C#

using Content.Client.UserInterface.Systems.Gameplay;
using Content.Shared.Borer;
using Robust.Client.Player;
using Robust.Client.UserInterface.Controllers;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Utility;
namespace Content.Client.Borer;
public sealed class BorerScannerUIController : UIController
{
[Dependency] private readonly GameplayStateLoadController _gameplayStateLoad = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
private ScannerWindow? _window;
public override void Initialize()
{
base.Initialize();
_gameplayStateLoad.OnScreenLoad += LoadGui;
_gameplayStateLoad.OnScreenUnload += UnloadGui;
SubscribeNetworkEvent<BorerScanDoAfterEvent>(OpenWindow);
}
private void LoadGui()
{
DebugTools.Assert(_window == null);
_window = UIManager.CreateWindow<ScannerWindow>();
LayoutContainer.SetAnchorPreset(_window, LayoutContainer.LayoutPreset.CenterTop);
}
private void UnloadGui()
{
if (_window != null)
{
_window.Dispose();
_window = null;
}
}
private void OpenWindow(BorerScanDoAfterEvent msg, EntitySessionEventArgs args)
{
var ent = _playerManager.LocalEntity;
if (_window == null || _window.IsOpen || ent != args.SenderSession.AttachedEntity)
return;
_window.SolutionContainer.DisposeAllChildren();
foreach (var reagent in msg.Solution)
{
var reagLabel = new Label();
reagLabel.Text = reagent.Key + " - " + reagent.Value + "u";
_window.SolutionContainer.Children.Add(reagLabel);
}
_window.Open();
}
}