--- /dev/null
+using Robust.Shared.GameStates;
+
+namespace Content.Server.Access.Components;
+
+[RegisterComponent]
+public sealed partial class IdBindComponent : Component
+{
+ /// <summary>
+ /// If true, also tries to get the PDA and set the owner to the entity
+ /// </summary>
+ [DataField]
+ public bool BindPDAOwner = true;
+}
+
--- /dev/null
+using Content.Server.Access.Components;
+using Content.Server.PDA;
+using Content.Shared.Inventory;
+using Content.Shared.Mind.Components;
+using Content.Shared.PDA;
+using Content.Shared.Roles;
+
+namespace Content.Server.Access.Systems;
+
+public sealed class IdBindSystem : EntitySystem
+{
+ [Dependency] private readonly IdCardSystem _cardSystem = default!;
+ [Dependency] private readonly PdaSystem _pdaSystem = default!;
+ [Dependency] private readonly InventorySystem _inventory = default!;
+
+ public override void Initialize()
+ {
+ base.Initialize();
+ //Activate on mind being added
+ SubscribeLocalEvent<IdBindComponent, MindAddedMessage>(TryBind);
+ }
+
+ private void TryBind(Entity<IdBindComponent> ent, ref MindAddedMessage args)
+ {
+ if (!_cardSystem.TryFindIdCard(ent, out var cardId))
+ return;
+
+ var data = MetaData(ent);
+
+ _cardSystem.TryChangeFullName(cardId, data.EntityName, cardId);
+
+ if (!ent.Comp.BindPDAOwner)
+ {
+ //Remove after running once
+ RemCompDeferred<IdBindComponent>(ent);
+ return;
+ }
+
+ //Get PDA from main slot and set us as owner
+ if (!_inventory.TryGetSlotEntity(ent, "id", out var uPda))
+ return;
+
+ if (!TryComp<PdaComponent>(uPda, out var pDA))
+ return;
+
+ _pdaSystem.SetOwner(uPda.Value, pDA, ent, data.EntityName);
+ //Remove after running once
+ RemCompDeferred<IdBindComponent>(ent);
+ }
+}
+
- type: RandomHumanoidAppearance
randomizeName: false
- type: GhostTakeoverAvailable
+ - type: IdBind
- type: randomHumanoidSettings
id: EventHumanoidMindShielded
parent: EventHumanoid
+ randomizeName: false
components:
- type: MindShield
- type: AntagImmune
- type: randomHumanoidSettings
id: DeathSquad
parent: EventHumanoidCentcomm
- randomizeName: false
components:
- type: GhostRole
name: ghost-role-information-Death-Squad-name
- type: randomHumanoidSettings
id: ERTLeader
parent: EventHumanoidCentcomm
- randomizeName: false
components:
- type: GhostRole
name: ghost-role-information-ert-leader-name