Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Head bandana ingestion blocking fix #28910

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -12,6 +12,7 @@
unfoldedSlots:
- MASK
- type: Mask
disableOnFolded: true
- type: IngestionBlocker
- type: IdentityBlocker
coverage: MOUTH
Expand Down
Loading