Allow IdentityBlocker partial coverage (#24741)

* Allow IdentityBlocker partial coverage

* rename to TotalCoverage
This commit is contained in:
themias
2024-01-30 22:49:19 -05:00
committed by GitHub
parent bd46d7cc8a
commit d75f6c3db4
5 changed files with 35 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
using Content.Shared.Actions;
using Content.Shared.Actions;
using Content.Shared.Clothing.Components;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
@@ -68,6 +68,6 @@ public sealed class MaskSystem : EntitySystem
RaiseLocalEvent(uid, ref maskEv);
var wearerEv = new WearerMaskToggledEvent(mask.IsToggled);
RaiseLocalEvent(uid, ref wearerEv);
RaiseLocalEvent(wearer, ref wearerEv);
}
}

View File

@@ -1,4 +1,4 @@
using Content.Shared.Inventory;
using Content.Shared.Inventory;
using Robust.Shared.GameStates;
namespace Content.Shared.IdentityManagement.Components;
@@ -7,6 +7,20 @@ namespace Content.Shared.IdentityManagement.Components;
public sealed partial class IdentityBlockerComponent : Component
{
public bool Enabled = true;
/// <summary>
/// What part of your face does this cover? Eyes, mouth, or full?
/// </summary>
[DataField]
public IdentityBlockerCoverage Coverage = IdentityBlockerCoverage.FULL;
}
public enum IdentityBlockerCoverage
{
NONE = 0,
MOUTH = 1 << 0,
EYES = 1 << 1,
FULL = MOUTH | EYES
}
/// <summary>
@@ -14,6 +28,9 @@ public sealed partial class IdentityBlockerComponent : Component
/// </summary>
public sealed class SeeIdentityAttemptEvent : CancellableEntityEventArgs, IInventoryRelayEvent
{
// i.e. masks or helmets.
public SlotFlags TargetSlots => SlotFlags.MASK | SlotFlags.HEAD;
// i.e. masks, helmets, or glasses.
public SlotFlags TargetSlots => SlotFlags.MASK | SlotFlags.HEAD | SlotFlags.EYES;
// cumulative coverage from each relayed slot
public IdentityBlockerCoverage TotalCoverage = IdentityBlockerCoverage.NONE;
}

View File

@@ -23,8 +23,12 @@ public abstract class SharedIdentitySystem : EntitySystem
private void OnSeeIdentity(EntityUid uid, IdentityBlockerComponent component, SeeIdentityAttemptEvent args)
{
if (component.Enabled)
{
args.TotalCoverage |= component.Coverage;
if(args.TotalCoverage == IdentityBlockerCoverage.FULL)
args.Cancel();
}
}
protected virtual void OnComponentInit(EntityUid uid, IdentityComponent component, ComponentInit args)
{

View File

@@ -122,6 +122,7 @@
sprite: Clothing/Eyes/Glasses/outlawglasses.rsi
- type: VisionCorrection
- type: IdentityBlocker
coverage: EYES
- type: entity
parent: ClothingEyesBase
@@ -140,6 +141,8 @@
tags:
- HamsterWearable
- WhitelistChameleon
- type: IdentityBlocker
coverage: EYES
- type: entity
parent: ClothingEyesBase
@@ -162,6 +165,8 @@
guides:
- Security
- type: ShowSecurityIcons
- type: IdentityBlocker
coverage: EYES
- type: entity
parent: ClothingEyesBase

View File

@@ -262,6 +262,8 @@
- type: IngestionBlocker
- type: Item
storedRotation: -90
- type: IdentityBlocker
coverage: MOUTH
- type: entity
parent: ClothingMaskBase
@@ -475,6 +477,7 @@
- type: Clothing
sprite: Clothing/Mask/neckgaiter.rsi
- type: IdentityBlocker
coverage: MOUTH
- type: Tag
tags:
- WhitelistChameleon