Fix pipe rotation. (#4939)
This commit is contained in:
@@ -25,11 +25,16 @@ namespace Content.Server.NodeContainer.Nodes
|
||||
|
||||
/// <summary>
|
||||
/// The directions in which this pipe can connect to other pipes around it.
|
||||
/// Used to check if this pipe can connect to another pipe in a given direction.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField("pipeDirection")]
|
||||
public PipeDirection PipeDirection { get; private set; }
|
||||
private PipeDirection _originalPipeDirection;
|
||||
|
||||
/// <summary>
|
||||
/// The *current* pipe directions (accounting for rotation)
|
||||
/// Used to check if this pipe can connect to another pipe in a given direction.
|
||||
/// </summary>
|
||||
public PipeDirection CurrentPipeDirection { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The directions in which this node is connected to other nodes.
|
||||
@@ -103,8 +108,6 @@ namespace Content.Server.NodeContainer.Nodes
|
||||
public override void OnContainerStartup()
|
||||
{
|
||||
base.OnContainerStartup();
|
||||
//HACK: THIS LINE RIGHT HERE IS A FILTHY HACK AND I HATE IT --moony
|
||||
PipeDirection = PipeDirection.RotatePipeDirection(Owner.Transform.LocalRotation);
|
||||
OnConnectedDirectionsNeedsUpdating();
|
||||
}
|
||||
|
||||
@@ -124,9 +127,6 @@ namespace Content.Server.NodeContainer.Nodes
|
||||
/// </summary>
|
||||
void IRotatableNode.RotateEvent(ref RotateEvent ev)
|
||||
{
|
||||
if (!RotationsEnabled) return;
|
||||
var diff = ev.NewRotation - ev.OldRotation;
|
||||
PipeDirection = PipeDirection.RotatePipeDirection(diff);
|
||||
OnConnectedDirectionsNeedsUpdating();
|
||||
UpdateAppearance();
|
||||
}
|
||||
@@ -137,7 +137,7 @@ namespace Content.Server.NodeContainer.Nodes
|
||||
{
|
||||
var pipeDir = (PipeDirection) (1 << i);
|
||||
|
||||
if (!PipeDirection.HasDirection(pipeDir))
|
||||
if (!CurrentPipeDirection.HasDirection(pipeDir))
|
||||
continue;
|
||||
|
||||
foreach (var pipe in LinkableNodesInDirection(pipeDir))
|
||||
@@ -157,7 +157,7 @@ namespace Content.Server.NodeContainer.Nodes
|
||||
|
||||
foreach (var pipe in PipesInDirection(pipeDir))
|
||||
{
|
||||
if (pipe.ConnectionsEnabled && pipe.PipeDirection.HasDirection(pipeDir.GetOpposite()))
|
||||
if (pipe.ConnectionsEnabled && pipe.CurrentPipeDirection.HasDirection(pipeDir.GetOpposite()))
|
||||
yield return pipe;
|
||||
}
|
||||
}
|
||||
@@ -210,9 +210,18 @@ namespace Content.Server.NodeContainer.Nodes
|
||||
|
||||
/// <summary>
|
||||
/// Updates the <see cref="ConnectedDirections"/> of this and all sorrounding pipes.
|
||||
/// Also updates CurrentPipeDirection.
|
||||
/// </summary>
|
||||
private void OnConnectedDirectionsNeedsUpdating()
|
||||
{
|
||||
if (RotationsEnabled)
|
||||
{
|
||||
CurrentPipeDirection = _originalPipeDirection.RotatePipeDirection(Owner.Transform.LocalRotation);
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentPipeDirection = _originalPipeDirection;
|
||||
}
|
||||
UpdateConnectedDirections();
|
||||
UpdateAdjacentConnectedDirections();
|
||||
UpdateAppearance();
|
||||
@@ -229,7 +238,7 @@ namespace Content.Server.NodeContainer.Nodes
|
||||
{
|
||||
var pipeDir = (PipeDirection) (1 << i);
|
||||
|
||||
if (!PipeDirection.HasDirection(pipeDir))
|
||||
if (!CurrentPipeDirection.HasDirection(pipeDir))
|
||||
continue;
|
||||
|
||||
foreach (var pipe in LinkableNodesInDirection(pipeDir))
|
||||
|
||||
Reference in New Issue
Block a user