Files
Delta-v/Content.Shared/_DV/Access/Systems/SharedSubdermalIdCardSystem.cs
T
BarryNorfolk 438e83ec1e [K9] Give Laika and other secdogs Access + Tracking (#5001)
* Add dataset for Secdog names

* Split secdog into a base + other dogs so laika keeps her name

* Add new system for enabling subdermal ID cards

* Check for subdermal ID cards for access and sensor information

* Add MindOnlyAccess marker component

* Add new generic K9 officer role for secdogs

* Add Laika/K9 officers to security

* Update Laika's role to match K9 officer

* Add subdermal implants and mind only access for K9 officers

* Set MobSecDogBase to abstract

* Set K9Officer card to sec colours

* Update comments for Subdermal IDCard

* Move mind check for access above log for access

* Re-use ImplanterComponent's slot name

* Move idcard container const into component as well

* Add missing setPreference and requirements to k9 officer

* Ensure admin tricks work on subdermal ID cards

* Remove subdermal ID cards from showing in nanochat

* Move secdogs.yml to _DV namespace

* Fix typo

* Unduplicate container id name
2026-05-29 22:33:11 +02:00

70 lines
2.5 KiB
C#

using System.Diagnostics.CodeAnalysis;
using Content.Shared._DV.Access.Components;
using Content.Shared.Access.Components;
using Content.Shared.Implants.Components;
using Robust.Shared.Containers;
namespace Content.Shared._DV.Access.Systems;
/// <summary>
/// Shared handling for subdermal ID Cards.
/// </summary>
public abstract class SharedSubdermalIdCardSystem : EntitySystem
{
[Dependency] private readonly SharedContainerSystem _container = default!;
/// <summary>
/// Name for the container, inside the subdermal implant, where the ID card will be spawned.
/// </summary>
public const string SubdermalContainerId = "subdermalIdCard";
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SubdermalIdCardComponent, ContainerGettingRemovedAttemptEvent>(OnRemoveAttempt);
}
/// <summary>
/// Attempts to find an ID card from within the subdermal card container, if one exists.
/// </summary>
/// <param name="ent">Entity to search.</param>
/// <param name="idEntity">Variable to place the found entityuid into.</param>
/// <returns>True if matching ID card entity was found, otherwise false.</returns>
public bool TryGetIdCard(EntityUid ent, [NotNullWhen(true)] out EntityUid? idEntity)
{
idEntity = default;
if (!_container.TryGetContainer(ent, ImplanterComponent.ImplantSlotId, out var implantContainer))
return false; // This entity is not implanted with anything
foreach (var implant in implantContainer.ContainedEntities)
{
if (!_container.TryGetContainer(implant, SubdermalContainerId, out var con) ||
con.ContainedEntities.Count == 0)
continue;
foreach (var item in con.ContainedEntities)
{
if (!HasComp<IdCardComponent>(item))
continue; // Not an ID card
idEntity = item;
return true;
}
}
return false;
}
/// <summary>
/// Handles when a subdermal ID card implant is attempted to be removed, blocking it completely.
/// </summary>
/// <param name="ent">The entity which is being removed.</param>
/// <param name="args">Args for the event.</param>
private void OnRemoveAttempt(Entity<SubdermalIdCardComponent> ent, ref ContainerGettingRemovedAttemptEvent args)
{
// Subdermal ID cards are NEVER removable by any means.
args.Cancel();
}
}