Add face bandanas (#24597)
* add face bandanas * oops * make face bandanas butcherable, also one bite * oops * Add mouth IdentityBlocker to bandanas * refactor to use foldablecomponent * remove some leftover bits * remove HamsterWearable until face sprite updated * oops * review changes * remove a few unneeded bits
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using Content.Shared.Clothing.Components;
|
||||
using Content.Shared.Foldable;
|
||||
using Content.Shared.Inventory;
|
||||
|
||||
namespace Content.Shared.Clothing.EntitySystems;
|
||||
|
||||
public sealed class FoldableClothingSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ClothingSystem _clothingSystem = default!;
|
||||
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<FoldableClothingComponent, FoldAttemptEvent>(OnFoldAttempt);
|
||||
SubscribeLocalEvent<FoldableClothingComponent, FoldedEvent>(OnFolded);
|
||||
}
|
||||
|
||||
private void OnFoldAttempt(Entity<FoldableClothingComponent> ent, ref FoldAttemptEvent args)
|
||||
{
|
||||
if (args.Cancelled)
|
||||
return;
|
||||
|
||||
// allow folding while equipped if allowed slots are the same:
|
||||
// e.g. flip a hat backwards while on your head
|
||||
if (_inventorySystem.TryGetContainingSlot(ent.Owner, out var slot) &&
|
||||
!ent.Comp.FoldedSlots.Equals(ent.Comp.UnfoldedSlots))
|
||||
args.Cancelled = true;
|
||||
}
|
||||
|
||||
private void OnFolded(Entity<FoldableClothingComponent> ent, ref FoldedEvent args)
|
||||
{
|
||||
if (TryComp<ClothingComponent>(ent.Owner, out var clothingComp))
|
||||
{
|
||||
if (args.IsFolded && ent.Comp.FoldedSlots.HasValue)
|
||||
_clothingSystem.SetSlots(ent.Owner, ent.Comp.FoldedSlots.Value, clothingComp);
|
||||
else if (!args.IsFolded && ent.Comp.UnfoldedSlots.HasValue)
|
||||
_clothingSystem.SetSlots(ent.Owner, ent.Comp.UnfoldedSlots.Value, clothingComp);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user