Files
tbd-station-14/Content.Server/Construction/Completions/SetAnchor.cs
J 2a80540b70 Construction spring cleaning (#36163)
* 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
2025-04-16 13:02:41 +02:00

29 lines
786 B
C#

using Content.Shared.Construction;
using JetBrains.Annotations;
namespace Content.Server.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public sealed partial class SetAnchor : IGraphAction
{
[DataField("value")] public bool Value { get; private set; } = true;
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
{
var transform = entityManager.GetComponent<TransformComponent>(uid);
if (transform.Anchored == Value)
return;
var sys = entityManager.System<SharedTransformSystem>();
if (Value)
sys.AnchorEntity(uid, transform);
else
sys.Unanchor(uid, transform);
}
}
}