* The all-in-one hacking solution The thinking man's lockpick The iconic EMAG * emagged medbay's stasis bed * left med, emagged sec' apc * went back to chem, emagged the dispenser * emagged the fax while i was there * had a donut while waiting for emag to charge * i broke into the bridge then announced 'mandatory johnson inspection in medical' * get system instead of dependency * feedback * net suggestion Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * use EnsureComp and import NetworkedComponent --------- Co-authored-by: deltanedas <user@zenith> Co-authored-by: deltanedas <deltanedas@laptop> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -7,13 +7,6 @@ namespace Content.Shared.Access.Components
|
||||
[RegisterComponent]
|
||||
public sealed class AccessReaderComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether this reader is enabled or not. If disabled, all access
|
||||
/// checks will pass.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool Enabled = true;
|
||||
|
||||
/// <summary>
|
||||
/// The set of tags that will automatically deny an allowed check, if any of them are present.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Emag.Components;
|
||||
using Content.Shared.Emag.Systems;
|
||||
using Content.Shared.PDA;
|
||||
using Content.Shared.Access.Components;
|
||||
@@ -28,7 +29,7 @@ namespace Content.Shared.Access.Systems
|
||||
{
|
||||
if (args.User == null) // AutoLink (and presumably future external linkers) have no user.
|
||||
return;
|
||||
if (component.Enabled && !IsAllowed(args.User.Value, component))
|
||||
if (!HasComp<EmaggedComponent>(uid) && !IsAllowed(args.User.Value, component))
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
@@ -46,12 +47,10 @@ namespace Content.Shared.Access.Systems
|
||||
|
||||
private void OnEmagged(EntityUid uid, AccessReaderComponent reader, ref GotEmaggedEvent args)
|
||||
{
|
||||
if (reader.Enabled)
|
||||
{
|
||||
reader.Enabled = false;
|
||||
args.Handled = true;
|
||||
}
|
||||
// no fancy conditions
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Searches the source for access tags
|
||||
/// then compares it with the targets readers access list to see if it is allowed.
|
||||
@@ -86,7 +85,7 @@ namespace Content.Shared.Access.Systems
|
||||
/// <param name="reader">An access reader to check against</param>
|
||||
public bool IsAllowed(ICollection<string> accessTags, AccessReaderComponent reader)
|
||||
{
|
||||
if (!reader.Enabled)
|
||||
if (HasComp<EmaggedComponent>(reader.Owner))
|
||||
{
|
||||
// Access reader is totally disabled, so access is always allowed.
|
||||
return true;
|
||||
|
||||
11
Content.Shared/Emag/Components/EmaggedComponent.cs
Normal file
11
Content.Shared/Emag/Components/EmaggedComponent.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Emag.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Marker component for emagged entities
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed class EmaggedComponent : Component
|
||||
{
|
||||
}
|
||||
@@ -156,12 +156,19 @@ namespace Content.Shared.Emag.Systems
|
||||
/// </summary>
|
||||
public bool DoEmagEffect(EntityUid user, EntityUid target)
|
||||
{
|
||||
// prevent emagging twice
|
||||
if (HasComp<EmaggedComponent>(target))
|
||||
return false;
|
||||
|
||||
var emaggedEvent = new GotEmaggedEvent(user);
|
||||
RaiseLocalEvent(target, ref emaggedEvent);
|
||||
|
||||
if (!emaggedEvent.Repeatable)
|
||||
EnsureComp<EmaggedComponent>(target);
|
||||
return emaggedEvent.Handled;
|
||||
}
|
||||
}
|
||||
|
||||
[ByRefEvent]
|
||||
public record struct GotEmaggedEvent(EntityUid UserUid, bool Handled = false);
|
||||
public record struct GotEmaggedEvent(EntityUid UserUid, bool Handled = false, bool Repeatable = false);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Shared.Emag.Components;
|
||||
using Robust.Shared.Prototypes;
|
||||
using System.Linq;
|
||||
|
||||
@@ -36,7 +37,7 @@ public abstract class SharedVendingMachineSystem : EntitySystem
|
||||
|
||||
/// <summary>
|
||||
/// Returns all of the vending machine's inventory. Only includes emagged and contraband inventories if
|
||||
/// <see cref="VendingMachineComponent.Emagged"/> and <see cref="VendingMachineComponent.Contraband"/>
|
||||
/// <see cref="EmaggedComponent"/> exists and <see cref="VendingMachineComponent.Contraband"/> is true
|
||||
/// are <c>true</c> respectively.
|
||||
/// </summary>
|
||||
/// <param name="uid"></param>
|
||||
@@ -49,7 +50,7 @@ public abstract class SharedVendingMachineSystem : EntitySystem
|
||||
|
||||
var inventory = new List<VendingMachineInventoryEntry>(component.Inventory.Values);
|
||||
|
||||
if (component.Emagged)
|
||||
if (HasComp<EmaggedComponent>(uid))
|
||||
inventory.AddRange(component.EmaggedInventory.Values);
|
||||
|
||||
if (component.Contraband)
|
||||
|
||||
@@ -40,7 +40,6 @@ namespace Content.Shared.VendingMachines
|
||||
[ViewVariables]
|
||||
public Dictionary<string, VendingMachineInventoryEntry> ContrabandInventory = new();
|
||||
|
||||
public bool Emagged;
|
||||
public bool Contraband;
|
||||
|
||||
public bool Ejecting;
|
||||
|
||||
Reference in New Issue
Block a user