-using Content.Shared.Roles;
+using Content.Shared.Roles;
using Robust.Shared.Configuration;
namespace Content.Shared.CCVar;
public static readonly CVarDef<bool> ContrabandExamine =
CVarDef.Create("game.contraband_examine", true, CVar.SERVER | CVar.REPLICATED);
+ /// <summary>
+ /// If true, contraband examination is only possible while wearing an item with `ShowContrabandDetailsComponent`. Requires `ContrabandExamine` to be true as well.
+ /// </summary>
+ public static readonly CVarDef<bool> ContrabandExamineOnlyInHUD =
+ CVarDef.Create("game.contraband_examine_only_in_hud", false, CVar.SERVER | CVar.REPLICATED);
+
/// <summary>
/// Size of the lookup area for adding entities to the context menu
/// </summary>
-using System.Linq;
using Content.Shared.Access.Systems;
using Content.Shared.CCVar;
using Content.Shared.Examine;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
+using System.Linq;
namespace Content.Shared.Contraband;
[Dependency] private readonly ExamineSystemShared _examine = default!;
private bool _contrabandExamineEnabled;
+ private bool _contrabandExamineOnlyInHudEnabled;
/// <inheritdoc/>
public override void Initialize()
SubscribeLocalEvent<ContrabandComponent, GetVerbsEvent<ExamineVerb>>(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)
Dirty(uid, contraband);
}
- private void OnDetailedExamine(EntityUid ent,ContrabandComponent component, ref GetVerbsEvent<ExamineVerb> args)
+ private void OnDetailedExamine(EntityUid ent, ContrabandComponent component, ref GetVerbsEvent<ExamineVerb> 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;
{
_contrabandExamineEnabled = val;
}
+
+ private void SetContrabandExamineOnlyInHUD(bool val)
+ {
+ _contrabandExamineOnlyInHudEnabled = val;
+ }
}
--- /dev/null
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Contraband;
+
+/// <summary>
+/// This component allows you to see Contraband details on examine items
+/// </summary>
+[RegisterComponent, NetworkedComponent]
+public sealed partial class ShowContrabandDetailsComponent : Component;
--- /dev/null
+using Content.Shared.Inventory;
+
+namespace Content.Shared.Contraband;
+
+public sealed partial class ShowContrabandSystem : EntitySystem
+{
+ public override void Initialize()
+ {
+ base.Initialize();
+ Subs.SubscribeWithRelay<ShowContrabandDetailsComponent, GetContrabandDetailsEvent>(OnGetContrabandDetails);
+
+ }
+
+ private void OnGetContrabandDetails(Entity<ShowContrabandDetailsComponent> ent, ref GetContrabandDetailsEvent args)
+ {
+ args.CanShowContraband = true;
+ }
+}
+
+/// <summary>
+/// Raised on an entity and its inventory to determine if it can see contraband information in the examination window.
+/// </summary>
+[ByRefEvent]
+public record struct GetContrabandDetailsEvent(bool CanShowContraband = false) : IInventoryRelayEvent
+{
+ SlotFlags IInventoryRelayEvent.TargetSlots => SlotFlags.EYES;
+}
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;
SubscribeLocalEvent<InventoryComponent, GetSlowedOverSlipperyModifierEvent>(RefRelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, ModifySlowOnDamageSpeedEvent>(RefRelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, ExtinguishEvent>(RefRelayInventoryEvent);
+ SubscribeLocalEvent<InventoryComponent, GetContrabandDetailsEvent>(RefRelayInventoryEvent);
// Eye/vision events
SubscribeLocalEvent<InventoryComponent, CanSeeAttemptEvent>(RelayInventoryEvent);
- type: ShowJobIcons
- type: ShowMindShieldIcons
- type: ShowCriminalRecordIcons
+ - type: ShowContrabandDetails
- type: entity
id: ShowMedicalIcons
- type: SolutionScanner
- type: IgnoreUIRange
- type: ShowAntagIcons
+ - type: ShowContrabandDetails
- type: Inventory
templateId: aghost
- type: Loadout