Files
wwdpublic/Content.Server/Humanoid/Systems/RandomHumanoidAppearanceSystem.cs
Gersoon 10a2b918fd Friday31 (#868)
* 1

* Squashed commit of the following:

commit 182403875c6b7348a6ae33aca959aefa7f2dad8e
Author: Kutosss <162154227+Kutosss@users.noreply.github.com>
Date:   Mon Oct 27 16:14:41 2025 +0300

    Бабайки (#3)

    * Джейсон

    Джейсон
    Звуки и спрайты
    Способность на отрубание головы
    Способность к воскрешению
    Тематическое лого

    * саунд для пениса

    * блядопеннивайз

    * шарики

    * Update jason_gear.yml

    * слендерчлен

    * Update SlendermanShadowWalkSystem.cs

    * трапики

* Friday31 (#6)

* Джейсон

Джейсон
Звуки и спрайты
Способность на отрубание головы
Способность к воскрешению
Тематическое лого

* саунд для пениса

* блядопеннивайз

* шарики

* Update jason_gear.yml

* слендерчлен

* Update SlendermanShadowWalkSystem.cs

* трапики

* крестик

* 3

* Friday31 (#7)

* Джейсон

Джейсон
Звуки и спрайты
Способность на отрубание головы
Способность к воскрешению
Тематическое лого

* саунд для пениса

* блядопеннивайз

* шарики

* Update jason_gear.yml

* слендерчлен

* Update SlendermanShadowWalkSystem.cs

* трапики

* крестик

* костюм

* Apply suggestions from code review

* 5

* 6

---------

Co-authored-by: Kutosss <162154227+Kutosss@users.noreply.github.com>
2025-10-31 19:39:33 +03:00

42 lines
1.6 KiB
C#

using Content.Server.CharacterAppearance.Components;
using Content.Shared.Humanoid;
using Content.Shared.Preferences;
namespace Content.Server.Humanoid.Systems;
public sealed class RandomHumanoidAppearanceSystem : EntitySystem
{
[Dependency] private readonly HumanoidAppearanceSystem _humanoid = default!;
[Dependency] private readonly MetaDataSystem _metaData = 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(uid, out HumanoidAppearanceComponent? humanoid) || !string.IsNullOrEmpty(humanoid.Initial))
{
return;
}
var profile = HumanoidCharacterProfile.RandomWithSpecies(humanoid.Species);
//If we have a specified hair style, change it to this
if(component.Hair != null)
profile = profile.WithCharacterAppearance(profile.Appearance.WithHairStyleName(component.Hair));
//If we have a specified facial hair style, change it to this
if(component.FacialHair != null)
profile = profile.WithCharacterAppearance(profile.Appearance.WithFacialHairStyleName(component.FacialHair));
_humanoid.LoadProfile(uid, profile, humanoid);
if (component.RandomizeName)
_metaData.SetEntityName(uid, profile.Name);
}
}