Reorganize commands into the Commands folder (#2679)
* Reorganize commands into the Commands folder * RIDER
This commit is contained in:
@@ -1,250 +0,0 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Server.Administration;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.GameObjects.Components.Body;
|
||||
using Content.Shared.GameObjects.Components.Body.Part;
|
||||
using Content.Shared.GameObjects.Components.Damage;
|
||||
using Robust.Server.Interfaces.Console;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Random;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Body
|
||||
{
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
class AddHandCommand : IClientCommand
|
||||
{
|
||||
public const string DefaultHandPrototype = "LeftHandHuman";
|
||||
|
||||
public string Command => "addhand";
|
||||
public string Description => "Adds a hand to your entity.";
|
||||
public string Help => $"Usage: {Command} <entityUid> <handPrototypeId> / {Command} <entityUid> / {Command} <handPrototypeId> / {Command}";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
|
||||
{
|
||||
if (args.Length > 1)
|
||||
{
|
||||
shell.SendText(player, Help);
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
|
||||
IEntity entity;
|
||||
IEntity hand;
|
||||
|
||||
switch (args.Length)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
shell.SendText(player, "Only a player can run this command without arguments.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.AttachedEntity == null)
|
||||
{
|
||||
shell.SendText(player, "You don't have an entity to add a hand to.");
|
||||
return;
|
||||
}
|
||||
|
||||
entity = player.AttachedEntity;
|
||||
hand = entityManager.SpawnEntity(DefaultHandPrototype, entity.Transform.Coordinates);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (EntityUid.TryParse(args[0], out var uid))
|
||||
{
|
||||
if (!entityManager.TryGetEntity(uid, out var parsedEntity))
|
||||
{
|
||||
shell.SendText(player, $"No entity found with uid {uid}");
|
||||
return;
|
||||
}
|
||||
|
||||
entity = parsedEntity;
|
||||
hand = entityManager.SpawnEntity(DefaultHandPrototype, entity.Transform.Coordinates);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
shell.SendText(player,
|
||||
"You must specify an entity to add a hand to when using this command from the server terminal.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.AttachedEntity == null)
|
||||
{
|
||||
shell.SendText(player, "You don't have an entity to add a hand to.");
|
||||
return;
|
||||
}
|
||||
|
||||
entity = player.AttachedEntity;
|
||||
hand = entityManager.SpawnEntity(args[0], entity.Transform.Coordinates);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (!EntityUid.TryParse(args[0], out var uid))
|
||||
{
|
||||
shell.SendText(player, $"{args[0]} is not a valid entity uid.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.TryGetEntity(uid, out var parsedEntity))
|
||||
{
|
||||
shell.SendText(player, $"No entity exists with uid {uid}.");
|
||||
return;
|
||||
}
|
||||
|
||||
entity = parsedEntity;
|
||||
|
||||
if (!prototypeManager.HasIndex<EntityPrototype>(args[1]))
|
||||
{
|
||||
shell.SendText(player, $"No hand entity exists with id {args[1]}.");
|
||||
return;
|
||||
}
|
||||
|
||||
hand = entityManager.SpawnEntity(args[1], entity.Transform.Coordinates);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
shell.SendText(player, Help);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!entity.TryGetComponent(out IBody? body))
|
||||
{
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
|
||||
|
||||
shell.SendText(player, text);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hand.TryGetComponent(out IBodyPart? part))
|
||||
{
|
||||
shell.SendText(player, $"Hand entity {hand} does not have a {nameof(IBodyPart)} component.");
|
||||
return;
|
||||
}
|
||||
|
||||
var slot = part.GetHashCode().ToString();
|
||||
var response = body.TryAddPart(slot, part, true)
|
||||
? $"Added hand to entity {entity.Name}"
|
||||
: $"Error occurred trying to add a hand to entity {entity.Name}";
|
||||
|
||||
shell.SendText(player, response);
|
||||
}
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
class RemoveHandCommand : IClientCommand
|
||||
{
|
||||
public string Command => "removehand";
|
||||
public string Description => "Removes a hand from your entity.";
|
||||
public string Help => $"Usage: {Command}";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
shell.SendText(player, "Only a player can run this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.AttachedEntity == null)
|
||||
{
|
||||
shell.SendText(player, "You have no entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.AttachedEntity.TryGetComponent(out IBody? body))
|
||||
{
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
|
||||
|
||||
shell.SendText(player, text);
|
||||
return;
|
||||
}
|
||||
|
||||
var hand = body.Parts.FirstOrDefault(x => x.Value.PartType == BodyPartType.Hand);
|
||||
if (hand.Value.Equals(default))
|
||||
{
|
||||
shell.SendText(player, "You have no hands.");
|
||||
}
|
||||
else
|
||||
{
|
||||
body.RemovePart(hand.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
class DestroyMechanismCommand : IClientCommand
|
||||
{
|
||||
public string Command => "destroymechanism";
|
||||
public string Description => "Destroys a mechanism from your entity";
|
||||
public string Help => $"Usage: {Command} <mechanism>";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
shell.SendText(player, "Only a player can run this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
shell.SendText(player, Help);
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.AttachedEntity == null)
|
||||
{
|
||||
shell.SendText(player, "You have no entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.AttachedEntity.TryGetComponent(out IBody? body))
|
||||
{
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
|
||||
|
||||
shell.SendText(player, text);
|
||||
return;
|
||||
}
|
||||
|
||||
var mechanismName = string.Join(" ", args).ToLowerInvariant();
|
||||
|
||||
foreach (var part in body.Parts.Values)
|
||||
foreach (var mechanism in part.Mechanisms)
|
||||
{
|
||||
if (mechanism.Name.ToLowerInvariant() == mechanismName)
|
||||
{
|
||||
part.DeleteMechanism(mechanism);
|
||||
shell.SendText(player, $"Mechanism with name {mechanismName} has been destroyed.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
shell.SendText(player, $"No mechanism was found with name {mechanismName}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#nullable enable
|
||||
using Content.Server.Observer;
|
||||
using Content.Server.Commands.Observer;
|
||||
using Content.Shared.GameObjects.Components.Body;
|
||||
using Content.Shared.GameObjects.Components.Body.Part;
|
||||
using Content.Shared.GameObjects.Components.Damage;
|
||||
|
||||
@@ -1,216 +0,0 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.GameObjects.Components.Damage;
|
||||
using Robust.Server.Interfaces.Console;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Damage
|
||||
{
|
||||
public abstract class DamageFlagCommand : IClientCommand
|
||||
{
|
||||
public abstract string Command { get; }
|
||||
public abstract string Description { get; }
|
||||
public abstract string Help { get; }
|
||||
|
||||
public abstract void Execute(IConsoleShell shell, IPlayerSession? player, string[] args);
|
||||
|
||||
public bool TryGetEntity(
|
||||
IConsoleShell shell,
|
||||
IPlayerSession? player,
|
||||
string[] args,
|
||||
bool adding,
|
||||
[NotNullWhen(true)] out IEntity? entity,
|
||||
out DamageFlag flag,
|
||||
[NotNullWhen(true)] out IDamageableComponent? damageable)
|
||||
{
|
||||
entity = null;
|
||||
flag = DamageFlag.None;
|
||||
damageable = null;
|
||||
|
||||
IEntity? parsedEntity;
|
||||
DamageFlag parsedFlag;
|
||||
IDamageableComponent? parsedDamageable;
|
||||
|
||||
switch (args.Length)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
shell.SendText(player, "An entity needs to be specified when the command isn't used by a player.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.AttachedEntity == null)
|
||||
{
|
||||
shell.SendText(player, "An entity needs to be specified when you aren't attached to an entity.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Enum.TryParse(args[0], true, out parsedFlag))
|
||||
{
|
||||
shell.SendText(player, $"{args[0]} is not a valid damage flag.");
|
||||
return false;
|
||||
}
|
||||
|
||||
parsedEntity = player.AttachedEntity;
|
||||
flag = parsedFlag;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (!EntityUid.TryParse(args[0], out var id))
|
||||
{
|
||||
shell.SendText(player, $"{args[0]} isn't a valid entity id.");
|
||||
return false;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entityManager.TryGetEntity(id, out parsedEntity))
|
||||
{
|
||||
shell.SendText(player, $"No entity found with id {id}.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Enum.TryParse(args[1], true, out parsedFlag))
|
||||
{
|
||||
shell.SendText(player, $"{args[1]} is not a valid damage flag.");
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
shell.SendText(player, Help);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parsedEntity.TryGetComponent(out parsedDamageable))
|
||||
{
|
||||
shell.SendText(player, $"Entity {parsedEntity.Name} doesn't have a {nameof(IDamageableComponent)}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (parsedDamageable.HasFlag(parsedFlag) && adding)
|
||||
{
|
||||
shell.SendText(player, $"Entity {parsedEntity.Name} already has damage flag {parsedFlag}.");
|
||||
return false;
|
||||
}
|
||||
else if (!parsedDamageable.HasFlag(parsedFlag) && !adding)
|
||||
{
|
||||
shell.SendText(player, $"Entity {parsedEntity.Name} doesn't have damage flag {parsedFlag}.");
|
||||
return false;
|
||||
}
|
||||
|
||||
entity = parsedEntity;
|
||||
flag = parsedFlag;
|
||||
damageable = parsedDamageable;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
public class AddDamageFlagCommand : DamageFlagCommand
|
||||
{
|
||||
public override string Command => "adddamageflag";
|
||||
public override string Description => "Adds a damage flag to your entity or another.";
|
||||
public override string Help => $"Usage: {Command} <flag> / {Command} <entityUid> <flag>";
|
||||
|
||||
public override void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
|
||||
{
|
||||
if (!TryGetEntity(shell, player, args, true, out var entity, out var flag, out var damageable))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
damageable.AddFlag(flag);
|
||||
shell.SendText(player, $"Added damage flag {flag} to entity {entity.Name}");
|
||||
}
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
public class RemoveDamageFlagCommand : DamageFlagCommand
|
||||
{
|
||||
public override string Command => "removedamageflag";
|
||||
public override string Description => "Removes a damage flag from your entity or another.";
|
||||
public override string Help => $"Usage: {Command} <flag> / {Command} <entityUid> <flag>";
|
||||
|
||||
public override void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
|
||||
{
|
||||
if (!TryGetEntity(shell, player, args, false, out var entity, out var flag, out var damageable))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
damageable.RemoveFlag(flag);
|
||||
shell.SendText(player, $"Removed damage flag {flag} from entity {entity.Name}");
|
||||
}
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public class GodModeCommand : IClientCommand
|
||||
{
|
||||
public string Command => "godmode";
|
||||
public string Description => "Makes your entity or another invulnerable to almost anything. May have irreversible changes.";
|
||||
public string Help => $"Usage: {Command} / {Command} <entityUid>";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
|
||||
{
|
||||
IEntity entity;
|
||||
|
||||
switch (args.Length)
|
||||
{
|
||||
case 0:
|
||||
if (player == null)
|
||||
{
|
||||
shell.SendText(player, "An entity needs to be specified when the command isn't used by a player.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.AttachedEntity == null)
|
||||
{
|
||||
shell.SendText(player, "An entity needs to be specified when you aren't attached to an entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
entity = player.AttachedEntity;
|
||||
break;
|
||||
case 1:
|
||||
if (!EntityUid.TryParse(args[0], out var id))
|
||||
{
|
||||
shell.SendText(player, $"{args[0]} isn't a valid entity id.");
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entityManager.TryGetEntity(id, out var parsedEntity))
|
||||
{
|
||||
shell.SendText(player, $"No entity found with id {id}.");
|
||||
return;
|
||||
}
|
||||
|
||||
entity = parsedEntity;
|
||||
break;
|
||||
default:
|
||||
shell.SendText(player, Help);
|
||||
return;
|
||||
}
|
||||
|
||||
var godmodeSystem = EntitySystem.Get<GodmodeSystem>();
|
||||
var enabled = godmodeSystem.ToggleGodmode(entity);
|
||||
|
||||
shell.SendText(player, enabled
|
||||
? $"Enabled godmode for entity {entity.Name} with id {entity.Uid}"
|
||||
: $"Disabled godmode for entity {entity.Name} with id {entity.Uid}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
#nullable enable
|
||||
using Content.Server.Administration;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Interfaces.Console;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Disposal
|
||||
{
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public class TubeConnectionsCommand : IClientCommand
|
||||
{
|
||||
public string Command => "tubeconnections";
|
||||
public string Description => Loc.GetString("Shows all the directions that a tube can connect in.");
|
||||
public string Help => $"Usage: {Command} <entityUid>";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
|
||||
{
|
||||
if (player?.AttachedEntity == null)
|
||||
{
|
||||
shell.SendText(player, Loc.GetString("Only players can use this command"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length < 1)
|
||||
{
|
||||
shell.SendText(player, Help);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var id))
|
||||
{
|
||||
shell.SendText(player, Loc.GetString("{0} isn't a valid entity uid", args[0]));
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entityManager.TryGetEntity(id, out var entity))
|
||||
{
|
||||
shell.SendText(player, Loc.GetString("No entity exists with uid {0}", id));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entity.TryGetComponent(out IDisposalTubeComponent? tube))
|
||||
{
|
||||
shell.SendText(player, Loc.GetString("Entity with uid {0} doesn't have a {1} component", id, nameof(IDisposalTubeComponent)));
|
||||
return;
|
||||
}
|
||||
|
||||
tube.PopupDirections(player.AttachedEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
#nullable enable
|
||||
using System.Linq;
|
||||
using Content.Server.Administration;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Maps;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.Interfaces.Console;
|
||||
using Robust.Server.Interfaces.GameObjects;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Interactable
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="TilePryingComponent.TryPryTile"/>
|
||||
/// </summary>
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
class TilePryCommand : IClientCommand
|
||||
{
|
||||
public string Command => "tilepry";
|
||||
public string Description => "Pries up all tiles in a radius around the user.";
|
||||
public string Help => $"Usage: {Command} <radius>";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
|
||||
{
|
||||
if (player?.AttachedEntity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length != 1)
|
||||
{
|
||||
shell.SendText(player, Help);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(args[0], out var radius))
|
||||
{
|
||||
shell.SendText(player, $"{args[0]} isn't a valid integer.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (radius < 0)
|
||||
{
|
||||
shell.SendText(player, "Radius must be positive.");
|
||||
return;
|
||||
}
|
||||
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
var playerGrid = player.AttachedEntity.Transform.GridID;
|
||||
var mapGrid = mapManager.GetGrid(playerGrid);
|
||||
var playerPosition = player.AttachedEntity.Transform.Coordinates;
|
||||
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
|
||||
|
||||
for (var i = -radius; i <= radius; i++)
|
||||
{
|
||||
for (var j = -radius; j <= radius; j++)
|
||||
{
|
||||
var tile = mapGrid.GetTileRef(playerPosition.Offset((i, j)));
|
||||
var coordinates = mapGrid.GridTileToLocal(tile.GridIndices);
|
||||
var tileDef = (ContentTileDefinition) tileDefinitionManager[tile.Tile.TypeId];
|
||||
|
||||
if (!tileDef.CanCrowbar) continue;
|
||||
|
||||
var underplating = tileDefinitionManager["underplating"];
|
||||
mapGrid.SetTile(coordinates, new Tile(underplating.TileId));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
class AnchorCommand : IClientCommand
|
||||
{
|
||||
public string Command => "anchor";
|
||||
public string Description => "Anchors all entities in a radius around the user";
|
||||
public string Help => $"Usage: {Command} <radius>";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
|
||||
{
|
||||
if (player?.AttachedEntity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length != 1)
|
||||
{
|
||||
shell.SendText(player, Help);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(args[0], out var radius))
|
||||
{
|
||||
shell.SendText(player, $"{args[0]} isn't a valid integer.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (radius < 0)
|
||||
{
|
||||
shell.SendText(player, "Radius must be positive.");
|
||||
return;
|
||||
}
|
||||
|
||||
var serverEntityManager = IoCManager.Resolve<IServerEntityManager>();
|
||||
var entities = serverEntityManager.GetEntitiesInRange(player.AttachedEntity, radius).ToList();
|
||||
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
if (entity.TryGetComponent(out AnchorableComponent? anchorable))
|
||||
{
|
||||
_ = anchorable.TryAnchor(player.AttachedEntity, force: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
class UnAnchorCommand : IClientCommand
|
||||
{
|
||||
public string Command => "unanchor";
|
||||
public string Description => "Unanchors all anchorable entities in a radius around the user";
|
||||
public string Help => $"Usage: {Command} <radius>";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
|
||||
{
|
||||
if (player?.AttachedEntity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length != 1)
|
||||
{
|
||||
shell.SendText(player, Help);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(args[0], out var radius))
|
||||
{
|
||||
shell.SendText(player, $"{args[0]} isn't a valid integer.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (radius < 0)
|
||||
{
|
||||
shell.SendText(player, "Radius must be positive.");
|
||||
return;
|
||||
}
|
||||
|
||||
var serverEntityManager = IoCManager.Resolve<IServerEntityManager>();
|
||||
var entities = serverEntityManager.GetEntitiesInRange(player.AttachedEntity, radius).ToList();
|
||||
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
if (entity.TryGetComponent(out AnchorableComponent? anchorable))
|
||||
{
|
||||
_ = anchorable.TryUnAnchor(player.AttachedEntity, force: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,9 @@
|
||||
using System;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Commands;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Robust.Server.Interfaces.Console;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Players;
|
||||
|
||||
@@ -89,82 +82,4 @@ namespace Content.Server.GameObjects.Components.Mobs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public sealed class ShowAlert : IClientCommand
|
||||
{
|
||||
public string Command => "showalert";
|
||||
public string Description => "Shows an alert for a player, defaulting to current player";
|
||||
public string Help => "showalert <alertType> <severity, -1 if no severity> <name or userID, omit for current player>";
|
||||
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
|
||||
{
|
||||
var attachedEntity = player.AttachedEntity;
|
||||
if (args.Length > 2)
|
||||
{
|
||||
var target = args[2];
|
||||
if (!Commands.CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return;
|
||||
}
|
||||
|
||||
if (!CommandUtils.ValidateAttachedEntity(shell, player, attachedEntity)) return;
|
||||
|
||||
|
||||
if (!attachedEntity.TryGetComponent(out ServerAlertsComponent alertsComponent))
|
||||
{
|
||||
shell.SendText(player, "user has no alerts component");
|
||||
return;
|
||||
}
|
||||
|
||||
var alertType = args[0];
|
||||
var severity = args[1];
|
||||
var alertMgr = IoCManager.Resolve<AlertManager>();
|
||||
if (!alertMgr.TryGet(Enum.Parse<AlertType>(alertType), out var alert))
|
||||
{
|
||||
shell.SendText(player, "unrecognized alertType " + alertType);
|
||||
return;
|
||||
}
|
||||
if (!short.TryParse(severity, out var sevint))
|
||||
{
|
||||
shell.SendText(player, "invalid severity " + sevint);
|
||||
return;
|
||||
}
|
||||
alertsComponent.ShowAlert(alert.AlertType, sevint == -1 ? (short?) null : sevint);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public sealed class ClearAlert : IClientCommand
|
||||
{
|
||||
public string Command => "clearalert";
|
||||
public string Description => "Clears an alert for a player, defaulting to current player";
|
||||
public string Help => "clearalert <alertType> <name or userID, omit for current player>";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
|
||||
{
|
||||
var attachedEntity = player.AttachedEntity;
|
||||
if (args.Length > 1)
|
||||
{
|
||||
var target = args[1];
|
||||
if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return;
|
||||
}
|
||||
|
||||
if (!CommandUtils.ValidateAttachedEntity(shell, player, attachedEntity)) return;
|
||||
|
||||
if (!attachedEntity.TryGetComponent(out ServerAlertsComponent alertsComponent))
|
||||
{
|
||||
shell.SendText(player, "user has no alerts component");
|
||||
return;
|
||||
}
|
||||
|
||||
var alertType = args[0];
|
||||
var alertMgr = IoCManager.Resolve<AlertManager>();
|
||||
if (!alertMgr.TryGet(Enum.Parse<AlertType>(alertType), out var alert))
|
||||
{
|
||||
shell.SendText(player, "unrecognized alertType " + alertType);
|
||||
return;
|
||||
}
|
||||
|
||||
alertsComponent.ClearAlert(alert.AlertType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Content.Server.Administration;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Interfaces.Console;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Mobs.Speech
|
||||
namespace Content.Server.GameObjects.Components.Mobs.Speech
|
||||
{
|
||||
internal interface IAccentComponent
|
||||
{
|
||||
@@ -18,79 +9,4 @@ namespace Content.Server.GameObjects.Components.Mobs.Speech
|
||||
/// <returns>The message after the transformation</returns>
|
||||
public string Accentuate(string message);
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
public class AddAccent : IClientCommand
|
||||
{
|
||||
public string Command => "addaccent";
|
||||
|
||||
public string Description => "Add a speech component to the current player";
|
||||
|
||||
public string Help => $"{Command} <component>/?";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
|
||||
{
|
||||
if (args.Length == 0)
|
||||
{
|
||||
shell.SendText(player, Help);
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.AttachedEntity == null)
|
||||
{
|
||||
shell.SendText(player, "You don't have a player!");
|
||||
return;
|
||||
}
|
||||
|
||||
var compFactory = IoCManager.Resolve<IComponentFactory>();
|
||||
|
||||
if (args[0] == "?")
|
||||
{
|
||||
// Get all components that implement the ISpeechComponent except
|
||||
var speeches = compFactory.GetAllRefTypes()
|
||||
.Where(c => typeof(IAccentComponent).IsAssignableFrom(c) && c.IsClass);
|
||||
var msg = "";
|
||||
foreach(var s in speeches)
|
||||
{
|
||||
msg += $"{compFactory.GetRegistration(s).Name}\n";
|
||||
}
|
||||
shell.SendText(player, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
var name = args[0];
|
||||
// Try to get the Component
|
||||
Type type;
|
||||
try
|
||||
{
|
||||
var comp = compFactory.GetComponent(name);
|
||||
type = comp.GetType();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
shell.SendText(player, $"Accent {name} not found. Try {Command} ? to get a list of all appliable accents.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if that already exists
|
||||
try
|
||||
{
|
||||
var comp = player.AttachedEntity.GetComponent(type);
|
||||
shell.SendText(player, "You already have this accent!");
|
||||
return;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Accent not found
|
||||
}
|
||||
|
||||
// Generic fuckery
|
||||
var ensure = typeof(IEntity).GetMethod("AddComponent");
|
||||
if (ensure == null)
|
||||
return;
|
||||
var method = ensure.MakeGenericMethod(type);
|
||||
method.Invoke(player.AttachedEntity, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user