Files
tbd-station-14/Content.Server/Salvage/SalvageRulerCommand.cs
metalgearsloth bf79acd127 Salvage magnet revamp (#23119)
* Generic offering window

* More work

* weh

* Parity

* Progression meter

* magnet

* rona

* PG asteroid work

* code red

* Asteroid spawnings

* clams

* a

* Marker fixes

* More fixes

* Workings of biome asteroids

* A

* Fix this loading code

* a

* Fix masking

* weh

* Fixes

* Magnet claiming

* toe

* petogue

* magnet

* Bunch of fixes

* Fix default

* Fixes

* asteroids

* Fix offerings

* Localisation and a bunch of fixes

* a

* Fixes

* Preliminary draft

* Announcement fixes

* Fixes and bump spawn rate

* Fix asteroid spawns and UI

* More fixes

* Expeditions fix

* fix

* Gravity

* Fix announcement rounding

* a

* Offset tweak

* sus

* jankass

* Fix merge
2024-01-04 14:25:32 +11:00

65 lines
2.0 KiB
C#

using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.Map;
namespace Content.Server.Salvage;
[AdminCommand(AdminFlags.Admin)]
sealed class SalvageRulerCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entities = default!;
[Dependency] private readonly IMapManager _maps = default!;
public string Command => "salvageruler";
public string Description => Loc.GetString("salvage-ruler-command-description");
public string Help => Loc.GetString("salvage-ruler-command-help-text", ("command",Command));
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 0)
{
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
return;
}
if (shell.Player is not { } player)
{
shell.WriteError(Loc.GetString("shell-only-players-can-run-this-command"));
return;
}
var entity = player.AttachedEntity;
if (entity == null)
{
shell.WriteError(Loc.GetString("shell-must-be-attached-to-entity"));
return;
}
var entityTransform = _entities.GetComponent<TransformComponent>(entity.Value);
var total = Box2.UnitCentered;
var first = true;
foreach (var mapGrid in _maps.GetAllGrids(entityTransform.MapID))
{
var aabb = _entities.System<SharedTransformSystem>().GetWorldMatrix(mapGrid).TransformBox(mapGrid.Comp.LocalAABB);
if (first)
{
total = aabb;
}
else
{
total = total.ExtendToContain(aabb.TopLeft);
total = total.ExtendToContain(aabb.TopRight);
total = total.ExtendToContain(aabb.BottomLeft);
total = total.ExtendToContain(aabb.BottomRight);
}
first = false;
}
shell.WriteLine(total.ToString());
}
}