diff --git a/Content.Client/Overlays/EquipmentHudSystem.cs b/Content.Client/Overlays/EquipmentHudSystem.cs index 3672892ae3..1e36f0a4d6 100644 --- a/Content.Client/Overlays/EquipmentHudSystem.cs +++ b/Content.Client/Overlays/EquipmentHudSystem.cs @@ -93,7 +93,8 @@ public abstract class EquipmentHudSystem : EntitySystem where T : IComponent protected virtual void OnRefreshEquipmentHud(EntityUid uid, T component, InventoryRelayedEvent> args) { - OnRefreshComponentHud(uid, component, args.Args); + args.Args.Active = true; + args.Args.Components.Add(component); } protected virtual void OnRefreshComponentHud(EntityUid uid, T component, RefreshEquipmentHudEvent args) diff --git a/Content.Client/Overlays/Switchable/NightVisionSystem.cs b/Content.Client/Overlays/Switchable/NightVisionSystem.cs index c85b3758d8..7764e39a0a 100644 --- a/Content.Client/Overlays/Switchable/NightVisionSystem.cs +++ b/Content.Client/Overlays/Switchable/NightVisionSystem.cs @@ -1,3 +1,4 @@ +using Content.Shared.Inventory; using Content.Shared.Inventory.Events; using Content.Shared.Overlays.Switchable; using Robust.Client.Graphics; @@ -20,6 +21,26 @@ public sealed class NightVisionSystem : EquipmentHudSystem _overlay = new BaseSwitchableOverlay(); } + protected override void OnRefreshComponentHud(EntityUid uid, + NightVisionComponent component, + RefreshEquipmentHudEvent args) + { + if (component.IsEquipment) + return; + + base.OnRefreshComponentHud(uid, component, args); + } + + protected override void OnRefreshEquipmentHud(EntityUid uid, + NightVisionComponent component, + InventoryRelayedEvent> args) + { + if (!component.IsEquipment) + return; + + base.OnRefreshEquipmentHud(uid, component, args); + } + private void OnToggle(Entity ent, ref SwitchableOverlayToggledEvent args) { RefreshOverlay(args.User); diff --git a/Content.Client/Overlays/Switchable/ThermalVisionOverlay.cs b/Content.Client/Overlays/Switchable/ThermalVisionOverlay.cs index eb12b33e3a..010d141170 100644 --- a/Content.Client/Overlays/Switchable/ThermalVisionOverlay.cs +++ b/Content.Client/Overlays/Switchable/ThermalVisionOverlay.cs @@ -143,9 +143,9 @@ public sealed class ThermalVisionOverlay : Overlay _stealth.GetVisibility(uid, stealth) > 0.5f); } - public void ResetLight() + public void ResetLight(bool checkFirstTimePredicted = true) { - if (_lightEntity == null || !_timing.IsFirstTimePredicted) + if (_lightEntity == null || checkFirstTimePredicted && !_timing.IsFirstTimePredicted) return; _entity.DeleteEntity(_lightEntity); diff --git a/Content.Client/Overlays/Switchable/ThermalVisionSystem.cs b/Content.Client/Overlays/Switchable/ThermalVisionSystem.cs index 9b6e5eed0f..7c3f33d068 100644 --- a/Content.Client/Overlays/Switchable/ThermalVisionSystem.cs +++ b/Content.Client/Overlays/Switchable/ThermalVisionSystem.cs @@ -1,3 +1,4 @@ +using Content.Shared.Inventory; using Content.Shared.Inventory.Events; using Content.Shared.Overlays.Switchable; using Robust.Client.Graphics; @@ -21,6 +22,26 @@ public sealed class ThermalVisionSystem : EquipmentHudSystem(); } + protected override void OnRefreshComponentHud(EntityUid uid, + ThermalVisionComponent component, + RefreshEquipmentHudEvent args) + { + if (component.IsEquipment) + return; + + base.OnRefreshComponentHud(uid, component, args); + } + + protected override void OnRefreshEquipmentHud(EntityUid uid, + ThermalVisionComponent component, + InventoryRelayedEvent> args) + { + if (!component.IsEquipment) + return; + + base.OnRefreshEquipmentHud(uid, component, args); + } + private void OnToggle(Entity ent, ref SwitchableOverlayToggledEvent args) { RefreshOverlay(args.User); @@ -54,6 +75,7 @@ public sealed class ThermalVisionSystem : EquipmentHudSystem + /// Whether it should grant equipment enhanced vision or is it mob vision + /// + [DataField] + public bool IsEquipment; + /// /// If it is greater than 0, overlay isn't toggled but pulsed instead /// diff --git a/Content.Shared/Overlays/Switchable/SwitchableOverlaySystem.cs b/Content.Shared/Overlays/Switchable/SwitchableOverlaySystem.cs index eb7b230cbc..9048052a06 100644 --- a/Content.Shared/Overlays/Switchable/SwitchableOverlaySystem.cs +++ b/Content.Shared/Overlays/Switchable/SwitchableOverlaySystem.cs @@ -102,18 +102,22 @@ public abstract class SwitchableOverlaySystem : EntitySystem component.IsActive = state.IsActive; - RaiseSwitchableOverlayToggledEvent(uid, uid, component.IsActive); - RaiseSwitchableOverlayToggledEvent(uid, Transform(uid).ParentUid, component.IsActive); + RaiseSwitchableOverlayToggledEvent(uid, + component.IsEquipment ? Transform(uid).ParentUid : uid, + component.IsActive); } private void OnGetItemActions(Entity ent, ref GetItemActionsEvent args) { - if (ent.Comp.ToggleAction != null && args.SlotFlags is not SlotFlags.POCKET and not null) + if (ent.Comp.IsEquipment && ent.Comp.ToggleAction != null && args.SlotFlags is not SlotFlags.POCKET and not null) args.AddAction(ref ent.Comp.ToggleActionEntity, ent.Comp.ToggleAction); } private void OnShutdown(EntityUid uid, TComp component, ComponentShutdown args) { + if (component.IsEquipment) + return; + _actions.RemoveAction(uid, component.ToggleActionEntity); } @@ -124,7 +128,7 @@ public abstract class SwitchableOverlaySystem : EntitySystem private void OnMapInit(EntityUid uid, TComp component, MapInitEvent args) { - if (component.ToggleActionEntity == null && component.ToggleAction != null) + if (component is { IsEquipment: false, ToggleActionEntity: null, ToggleAction: not null }) _actions.AddAction(uid, ref component.ToggleActionEntity, component.ToggleAction); } diff --git a/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml b/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml index 68900dfef7..7544507442 100644 --- a/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml +++ b/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml @@ -413,6 +413,7 @@ sprite: Clothing/Eyes/Glasses/ninjavisor.rsi - type: FlashImmunity - type: NightVision + isEquipment: true - type: entity #Fake goggles, the latest in anti-valid hunting technology parent: ClothingEyesBase diff --git a/Resources/Prototypes/Entities/Clothing/Eyes/goggles.yml b/Resources/Prototypes/Entities/Clothing/Eyes/goggles.yml index 4348c87227..41840b6bf7 100644 --- a/Resources/Prototypes/Entities/Clothing/Eyes/goggles.yml +++ b/Resources/Prototypes/Entities/Clothing/Eyes/goggles.yml @@ -11,6 +11,7 @@ - type: Clothing sprite: Clothing/Eyes/Goggles/nightvision.rsi - type: NightVision + isEquipment: true - type: IdentityBlocker coverage: EYES @@ -77,6 +78,7 @@ - type: Clothing sprite: Clothing/Eyes/Goggles/thermal.rsi - type: ThermalVision + isEquipment: true pulseTime: 2 toggleAction: PulseThermalVision - type: IdentityBlocker diff --git a/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml b/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml index 6f28812549..d69d0fc6f1 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml @@ -800,6 +800,7 @@ maxRange: 0 # WD EDIT END - type: ThermalVision + isEquipment: true color: "#98EEFB" lightRadius: 15 diff --git a/Resources/Prototypes/WhiteDream/Entities/Clothing/Cult/armor.yml b/Resources/Prototypes/WhiteDream/Entities/Clothing/Cult/armor.yml index bdbb4bac46..88b578cb5f 100644 --- a/Resources/Prototypes/WhiteDream/Entities/Clothing/Cult/armor.yml +++ b/Resources/Prototypes/WhiteDream/Entities/Clothing/Cult/armor.yml @@ -115,6 +115,7 @@ - type: EyeProtection - type: NightVision isActive: true + isEquipment: true toggleAction: null activateSound: null deactivateSound: null