2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Body.Components;
|
|
|
|
|
using Content.Shared.CharacterAppearance;
|
|
|
|
|
using Content.Shared.CharacterAppearance.Components;
|
2020-10-10 15:25:13 +02:00
|
|
|
using Robust.Server.GameObjects;
|
2019-11-23 21:55:46 +01:00
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.CharacterAppearance.Components
|
2019-11-23 21:55:46 +01:00
|
|
|
{
|
|
|
|
|
[RegisterComponent]
|
2020-01-18 01:54:13 +01:00
|
|
|
public sealed class HumanoidAppearanceComponent : SharedHumanoidAppearanceComponent
|
2019-11-23 21:55:46 +01:00
|
|
|
{
|
2020-10-10 15:25:13 +02:00
|
|
|
public override HumanoidCharacterAppearance Appearance
|
|
|
|
|
{
|
|
|
|
|
get => base.Appearance;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
base.Appearance = value;
|
2019-11-23 21:55:46 +01:00
|
|
|
|
2021-06-16 16:44:38 +02:00
|
|
|
if (Owner.TryGetComponent(out SharedBodyComponent? body))
|
2020-10-10 15:25:13 +02:00
|
|
|
{
|
2021-04-05 14:54:51 +02:00
|
|
|
foreach (var (part, _) in body.Parts)
|
2020-10-10 15:25:13 +02:00
|
|
|
{
|
2021-03-16 15:50:20 +01:00
|
|
|
if (!part.Owner.TryGetComponent(out SpriteComponent? sprite))
|
2020-10-10 15:25:13 +02:00
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sprite.Color = value.SkinColor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Startup()
|
|
|
|
|
{
|
|
|
|
|
base.Startup();
|
|
|
|
|
|
2021-06-16 16:44:38 +02:00
|
|
|
if (Appearance != null! && Owner.TryGetComponent(out SharedBodyComponent? body))
|
2020-10-10 15:25:13 +02:00
|
|
|
{
|
2021-04-05 14:54:51 +02:00
|
|
|
foreach (var (part, _) in body.Parts)
|
2020-10-10 15:25:13 +02:00
|
|
|
{
|
2021-03-16 15:50:20 +01:00
|
|
|
if (!part.Owner.TryGetComponent(out SpriteComponent? sprite))
|
2020-10-10 15:25:13 +02:00
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sprite.Color = Appearance.SkinColor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-23 21:55:46 +01:00
|
|
|
}
|
|
|
|
|
}
|