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>
27 lines
792 B
C#
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;
|
|
}
|
|
}
|
|
}
|
|
}
|