* Fix broken layer hiding on clothes with multiple equipment slots * Refactor ToggleVisualLayers, HideLayerClothingComponent, and ClothingComponent to allow more precise layer hide behavior and more CPU efficient layer toggling. * Adjust HumanoidAppearaceSystem to track which slots are hiding a given layer (e.g. gas mask and welding mask) Add documentation Change gas masks to use the new HideLayerClothingComponent structure as an example of its usage * Fix the delayed snout bug * Misc cleanup * Make `bool permanent` implicit from SlotFlags any non-permanent visibility toggle with `SlotFlags.None` isn't supported with how its set up. And similarly, the slot flags argument does nothing if permanent = true. So IMO it makes more sense to infer it from a nullable arg. * Split into separate system Too much pasta * Remove (hopefully unnecessary) refresh * Fisk mask networking AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * Keep old behaviour, use clearer names? I'm just guessing at what this was meant to do * english * Separate slot name & flag * dirty = true * fix comment * Improved SetLayerVisibility with dirtying logic suggested by @ElectroJr * Only set mask toggled if DisableOnFold is true * FoldableClothingSystem fixes * fix bandana state * Better comment --------- Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
using Content.Shared.Clothing;
|
|
using Content.Shared.IdentityManagement.Components;
|
|
using Content.Shared.Inventory;
|
|
using Robust.Shared.Containers;
|
|
|
|
namespace Content.Shared.IdentityManagement;
|
|
|
|
public abstract class SharedIdentitySystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedContainerSystem _container = default!;
|
|
private static string SlotName = "identity";
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<IdentityComponent, ComponentInit>(OnComponentInit);
|
|
SubscribeLocalEvent<IdentityBlockerComponent, SeeIdentityAttemptEvent>(OnSeeIdentity);
|
|
SubscribeLocalEvent<IdentityBlockerComponent, InventoryRelayedEvent<SeeIdentityAttemptEvent>>((e, c, ev) => OnSeeIdentity(e, c, ev.Args));
|
|
SubscribeLocalEvent<IdentityBlockerComponent, ItemMaskToggledEvent>(OnMaskToggled);
|
|
}
|
|
|
|
private void OnSeeIdentity(EntityUid uid, IdentityBlockerComponent component, SeeIdentityAttemptEvent args)
|
|
{
|
|
if (component.Enabled)
|
|
{
|
|
args.TotalCoverage |= component.Coverage;
|
|
if(args.TotalCoverage == IdentityBlockerCoverage.FULL)
|
|
args.Cancel();
|
|
}
|
|
}
|
|
|
|
protected virtual void OnComponentInit(EntityUid uid, IdentityComponent component, ComponentInit args)
|
|
{
|
|
component.IdentityEntitySlot = _container.EnsureContainer<ContainerSlot>(uid, SlotName);
|
|
}
|
|
|
|
private void OnMaskToggled(Entity<IdentityBlockerComponent> ent, ref ItemMaskToggledEvent args)
|
|
{
|
|
ent.Comp.Enabled = !args.Mask.Comp.IsToggled;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Gets called whenever an entity changes their identity.
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public record struct IdentityChangedEvent(EntityUid CharacterEntity, EntityUid IdentityEntity);
|