* 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.
38 lines
1.1 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|
|
}
|