SnapToGrid.cs 800 B

1234567891011121314151617181920212223242526
  1. using Content.Shared.Coordinates.Helpers;
  2. using Content.Shared.Construction;
  3. using JetBrains.Annotations;
  4. namespace Content.Server.Construction.Completions
  5. {
  6. [UsedImplicitly]
  7. [DataDefinition]
  8. public sealed partial class SnapToGrid : IGraphAction
  9. {
  10. [DataField("southRotation")] public bool SouthRotation { get; private set; }
  11. public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
  12. {
  13. var transform = entityManager.GetComponent<TransformComponent>(uid);
  14. if (!transform.Anchored)
  15. transform.Coordinates = transform.Coordinates.SnapToGrid(entityManager);
  16. if (SouthRotation)
  17. {
  18. transform.LocalRotation = Angle.Zero;
  19. }
  20. }
  21. }
  22. }