Files
Delta-v/Content.Client/Humanoid/HideableHumanoidLayersSystem.cs
T
pathetic meowmeow c57721eca5 Visual nubody (humanoid appearance refactor) (#42476)
* initial visual nubody

* oops overlay

* im so pheeming rn

* conversion...

* tests

* comeback of the underwear

* oops eyes

* blabbl

* zeds

* yaml linted

* search and visible count constraints

* reordering

* preserve previously selected markings colors

* fix test

* some ui niceties

* ordering

* make DB changes backwards-compatible/downgrade-friendly

* fix things again

* fix migration

* vulpkanin markings limit increase

* wrapping

* code cleanup and more code cleanup and more code cleanup and more code cleanup and

* fix slop ports

* better sampling API

* make filter work + use the method i made for its intended purpose

* fix test fails real quick

* magic mirror cleanup, remove TODO

* don't 0-init the organ profile data

* remove deltastates

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>

# Conflicts:
#	Content.Server/Humanoid/Components/RandomHumanoidAppearanceComponent.cs
#	Content.Server/Humanoid/Systems/RandomHumanoidAppearanceSystem.cs

# Conflicts:
#	Resources/Prototypes/Species/diona.yml

# Conflicts:
#	Content.Server/Zombies/ZombieSystem.Transform.cs
2026-06-29 12:43:35 +02:00

75 lines
2.3 KiB
C#

using Content.Shared.Humanoid;
using Content.Shared.Inventory;
using Robust.Client.GameObjects;
namespace Content.Client.Humanoid;
public sealed class HideableHumanoidLayersSystem : SharedHideableHumanoidLayersSystem
{
[Dependency] private readonly SpriteSystem _sprite = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HideableHumanoidLayersComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<HideableHumanoidLayersComponent, AfterAutoHandleStateEvent>(OnHandleState);
}
private void OnComponentInit(Entity<HideableHumanoidLayersComponent> ent, ref ComponentInit args)
{
UpdateSprite(ent);
}
private void OnHandleState(Entity<HideableHumanoidLayersComponent> ent, ref AfterAutoHandleStateEvent args)
{
UpdateSprite(ent);
}
public override void SetLayerVisibility(
Entity<HideableHumanoidLayersComponent?> ent,
HumanoidVisualLayers layer,
bool visible,
SlotFlags source)
{
base.SetLayerVisibility(ent, layer, visible, source);
if (Resolve(ent, ref ent.Comp))
UpdateSprite((ent, ent.Comp));
}
private void UpdateSprite(Entity<HideableHumanoidLayersComponent> ent)
{
foreach (var item in ent.Comp.LastHiddenLayers)
{
if (ent.Comp.HiddenLayers.ContainsKey(item))
continue;
var evt = new HumanoidLayerVisibilityChangedEvent(item, true);
RaiseLocalEvent(ent, ref evt);
if (!_sprite.LayerMapTryGet(ent.Owner, item, out var index, true))
continue;
_sprite.LayerSetVisible(ent.Owner, index, true);
}
foreach (var item in ent.Comp.HiddenLayers.Keys)
{
if (ent.Comp.LastHiddenLayers.Contains(item))
continue;
var evt = new HumanoidLayerVisibilityChangedEvent(item, false);
RaiseLocalEvent(ent, ref evt);
if (!_sprite.LayerMapTryGet(ent.Owner, item, out var index, true))
continue;
_sprite.LayerSetVisible(ent.Owner, index, false);
}
ent.Comp.LastHiddenLayers.Clear();
ent.Comp.LastHiddenLayers.UnionWith(ent.Comp.HiddenLayers.Keys);
}
}