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.
This commit is contained in:
Acruid
2021-06-19 19:41:26 -07:00
committed by GitHub
parent 0ab7b3a5d2
commit 15fb554c28
187 changed files with 279 additions and 287 deletions

View File

@@ -11,11 +11,11 @@ namespace Content.Server.NodeContainer.EntitySystems
{
base.Initialize();
SubscribeLocalEvent<NodeContainerComponent, PhysicsBodyTypeChangedEvent>(OnBodyTypeChanged);
SubscribeLocalEvent<NodeContainerComponent, AnchorStateChangedEvent>(OnAnchorStateChanged);
SubscribeLocalEvent<NodeContainerComponent, RotateEvent>(OnRotateEvent);
}
private void OnBodyTypeChanged(EntityUid uid, NodeContainerComponent component, PhysicsBodyTypeChangedEvent args)
private void OnAnchorStateChanged(EntityUid uid, NodeContainerComponent component, AnchorStateChangedEvent args)
{
component.AnchorUpdate();
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Content.Server.NodeContainer.NodeGroups;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
@@ -10,21 +10,6 @@ namespace Content.Server.NodeContainer.EntitySystems
{
private readonly HashSet<INodeGroup> _dirtyNodeGroups = new();
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<NodeContainerComponent, SnapGridPositionChangedEvent>(OnSnapGridPositionChanged);
}
private void OnSnapGridPositionChanged(EntityUid uid, NodeContainerComponent component, SnapGridPositionChangedEvent args)
{
foreach (var node in component.Nodes.Values)
{
node.OnSnapGridMove();
}
}
public void AddDirtyNodeGroup(INodeGroup nodeGroup)
{
_dirtyNodeGroups.Add(nodeGroup);

View File

@@ -29,7 +29,7 @@ namespace Content.Server.NodeContainer
[DataField("examinable")]
private bool _examinable = false;
public override void Initialize()
protected override void Initialize()
{
base.Initialize();
foreach (var node in _nodes.Values)
@@ -62,6 +62,7 @@ namespace Content.Server.NodeContainer
foreach (var node in Nodes.Values)
{
node.AnchorUpdate();
node.AnchorStateChanged();
}
}

View File

@@ -41,7 +41,7 @@ namespace Content.Server.NodeContainer.Nodes
/// </summary>
public bool Connectable => !_deleting && Anchored;
protected bool Anchored => !NeedAnchored || !Owner.TryGetComponent<IPhysBody>(out var physics) || physics.BodyType == BodyType.Static;
protected bool Anchored => !NeedAnchored || Owner.Transform.Anchored;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("needAnchored")]
@@ -76,7 +76,7 @@ namespace Content.Server.NodeContainer.Nodes
}
}
public virtual void OnSnapGridMove()
public virtual void AnchorStateChanged()
{
}

View File

@@ -125,11 +125,6 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
UpdateAdjacentConnectedDirections();
}
public override void OnSnapGridMove()
{
OnConnectedDirectionsNeedsUpdating();
}
public void JoinPipeNet(IPipeNet pipeNet)
{
_pipeNet = pipeNet;