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:
@@ -38,14 +38,13 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private bool Connectable => !_deleting && Anchored;
|
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>
|
/// <summary>
|
||||||
/// Prevents a node from being used by other nodes while midway through removal.
|
/// Prevents a node from being used by other nodes while midway through removal.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool _deleting = false;
|
private bool _deleting = false;
|
||||||
|
|
||||||
|
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency] private readonly INodeGroupFactory _nodeGroupFactory;
|
[Dependency] private readonly INodeGroupFactory _nodeGroupFactory;
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
@@ -60,19 +59,19 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
|
|||||||
{
|
{
|
||||||
TryAssignGroupIfNeeded();
|
TryAssignGroupIfNeeded();
|
||||||
CombineGroupWithReachable();
|
CombineGroupWithReachable();
|
||||||
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
|
if (Owner.TryGetComponent<ICollidableComponent>(out var collidable))
|
||||||
{
|
{
|
||||||
AnchorUpdate();
|
AnchorUpdate();
|
||||||
physics.AnchoredChanged += AnchorUpdate;
|
collidable.AnchoredChanged += AnchorUpdate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnContainerRemove()
|
public void OnContainerRemove()
|
||||||
{
|
{
|
||||||
_deleting = true;
|
_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);
|
NodeGroup.RemoveNode(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Connectable => Anchored;
|
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]
|
[ViewVariables]
|
||||||
public bool NeedsProvider { get; private set; } = true;
|
public bool NeedsProvider { get; private set; } = true;
|
||||||
@@ -89,18 +89,18 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
|
|||||||
{
|
{
|
||||||
TryFindAndSetProvider();
|
TryFindAndSetProvider();
|
||||||
}
|
}
|
||||||
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
|
if (Owner.TryGetComponent<ICollidableComponent>(out var collidable))
|
||||||
{
|
{
|
||||||
AnchorUpdate();
|
AnchorUpdate();
|
||||||
((IPhysicsComponent) physics).AnchoredChanged += AnchorUpdate;
|
collidable.AnchoredChanged += AnchorUpdate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnRemove()
|
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);
|
_provider.RemoveReceiver(this);
|
||||||
base.OnRemove();
|
base.OnRemove();
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
- type: Destructible
|
- type: Destructible
|
||||||
thresholdvalue: 100
|
thresholdvalue: 100
|
||||||
- type: SubFloorHide
|
- type: SubFloorHide
|
||||||
|
- type: Physics
|
||||||
|
Anchored: true
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: WireBase
|
parent: WireBase
|
||||||
|
|||||||
Reference in New Issue
Block a user