Add commands to show and hide organs inside bodies (#2292)
* Add seeing entities through containers and on the context menu and 4 commands * Remove unused imports
This commit is contained in:
26
Content.Server/Commands/HideContainedContextCommand.cs
Normal file
26
Content.Server/Commands/HideContainedContextCommand.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
#nullable enable
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Robust.Server.Interfaces.Console;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
|
||||
namespace Content.Server.Commands
|
||||
{
|
||||
public class HideContainedContextCommand : IClientCommand
|
||||
{
|
||||
public string Command => "hidecontainedcontext";
|
||||
public string Description => $"Reverts the effects of {ShowContainedContextCommand.CommandName}";
|
||||
public string Help => $"{Command}";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
shell.SendText(player, "You need to be a player to use this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
EntitySystem.Get<VerbSystem>().RemoveContainerVisibility(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Content.Server/Commands/ShowContainedContextCommand.cs
Normal file
29
Content.Server/Commands/ShowContainedContextCommand.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
#nullable enable
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Robust.Server.Interfaces.Console;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
|
||||
namespace Content.Server.Commands
|
||||
{
|
||||
public class ShowContainedContextCommand : IClientCommand
|
||||
{
|
||||
public const string CommandName = "showcontainedcontext";
|
||||
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
public string Command => CommandName;
|
||||
public string Description => "Makes contained entities visible on the context menu, even when they shouldn't be.";
|
||||
public string Help => $"{Command}";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
shell.SendText(player, "You need to be a player to use this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
EntitySystem.Get<VerbSystem>().AddContainerVisibility(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Content.Shared.GameObjects.EntitySystemMessages;
|
||||
using Content.Shared.GameObjects.Verbs;
|
||||
using Content.Shared.GameTicking;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -10,18 +15,63 @@ using static Content.Shared.GameObjects.EntitySystemMessages.VerbSystemMessages;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
public class VerbSystem : SharedVerbSystem
|
||||
public class VerbSystem : SharedVerbSystem, IResettingEntitySystem
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
|
||||
private readonly HashSet<IPlayerSession> _seesThroughContainers = new HashSet<IPlayerSession>();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
SubscribeNetworkEvent<RequestVerbsMessage>(RequestVerbs);
|
||||
SubscribeNetworkEvent<UseVerbMessage>(UseVerb);
|
||||
|
||||
IoCManager.InjectDependencies(this);
|
||||
_playerManager.PlayerStatusChanged += PlayerStatusChanged;
|
||||
}
|
||||
|
||||
private void PlayerStatusChanged(object? sender, SessionStatusEventArgs args)
|
||||
{
|
||||
if (args.NewStatus == SessionStatus.Disconnected)
|
||||
{
|
||||
_seesThroughContainers.Remove(args.Session);
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_seesThroughContainers.Clear();
|
||||
}
|
||||
|
||||
public void AddContainerVisibility(IPlayerSession session)
|
||||
{
|
||||
if (!_seesThroughContainers.Add(session))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var message = new PlayerContainerVisibilityMessage(true);
|
||||
RaiseNetworkEvent(message, session.ConnectedClient);
|
||||
}
|
||||
|
||||
public void RemoveContainerVisibility(IPlayerSession session)
|
||||
{
|
||||
if (!_seesThroughContainers.Remove(session))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var message = new PlayerContainerVisibilityMessage(false);
|
||||
RaiseNetworkEvent(message, session.ConnectedClient);
|
||||
}
|
||||
|
||||
public bool HasContainerVisibility(IPlayerSession session)
|
||||
{
|
||||
return _seesThroughContainers.Contains(session);
|
||||
}
|
||||
|
||||
private void UseVerb(UseVerbMessage use, EntitySessionEventArgs eventArgs)
|
||||
|
||||
Reference in New Issue
Block a user