]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Intellicards rename to AI stored on them (#40402)
authorScarKy0 <106310278+ScarKy0@users.noreply.github.com>
Tue, 16 Sep 2025 19:04:50 +0000 (21:04 +0200)
committerGitHub <noreply@github.com>
Tue, 16 Sep 2025 19:04:50 +0000 (21:04 +0200)
* intellicard name changing

* review

Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs
Content.Shared/Silicons/StationAi/StationAiHolderComponent.cs

index e109c23fe6103ae25ebe8ccefeded602b4d42aa4..e9b2575e40670c7e9b0c1c0415b5d90998fab2cc 100644 (file)
@@ -322,12 +322,30 @@ public abstract partial class SharedStationAiSystem : EntitySystem
 
     private void OnHolderConInsert(Entity<StationAiHolderComponent> ent, ref EntInsertedIntoContainerMessage args)
     {
+        if (_timing.ApplyingState)
+            return;
+
+        if (args.Container.ID != ent.Comp.Slot.ID)
+            return;
+
         UpdateAppearance((ent.Owner, ent.Comp));
+
+        if (ent.Comp.RenameOnInsert)
+            _metadata.SetEntityName(ent.Owner, MetaData(args.Entity).EntityName);
     }
 
     private void OnHolderConRemove(Entity<StationAiHolderComponent> ent, ref EntRemovedFromContainerMessage args)
     {
+        if (_timing.ApplyingState)
+            return;
+
+        if (args.Container.ID != ent.Comp.Slot.ID)
+            return;
+
         UpdateAppearance((ent.Owner, ent.Comp));
+
+        if (ent.Comp.RenameOnInsert)
+            _metadata.SetEntityName(ent.Owner, Prototype(ent.Owner)?.Name ?? string.Empty);
     }
 
     private void OnHolderMapInit(Entity<StationAiHolderComponent> ent, ref MapInitEvent args)
@@ -498,9 +516,6 @@ public abstract partial class SharedStationAiSystem : EntitySystem
         ClearEye(ent);
         ent.Comp.Remote = true;
 
-        // Just so text and the likes works properly
-        _metadata.SetEntityName(ent.Owner, MetaData(args.Entity).EntityName);
-
         if (SetupEye(ent))
             AttachEye(ent);
     }
@@ -515,9 +530,6 @@ public abstract partial class SharedStationAiSystem : EntitySystem
 
         ent.Comp.Remote = true;
 
-        // Reset name to whatever
-        _metadata.SetEntityName(ent.Owner, Prototype(ent.Owner)?.Name ?? string.Empty);
-
         // Remove eye relay
         RemCompDeferred<RelayInputMoverComponent>(args.Entity);
 
index 221845d493dcbb5caf8f7d33c436fc268fb9aa01..21ec67f004e88c9bacd1f42223cb44816b3978fe 100644 (file)
@@ -11,6 +11,12 @@ public sealed partial class StationAiHolderComponent : Component
 {
     public const string Container = StationAiCoreComponent.Container;
 
+    /// <summary>
+    /// Whether the holder should be renamed to the name of the inserted object.
+    /// </summary>
+    [DataField]
+    public bool RenameOnInsert = true;
+
     [DataField]
     public ItemSlot Slot = new();
 }