Fix makeghostrole eui (#19998)
This commit is contained in:
@@ -6,72 +6,70 @@ using Robust.Client.Console;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
|
||||
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles;
|
||||
|
||||
[UsedImplicitly]
|
||||
public sealed class MakeGhostRoleEui : BaseEui
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class MakeGhostRoleEui : BaseEui
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
|
||||
|
||||
private readonly MakeGhostRoleWindow _window;
|
||||
|
||||
public MakeGhostRoleEui()
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
|
||||
_window = new MakeGhostRoleWindow();
|
||||
|
||||
private readonly MakeGhostRoleWindow _window;
|
||||
_window.OnClose += OnClose;
|
||||
_window.OnMake += OnMake;
|
||||
}
|
||||
|
||||
public MakeGhostRoleEui()
|
||||
public override void HandleState(EuiStateBase state)
|
||||
{
|
||||
if (state is not MakeGhostRoleEuiState uiState)
|
||||
{
|
||||
_window = new MakeGhostRoleWindow();
|
||||
|
||||
|
||||
_window.OnClose += OnClose;
|
||||
_window.OnMake += OnMake;
|
||||
return;
|
||||
}
|
||||
|
||||
public override void HandleState(EuiStateBase state)
|
||||
{
|
||||
if (state is not MakeGhostRoleEuiState uiState)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_window.SetEntity(_entManager, uiState.Entity);
|
||||
}
|
||||
|
||||
_window.SetEntity(_entManager.GetEntity(uiState.EntityUid));
|
||||
public override void Opened()
|
||||
{
|
||||
base.Opened();
|
||||
_window.OpenCentered();
|
||||
}
|
||||
|
||||
private void OnMake(NetEntity entity, string name, string description, string rules, bool makeSentient)
|
||||
{
|
||||
var player = _playerManager.LocalPlayer;
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public override void Opened()
|
||||
var makeGhostRoleCommand =
|
||||
$"makeghostrole " +
|
||||
$"\"{CommandParsing.Escape(entity.ToString())}\" " +
|
||||
$"\"{CommandParsing.Escape(name)}\" " +
|
||||
$"\"{CommandParsing.Escape(description)}\" " +
|
||||
$"\"{CommandParsing.Escape(rules)}\"";
|
||||
|
||||
_consoleHost.ExecuteCommand(player.Session, makeGhostRoleCommand);
|
||||
|
||||
if (makeSentient)
|
||||
{
|
||||
base.Opened();
|
||||
_window.OpenCentered();
|
||||
var makeSentientCommand = $"makesentient \"{CommandParsing.Escape(entity.ToString())}\"";
|
||||
_consoleHost.ExecuteCommand(player.Session, makeSentientCommand);
|
||||
}
|
||||
|
||||
private void OnMake(EntityUid uid, string name, string description, string rules, bool makeSentient)
|
||||
{
|
||||
var player = _playerManager.LocalPlayer;
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_window.Close();
|
||||
}
|
||||
|
||||
var makeGhostRoleCommand =
|
||||
$"makeghostrole " +
|
||||
$"\"{CommandParsing.Escape(uid.ToString())}\" " +
|
||||
$"\"{CommandParsing.Escape(name)}\" " +
|
||||
$"\"{CommandParsing.Escape(description)}\" " +
|
||||
$"\"{CommandParsing.Escape(rules)}\"";
|
||||
|
||||
_consoleHost.ExecuteCommand(player.Session, makeGhostRoleCommand);
|
||||
|
||||
if (makeSentient)
|
||||
{
|
||||
var makeSentientCommand = $"makesentient \"{CommandParsing.Escape(uid.ToString())}\"";
|
||||
_consoleHost.ExecuteCommand(player.Session, makeSentientCommand);
|
||||
}
|
||||
|
||||
_window.Close();
|
||||
}
|
||||
|
||||
private void OnClose()
|
||||
{
|
||||
base.Closed();
|
||||
SendMessage(new CloseEuiMessage());
|
||||
}
|
||||
private void OnClose()
|
||||
{
|
||||
base.Closed();
|
||||
SendMessage(new CloseEuiMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user