* Remove unused IChatCommand. * Lots of refactoring into a shared context. * Removed ICommonSession from server concmd Execute. * Added argStr parameter to concmd execute. * The execute function of client concmds now returns void, use the new shell.RemoteExecuteCommand function to forward commands. * Finally move shells and commands into shared. * Console commands can now be registered directly without a class in a shared context. * Engine API Changes. * Repair rebase damage. * Update Submodule.
73 lines
2.4 KiB
C#
73 lines
2.4 KiB
C#
#nullable enable
|
|
using Content.Server.Administration;
|
|
using Content.Server.GameObjects.Components.Interactable;
|
|
using Content.Shared.Administration;
|
|
using Content.Shared.Maps;
|
|
using Robust.Server.Interfaces.Player;
|
|
using Robust.Shared.Console;
|
|
using Robust.Shared.Interfaces.Map;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Map;
|
|
|
|
namespace Content.Server.Commands.Interactable
|
|
{
|
|
/// <summary>
|
|
/// <see cref="TilePryingComponent.TryPryTile"/>
|
|
/// </summary>
|
|
[AdminCommand(AdminFlags.Debug)]
|
|
class TilePryCommand : IConsoleCommand
|
|
{
|
|
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, string argStr, string[] args)
|
|
{
|
|
var player = shell.Player as IPlayerSession;
|
|
if (player?.AttachedEntity == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (args.Length != 1)
|
|
{
|
|
shell.WriteLine(Help);
|
|
return;
|
|
}
|
|
|
|
if (!int.TryParse(args[0], out var radius))
|
|
{
|
|
shell.WriteLine($"{args[0]} isn't a valid integer.");
|
|
return;
|
|
}
|
|
|
|
if (radius < 0)
|
|
{
|
|
shell.WriteLine("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));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|