Only sec glasses can show contraband: second attempt (#36412)
* Add base code for cheking contraband in hud * Fix missing using in InventorySystem.Relay * Fix errors and update HUD yml * Add show contraband with component on entity * fix component description * Update Content.Shared/Contraband/ShowContrabandDetailsComponent.cs Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com> * Update "if" for check if ent hasComp in contrabandSystem * Remove << InventorySystem.Relay.cs * Update Content.Shared/Contraband/ShowContrabandDetailsComponent.cs Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Update Content.Shared/CCVar/CCVars.Game.cs Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Fix partial class ShowContrabandSystem Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Update Content.Shared/Contraband/ShowContrabandDetailsComponent.cs Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Update Content.Shared/Inventory/InventorySystem.Relay.cs Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Some update ShowContrabandSystem * Try with record struct * back again ti default class with EntityEventArgs * Remove EntityEventArgs * Finally use record struct --------- Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com> Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
using Content.Shared.Roles;
|
using Content.Shared.Roles;
|
||||||
using Robust.Shared.Configuration;
|
using Robust.Shared.Configuration;
|
||||||
|
|
||||||
namespace Content.Shared.CCVar;
|
namespace Content.Shared.CCVar;
|
||||||
@@ -386,6 +386,12 @@ public sealed partial class CCVars
|
|||||||
public static readonly CVarDef<bool> ContrabandExamine =
|
public static readonly CVarDef<bool> ContrabandExamine =
|
||||||
CVarDef.Create("game.contraband_examine", true, CVar.SERVER | CVar.REPLICATED);
|
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>
|
/// <summary>
|
||||||
/// Size of the lookup area for adding entities to the context menu
|
/// Size of the lookup area for adding entities to the context menu
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using System.Linq;
|
|
||||||
using Content.Shared.Access.Systems;
|
using Content.Shared.Access.Systems;
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
@@ -8,6 +7,7 @@ using Content.Shared.Verbs;
|
|||||||
using Robust.Shared.Configuration;
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Content.Shared.Contraband;
|
namespace Content.Shared.Contraband;
|
||||||
|
|
||||||
@@ -22,6 +22,7 @@ public sealed class ContrabandSystem : EntitySystem
|
|||||||
[Dependency] private readonly ExamineSystemShared _examine = default!;
|
[Dependency] private readonly ExamineSystemShared _examine = default!;
|
||||||
|
|
||||||
private bool _contrabandExamineEnabled;
|
private bool _contrabandExamineEnabled;
|
||||||
|
private bool _contrabandExamineOnlyInHudEnabled;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
@@ -29,6 +30,7 @@ public sealed class ContrabandSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<ContrabandComponent, GetVerbsEvent<ExamineVerb>>(OnDetailedExamine);
|
SubscribeLocalEvent<ContrabandComponent, GetVerbsEvent<ExamineVerb>>(OnDetailedExamine);
|
||||||
|
|
||||||
Subs.CVar(_configuration, CCVars.ContrabandExamine, SetContrabandExamine, true);
|
Subs.CVar(_configuration, CCVars.ContrabandExamine, SetContrabandExamine, true);
|
||||||
|
Subs.CVar(_configuration, CCVars.ContrabandExamineOnlyInHUD, SetContrabandExamineOnlyInHUD, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CopyDetails(EntityUid uid, ContrabandComponent other, ContrabandComponent? contraband = null)
|
public void CopyDetails(EntityUid uid, ContrabandComponent other, ContrabandComponent? contraband = null)
|
||||||
@@ -42,12 +44,21 @@ public sealed class ContrabandSystem : EntitySystem
|
|||||||
Dirty(uid, contraband);
|
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)
|
if (!_contrabandExamineEnabled)
|
||||||
return;
|
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.
|
// CanAccess is not used here, because we want people to be able to examine legality in strip menu.
|
||||||
if (!args.CanInteract)
|
if (!args.CanInteract)
|
||||||
return;
|
return;
|
||||||
@@ -114,4 +125,9 @@ public sealed class ContrabandSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
_contrabandExamineEnabled = val;
|
_contrabandExamineEnabled = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetContrabandExamineOnlyInHUD(bool val)
|
||||||
|
{
|
||||||
|
_contrabandExamineOnlyInHudEnabled = val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
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;
|
||||||
27
Content.Shared/Contraband/ShowContrabandSystem.cs
Normal file
27
Content.Shared/Contraband/ShowContrabandSystem.cs
Normal file
@@ -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<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;
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ using Content.Shared.Chat;
|
|||||||
using Content.Shared.Chemistry;
|
using Content.Shared.Chemistry;
|
||||||
using Content.Shared.Chemistry.Hypospray.Events;
|
using Content.Shared.Chemistry.Hypospray.Events;
|
||||||
using Content.Shared.Climbing.Events;
|
using Content.Shared.Climbing.Events;
|
||||||
|
using Content.Shared.Contraband;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.Damage.Events;
|
using Content.Shared.Damage.Events;
|
||||||
using Content.Shared.Electrocution;
|
using Content.Shared.Electrocution;
|
||||||
@@ -55,6 +56,7 @@ public partial class InventorySystem
|
|||||||
SubscribeLocalEvent<InventoryComponent, GetSlowedOverSlipperyModifierEvent>(RefRelayInventoryEvent);
|
SubscribeLocalEvent<InventoryComponent, GetSlowedOverSlipperyModifierEvent>(RefRelayInventoryEvent);
|
||||||
SubscribeLocalEvent<InventoryComponent, ModifySlowOnDamageSpeedEvent>(RefRelayInventoryEvent);
|
SubscribeLocalEvent<InventoryComponent, ModifySlowOnDamageSpeedEvent>(RefRelayInventoryEvent);
|
||||||
SubscribeLocalEvent<InventoryComponent, ExtinguishEvent>(RefRelayInventoryEvent);
|
SubscribeLocalEvent<InventoryComponent, ExtinguishEvent>(RefRelayInventoryEvent);
|
||||||
|
SubscribeLocalEvent<InventoryComponent, GetContrabandDetailsEvent>(RefRelayInventoryEvent);
|
||||||
|
|
||||||
// Eye/vision events
|
// Eye/vision events
|
||||||
SubscribeLocalEvent<InventoryComponent, CanSeeAttemptEvent>(RelayInventoryEvent);
|
SubscribeLocalEvent<InventoryComponent, CanSeeAttemptEvent>(RelayInventoryEvent);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
- type: ShowJobIcons
|
- type: ShowJobIcons
|
||||||
- type: ShowMindShieldIcons
|
- type: ShowMindShieldIcons
|
||||||
- type: ShowCriminalRecordIcons
|
- type: ShowCriminalRecordIcons
|
||||||
|
- type: ShowContrabandDetails
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: ShowMedicalIcons
|
id: ShowMedicalIcons
|
||||||
|
|||||||
@@ -95,6 +95,7 @@
|
|||||||
- type: SolutionScanner
|
- type: SolutionScanner
|
||||||
- type: IgnoreUIRange
|
- type: IgnoreUIRange
|
||||||
- type: ShowAntagIcons
|
- type: ShowAntagIcons
|
||||||
|
- type: ShowContrabandDetails
|
||||||
- type: Inventory
|
- type: Inventory
|
||||||
templateId: aghost
|
templateId: aghost
|
||||||
- type: Loadout
|
- type: Loadout
|
||||||
|
|||||||
Reference in New Issue
Block a user