Makes EventRole Ids properly set ID names. (#28958)

* Add id binding system

* Change so it activates when added too

* Add to eventhumanoid

* Add PDA binding, try to fix some things

* Still not fixed, PDA is working right

* Move to server, add on mind instead

* Implement suggestions

* Fix things

* Finish review stuff

* Messed up cluwne

* Remove after only changing id too

---------

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
This commit is contained in:
Verm
2025-04-21 13:25:22 -05:00
committed by GitHub
parent e8ee73dd33
commit dd308c6d2d
4 changed files with 68 additions and 3 deletions

View File

@@ -0,0 +1,14 @@
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;
}

View File

@@ -0,0 +1,51 @@
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);
}
}

View File

@@ -21,7 +21,7 @@ public sealed partial class RandomHumanoidSettingsPrototype : IPrototype, IInher
/// <summary> /// <summary>
/// Whether the humanoid's name should take from the randomized profile or not. /// Whether the humanoid's name should take from the randomized profile or not.
/// </summary> /// </summary>
[DataField("randomizeName")] [DataField]
public bool RandomizeName { get; private set; } = true; public bool RandomizeName { get; private set; } = true;
/// <summary> /// <summary>

View File

@@ -6,10 +6,12 @@
- type: RandomHumanoidAppearance - type: RandomHumanoidAppearance
randomizeName: false randomizeName: false
- type: GhostTakeoverAvailable - type: GhostTakeoverAvailable
- type: IdBind
- type: randomHumanoidSettings - type: randomHumanoidSettings
id: EventHumanoidMindShielded id: EventHumanoidMindShielded
parent: EventHumanoid parent: EventHumanoid
randomizeName: false
components: components:
- type: MindShield - type: MindShield
- type: AntagImmune - type: AntagImmune
@@ -43,7 +45,6 @@
- type: randomHumanoidSettings - type: randomHumanoidSettings
id: DeathSquad id: DeathSquad
parent: EventHumanoidCentcomm parent: EventHumanoidCentcomm
randomizeName: false
components: components:
- type: GhostRole - type: GhostRole
name: ghost-role-information-Death-Squad-name name: ghost-role-information-Death-Squad-name
@@ -84,7 +85,6 @@
- type: randomHumanoidSettings - type: randomHumanoidSettings
id: ERTLeader id: ERTLeader
parent: EventHumanoidCentcomm parent: EventHumanoidCentcomm
randomizeName: false
components: components:
- type: GhostRole - type: GhostRole
name: ghost-role-information-ert-leader-name name: ghost-role-information-ert-leader-name