Files
tbd-station-14/Content.Server/NodeContainer/EntitySystems/NodeContainerSystem.cs
Acruid 15fb554c28 Engine Entity Anchoring Changes (#4195)
* Converted all SnapGridPositionChangedEvent subscriptions to AnchorStateChangedEvent.

* Fixes power tests with new anchored requirements.

* Moved AnchorableComponent into construction.
AnchorableComponent now uses Transform.Anchored.

* Fixed bug with nodes, power works again.

* Adds lifetime stages to Component.

* Update Engine to v0.4.70.
2021-06-19 19:41:26 -07:00

38 lines
1.1 KiB
C#

using Content.Server.NodeContainer.Nodes;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
namespace Content.Server.NodeContainer.EntitySystems
{
[UsedImplicitly]
public class NodeContainerSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<NodeContainerComponent, AnchorStateChangedEvent>(OnAnchorStateChanged);
SubscribeLocalEvent<NodeContainerComponent, RotateEvent>(OnRotateEvent);
}
private void OnAnchorStateChanged(EntityUid uid, NodeContainerComponent component, AnchorStateChangedEvent args)
{
component.AnchorUpdate();
}
private void OnRotateEvent(EntityUid uid, NodeContainerComponent container, RotateEvent ev)
{
if (ev.NewRotation == ev.OldRotation)
{
return;
}
foreach (var node in container.Nodes.Values)
{
if (node is not IRotatableNode rotatableNode) continue;
rotatableNode.RotateEvent(ev);
}
}
}
}