2023-09-17 18:51:42 +06:00
|
|
|
using Content.Server.Access.Systems;
|
|
|
|
|
using Content.Server.Humanoid;
|
|
|
|
|
using Content.Server.IdentityManagement;
|
|
|
|
|
using Content.Server.PDA;
|
2023-10-17 00:52:02 +09:00
|
|
|
using Content.Server.Roles;
|
2023-09-17 18:51:42 +06:00
|
|
|
using Content.Shared.Access.Components;
|
|
|
|
|
using Content.Shared.Inventory;
|
2023-10-19 02:32:18 +09:00
|
|
|
using Content.Shared.Mind.Components;
|
|
|
|
|
using Content.Shared.NukeOps;
|
2023-09-17 18:51:42 +06:00
|
|
|
using Content.Shared.PDA;
|
|
|
|
|
using Content.Shared.Preferences;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.White.Other.RandomHumanSystem;
|
|
|
|
|
|
|
|
|
|
public sealed class RandomHumanSystem : EntitySystem
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly HumanoidAppearanceSystem _humanoid = default!;
|
|
|
|
|
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
|
|
|
|
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
|
|
|
|
[Dependency] private readonly IdCardSystem _card = default!;
|
|
|
|
|
[Dependency] private readonly PdaSystem _pda = default!;
|
|
|
|
|
[Dependency] private readonly IdentitySystem _identity = default!;
|
2023-10-19 02:32:18 +09:00
|
|
|
[Dependency] private readonly RoleSystem _roles = default!;
|
2023-09-17 18:51:42 +06:00
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<RandomHumanComponent, ComponentInit>(OnInit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnInit(EntityUid uid, RandomHumanComponent component, ComponentInit args)
|
|
|
|
|
{
|
|
|
|
|
var newProfile = HumanoidCharacterProfile.RandomWithSpecies();
|
|
|
|
|
|
|
|
|
|
_humanoid.LoadProfile(uid, newProfile);
|
|
|
|
|
|
2023-10-19 02:32:18 +09:00
|
|
|
if (HasComp<NukeOperativeComponent>(uid))
|
2023-10-17 00:52:02 +09:00
|
|
|
return;
|
|
|
|
|
|
2023-09-17 18:51:42 +06:00
|
|
|
_metaData.SetEntityName(uid, newProfile.Name);
|
|
|
|
|
|
|
|
|
|
if (!_inventorySystem.TryGetSlotEntity(uid, "id", out var idUid))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!EntityManager.TryGetComponent(idUid, out PdaComponent? pdaComponent) || !TryComp<IdCardComponent>(pdaComponent.ContainedId, out var card))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var cardId = pdaComponent.ContainedId.Value;
|
|
|
|
|
|
|
|
|
|
_card.TryChangeFullName(cardId, newProfile.Name, card);
|
|
|
|
|
_pda.SetOwner(idUid.Value, pdaComponent, newProfile.Name);
|
|
|
|
|
|
|
|
|
|
_identity.QueueIdentityUpdate(uid);
|
|
|
|
|
}
|
|
|
|
|
}
|