* Construction warnings cleanup * More construction warnings cleanup * Fix failing ITests - Remove unnecessary casts and dodgy anchroing implementation. * Checking anchor status before setting * Reusing shared system call * inlining anchor setting
27 lines
843 B
C#
27 lines
843 B
C#
using Content.Shared.Coordinates.Helpers;
|
|
using Content.Shared.Construction;
|
|
using JetBrains.Annotations;
|
|
|
|
namespace Content.Server.Construction.Completions
|
|
{
|
|
[UsedImplicitly]
|
|
[DataDefinition]
|
|
public sealed partial 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)
|
|
entityManager.System<SharedTransformSystem>().SetCoordinates(uid, transform.Coordinates.SnapToGrid(entityManager));
|
|
|
|
if (SouthRotation)
|
|
{
|
|
transform.LocalRotation = Angle.Zero;
|
|
}
|
|
}
|
|
}
|
|
}
|