Files
tbd-station-14/Content.Server/Construction/Completions/SnapToGrid.cs
Ben c858c76341 Anchorable shared (#17422)
Co-authored-by: BenOwnby <ownbyb@appstate.edu>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2023-06-29 22:35:54 +10:00

27 lines
792 B
C#

using Content.Shared.Coordinates.Helpers;
using Content.Shared.Construction;
using JetBrains.Annotations;
namespace Content.Server.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public sealed class SnapToGrid : IGraphAction
{
[DataField("southRotation")] public bool SouthRotation { get; private set; }
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
{
var transform = entityManager.GetComponent<TransformComponent>(uid);
if (!transform.Anchored)
transform.Coordinates = transform.Coordinates.SnapToGrid(entityManager);
if (SouthRotation)
{
transform.LocalRotation = Angle.Zero;
}
}
}
}