Skip to content

Commit

Permalink
Head bandana ingestion blocking fix (#28910)
Browse files Browse the repository at this point in the history
  • Loading branch information
stalengd authored Aug 9, 2024
1 parent 05a21ab commit 60b63b5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Content.Shared/Clothing/Components/MaskComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,16 @@ public sealed partial class MaskComponent : Component

[DataField, AutoNetworkedField]
public string EquippedPrefix = "toggled";

/// <summary>
/// When <see langword="true"/> will function normally, otherwise will not react to events
/// </summary>
[DataField("enabled"), AutoNetworkedField]
public bool IsEnabled = true;

/// <summary>
/// When <see langword="true"/> will disable <see cref="IsEnabled"/> when folded
/// </summary>
[DataField, AutoNetworkedField]
public bool DisableOnFolded;
}
6 changes: 4 additions & 2 deletions Content.Shared/Clothing/EntitySystems/MaskSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private void OnGetActions(EntityUid uid, MaskComponent component, GetItemActions
private void OnToggleMask(Entity<MaskComponent> ent, ref ToggleMaskEvent args)
{
var (uid, mask) = ent;
if (mask.ToggleActionEntity == null || !_timing.IsFirstTimePredicted)
if (mask.ToggleActionEntity == null || !_timing.IsFirstTimePredicted || !mask.IsEnabled)
return;

if (!_inventorySystem.TryGetSlotEntity(args.Performer, "mask", out var existing) || !uid.Equals(existing))
Expand All @@ -53,7 +53,7 @@ private void OnToggleMask(Entity<MaskComponent> ent, ref ToggleMaskEvent args)
// set to untoggled when unequipped, so it isn't left in a 'pulled down' state
private void OnGotUnequipped(EntityUid uid, MaskComponent mask, GotUnequippedEvent args)
{
if (!mask.IsToggled)
if (!mask.IsToggled || !mask.IsEnabled)
return;

mask.IsToggled = false;
Expand All @@ -78,6 +78,8 @@ private void ToggleMaskComponents(EntityUid uid, MaskComponent mask, EntityUid w

private void OnFolded(Entity<MaskComponent> ent, ref FoldedEvent args)
{
if (ent.Comp.DisableOnFolded)
ent.Comp.IsEnabled = !args.IsFolded;
ent.Comp.IsToggled = args.IsFolded;

ToggleMaskComponents(ent.Owner, ent.Comp, ent.Owner);
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/Entities/Clothing/Head/bandanas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
folded: true
- type: Mask
isToggled: true
enabled: false
disableOnFolded: true
- type: IngestionBlocker
enabled: false
- type: IdentityBlocker
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Clothing/Masks/bandanas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
unfoldedHideLayers:
- Snout
- type: Mask
disableOnFolded: true
- type: IngestionBlocker
- type: IdentityBlocker
coverage: MOUTH
Expand Down

0 comments on commit 60b63b5

Please sign in to comment.