* 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>
103 lines
3.2 KiB
C#
103 lines
3.2 KiB
C#
|
|
using Content.Shared.Actions;
|
|
using Content.Shared.Clothing.Components;
|
|
|
|
namespace Content.Shared.Clothing;
|
|
|
|
/// <summary>
|
|
/// Raised directed at a piece of clothing to get the set of layers to show on the wearer's sprite
|
|
/// </summary>
|
|
public sealed class GetEquipmentVisualsEvent : EntityEventArgs
|
|
{
|
|
/// <summary>
|
|
/// Entity that is wearing the item.
|
|
/// </summary>
|
|
public readonly EntityUid Equipee;
|
|
|
|
public readonly string Slot;
|
|
|
|
/// <summary>
|
|
/// The layers that will be added to the entity that is wearing this item.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Note that the actual ordering of the layers depends on the order in which they are added to this list;
|
|
/// </remarks>
|
|
public List<(string, PrototypeLayerData)> Layers = new();
|
|
|
|
public GetEquipmentVisualsEvent(EntityUid equipee, string slot)
|
|
{
|
|
Equipee = equipee;
|
|
Slot = slot;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Raised directed at a piece of clothing after its visuals have been updated.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Useful for systems/components that modify the visual layers that an item adds to a player. (e.g. RGB memes)
|
|
/// </remarks>
|
|
public sealed class EquipmentVisualsUpdatedEvent : EntityEventArgs
|
|
{
|
|
/// <summary>
|
|
/// Entity that is wearing the item.
|
|
/// </summary>
|
|
public readonly EntityUid Equipee;
|
|
|
|
public readonly string Slot;
|
|
|
|
/// <summary>
|
|
/// The layers that this item is now revealing.
|
|
/// </summary>
|
|
public HashSet<string> RevealedLayers;
|
|
|
|
public EquipmentVisualsUpdatedEvent(EntityUid equipee, string slot, HashSet<string> revealedLayers)
|
|
{
|
|
Equipee = equipee;
|
|
Slot = slot;
|
|
RevealedLayers = revealedLayers;
|
|
}
|
|
}
|
|
|
|
public sealed partial class ToggleMaskEvent : InstantActionEvent { }
|
|
|
|
/// <summary>
|
|
/// Event raised on the mask entity when it is toggled.
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public readonly record struct ItemMaskToggledEvent(Entity<MaskComponent> Mask, EntityUid? Wearer);
|
|
|
|
/// <summary>
|
|
/// Event raised on the entity wearing the mask when it is toggled.
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public readonly record struct WearerMaskToggledEvent(Entity<MaskComponent> Mask);
|
|
|
|
/// <summary>
|
|
/// Raised on the clothing entity when it is equipped to a valid slot,
|
|
/// as determined by <see cref="ClothingComponent.Slots"/>.
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public readonly record struct ClothingGotEquippedEvent(EntityUid Wearer, ClothingComponent Clothing);
|
|
|
|
/// <summary>
|
|
/// Raised on the clothing entity when it is unequipped from a valid slot,
|
|
/// as determined by <see cref="ClothingComponent.Slots"/>.
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public readonly record struct ClothingGotUnequippedEvent(EntityUid Wearer, ClothingComponent Clothing);
|
|
|
|
/// <summary>
|
|
/// Raised on an entity when they equip a clothing item to a valid slot,
|
|
/// as determined by <see cref="ClothingComponent.Slots"/>.
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public readonly record struct ClothingDidEquippedEvent(Entity<ClothingComponent> Clothing);
|
|
|
|
/// <summary>
|
|
/// Raised on an entity when they unequip a clothing item from a valid slot,
|
|
/// as determined by <see cref="ClothingComponent.Slots"/>.
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public readonly record struct ClothingDidUnequippedEvent(Entity<ClothingComponent> Clothing);
|