Construction spring cleaning (#36163)

* Construction warnings cleanup

* More construction warnings cleanup

* Fix failing ITests - Remove unnecessary casts and dodgy anchroing implementation.

* Checking anchor status before setting

* Reusing shared system call

* inlining anchor setting
This commit is contained in:
J
2025-04-16 11:02:41 +00:00
committed by GitHub
parent 0a750fd6db
commit 2a80540b70
10 changed files with 47 additions and 37 deletions

View File

@@ -66,10 +66,10 @@ namespace Content.Server.Construction
if (!Resolve(uid, ref construction, false))
return null;
if (construction.Node is not {} nodeIdentifier)
if (construction.Node is not { } nodeIdentifier)
return null;
return GetCurrentGraph(uid, construction) is not {} graph ? null : GetNodeFromGraph(graph, nodeIdentifier);
return GetCurrentGraph(uid, construction) is not { } graph ? null : GetNodeFromGraph(graph, nodeIdentifier);
}
/// <summary>
@@ -85,10 +85,10 @@ namespace Content.Server.Construction
if (!Resolve(uid, ref construction, false))
return null;
if (construction.EdgeIndex is not {} edgeIndex)
if (construction.EdgeIndex is not { } edgeIndex)
return null;
return GetCurrentNode(uid, construction) is not {} node ? null : GetEdgeFromNode(node, edgeIndex);
return GetCurrentNode(uid, construction) is not { } node ? null : GetEdgeFromNode(node, edgeIndex);
}
/// <summary>
@@ -102,7 +102,7 @@ namespace Content.Server.Construction
if (GetCurrentNode(uid, construction) is not { } node)
return (null, null);
if (construction.EdgeIndex is not {} edgeIndex)
if (construction.EdgeIndex is not { } edgeIndex)
return (node, null);
return (node, GetEdgeFromNode(node, edgeIndex));
@@ -121,7 +121,7 @@ namespace Content.Server.Construction
if (!Resolve(uid, ref construction, false))
return null;
if (GetCurrentEdge(uid, construction) is not {} edge)
if (GetCurrentEdge(uid, construction) is not { } edge)
return null;
return GetStepFromEdge(edge, construction.StepIndex);
@@ -141,10 +141,10 @@ namespace Content.Server.Construction
if (!Resolve(uid, ref construction))
return null;
if (construction.TargetNode is not {} targetNodeId)
if (construction.TargetNode is not { } targetNodeId)
return null;
if (GetCurrentGraph(uid, construction) is not {} graph)
if (GetCurrentGraph(uid, construction) is not { } graph)
return null;
return GetNodeFromGraph(graph, targetNodeId);
@@ -165,10 +165,10 @@ namespace Content.Server.Construction
if (!Resolve(uid, ref construction))
return null;
if (construction.TargetEdgeIndex is not {} targetEdgeIndex)
if (construction.TargetEdgeIndex is not { } targetEdgeIndex)
return null;
if (GetCurrentNode(uid, construction) is not {} node)
if (GetCurrentNode(uid, construction) is not { } node)
return null;
return GetEdgeFromNode(node, targetEdgeIndex);
@@ -245,8 +245,8 @@ namespace Content.Server.Construction
if (!Resolve(uid, ref construction))
return false;
if (GetCurrentGraph(uid, construction) is not {} graph
|| GetNodeFromGraph(graph, id) is not {} node)
if (GetCurrentGraph(uid, construction) is not { } graph
|| GetNodeFromGraph(graph, id) is not { } node)
return false;
var oldNode = construction.Node;
@@ -257,11 +257,11 @@ namespace Content.Server.Construction
$"{ToPrettyString(userUid.Value):player} changed {ToPrettyString(uid):entity}'s node from \"{oldNode}\" to \"{id}\"");
// ChangeEntity will handle the pathfinding update.
if (node.Entity.GetId(uid, userUid, new(EntityManager)) is {} newEntity
if (node.Entity.GetId(uid, userUid, new(EntityManager)) is { } newEntity
&& ChangeEntity(uid, userUid, newEntity, construction) != null)
return true;
if(performActions)
if (performActions)
PerformActions(uid, userUid, node.Actions);
// An action might have deleted the entity... Account for this.
@@ -347,7 +347,7 @@ namespace Content.Server.Construction
// Retain the target node if an entity change happens in response to deconstruction;
// in that case, we must continue to move towards the start node.
if (construction.TargetNode is {} targetNode)
if (construction.TargetNode is { } targetNode)
SetPathfindingTarget(newUid, targetNode, newConstruction);
}
@@ -358,7 +358,7 @@ namespace Content.Server.Construction
}
if (newConstruction.InteractionQueue.Count > 0 && _queuedUpdates.Add(newUid))
_constructionUpdateQueue.Enqueue(newUid);
_constructionUpdateQueue.Enqueue(newUid);
// Transform transferring.
var newTransform = Transform(newUid);
@@ -430,7 +430,7 @@ namespace Content.Server.Construction
if (!PrototypeManager.TryIndex<ConstructionGraphPrototype>(graphId, out var graph))
return false;
if(GetNodeFromGraph(graph, nodeId) is not {})
if (GetNodeFromGraph(graph, nodeId) is not { })
return false;
construction.Graph = graphId;