From dfc7d183add0185b837a1cf0f1d24afb016fe2d2 Mon Sep 17 00:00:00 2001 From: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> Date: Tue, 16 Sep 2025 21:04:50 +0200 Subject: [PATCH] Intellicards rename to AI stored on them (#40402) * intellicard name changing * review --- .../StationAi/SharedStationAiSystem.cs | 24 ++++++++++++++----- .../StationAi/StationAiHolderComponent.cs | 6 +++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs index e109c23fe6..e9b2575e40 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs @@ -322,12 +322,30 @@ public abstract partial class SharedStationAiSystem : EntitySystem private void OnHolderConInsert(Entity 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 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 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(args.Entity); diff --git a/Content.Shared/Silicons/StationAi/StationAiHolderComponent.cs b/Content.Shared/Silicons/StationAi/StationAiHolderComponent.cs index 221845d493..21ec67f004 100644 --- a/Content.Shared/Silicons/StationAi/StationAiHolderComponent.cs +++ b/Content.Shared/Silicons/StationAi/StationAiHolderComponent.cs @@ -11,6 +11,12 @@ public sealed partial class StationAiHolderComponent : Component { public const string Container = StationAiCoreComponent.Container; + /// + /// Whether the holder should be renamed to the name of the inserted object. + /// + [DataField] + public bool RenameOnInsert = true; + [DataField] public ItemSlot Slot = new(); } -- 2.51.2