* Refactor body component to use slots instead of an army of dictionaries * Update vox * Replace static method call with extension * Add setpart method, replace dispose with shutdown * Fix tests, fix not listening to slot events when setting a part
53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using Content.Shared.GameObjects.Components.Body;
|
|
using Content.Shared.GameObjects.Components.Mobs;
|
|
using Content.Shared.Preferences;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Shared.GameObjects;
|
|
|
|
namespace Content.Server.GameObjects.Components.Mobs
|
|
{
|
|
[RegisterComponent]
|
|
public sealed class HumanoidAppearanceComponent : SharedHumanoidAppearanceComponent
|
|
{
|
|
public override HumanoidCharacterAppearance Appearance
|
|
{
|
|
get => base.Appearance;
|
|
set
|
|
{
|
|
base.Appearance = value;
|
|
|
|
if (Owner.TryGetComponent(out IBody? body))
|
|
{
|
|
foreach (var (part, _) in body.Parts)
|
|
{
|
|
if (!part.Owner.TryGetComponent(out SpriteComponent? sprite))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
sprite.Color = value.SkinColor;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void Startup()
|
|
{
|
|
base.Startup();
|
|
|
|
if (Appearance != null! && Owner.TryGetComponent(out IBody? body))
|
|
{
|
|
foreach (var (part, _) in body.Parts)
|
|
{
|
|
if (!part.Owner.TryGetComponent(out SpriteComponent? sprite))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
sprite.Color = Appearance.SkinColor;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|