2021-02-25 02:52:26 -08:00
|
|
|
#nullable enable
|
2020-10-08 17:41:23 +02:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Content.Server.Utility;
|
|
|
|
|
using Content.Shared.Construction;
|
|
|
|
|
using JetBrains.Annotations;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2020-10-08 17:41:23 +02:00
|
|
|
using Robust.Shared.Serialization;
|
2021-02-01 20:58:47 +00:00
|
|
|
using Robust.Shared.Maths;
|
2021-03-05 01:08:38 +01:00
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
|
|
|
|
using YamlDotNet.Serialization;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
|
|
|
|
namespace Content.Server.Construction.Completions
|
|
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataDefinition]
|
2020-10-08 17:41:23 +02:00
|
|
|
public class SnapToGrid : IGraphAction
|
|
|
|
|
{
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("offset")] public SnapGridOffset Offset { get; private set; } = SnapGridOffset.Center;
|
|
|
|
|
[DataField("southRotation")] public bool SouthRotation { get; private set; } = false;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
|
|
|
|
public async Task PerformAction(IEntity entity, IEntity? user)
|
|
|
|
|
{
|
|
|
|
|
if (entity.Deleted) return;
|
|
|
|
|
|
|
|
|
|
entity.SnapToGrid(Offset);
|
2021-02-01 20:58:47 +00:00
|
|
|
if (SouthRotation)
|
|
|
|
|
{
|
2021-02-25 02:52:26 -08:00
|
|
|
entity.Transform.LocalRotation = Angle.Zero;
|
2021-02-01 20:58:47 +00:00
|
|
|
}
|
2020-10-08 17:41:23 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|