Files
Delta-v/Content.Shared/Humanoid/SharedHideableHumanoidLayersSystem.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

59 lines
2.1 KiB
C#

using System.Numerics;
using Content.Shared.Inventory;
using Robust.Shared.Utility;
namespace Content.Shared.Humanoid;
public abstract partial class SharedHideableHumanoidLayersSystem : EntitySystem
{
/// <summary>
/// Toggles a humanoid's sprite layer visibility.
/// </summary>
/// <param name="ent">Humanoid entity</param>
/// <param name="layer">Layer to toggle visibility for</param>
/// <param name="visible">Whether to hide or show the layer. If more than once piece of clothing is hiding the layer, it may remain hidden.</param>
/// <param name="slot">Equipment slot that has the clothing that is (or was) hiding the layer.</param>
public virtual void SetLayerVisibility(
Entity<HideableHumanoidLayersComponent?> ent,
HumanoidVisualLayers layer,
bool visible,
SlotFlags slot)
{
if (!Resolve(ent, ref ent.Comp))
return;
#if DEBUG
DebugTools.AssertNotEqual(slot, SlotFlags.NONE);
// Check that only a single bit in the bitflag is set
var powerOfTwo = BitOperations.RoundUpToPowerOf2((uint)slot);
DebugTools.AssertEqual((uint)slot, powerOfTwo);
#endif
var dirty = false;
if (visible)
{
var oldSlots = ent.Comp.HiddenLayers.GetValueOrDefault(layer);
ent.Comp.HiddenLayers[layer] = slot | oldSlots;
dirty |= (oldSlots & slot) != slot;
}
else if (ent.Comp.HiddenLayers.TryGetValue(layer, out var oldSlots))
{
// This layer might be getting hidden by more than one piece of equipped clothing.
// remove slot flag from the set of slots hiding this layer, then check if there are any left.
ent.Comp.HiddenLayers[layer] = ~slot & oldSlots;
if (ent.Comp.HiddenLayers[layer] == SlotFlags.NONE)
ent.Comp.HiddenLayers.Remove(layer);
dirty |= (oldSlots & slot) != 0;
}
if (!dirty)
return;
Dirty(ent);
var evt = new HumanoidLayerVisibilityChangedEvent(layer, visible);
RaiseLocalEvent(ent, ref evt);
}
}