CatStation/Content.Server/Mapping/StructureAlignCommand.cs
Errant c85a58eb37
Structure Aligner System (#45395)
* wip

* fix merge conflict messup

* testing changes

* make command be able to target specific map, make system work on preinit maps

* so long. also, firelocks

* fix rotation logic

* do not align

* better temp feedback

* onmapinit cvar, anchoredalign datafield

* some firelock stuff

* track unanchored AlignTo entities, with lower weight

* finish aligncommand

* comment update

* system cleanup

* wip

* firelock final

* Resources/Prototypes/ plastic flaps

* review fixes

* changes to logging and feedback loc

* add dry run parameter to command

* don't spam AllEntityQuery on calls that can happing midround

* redundant aligncommand dependencies

* rewrite a bunch of jank in the system

* network the comps

* change aligner type to bitmask for performance. Rename some files and names to be easier to comprehend and use

* detailed logs only when called via command

* shuttle windows did not follow the flock

* fix bitmask check issue

* more flag shenanigans were found

* another non-inheriting base prototype. Not ideal.

* remove redundant component definition

* XML summary updates

* Add todo

---------

Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
2026-08-22 09:48:37 +00:00

69 lines
2.1 KiB
C#

using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.Mapping;
using Robust.Shared.Console;
using Robust.Shared.Map;
namespace Content.Server.Mapping;
/// <summary>
/// Automatically snap the alignment of all anchored airlocks, doors, firelocks etc.
/// to line up with adjacent structures.
/// </summary>
[AdminCommand(AdminFlags.Mapping)]
public sealed partial class StructureAlignCommand : LocalizedEntityCommands
{
[Dependency] private SharedStructureAlignerSystem _aligner = default!;
/// <inheritdoc/>
public override string Command => "align";
/// <inheritdoc/>
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length > 2)
{
shell.WriteError(Loc.GetString("shell-need-between-arguments", ("lower", 0), ("upper", 2)));
return;
}
MapId? map = null;
if (args.Length > 0)
{
if (!int.TryParse(args[0], out var intMapId))
{
shell.WriteError(Loc.GetString("shell-argument-must-be-number"));
return;
}
map = new MapId(intMapId);
}
var dry = false;
if (args.Length > 1)
{
if (!bool.TryParse(args[1], out dry))
{
shell.WriteError(Loc.GetString("shell-invalid-bool-value", ("value", args[1])));
return;
}
}
var response = _aligner.AlignAll(map, dry, verbose: true);
if (!string.IsNullOrEmpty(response))
shell.WriteLine(response);
}
/// <inheritdoc/>
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
return args.Length switch
{
1 => CompletionResult.FromHintOptions(CompletionHelper.MapIds(EntityManager),
Loc.GetString("cmd-align-hint-id")),
2 => CompletionResult.FromHintOptions(["false", "true"], Loc.GetString("cmd-align-hint-dry")),
_ => CompletionResult.Empty
};
}
}