Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes EventRole Ids properly set ID names. #28958

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
18 changes: 18 additions & 0 deletions Content.Server/Access/Components/IdBindComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Robust.Shared.GameStates;

namespace Content.Server.Access.Components;
/// <summary>
/// Makes it so when starting gear loads up, the name on a PDA/Id (if present) is changed to the character's name.
/// </summary>

Vermidia marked this conversation as resolved.
Show resolved Hide resolved
[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;

}

Vermidia marked this conversation as resolved.
Show resolved Hide resolved
48 changes: 48 additions & 0 deletions Content.Server/Access/Systems/IdBindSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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;

if (!TryComp<MetaDataComponent>(ent, out var data))
return;
Vermidia marked this conversation as resolved.
Show resolved Hide resolved

_cardSystem.TryChangeFullName(cardId, data.EntityName, cardId);

if (!ent.Comp.BindPDAOwner)
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, data.EntityName);
//Remove after running once
EntityManager.RemoveComponent(ent, ent.Comp);
Vermidia marked this conversation as resolved.
Show resolved Hide resolved
}
}

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

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion Resources/Prototypes/Entities/Mobs/Player/humanoid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- type: RandomHumanoidAppearance
randomizeName: false
- type: GhostTakeoverAvailable
- type: IdBind

- type: randomHumanoidSettings
id: EventHumanoidMindShielded
Expand Down Expand Up @@ -71,7 +72,6 @@
- type: randomHumanoidSettings
id: ERTLeader
parent: EventHumanoidMindShielded
randomizeName: false
Vermidia marked this conversation as resolved.
Show resolved Hide resolved
components:
- type: GhostRole
name: ghost-role-information-ert-leader-name
Expand Down Expand Up @@ -458,6 +458,7 @@
- type: randomHumanoidSettings
id: CBURNAgent
parent: EventHumanoidMindShielded
randomizeName: false
Vermidia marked this conversation as resolved.
Show resolved Hide resolved
components:
- type: Loadout
prototypes: [CBURNGear]
Expand Down
Loading