]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix xenoarch exceptions + misc. cleanup (#38742)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Sat, 4 Oct 2025 00:05:04 +0000 (20:05 -0400)
committerGitHub <noreply@github.com>
Sat, 4 Oct 2025 00:05:04 +0000 (00:05 +0000)
Content.Server/Xenoarchaeology/Artifact/XAT/XATMagnetSystem.cs
Content.Shared/Xenoarchaeology/Artifact/Components/XenoArtifactNodeComponent.cs
Content.Shared/Xenoarchaeology/Artifact/SharedXenoArtifactSystem.Graph.cs
Content.Shared/Xenoarchaeology/Artifact/SharedXenoArtifactSystem.Node.cs
Content.Shared/Xenoarchaeology/Artifact/SharedXenoArtifactSystem.Unlock.cs
Content.Shared/Xenoarchaeology/Artifact/XAT/BaseQueryUpdateXATSystem.cs
Content.Shared/Xenoarchaeology/Artifact/XAT/XATDeathSystem.cs

index d045682d5597de8e0c96f28702db6476b9017770..5656182a9e5d83c0de3fe1c526390cfda88101dc 100644 (file)
@@ -54,7 +54,7 @@ public sealed class XATMagnetSystem : BaseQueryUpdateXATSystem<XATMagnetComponen
             if (node.Attached == null)
                 continue;
 
-            var artifact = _xenoArtifactQuery.Get(GetEntity(node.Attached.Value));
+            var artifact = _xenoArtifactQuery.Get(node.Attached.Value);
 
             if (!CanTrigger(artifact, (uid, node)))
                 continue;
index 4a8b8ec49f796462748853fd2833acc44d3bc125..b18f9cb69d79cd33ba597c647efd634ace60a54e 100644 (file)
@@ -32,7 +32,7 @@ public sealed partial class XenoArtifactNodeComponent : Component
     /// The entity whose graph this node is a part of.
     /// </summary>
     [DataField, AutoNetworkedField]
-    public NetEntity? Attached;
+    public EntityUid? Attached;
 
     #region Durability
     /// <summary>
index fca5baf10ffc60a7fc88c8e3fec8cabdb0e317bc..24ff50b5ede5e1604b9c02bf72c77d7d9e20040b 100644 (file)
@@ -53,8 +53,8 @@ public abstract partial class SharedXenoArtifactSystem
     /// <exception cref="ArgumentException">Throws if requested index doesn't exist on artifact. </exception>
     public Entity<XenoArtifactNodeComponent> GetNode(Entity<XenoArtifactComponent> ent, int index)
     {
-        if (ent.Comp.NodeVertices[index] is { } netUid && GetEntity(netUid) is var uid)
-            return (uid, XenoArtifactNode(uid));
+        if (ent.Comp.NodeVertices[index] is { } netUid && GetEntity(netUid) is var uid && _nodeQuery.TryComp(uid, out var comp))
+            return (uid, comp);
 
         throw new ArgumentException($"index {index} does not correspond to an existing node in {ToPrettyString(ent)}");
     }
@@ -71,8 +71,8 @@ public abstract partial class SharedXenoArtifactSystem
         if (index < 0 || index >= ent.Comp.NodeVertices.Length)
             return false;
 
-        if (ent.Comp.NodeVertices[index] is { } netUid && GetEntity(netUid) is var uid)
-            node = (uid, XenoArtifactNode(uid));
+        if (ent.Comp.NodeVertices[index] is { } netUid && GetEntity(netUid) is var uid && _nodeQuery.TryComp(uid, out var comp))
+            node = (uid, comp);
 
         return node != null;
     }
@@ -102,8 +102,8 @@ public abstract partial class SharedXenoArtifactSystem
     {
         foreach (var netNode in ent.Comp.NodeVertices)
         {
-            if (TryGetEntity(netNode, out var node))
-                yield return (node.Value, XenoArtifactNode(node.Value));
+            if (TryGetEntity(netNode, out var node) && _nodeQuery.TryComp(node, out var comp))
+                yield return (node.Value, comp);
         }
     }
 
@@ -253,7 +253,8 @@ public abstract partial class SharedXenoArtifactSystem
             return false;
 
         var uid = Spawn(entProtoId);
-        node = (uid, XenoArtifactNode(uid));
+        var comp = EnsureComp<XenoArtifactNodeComponent>(uid);
+        node = (uid, comp);
         return AddNode(ent, (node.Value, node.Value.Comp), dirty: dirty);
     }
 
