Move CloneAppearance to Shared (#35017)

* Move CloneAppearance

- Move CloneAppearance from HumanoidAppearanceSystem
to SharedHumanoidAppearanceSystem

* CR - Fix the sins of the past
This commit is contained in:
Zachary Higgs
2025-02-09 23:13:27 -04:00
committed by GitHub
parent 03bab30fc6
commit 8b46538e3f
2 changed files with 28 additions and 34 deletions

View File

@@ -132,6 +132,34 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem
Dirty(uid, humanoid);
}
/// <summary>
/// Clones a humanoid's appearance to a target mob, provided they both have humanoid components.
/// </summary>
/// <param name="source">Source entity to fetch the original appearance from.</param>
/// <param name="target">Target entity to apply the source entity's appearance to.</param>
/// <param name="sourceHumanoid">Source entity's humanoid component.</param>
/// <param name="targetHumanoid">Target entity's humanoid component.</param>
public void CloneAppearance(EntityUid source, EntityUid target, HumanoidAppearanceComponent? sourceHumanoid = null,
HumanoidAppearanceComponent? targetHumanoid = null)
{
if (!Resolve(source, ref sourceHumanoid) || !Resolve(target, ref targetHumanoid))
return;
targetHumanoid.Species = sourceHumanoid.Species;
targetHumanoid.SkinColor = sourceHumanoid.SkinColor;
targetHumanoid.EyeColor = sourceHumanoid.EyeColor;
targetHumanoid.Age = sourceHumanoid.Age;
SetSex(target, sourceHumanoid.Sex, false, targetHumanoid);
targetHumanoid.CustomBaseLayers = new(sourceHumanoid.CustomBaseLayers);
targetHumanoid.MarkingSet = new(sourceHumanoid.MarkingSet);
targetHumanoid.Gender = sourceHumanoid.Gender;
if (TryComp<GrammarComponent>(target, out var grammar))
grammar.Gender = sourceHumanoid.Gender;
Dirty(target, targetHumanoid);
}
/// <summary>
/// Sets the visibility for multiple layers at once on a humanoid's sprite.
/// </summary>