CatStation/Content.Server/Humanoid/Systems/RandomHumanoidAppearanceSystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

35 lines
1.2 KiB
C#

using Content.Server.Humanoid.Components;
using Content.Shared.Body;
using Content.Shared.Humanoid;
using Content.Shared.Preferences;
namespace Content.Server.Humanoid.Systems;
public sealed partial class RandomHumanoidAppearanceSystem : EntitySystem
{
[Dependency] private HumanoidProfileSystem _humanoidProfile = default!;
[Dependency] private MetaDataSystem _metaData = default!;
[Dependency] private SharedVisualBodySystem _visualBody = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RandomHumanoidAppearanceComponent, MapInitEvent>(OnMapInit);
}
private void OnMapInit(EntityUid uid, RandomHumanoidAppearanceComponent component, MapInitEvent args)
{
// If we have an initial profile/base layer set, do not randomize this humanoid.
if (!TryComp<HumanoidProfileComponent>(uid, out var humanoid))
return;
var profile = HumanoidCharacterProfile.RandomWithSpecies(humanoid.Species);
_visualBody.ApplyProfileTo(uid, profile);
_humanoidProfile.ApplyProfileTo(uid, profile);
if (component.RandomizeName)
_metaData.SetEntityName(uid, profile.Name);
}
}