From 78afc2db0feec48dc2f3befc6cac907125b90ff8 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Tue, 16 Feb 2021 09:51:27 +0100 Subject: [PATCH] Add make ghost role verb (#3204) --- .../{ => GhostRoles}/GhostRolesEntry.xaml | 0 .../{ => GhostRoles}/GhostRolesEntry.xaml.cs | 3 +- .../{ => GhostRoles}/GhostRolesEui.cs | 3 +- .../{ => GhostRoles}/GhostRolesWindow.xaml | 0 .../{ => GhostRoles}/GhostRolesWindow.xaml.cs | 3 +- .../Observer/GhostRoles/MakeGhostRoleEui.cs | 76 +++++++++++++++++++ .../GhostRoles/MakeGhostRoleWindow.xaml | 27 +++++++ .../GhostRoles/MakeGhostRoleWindow.xaml.cs | 49 ++++++++++++ .../GhostRoles/MakeGhostRoleCommand.cs | 63 +++++++++++++++ .../{ => GhostRoles}/GhostRoleComponent.cs | 16 ++-- .../GhostRoleMobSpawnerComponent.cs | 2 +- .../{ => GhostRoles}/GhostRolesEui.cs | 4 +- .../GhostTakeoverAvailableComponent.cs | 2 +- .../Observer/GhostRoles/MakeGhostRoleEui.cs | 42 ++++++++++ .../EntitySystems/GhostRoleSystem.cs | 25 +++++- .../GlobalVerbs/MakeGhostRoleVerb.cs | 62 +++++++++++++++ .../{ => GhostRoles}/GhostRolesEuiMessages.cs | 2 +- .../GhostRoles/MakeGhostRoleEuiState.cs | 18 +++++ .../MakeGhostRoleWindowClosedMessage.cs | 11 +++ 19 files changed, 388 insertions(+), 20 deletions(-) rename Content.Client/GameObjects/Components/Observer/{ => GhostRoles}/GhostRolesEntry.xaml (100%) rename Content.Client/GameObjects/Components/Observer/{ => GhostRoles}/GhostRolesEntry.xaml.cs (82%) rename Content.Client/GameObjects/Components/Observer/{ => GhostRoles}/GhostRolesEui.cs (90%) rename Content.Client/GameObjects/Components/Observer/{ => GhostRoles}/GhostRolesWindow.xaml (100%) rename Content.Client/GameObjects/Components/Observer/{ => GhostRoles}/GhostRolesWindow.xaml.cs (85%) create mode 100644 Content.Client/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleEui.cs create mode 100644 Content.Client/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleWindow.xaml create mode 100644 Content.Client/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleWindow.xaml.cs create mode 100644 Content.Server/Commands/GhostRoles/MakeGhostRoleCommand.cs rename Content.Server/GameObjects/Components/Observer/{ => GhostRoles}/GhostRoleComponent.cs (86%) rename Content.Server/GameObjects/Components/Observer/{ => GhostRoles}/GhostRoleMobSpawnerComponent.cs (97%) rename Content.Server/GameObjects/Components/Observer/{ => GhostRoles}/GhostRolesEui.cs (87%) rename Content.Server/GameObjects/Components/Observer/{ => GhostRoles}/GhostTakeoverAvailableComponent.cs (93%) create mode 100644 Content.Server/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleEui.cs create mode 100644 Content.Server/GlobalVerbs/MakeGhostRoleVerb.cs rename Content.Shared/GameObjects/Components/Observer/{ => GhostRoles}/GhostRolesEuiMessages.cs (93%) create mode 100644 Content.Shared/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleEuiState.cs create mode 100644 Content.Shared/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleWindowClosedMessage.cs diff --git a/Content.Client/GameObjects/Components/Observer/GhostRolesEntry.xaml b/Content.Client/GameObjects/Components/Observer/GhostRoles/GhostRolesEntry.xaml similarity index 100% rename from Content.Client/GameObjects/Components/Observer/GhostRolesEntry.xaml rename to Content.Client/GameObjects/Components/Observer/GhostRoles/GhostRolesEntry.xaml diff --git a/Content.Client/GameObjects/Components/Observer/GhostRolesEntry.xaml.cs b/Content.Client/GameObjects/Components/Observer/GhostRoles/GhostRolesEntry.xaml.cs similarity index 82% rename from Content.Client/GameObjects/Components/Observer/GhostRolesEntry.xaml.cs rename to Content.Client/GameObjects/Components/Observer/GhostRoles/GhostRolesEntry.xaml.cs index d00ebc0c91..2f3d1b0b2c 100644 --- a/Content.Client/GameObjects/Components/Observer/GhostRolesEntry.xaml.cs +++ b/Content.Client/GameObjects/Components/Observer/GhostRoles/GhostRolesEntry.xaml.cs @@ -1,10 +1,11 @@ using System; using Content.Shared.GameObjects.Components.Observer; +using Content.Shared.GameObjects.Components.Observer.GhostRoles; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; -namespace Content.Client.GameObjects.Components.Observer +namespace Content.Client.GameObjects.Components.Observer.GhostRoles { [GenerateTypedNameReferences] public partial class GhostRolesEntry : VBoxContainer diff --git a/Content.Client/GameObjects/Components/Observer/GhostRolesEui.cs b/Content.Client/GameObjects/Components/Observer/GhostRoles/GhostRolesEui.cs similarity index 90% rename from Content.Client/GameObjects/Components/Observer/GhostRolesEui.cs rename to Content.Client/GameObjects/Components/Observer/GhostRoles/GhostRolesEui.cs index e5d5c188b2..39b09dfb6c 100644 --- a/Content.Client/GameObjects/Components/Observer/GhostRolesEui.cs +++ b/Content.Client/GameObjects/Components/Observer/GhostRoles/GhostRolesEui.cs @@ -1,9 +1,10 @@ using Content.Client.Eui; using Content.Shared.Eui; using Content.Shared.GameObjects.Components.Observer; +using Content.Shared.GameObjects.Components.Observer.GhostRoles; using JetBrains.Annotations; -namespace Content.Client.GameObjects.Components.Observer +namespace Content.Client.GameObjects.Components.Observer.GhostRoles { [UsedImplicitly] public class GhostRolesEui : BaseEui diff --git a/Content.Client/GameObjects/Components/Observer/GhostRolesWindow.xaml b/Content.Client/GameObjects/Components/Observer/GhostRoles/GhostRolesWindow.xaml similarity index 100% rename from Content.Client/GameObjects/Components/Observer/GhostRolesWindow.xaml rename to Content.Client/GameObjects/Components/Observer/GhostRoles/GhostRolesWindow.xaml diff --git a/Content.Client/GameObjects/Components/Observer/GhostRolesWindow.xaml.cs b/Content.Client/GameObjects/Components/Observer/GhostRoles/GhostRolesWindow.xaml.cs similarity index 85% rename from Content.Client/GameObjects/Components/Observer/GhostRolesWindow.xaml.cs rename to Content.Client/GameObjects/Components/Observer/GhostRoles/GhostRolesWindow.xaml.cs index b67fa4782b..59cead269c 100644 --- a/Content.Client/GameObjects/Components/Observer/GhostRolesWindow.xaml.cs +++ b/Content.Client/GameObjects/Components/Observer/GhostRoles/GhostRolesWindow.xaml.cs @@ -1,10 +1,11 @@ using System; using Content.Shared.GameObjects.Components.Observer; +using Content.Shared.GameObjects.Components.Observer.GhostRoles; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface.CustomControls; using Robust.Shared.Maths; -namespace Content.Client.GameObjects.Components.Observer +namespace Content.Client.GameObjects.Components.Observer.GhostRoles { [GenerateTypedNameReferences] public partial class GhostRolesWindow : SS14Window diff --git a/Content.Client/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleEui.cs b/Content.Client/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleEui.cs new file mode 100644 index 0000000000..68714e4835 --- /dev/null +++ b/Content.Client/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleEui.cs @@ -0,0 +1,76 @@ +using Content.Client.Eui; +using Content.Shared.Eui; +using Content.Shared.GameObjects.Components.Observer.GhostRoles; +using JetBrains.Annotations; +using Robust.Client.Console; +using Robust.Client.Player; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Utility; + +namespace Content.Client.GameObjects.Components.Observer.GhostRoles +{ + [UsedImplicitly] + public class MakeGhostRoleEui : BaseEui + { + [Dependency] private readonly IPlayerManager _playerManager = default!; + [Dependency] private readonly IClientConsoleHost _consoleHost = default!; + + private readonly MakeGhostRoleWindow _window; + + public MakeGhostRoleEui() + { + _window = new MakeGhostRoleWindow(); + + _window.OnClose += OnClose; + _window.OnMake += OnMake; + } + + public override void HandleState(EuiStateBase state) + { + if (state is not MakeGhostRoleEuiState uiState) + { + return; + } + + _window.SetEntity(uiState.EntityUid); + } + + public override void Opened() + { + base.Opened(); + _window.OpenCentered(); + } + + private void OnMake(EntityUid uid, string name, string description, bool makeSentient) + { + var player = _playerManager.LocalPlayer; + if (player == null) + { + return; + } + + var makeGhostRoleCommand = + $"makeghostrole " + + $"\"{CommandParsing.Escape(uid.ToString())}\" " + + $"\"{CommandParsing.Escape(name)}\" " + + $"\"{CommandParsing.Escape(description)}\""; + + _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 MakeGhostRoleWindowClosedMessage()); + } + } +} diff --git a/Content.Client/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleWindow.xaml b/Content.Client/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleWindow.xaml new file mode 100644 index 0000000000..cadb52c617 --- /dev/null +++ b/Content.Client/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleWindow.xaml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Content.Client/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleWindow.xaml.cs b/Content.Client/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleWindow.xaml.cs new file mode 100644 index 0000000000..c12400eee7 --- /dev/null +++ b/Content.Client/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleWindow.xaml.cs @@ -0,0 +1,49 @@ +#nullable enable +using Robust.Client.AutoGenerated; +using Robust.Client.UserInterface.CustomControls; +using Robust.Client.UserInterface.XAML; +using Robust.Shared.GameObjects; +using static Robust.Client.UserInterface.Controls.BaseButton; + +namespace Content.Client.GameObjects.Components.Observer.GhostRoles +{ + [GenerateTypedNameReferences] + public partial class MakeGhostRoleWindow : SS14Window + { + public delegate void MakeRole(EntityUid uid, string name, string description, bool makeSentient); + + public MakeGhostRoleWindow() + { + RobustXamlLoader.Load(this); + + MakeSentientLabel.CustomMinimumSize = (150, 0); + RoleEntityLabel.CustomMinimumSize = (150, 0); + RoleNameLabel.CustomMinimumSize = (150, 0); + RoleName.CustomMinimumSize = (300, 0); + RoleDescriptionLabel.CustomMinimumSize = (150, 0); + RoleDescription.CustomMinimumSize = (300, 0); + + MakeButton.OnPressed += OnPressed; + } + + private EntityUid? EntityUid { get; set; } + + public event MakeRole? OnMake; + + public void SetEntity(EntityUid uid) + { + EntityUid = uid; + RoleEntity.Text = $"{uid}"; + } + + private void OnPressed(ButtonEventArgs args) + { + if (EntityUid == null) + { + return; + } + + OnMake?.Invoke(EntityUid.Value, RoleName.Text, RoleDescription.Text, MakeSentientCheckbox.Pressed); + } + } +} diff --git a/Content.Server/Commands/GhostRoles/MakeGhostRoleCommand.cs b/Content.Server/Commands/GhostRoles/MakeGhostRoleCommand.cs new file mode 100644 index 0000000000..107852b302 --- /dev/null +++ b/Content.Server/Commands/GhostRoles/MakeGhostRoleCommand.cs @@ -0,0 +1,63 @@ +#nullable enable +using Content.Server.Administration; +using Content.Server.GameObjects.Components.Mobs; +using Content.Server.GameObjects.Components.Observer.GhostRoles; +using Content.Shared.Administration; +using Robust.Shared.Console; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; + +namespace Content.Server.Commands.GhostRoles +{ + [AdminCommand(AdminFlags.Fun)] + public class MakeGhostRoleCommand : IConsoleCommand + { + public string Command => "makeghostrole"; + public string Description => "Turns an entity into a ghost role."; + public string Help => $"Usage: {Command} "; + + public void Execute(IConsoleShell shell, string argStr, string[] args) + { + if (args.Length != 3) + { + shell.WriteLine($"Invalid amount of arguments.\n{Help}"); + return; + } + + var entityManager = IoCManager.Resolve(); + + if (!EntityUid.TryParse(args[0], out var uid)) + { + shell.WriteLine($"{args[0]} is not a valid entity uid."); + return; + } + + if (!entityManager.TryGetEntity(uid, out var entity)) + { + shell.WriteLine($"No entity found with uid {uid}"); + return; + } + + if (entity.TryGetComponent(out MindComponent? mind) && + mind.HasMind) + { + shell.WriteLine($"Entity {entity.Name} with id {uid} already has a mind."); + return; + } + + var name = args[1]; + var description = args[2]; + + if (entity.EnsureComponent(out GhostTakeoverAvailableComponent takeOver)) + { + shell.WriteLine($"Entity {entity.Name} with id {uid} already has a {nameof(GhostTakeoverAvailableComponent)}"); + return; + } + + takeOver.RoleName = name; + takeOver.RoleDescription = description; + + shell.WriteLine($"Made entity {entity.Name} a ghost role."); + } + } +} diff --git a/Content.Server/GameObjects/Components/Observer/GhostRoleComponent.cs b/Content.Server/GameObjects/Components/Observer/GhostRoles/GhostRoleComponent.cs similarity index 86% rename from Content.Server/GameObjects/Components/Observer/GhostRoleComponent.cs rename to Content.Server/GameObjects/Components/Observer/GhostRoles/GhostRoleComponent.cs index 209b9f4a9a..b768a081eb 100644 --- a/Content.Server/GameObjects/Components/Observer/GhostRoleComponent.cs +++ b/Content.Server/GameObjects/Components/Observer/GhostRoles/GhostRoleComponent.cs @@ -4,7 +4,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; -namespace Content.Server.GameObjects.Components.Observer +namespace Content.Server.GameObjects.Components.Observer.GhostRoles { public abstract class GhostRoleComponent : Component { @@ -16,11 +16,8 @@ namespace Content.Server.GameObjects.Components.Observer [ViewVariables(VVAccess.ReadWrite)] public string RoleName { - get - { - return _roleName; - } - private set + get => _roleName; + set { _roleName = value; EntitySystem.Get().UpdateAllEui(); @@ -30,11 +27,8 @@ namespace Content.Server.GameObjects.Components.Observer [ViewVariables(VVAccess.ReadWrite)] public string RoleDescription { - get - { - return _roleDescription; - } - private set + get => _roleDescription; + set { _roleDescription = value; EntitySystem.Get().UpdateAllEui(); diff --git a/Content.Server/GameObjects/Components/Observer/GhostRoleMobSpawnerComponent.cs b/Content.Server/GameObjects/Components/Observer/GhostRoles/GhostRoleMobSpawnerComponent.cs similarity index 97% rename from Content.Server/GameObjects/Components/Observer/GhostRoleMobSpawnerComponent.cs rename to Content.Server/GameObjects/Components/Observer/GhostRoles/GhostRoleMobSpawnerComponent.cs index 632ec9eb81..db9e0ceb11 100644 --- a/Content.Server/GameObjects/Components/Observer/GhostRoleMobSpawnerComponent.cs +++ b/Content.Server/GameObjects/Components/Observer/GhostRoles/GhostRoleMobSpawnerComponent.cs @@ -8,7 +8,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; -namespace Content.Server.GameObjects.Components.Observer +namespace Content.Server.GameObjects.Components.Observer.GhostRoles { /// /// Allows a ghost to take this role, spawning a new entity. diff --git a/Content.Server/GameObjects/Components/Observer/GhostRolesEui.cs b/Content.Server/GameObjects/Components/Observer/GhostRoles/GhostRolesEui.cs similarity index 87% rename from Content.Server/GameObjects/Components/Observer/GhostRolesEui.cs rename to Content.Server/GameObjects/Components/Observer/GhostRoles/GhostRolesEui.cs index 4e1b431844..82728330e3 100644 --- a/Content.Server/GameObjects/Components/Observer/GhostRolesEui.cs +++ b/Content.Server/GameObjects/Components/Observer/GhostRoles/GhostRolesEui.cs @@ -1,10 +1,10 @@ using Content.Server.Eui; using Content.Server.GameObjects.EntitySystems; using Content.Shared.Eui; -using Content.Shared.GameObjects.Components.Observer; +using Content.Shared.GameObjects.Components.Observer.GhostRoles; using Robust.Shared.GameObjects; -namespace Content.Server.GameObjects.Components.Observer +namespace Content.Server.GameObjects.Components.Observer.GhostRoles { public class GhostRolesEui : BaseEui { diff --git a/Content.Server/GameObjects/Components/Observer/GhostTakeoverAvailableComponent.cs b/Content.Server/GameObjects/Components/Observer/GhostRoles/GhostTakeoverAvailableComponent.cs similarity index 93% rename from Content.Server/GameObjects/Components/Observer/GhostTakeoverAvailableComponent.cs rename to Content.Server/GameObjects/Components/Observer/GhostRoles/GhostTakeoverAvailableComponent.cs index 5ac64295f3..8d46baf34d 100644 --- a/Content.Server/GameObjects/Components/Observer/GhostTakeoverAvailableComponent.cs +++ b/Content.Server/GameObjects/Components/Observer/GhostRoles/GhostTakeoverAvailableComponent.cs @@ -5,7 +5,7 @@ using Content.Server.Players; using Robust.Server.Player; using Robust.Shared.GameObjects; -namespace Content.Server.GameObjects.Components.Observer +namespace Content.Server.GameObjects.Components.Observer.GhostRoles { /// /// Allows a ghost to take over the Owner entity. diff --git a/Content.Server/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleEui.cs b/Content.Server/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleEui.cs new file mode 100644 index 0000000000..732c658271 --- /dev/null +++ b/Content.Server/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleEui.cs @@ -0,0 +1,42 @@ +using Content.Server.Eui; +using Content.Server.GameObjects.EntitySystems; +using Content.Shared.Eui; +using Content.Shared.GameObjects.Components.Observer.GhostRoles; +using Robust.Shared.GameObjects; + +namespace Content.Server.GameObjects.Components.Observer.GhostRoles +{ + public class MakeGhostRoleEui : BaseEui + { + public MakeGhostRoleEui(EntityUid entityUid) + { + EntityUid = entityUid; + } + + public EntityUid EntityUid { get; } + + public override EuiStateBase GetNewState() + { + return new MakeGhostRoleEuiState(EntityUid); + } + + public override void HandleMessage(EuiMessageBase msg) + { + base.HandleMessage(msg); + + switch (msg) + { + case MakeGhostRoleWindowClosedMessage _: + Closed(); + break; + } + } + + public override void Closed() + { + base.Closed(); + + EntitySystem.Get().CloseMakeGhostRoleEui(Player); + } + } +} diff --git a/Content.Server/GameObjects/EntitySystems/GhostRoleSystem.cs b/Content.Server/GameObjects/EntitySystems/GhostRoleSystem.cs index f3eff20a12..61e5ba93e2 100644 --- a/Content.Server/GameObjects/EntitySystems/GhostRoleSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/GhostRoleSystem.cs @@ -2,7 +2,8 @@ using System.Collections.Generic; using Content.Server.Administration; using Content.Server.Eui; using Content.Server.GameObjects.Components.Observer; -using Content.Shared.GameObjects.Components.Observer; +using Content.Server.GameObjects.Components.Observer.GhostRoles; +using Content.Shared.GameObjects.Components.Observer.GhostRoles; using Content.Shared.GameTicking; using JetBrains.Annotations; using Robust.Server.GameObjects; @@ -22,6 +23,7 @@ namespace Content.Server.GameObjects.EntitySystems private uint _nextRoleIdentifier = 0; private readonly Dictionary _ghostRoles = new(); private readonly Dictionary _openUis = new(); + private readonly Dictionary _openMakeGhostRoleUis = new(); [ViewVariables] public IReadOnlyCollection GhostRoles => _ghostRoles.Values; @@ -49,6 +51,19 @@ namespace Content.Server.GameObjects.EntitySystems eui.StateDirty(); } + public void OpenMakeGhostRoleEui(IPlayerSession session, EntityUid uid) + { + if (session.AttachedEntity == null) + return; + + if (_openMakeGhostRoleUis.ContainsKey(session)) + CloseEui(session); + + var eui = _openMakeGhostRoleUis[session] = new MakeGhostRoleEui(uid); + _euiManager.OpenEui(eui, session); + eui.StateDirty(); + } + public void CloseEui(IPlayerSession session) { if (!_openUis.ContainsKey(session)) return; @@ -58,6 +73,14 @@ namespace Content.Server.GameObjects.EntitySystems eui?.Close(); } + public void CloseMakeGhostRoleEui(IPlayerSession session) + { + if (_openMakeGhostRoleUis.Remove(session, out var eui)) + { + eui?.Close(); + } + } + public void UpdateAllEui() { foreach (var eui in _openUis.Values) diff --git a/Content.Server/GlobalVerbs/MakeGhostRoleVerb.cs b/Content.Server/GlobalVerbs/MakeGhostRoleVerb.cs new file mode 100644 index 0000000000..be4e3c5c67 --- /dev/null +++ b/Content.Server/GlobalVerbs/MakeGhostRoleVerb.cs @@ -0,0 +1,62 @@ +#nullable enable +using Content.Server.GameObjects.Components.Mobs; +using Content.Server.GameObjects.EntitySystems; +using Content.Shared.GameObjects.Verbs; +using Robust.Server.Console; +using Robust.Server.GameObjects; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Localization; + +namespace Content.Server.GlobalVerbs +{ + [GlobalVerb] + public class MakeGhostRoleVerb : GlobalVerb + { + public override bool RequireInteractionRange => false; + public override bool BlockedByContainers => false; + + public override void GetData(IEntity user, IEntity target, VerbData data) + { + data.Visibility = VerbVisibility.Invisible; + + var groupController = IoCManager.Resolve(); + + if (target.TryGetComponent(out MindComponent? mind) && + mind.HasMind) + { + return; + } + + if (!user.TryGetComponent(out IActorComponent? actor) || + !groupController.CanCommand(actor.playerSession, "makeghostrole")) + { + return; + } + + data.Visibility = VerbVisibility.Visible; + data.Text = Loc.GetString("Make Ghost Role"); + data.CategoryData = VerbCategories.Debug; + } + + public override void Activate(IEntity user, IEntity target) + { + var groupController = IoCManager.Resolve(); + + if (target.TryGetComponent(out MindComponent? mind) && + mind.HasMind) + { + return; + } + + if (!user.TryGetComponent(out IActorComponent? actor) || + !groupController.CanCommand(actor.playerSession, "makeghostrole")) + { + return; + } + + var ghostRoleSystem = EntitySystem.Get(); + ghostRoleSystem.OpenMakeGhostRoleEui(actor.playerSession, target.Uid); + } + } +} diff --git a/Content.Shared/GameObjects/Components/Observer/GhostRolesEuiMessages.cs b/Content.Shared/GameObjects/Components/Observer/GhostRoles/GhostRolesEuiMessages.cs similarity index 93% rename from Content.Shared/GameObjects/Components/Observer/GhostRolesEuiMessages.cs rename to Content.Shared/GameObjects/Components/Observer/GhostRoles/GhostRolesEuiMessages.cs index ce646e8d8b..9c2d10a5f0 100644 --- a/Content.Shared/GameObjects/Components/Observer/GhostRolesEuiMessages.cs +++ b/Content.Shared/GameObjects/Components/Observer/GhostRoles/GhostRolesEuiMessages.cs @@ -2,7 +2,7 @@ using System; using Content.Shared.Eui; using Robust.Shared.Serialization; -namespace Content.Shared.GameObjects.Components.Observer +namespace Content.Shared.GameObjects.Components.Observer.GhostRoles { [NetSerializable, Serializable] public struct GhostRoleInfo diff --git a/Content.Shared/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleEuiState.cs b/Content.Shared/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleEuiState.cs new file mode 100644 index 0000000000..21735e3e9f --- /dev/null +++ b/Content.Shared/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleEuiState.cs @@ -0,0 +1,18 @@ +using System; +using Content.Shared.Eui; +using Robust.Shared.GameObjects; +using Robust.Shared.Serialization; + +namespace Content.Shared.GameObjects.Components.Observer.GhostRoles +{ + [Serializable, NetSerializable] + public class MakeGhostRoleEuiState : EuiStateBase + { + public MakeGhostRoleEuiState(EntityUid entityUid) + { + EntityUid = entityUid; + } + + public EntityUid EntityUid { get; } + } +} diff --git a/Content.Shared/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleWindowClosedMessage.cs b/Content.Shared/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleWindowClosedMessage.cs new file mode 100644 index 0000000000..b604223dd4 --- /dev/null +++ b/Content.Shared/GameObjects/Components/Observer/GhostRoles/MakeGhostRoleWindowClosedMessage.cs @@ -0,0 +1,11 @@ +using System; +using Content.Shared.Eui; +using Robust.Shared.Serialization; + +namespace Content.Shared.GameObjects.Components.Observer.GhostRoles +{ + [Serializable, NetSerializable] + public class MakeGhostRoleWindowClosedMessage : EuiMessageBase + { + } +}