Skip to content

Commit

Permalink
Revert "Prevent stacking pipes (#28308)" (#43)
Browse files Browse the repository at this point in the history
This reverts commit 44b93e6.

Co-authored-by: Poopp <[email protected]>
  • Loading branch information
1 parent 68317dc commit af626ce
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 170 deletions.

This file was deleted.

123 changes: 0 additions & 123 deletions Content.Server/Atmos/EntitySystems/PipeRestrictOverlapSystem.cs

This file was deleted.

39 changes: 15 additions & 24 deletions Content.Server/Construction/ConstructionSystem.Initial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using Content.Shared.Storage;
using Content.Shared.Whitelist;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Timing;

Expand Down Expand Up @@ -94,14 +93,7 @@ private IEnumerable<EntityUid> EnumerateNearby(EntityUid user)
}

// LEGACY CODE. See warning at the top of the file!
private async Task<EntityUid?> Construct(
EntityUid user,
string materialContainer,
ConstructionGraphPrototype graph,
ConstructionGraphEdge edge,
ConstructionGraphNode targetNode,
EntityCoordinates coords,
Angle angle = default)
private async Task<EntityUid?> Construct(EntityUid user, string materialContainer, ConstructionGraphPrototype graph, ConstructionGraphEdge edge, ConstructionGraphNode targetNode)
{
// We need a place to hold our construction items!
var container = _container.EnsureContainer<Container>(user, materialContainer, out var existed);
Expand Down Expand Up @@ -271,7 +263,7 @@ void ShutdownContainers()
}

var newEntityProto = graph.Nodes[edge.Target].Entity.GetId(null, user, new(EntityManager));
var newEntity = Spawn(newEntityProto, _transformSystem.ToMapCoordinates(coords), rotation: angle);
var newEntity = EntityManager.SpawnEntity(newEntityProto, EntityManager.GetComponent<TransformComponent>(user).Coordinates);

if (!TryComp(newEntity, out ConstructionComponent? construction))
{
Expand Down Expand Up @@ -386,13 +378,7 @@ public async Task<bool> TryStartItemConstruction(string prototype, EntityUid use
}
}

if (await Construct(
user,
"item_construction",
constructionGraph,
edge,
targetNode,
Transform(user).Coordinates) is not { Valid: true } item)
if (await Construct(user, "item_construction", constructionGraph, edge, targetNode) is not { Valid: true } item)
return false;

// Just in case this is a stack, attempt to merge it. If it isn't a stack, this will just normally pick up
Expand Down Expand Up @@ -527,18 +513,23 @@ void Cleanup()
return;
}

if (await Construct(user,
(ev.Ack + constructionPrototype.GetHashCode()).ToString(),
constructionGraph,
edge,
targetNode,
GetCoordinates(ev.Location),
constructionPrototype.CanRotate ? ev.Angle : Angle.Zero) is not {Valid: true} structure)
if (await Construct(user, (ev.Ack + constructionPrototype.GetHashCode()).ToString(), constructionGraph,
edge, targetNode) is not {Valid: true} structure)
{
Cleanup();
return;
}

// We do this to be able to move the construction to its proper position in case it's anchored...
// Oh wow transform anchoring is amazing wow I love it!!!!
// ikr
var xform = Transform(structure);
var wasAnchored = xform.Anchored;
xform.Anchored = false;
xform.Coordinates = GetCoordinates(ev.Location);
xform.LocalRotation = constructionPrototype.CanRotate ? ev.Angle : Angle.Zero;
xform.Anchored = wasAnchored;

RaiseNetworkEvent(new AckStructureConstructionMessage(ev.Ack, GetNetEntity(structure)));
_adminLogger.Add(LogType.Construction, LogImpact.Low, $"{ToPrettyString(user):player} has turned a {ev.PrototypeName} construction ghost into {ToPrettyString(structure)} at {Transform(structure).Coordinates}");
Cleanup();
Expand Down
16 changes: 8 additions & 8 deletions Content.Server/NodeContainer/Nodes/PipeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public partial class PipeNode : Node, IGasMixtureHolder, IRotatableNode
/// The directions in which this pipe can connect to other pipes around it.
/// </summary>
[DataField("pipeDirection")]
public PipeDirection OriginalPipeDirection;
private PipeDirection _originalPipeDirection;

/// <summary>
/// The *current* pipe directions (accounting for rotation)
Expand Down Expand Up @@ -110,26 +110,26 @@ public override void Initialize(EntityUid owner, IEntityManager entMan)
return;

var xform = entMan.GetComponent<TransformComponent>(owner);
CurrentPipeDirection = OriginalPipeDirection.RotatePipeDirection(xform.LocalRotation);
CurrentPipeDirection = _originalPipeDirection.RotatePipeDirection(xform.LocalRotation);
}

bool IRotatableNode.RotateNode(in MoveEvent ev)
{
if (OriginalPipeDirection == PipeDirection.Fourway)
if (_originalPipeDirection == PipeDirection.Fourway)
return false;

// update valid pipe direction
if (!RotationsEnabled)
{
if (CurrentPipeDirection == OriginalPipeDirection)
if (CurrentPipeDirection == _originalPipeDirection)
return false;

CurrentPipeDirection = OriginalPipeDirection;
CurrentPipeDirection = _originalPipeDirection;
return true;
}

var oldDirection = CurrentPipeDirection;
CurrentPipeDirection = OriginalPipeDirection.RotatePipeDirection(ev.NewRotation);
CurrentPipeDirection = _originalPipeDirection.RotatePipeDirection(ev.NewRotation);
return oldDirection != CurrentPipeDirection;
}

Expand All @@ -142,12 +142,12 @@ public override void OnAnchorStateChanged(IEntityManager entityManager, bool anc

if (!RotationsEnabled)
{
CurrentPipeDirection = OriginalPipeDirection;
CurrentPipeDirection = _originalPipeDirection;
return;
}

var xform = entityManager.GetComponent<TransformComponent>(Owner);
CurrentPipeDirection = OriginalPipeDirection.RotatePipeDirection(xform.LocalRotation);
CurrentPipeDirection = _originalPipeDirection.RotatePipeDirection(xform.LocalRotation);
}

public override IEnumerable<Node> GetReachableNodes(TransformComponent xform,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
construction-step-condition-no-unstackable-in-tile = You cannot make a stack of similar devices.
pipe-restrict-overlap-popup-blocked = { CAPITALIZE(THE($pipe))} doesn't fit over the other pipes!
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@
- type: PipeColorVisuals
- type: Rotatable
- type: GasRecycler
- type: PipeRestrictOverlap
- type: NodeContainer
nodes:
inlet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
- type: Appearance
- type: PipeColorVisuals
- type: NodeContainer
- type: PipeRestrictOverlap
- type: AtmosUnsafeUnanchor
- type: AtmosPipeColor
- type: Tag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@
key: enum.ThermomachineUiKey.Key
- type: WiresPanel
- type: WiresVisuals
- type: PipeRestrictOverlap
- type: NodeContainer
nodes:
pipe:
Expand Down Expand Up @@ -421,7 +420,6 @@
- type: GasCondenser
- type: AtmosPipeColor
- type: AtmosDevice
- type: PipeRestrictOverlap
- type: ApcPowerReceiver
powerLoad: 10000
- type: Machine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@
nodeGroupID: Teg

- type: AtmosUnsafeUnanchor
- type: PipeRestrictOverlap
- type: TegCirculator
- type: StealTarget
stealGroup: Teg
Expand Down

0 comments on commit af626ce

Please sign in to comment.