Make hardsuit helmets hide hair. (#6985)

This commit is contained in:
Leon Friedrich
2022-03-06 11:27:27 +13:00
committed by GitHub
parent f08cdfcaa8
commit 91f63ddbbd
3 changed files with 30 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ using Content.Shared.Clothing;
using Content.Shared.Inventory; using Content.Shared.Inventory;
using Content.Shared.Inventory.Events; using Content.Shared.Inventory.Events;
using Content.Shared.Item; using Content.Shared.Item;
using Content.Shared.Tag;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.ResourceManagement; using Robust.Client.ResourceManagement;
@@ -42,6 +43,7 @@ public sealed class ClothingSystem : EntitySystem
[Dependency] private IResourceCache _cache = default!; [Dependency] private IResourceCache _cache = default!;
[Dependency] private InventorySystem _inventorySystem = default!; [Dependency] private InventorySystem _inventorySystem = default!;
[Dependency] private TagSystem _tagSystem = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -146,6 +148,17 @@ public sealed class ClothingSystem : EntitySystem
private void OnGotUnequipped(EntityUid uid, ClothingComponent component, GotUnequippedEvent args) private void OnGotUnequipped(EntityUid uid, ClothingComponent component, GotUnequippedEvent args)
{ {
if (component.InSlot == "head"
&& _tagSystem.HasTag(uid, "HidesHair")
&& TryComp(args.Equipee, out SpriteComponent? sprite))
{
if (sprite.LayerMapTryGet(HumanoidVisualLayers.FacialHair, out var facial))
sprite[facial].Visible = true;
if (sprite.LayerMapTryGet(HumanoidVisualLayers.Hair, out var hair))
sprite[hair].Visible = true;
}
component.InSlot = null; component.InSlot = null;
} }
@@ -183,6 +196,17 @@ public sealed class ClothingSystem : EntitySystem
{ {
component.InSlot = args.Slot; component.InSlot = args.Slot;
if (args.Slot == "head"
&& _tagSystem.HasTag(uid, "HidesHair")
&& TryComp(args.Equipee, out SpriteComponent? sprite))
{
if (sprite.LayerMapTryGet(HumanoidVisualLayers.FacialHair, out var facial))
sprite[facial].Visible = false;
if (sprite.LayerMapTryGet(HumanoidVisualLayers.Hair, out var hair))
sprite[hair].Visible = false;
}
RenderEquipment(args.Equipee, uid, args.Slot, clothingComponent: component); RenderEquipment(args.Equipee, uid, args.Slot, clothingComponent: component);
} }

View File

@@ -42,6 +42,9 @@
Heat: 0.90 Heat: 0.90
Radiation: 0.25 Radiation: 0.25
- type: IngestionBlocker - type: IngestionBlocker
- type: Tag
tags:
- HidesHair
- type: entity - type: entity
abstract: true abstract: true

View File

@@ -162,6 +162,9 @@
- type: Tag - type: Tag
id: HideContextMenu id: HideContextMenu
- type: Tag
id: HidesHair # for headwear.
- type: Tag - type: Tag
id: Hoe id: Hoe