Prevent stacking pipes (#28308)
* prevent stacking pipes * access * notafet review * notafet review pt. 2 * not the actual fix
This commit is contained in:
@@ -15,6 +15,7 @@ using Content.Shared.Interaction;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Storage;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -91,7 +92,14 @@ namespace Content.Server.Construction
|
||||
}
|
||||
|
||||
// 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)
|
||||
private async Task<EntityUid?> Construct(
|
||||
EntityUid user,
|
||||
string materialContainer,
|
||||
ConstructionGraphPrototype graph,
|
||||
ConstructionGraphEdge edge,
|
||||
ConstructionGraphNode targetNode,
|
||||
EntityCoordinates coords,
|
||||
Angle angle = default)
|
||||
{
|
||||
// We need a place to hold our construction items!
|
||||
var container = _container.EnsureContainer<Container>(user, materialContainer, out var existed);
|
||||
@@ -261,7 +269,7 @@ namespace Content.Server.Construction
|
||||
}
|
||||
|
||||
var newEntityProto = graph.Nodes[edge.Target].Entity.GetId(null, user, new(EntityManager));
|
||||
var newEntity = EntityManager.SpawnEntity(newEntityProto, EntityManager.GetComponent<TransformComponent>(user).Coordinates);
|
||||
var newEntity = Spawn(newEntityProto, _transformSystem.ToMapCoordinates(coords), rotation: angle);
|
||||
|
||||
if (!TryComp(newEntity, out ConstructionComponent? construction))
|
||||
{
|
||||
@@ -376,7 +384,13 @@ namespace Content.Server.Construction
|
||||
}
|
||||
}
|
||||
|
||||
if (await Construct(user, "item_construction", constructionGraph, edge, targetNode) is not { Valid: true } item)
|
||||
if (await Construct(
|
||||
user,
|
||||
"item_construction",
|
||||
constructionGraph,
|
||||
edge,
|
||||
targetNode,
|
||||
Transform(user).Coordinates) 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
|
||||
@@ -511,23 +525,18 @@ namespace Content.Server.Construction
|
||||
return;
|
||||
}
|
||||
|
||||
if (await Construct(user, (ev.Ack + constructionPrototype.GetHashCode()).ToString(), constructionGraph,
|
||||
edge, targetNode) is not {Valid: true} structure)
|
||||
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)
|
||||
{
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user