Fix humanoid appearance error (#13721)
This commit is contained in:
@@ -114,9 +114,9 @@ public sealed class HumanoidAppearanceState : ComponentState
|
||||
[Serializable, NetSerializable]
|
||||
public readonly struct CustomBaseLayerInfo
|
||||
{
|
||||
public CustomBaseLayerInfo(string id, Color? color = null)
|
||||
public CustomBaseLayerInfo(string? id, Color? color = null)
|
||||
{
|
||||
DebugTools.Assert(IoCManager.Resolve<IPrototypeManager>().HasIndex<HumanoidSpeciesSpriteLayer>(id));
|
||||
DebugTools.Assert(id == null || IoCManager.Resolve<IPrototypeManager>().HasIndex<HumanoidSpeciesSpriteLayer>(id));
|
||||
ID = id;
|
||||
Color = color;
|
||||
}
|
||||
@@ -124,11 +124,11 @@ public sealed class HumanoidAppearanceState : ComponentState
|
||||
/// <summary>
|
||||
/// ID of this custom base layer. Must be a <see cref="HumanoidSpeciesSpriteLayer"/>.
|
||||
/// </summary>
|
||||
[DataField("id", customTypeSerializer: typeof(PrototypeIdSerializer<HumanoidSpeciesSpriteLayer>), required: true)]
|
||||
public string ID { init; get; }
|
||||
[DataField("id", customTypeSerializer: typeof(PrototypeIdSerializer<HumanoidSpeciesSpriteLayer>))]
|
||||
public string? ID { init; get; }
|
||||
|
||||
/// <summary>
|
||||
/// Color of this custom base layer. Null implies skin colour.
|
||||
/// Color of this custom base layer. Null implies skin colour if the corresponding <see cref="HumanoidSpeciesSpriteLayer"/> is set to match skin.
|
||||
/// </summary>
|
||||
[DataField("color")]
|
||||
public Color? Color { init; get; }
|
||||
|
||||
@@ -165,7 +165,7 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem
|
||||
/// <param name="id">The ID of the sprite to use. See <see cref="HumanoidSpeciesSpriteLayer"/>.</param>
|
||||
/// <param name="sync">Whether to synchronize this to the humanoid mob, or not.</param>
|
||||
/// <param name="humanoid">Humanoid component of the entity</param>
|
||||
public void SetBaseLayerId(EntityUid uid, HumanoidVisualLayers layer, string id, bool sync = true,
|
||||
public void SetBaseLayerId(EntityUid uid, HumanoidVisualLayers layer, string? id, bool sync = true,
|
||||
HumanoidAppearanceComponent? humanoid = null)
|
||||
{
|
||||
if (!Resolve(uid, ref humanoid))
|
||||
@@ -192,7 +192,10 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem
|
||||
if (!Resolve(uid, ref humanoid))
|
||||
return;
|
||||
|
||||
humanoid.CustomBaseLayers[layer] = humanoid.CustomBaseLayers[layer] with { Color = color };
|
||||
if (humanoid.CustomBaseLayers.TryGetValue(layer, out var info))
|
||||
humanoid.CustomBaseLayers[layer] = info with { Color = color };
|
||||
else
|
||||
humanoid.CustomBaseLayers[layer] = new(null, color);
|
||||
|
||||
if (sync)
|
||||
Dirty(humanoid);
|
||||
|
||||
Reference in New Issue
Block a user