Head bandana ingestion blocking fix (#28910)

This commit is contained in:
Stalen
2024-08-09 09:17:51 +03:00
committed by GitHub
parent 05a21ab3ca
commit 60b63b58dd
4 changed files with 19 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -35,7 +35,7 @@ public sealed class MaskSystem : EntitySystem
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))
@@ -53,7 +53,7 @@ public sealed class MaskSystem : EntitySystem
// 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;
@@ -78,6 +78,8 @@ public sealed class MaskSystem : EntitySystem
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);

View File

@@ -7,6 +7,8 @@
folded: true
- type: Mask
isToggled: true
enabled: false
disableOnFolded: true
- type: IngestionBlocker
enabled: false
- type: IdentityBlocker

View File

@@ -15,6 +15,7 @@
unfoldedHideLayers:
- Snout
- type: Mask
disableOnFolded: true
- type: IngestionBlocker
- type: IdentityBlocker
coverage: MOUTH