Intellicards rename to AI stored on them (#40402)

* intellicard name changing

* review
This commit is contained in:
ScarKy0
2025-09-16 21:04:50 +02:00
committed by GitHub
parent 972adcee21
commit dfc7d183ad
2 changed files with 24 additions and 6 deletions

View 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);

View 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();
}