2021-10-16 15:28:02 -07:00
|
|
|
using Content.Shared.Body.Components;
|
|
|
|
|
using Content.Shared.CharacterAppearance.Components;
|
|
|
|
|
using Content.Shared.CharacterAppearance.Systems;
|
|
|
|
|
using Robust.Server.GameObjects;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-03 14:17:01 +01:00
|
|
|
using Robust.Shared.IoC;
|
2021-10-16 15:28:02 -07:00
|
|
|
|
|
|
|
|
namespace Content.Server.CharacterAppearance.Systems
|
|
|
|
|
{
|
|
|
|
|
public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem
|
|
|
|
|
{
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<HumanoidAppearanceComponent, ChangedHumanoidAppearanceEvent>(UpdateSkinColor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateSkinColor(EntityUid uid, HumanoidAppearanceComponent component, ChangedHumanoidAppearanceEvent _)
|
|
|
|
|
{
|
|
|
|
|
if (EntityManager.TryGetComponent<SharedBodyComponent>(uid, out SharedBodyComponent? body))
|
|
|
|
|
{
|
|
|
|
|
foreach (var (part, _) in body.Parts)
|
|
|
|
|
{
|
2021-12-08 19:39:03 +01:00
|
|
|
if (EntityManager.TryGetComponent(part.Owner, out SpriteComponent? sprite))
|
2021-10-16 15:28:02 -07:00
|
|
|
{
|
|
|
|
|
sprite!.Color = component.Appearance.SkinColor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|