diff --git a/Content.Shared/CCVar/CCVars.Game.cs b/Content.Shared/CCVar/CCVars.Game.cs index a316577fc1..00e6ff93ae 100644 --- a/Content.Shared/CCVar/CCVars.Game.cs +++ b/Content.Shared/CCVar/CCVars.Game.cs @@ -1,4 +1,4 @@ -using Content.Shared.Roles; +using Content.Shared.Roles; using Robust.Shared.Configuration; namespace Content.Shared.CCVar; @@ -386,6 +386,12 @@ public sealed partial class CCVars public static readonly CVarDef ContrabandExamine = CVarDef.Create("game.contraband_examine", true, CVar.SERVER | CVar.REPLICATED); + /// + /// If true, contraband examination is only possible while wearing an item with `ShowContrabandDetailsComponent`. Requires `ContrabandExamine` to be true as well. + /// + public static readonly CVarDef ContrabandExamineOnlyInHUD = + CVarDef.Create("game.contraband_examine_only_in_hud", false, CVar.SERVER | CVar.REPLICATED); + /// /// Size of the lookup area for adding entities to the context menu /// diff --git a/Content.Shared/Contraband/ContrabandSystem.cs b/Content.Shared/Contraband/ContrabandSystem.cs index c998875c87..2c2495ba9a 100644 --- a/Content.Shared/Contraband/ContrabandSystem.cs +++ b/Content.Shared/Contraband/ContrabandSystem.cs @@ -1,4 +1,3 @@ -using System.Linq; using Content.Shared.Access.Systems; using Content.Shared.CCVar; using Content.Shared.Examine; @@ -8,6 +7,7 @@ using Content.Shared.Verbs; using Robust.Shared.Configuration; using Robust.Shared.Prototypes; using Robust.Shared.Utility; +using System.Linq; namespace Content.Shared.Contraband; @@ -22,6 +22,7 @@ public sealed class ContrabandSystem : EntitySystem [Dependency] private readonly ExamineSystemShared _examine = default!; private bool _contrabandExamineEnabled; + private bool _contrabandExamineOnlyInHudEnabled; /// public override void Initialize() @@ -29,6 +30,7 @@ public sealed class ContrabandSystem : EntitySystem SubscribeLocalEvent>(OnDetailedExamine); Subs.CVar(_configuration, CCVars.ContrabandExamine, SetContrabandExamine, true); + Subs.CVar(_configuration, CCVars.ContrabandExamineOnlyInHUD, SetContrabandExamineOnlyInHUD, true); } public void CopyDetails(EntityUid uid, ContrabandComponent other, ContrabandComponent? contraband = null) @@ -42,12 +44,21 @@ public sealed class ContrabandSystem : EntitySystem Dirty(uid, contraband); } - private void OnDetailedExamine(EntityUid ent,ContrabandComponent component, ref GetVerbsEvent args) + private void OnDetailedExamine(EntityUid ent, ContrabandComponent component, ref GetVerbsEvent args) { if (!_contrabandExamineEnabled) return; + // Checking if contraband is only shown in the HUD + if (_contrabandExamineOnlyInHudEnabled) + { + var ev = new GetContrabandDetailsEvent(); + RaiseLocalEvent(args.User, ref ev); + if (!ev.CanShowContraband) + return; + } + // CanAccess is not used here, because we want people to be able to examine legality in strip menu. if (!args.CanInteract) return; @@ -114,4 +125,9 @@ public sealed class ContrabandSystem : EntitySystem { _contrabandExamineEnabled = val; } + + private void SetContrabandExamineOnlyInHUD(bool val) + { + _contrabandExamineOnlyInHudEnabled = val; + } } diff --git a/Content.Shared/Contraband/ShowContrabandDetailsComponent.cs b/Content.Shared/Contraband/ShowContrabandDetailsComponent.cs new file mode 100644 index 0000000000..50e9c499cf --- /dev/null +++ b/Content.Shared/Contraband/ShowContrabandDetailsComponent.cs @@ -0,0 +1,9 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.Contraband; + +/// +/// This component allows you to see Contraband details on examine items +/// +[RegisterComponent, NetworkedComponent] +public sealed partial class ShowContrabandDetailsComponent : Component; diff --git a/Content.Shared/Contraband/ShowContrabandSystem.cs b/Content.Shared/Contraband/ShowContrabandSystem.cs new file mode 100644 index 0000000000..4542c0fcc7 --- /dev/null +++ b/Content.Shared/Contraband/ShowContrabandSystem.cs @@ -0,0 +1,27 @@ +using Content.Shared.Inventory; + +namespace Content.Shared.Contraband; + +public sealed partial class ShowContrabandSystem : EntitySystem +{ + public override void Initialize() + { + base.Initialize(); + Subs.SubscribeWithRelay(OnGetContrabandDetails); + + } + + private void OnGetContrabandDetails(Entity ent, ref GetContrabandDetailsEvent args) + { + args.CanShowContraband = true; + } +} + +/// +/// Raised on an entity and its inventory to determine if it can see contraband information in the examination window. +/// +[ByRefEvent] +public record struct GetContrabandDetailsEvent(bool CanShowContraband = false) : IInventoryRelayEvent +{ + SlotFlags IInventoryRelayEvent.TargetSlots => SlotFlags.EYES; +} diff --git a/Content.Shared/Inventory/InventorySystem.Relay.cs b/Content.Shared/Inventory/InventorySystem.Relay.cs index 01d3e87246..ce245992a9 100644 --- a/Content.Shared/Inventory/InventorySystem.Relay.cs +++ b/Content.Shared/Inventory/InventorySystem.Relay.cs @@ -4,6 +4,7 @@ using Content.Shared.Chat; using Content.Shared.Chemistry; using Content.Shared.Chemistry.Hypospray.Events; using Content.Shared.Climbing.Events; +using Content.Shared.Contraband; using Content.Shared.Damage; using Content.Shared.Damage.Events; using Content.Shared.Electrocution; @@ -55,6 +56,7 @@ public partial class InventorySystem SubscribeLocalEvent(RefRelayInventoryEvent); SubscribeLocalEvent(RefRelayInventoryEvent); SubscribeLocalEvent(RefRelayInventoryEvent); + SubscribeLocalEvent(RefRelayInventoryEvent); // Eye/vision events SubscribeLocalEvent(RelayInventoryEvent); diff --git a/Resources/Prototypes/Entities/Clothing/Eyes/hud.yml b/Resources/Prototypes/Entities/Clothing/Eyes/hud.yml index 98fb8fdded..3b8ade1dd5 100644 --- a/Resources/Prototypes/Entities/Clothing/Eyes/hud.yml +++ b/Resources/Prototypes/Entities/Clothing/Eyes/hud.yml @@ -6,6 +6,7 @@ - type: ShowJobIcons - type: ShowMindShieldIcons - type: ShowCriminalRecordIcons + - type: ShowContrabandDetails - type: entity id: ShowMedicalIcons diff --git a/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml b/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml index ce4fc4ded0..2b18468ace 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml @@ -95,6 +95,7 @@ - type: SolutionScanner - type: IgnoreUIRange - type: ShowAntagIcons + - type: ShowContrabandDetails - type: Inventory templateId: aghost - type: Loadout