@@ -269,11 +270,10 @@ public abstract partial class SharedXenoArtifactSystem
     /// <returns>True if node adding was successful, false otherwise.</returns>
     public bool AddNode(Entity<XenoArtifactComponent?> ent, Entity<XenoArtifactNodeComponent?> node, bool dirty = true)
     {
-        if (!Resolve(ent, ref ent.Comp))
+        if (!Resolve(ent, ref ent.Comp) || !Resolve(node, ref node.Comp, false))
             return false;
 
-        node.Comp ??= XenoArtifactNode(node);
-        node.Comp.Attached = GetNetEntity(ent);
+        node.Comp.Attached = ent.Owner;
 
         var nodeIdx = GetFreeNodeIndex((ent, ent.Comp));
         _container.Insert(node.Owner, ent.Comp.NodeContainer);
@@ -300,11 +300,9 @@ public abstract partial class SharedXenoArtifactSystem
     /// <returns>True if node was removed successfully, false otherwise.</returns>
     public bool RemoveNode(Entity<XenoArtifactComponent?> ent, Entity<XenoArtifactNodeComponent?> node, bool dirty = true)
     {
-        if (!Resolve(ent, ref ent.Comp))
+        if (!Resolve(ent, ref ent.Comp) || !Resolve(node, ref node.Comp, false))
             return false;
 
-        node.Comp ??= XenoArtifactNode(node);
-
         if (!TryGetIndex(ent, node, out var idx))
             return false; // node isn't attached to this entity.
 
index 899e578bcf0d8706237a85f77319f49d3e026a9d..09a1e0bfeafbb54bc5eb5ae2351489e96ba5ca66 100644 (file)
@@ -33,21 +33,14 @@ public abstract partial class SharedXenoArtifactSystem
         SetNodeDurability((ent, ent), nodeComponent.MaxDurability);
     }
 
-    /// <summary> Gets node component by node entity uid. </summary>
-    public XenoArtifactNodeComponent XenoArtifactNode(EntityUid uid)
-    {
-        return _nodeQuery.Get(uid);
-    }
-
     public void SetNodeUnlocked(Entity<XenoArtifactNodeComponent?> ent)
     {
         if (!Resolve(ent, ref ent.Comp))
             return;
 
-        if (ent.Comp.Attached is not { } netArtifact)
+        if (ent.Comp.Attached is not { } artifact)
             return;
 
-        var artifact = GetEntity(netArtifact);
         if (!TryComp<XenoArtifactComponent>(artifact, out var artifactComponent))
             return;
 
@@ -197,7 +190,10 @@ public abstract partial class SharedXenoArtifactSystem
             foreach (var netNode in segment)
             {
                 var node = GetEntity(netNode);
-                outSegment.Add((node, XenoArtifactNode(node)));
+                if (!_nodeQuery.TryComp(node, out var comp))
+                    continue;
+
+                outSegment.Add((node, comp));
             }
 
             output.Add(outSegment);
@@ -385,7 +381,7 @@ public abstract partial class SharedXenoArtifactSystem
             return;
         }
 
-        var artifact = _xenoArtifactQuery.Get(GetEntity(nodeComponent.Attached.Value));
+        var artifact = _xenoArtifactQuery.Get(nodeComponent.Attached.Value);
 
         var nonactiveNodes = GetActiveNodes(artifact);
         var durabilityEffect = MathF.Pow((float)nodeComponent.Durability / nodeComponent.MaxDurability, 2);
index 57d6502bfb3cf73e1bf00c0d4f9d7da392785965..fedb7f1f60d7d728c841390c65108a4cf162b1ba 100644 (file)
@@ -45,7 +45,7 @@ public abstract partial class SharedXenoArtifactSystem
         if (!Resolve(ent, ref ent.Comp))
             return false;
 
-        var artifact = GetEntity(ent.Comp.Attached);
+        var artifact = ent.Comp.Attached;
         if (!TryComp<XenoArtifactComponent>(artifact, out var artiComp))
             return false;
 
index 5a7fc53e9eb2227694a17fb8d5bd21f72ab68d27..0abad7bdd5ba9b2cfe34584c47eea6fcd98e4540 100644 (file)
@@ -31,7 +31,7 @@ public abstract class BaseQueryUpdateXATSystem<T> : BaseXATSystem<T> where T : C
             if (node.Attached == null)
                 continue;
 
-            var artifact = _xenoArtifactQuery.Get(GetEntity(node.Attached.Value));
+            var artifact = _xenoArtifactQuery.Get(node.Attached.Value);
 
             if (!CanTrigger(artifact, (uid, node)))
                 continue;
index 747bd82feb0a298428b77875fcc7f04fe4a2d416..50a7b0200e008982221b0b3a644b243642c58d03 100644 (file)
@@ -36,7 +36,7 @@ public sealed class XATDeathSystem : BaseXATSystem<XATDeathComponent>
             if (node.Attached == null)
                 continue;
 
-            var artifact = _xenoArtifactQuery.Get(GetEntity(node.Attached.Value));
+            var artifact = _xenoArtifactQuery.Get(node.Attached.Value);
 
             if (!CanTrigger(artifact, (uid, node)))
                 continue;