Files
tbd-station-14/Content.Server/Commands/GameTicking/FixRotationsCommand.cs
ShadowCommander 7a842f7c22 Fix tests (#3707)
* First pass

* Fix access and rename banananium to bananium

* Fix captialization of CookTimeInfoLabel

* Fix InteractUsing calls

* Remove unused [Dependency]

* Replace obsolete references to Anchored with BodyType

* Assign default value to shoving someone in disposals

* Fix naming

* Replace Initialize TryGetComponents with EnsureComponent

* Rework AnchorableComponent

* Fix singularity component

* Replace obsolete usages of Angle.South

* Fix efcore warning

* Fix container tests

* Fix DebugPressurePump invalid PressurePump yaml

* Fix getting pathfinding region of grid 0

* Fix atmos plaque missing layer and add info message when it happens

* Fix AiSteeringSystem steering in an invalid grid in entity test

* Make content able to choose which log level leads to test failures

* Revert container test fix for Acruid

* Fix sprite, pipe and saving errors
Make EntityTest print all errors instead of stopping on the first

* Reorder singularity visualizer

* Disable pvs for container occlusion adn simple predict reconcile, they use entities other than map ones

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2021-03-31 21:41:23 +02:00

97 lines
3.2 KiB
C#

using Content.Server.Administration;
using Content.Shared.GameObjects.Components;
using Content.Server.GameObjects.Components;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
namespace Content.Server.Commands.GameTicking
{
[AdminCommand(AdminFlags.Mapping)]
class FixRotationsCommand : IConsoleCommand
{
// ReSharper disable once StringLiteralTypo
public string Command => "fixrotations";
public string Description => "Sets the rotation of all occluders, low walls and windows to south.";
public string Help => $"Usage: {Command} <gridId> | {Command}";
public void Execute(IConsoleShell shell, string argsOther, string[] args)
{
var player = shell.Player as IPlayerSession;
GridId gridId;
switch (args.Length)
{
case 0:
if (player?.AttachedEntity == null)
{
shell.WriteLine("Only a player can run this command.");
return;
}
gridId = player.AttachedEntity.Transform.GridID;
break;
case 1:
if (!int.TryParse(args[0], out var id))
{
shell.WriteLine($"{args[0]} is not a valid integer.");
return;
}
gridId = new GridId(id);
break;
default:
shell.WriteLine(Help);
return;
}
var mapManager = IoCManager.Resolve<IMapManager>();
if (!mapManager.TryGetGrid(gridId, out var grid))
{
shell.WriteLine($"No grid exists with id {gridId}");
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity))
{
shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity.");
return;
}
var changed = 0;
foreach (var childUid in gridEntity.Transform.ChildEntityUids)
{
if (!entityManager.TryGetEntity(childUid, out var childEntity))
{
continue;
}
var valid = false;
valid |= childEntity.HasComponent<OccluderComponent>();
valid |= childEntity.HasComponent<SharedCanBuildWindowOnTopComponent>();
valid |= childEntity.HasComponent<WindowComponent>();
if (!valid)
{
continue;
}
if (childEntity.Transform.LocalRotation != Angle.Zero)
{
childEntity.Transform.LocalRotation = Angle.Zero;
changed++;
}
}
shell.WriteLine($"Changed {changed} entities. If things seem wrong, reconnect.");
}
}
}