add access reader log wire (#29094)

* add LoggingDisabled to AccessReader

* add LogWireAction

* -m give everything besides high-security door a log wire

* make LogAccess public and support string arg

* add log when pulsing

* m

* l

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2024-06-22 15:12:58 +00:00
committed by GitHub
parent 092cad4ba1
commit 475c2a0b42
6 changed files with 105 additions and 7 deletions

View File

@@ -382,18 +382,15 @@ public sealed class AccessReaderSystem : EntitySystem
}
/// <summary>
/// Logs an access
/// Logs an access for a specific entity.
/// </summary>
/// <param name="ent">The reader to log the access on</param>
/// <param name="accessor">The accessor to log</param>
private void LogAccess(Entity<AccessReaderComponent> ent, EntityUid accessor)
public void LogAccess(Entity<AccessReaderComponent> ent, EntityUid accessor)
{
if (IsPaused(ent))
if (IsPaused(ent) || ent.Comp.LoggingDisabled)
return;
if (ent.Comp.AccessLog.Count >= ent.Comp.AccessLogLimit)
ent.Comp.AccessLog.Dequeue();
string? name = null;
if (TryComp<NameIdentifierComponent>(accessor, out var nameIdentifier))
name = nameIdentifier.FullIdentifier;
@@ -404,7 +401,21 @@ public sealed class AccessReaderSystem : EntitySystem
&& idCard.Comp is { BypassLogging: false, FullName: not null })
name = idCard.Comp.FullName;
name ??= Loc.GetString("access-reader-unknown-id");
LogAccess(ent, name ?? Loc.GetString("access-reader-unknown-id"));
}
/// <summary>
/// Logs an access with a predetermined name
/// </summary>
/// <param name="ent">The reader to log the access on</param>
/// <param name="name">The name to log as</param>
public void LogAccess(Entity<AccessReaderComponent> ent, string name)
{
if (IsPaused(ent) || ent.Comp.LoggingDisabled)
return;
if (ent.Comp.AccessLog.Count >= ent.Comp.AccessLogLimit)
ent.Comp.AccessLog.Dequeue();
var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);
ent.Comp.AccessLog.Enqueue(new AccessRecord(stationTime, name));