Replaces obsolete PhysicsComponent usage in Power and Node (#1515)

* Node Physics replacement

* PowerReceiver Physics replacement

* wires are anchored

Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
py01
2020-07-28 00:34:01 -06:00
committed by GitHub
parent e2b02c69c9
commit 5e0ca8a85a
3 changed files with 12 additions and 11 deletions

View File

@@ -38,14 +38,13 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
/// </summary>
private bool Connectable => !_deleting && Anchored;
private bool Anchored => !Owner.TryGetComponent<IPhysicsComponent>(out var physics) || physics.Anchored;
private bool Anchored => !Owner.TryGetComponent<ICollidableComponent>(out var collidable) || collidable.Anchored;
/// <summary>
/// Prevents a node from being used by other nodes while midway through removal.
/// </summary>
private bool _deleting = false;
#pragma warning disable 649
[Dependency] private readonly INodeGroupFactory _nodeGroupFactory;
#pragma warning restore 649
@@ -60,19 +59,19 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
{
TryAssignGroupIfNeeded();
CombineGroupWithReachable();
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
if (Owner.TryGetComponent<ICollidableComponent>(out var collidable))
{
AnchorUpdate();
physics.AnchoredChanged += AnchorUpdate;
collidable.AnchoredChanged += AnchorUpdate;
}
}
public void OnContainerRemove()
{
_deleting = true;
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
if (Owner.TryGetComponent<ICollidableComponent>(out var collidable))
{
((IPhysicsComponent) physics).AnchoredChanged -= AnchorUpdate;
collidable.AnchoredChanged -= AnchorUpdate;
}
NodeGroup.RemoveNode(this);
}

View File

@@ -48,7 +48,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
/// </summary>
public bool Connectable => Anchored;
private bool Anchored => !Owner.TryGetComponent<IPhysicsComponent>(out var physics) || physics.Anchored;
private bool Anchored => !Owner.TryGetComponent<ICollidableComponent>(out var collidable) || collidable.Anchored;
[ViewVariables]
public bool NeedsProvider { get; private set; } = true;
@@ -89,18 +89,18 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
{
TryFindAndSetProvider();
}
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
if (Owner.TryGetComponent<ICollidableComponent>(out var collidable))
{
AnchorUpdate();
((IPhysicsComponent) physics).AnchoredChanged += AnchorUpdate;
collidable.AnchoredChanged += AnchorUpdate;
}
}
public override void OnRemove()
{
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
if (Owner.TryGetComponent<ICollidableComponent>(out var collidable))
{
((IPhysicsComponent) physics).AnchoredChanged -= AnchorUpdate;
collidable.AnchoredChanged -= AnchorUpdate;
}
_provider.RemoveReceiver(this);
base.OnRemove();

View File

@@ -18,6 +18,8 @@
- type: Destructible
thresholdvalue: 100
- type: SubFloorHide
- type: Physics
Anchored: true
- type: entity
parent: WireBase