--- /dev/null
+using Content.Server.Administration;
+using Content.Shared.Access.Components;
+using Content.Shared.Administration;
+using Robust.Shared.Toolshed;
+using Robust.Shared.Toolshed.Syntax;
+
+namespace Content.Server.Access;
+
+[ToolshedCommand, AdminCommand(AdminFlags.Mapping)]
+public sealed class AddAccessLogCommand : ToolshedCommand
+{
+ [CommandImplementation]
+ public void AddAccessLog(
+ [CommandInvocationContext] IInvocationContext ctx,
+ [CommandArgument] EntityUid input,
+ [CommandArgument] float seconds,
+ [CommandArgument] ValueRef<string> accessor)
+ {
+ var accessReader = EnsureComp<AccessReaderComponent>(input);
+
+ var accessLogCount = accessReader.AccessLog.Count;
+ if (accessLogCount >= accessReader.AccessLogLimit)
+ ctx.WriteLine($"WARNING: Surpassing the limit of the log by {accessLogCount - accessReader.AccessLogLimit+1} entries!");
+
+ var accessTime = TimeSpan.FromSeconds(seconds);
+ var accessName = accessor.Evaluate(ctx)!;
+ accessReader.AccessLog.Enqueue(new AccessRecord(accessTime, accessName));
+ ctx.WriteLine($"Successfully added access log to {input} with this information inside:\n " +
+ $"Time of access: {accessTime}\n " +
+ $"Accessed by: {accessName}");
+ }
+
+ [CommandImplementation]
+ public void AddAccessLogPiped(
+ [CommandInvocationContext] IInvocationContext ctx,
+ [PipedArgument] EntityUid input,
+ [CommandArgument] float seconds,
+ [CommandArgument] ValueRef<string> accessor)
+ {
+ AddAccessLog(ctx, input, seconds, accessor);
+ }
+}
public int AccessLogLimit = 20;
}
-[Serializable, NetSerializable]
-public record struct AccessRecord(TimeSpan AccessTime, string Accessor);
+[DataDefinition, Serializable, NetSerializable]
+public readonly partial record struct AccessRecord(
+ [property: DataField, ViewVariables(VVAccess.ReadWrite)]
+ TimeSpan AccessTime,
+ [property: DataField, ViewVariables(VVAccess.ReadWrite)]
+ string Accessor)
+{
+ public AccessRecord() : this(TimeSpan.Zero, string.Empty)
+ {
+ }
+}
[Serializable, NetSerializable]
public sealed class AccessReaderComponentState : ComponentState
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
using Content.Shared.Access.Components;
using Content.Shared.DeviceLinking.Events;
using Content.Shared.Emag.Components;
using Content.Shared.StationRecords;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
using Content.Shared.GameTicking;
using Robust.Shared.Collections;
using Robust.Shared.Prototypes;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly SharedIdCardSystem _idCardSystem = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
- [Dependency] private readonly SharedStationRecordsSystem _records = default!;
+ [Dependency] private readonly SharedStationRecordsSystem _recordsSystem = default!;
public override void Initialize()
{
private void OnGetState(EntityUid uid, AccessReaderComponent component, ref ComponentGetState args)
{
args.State = new AccessReaderComponentState(component.Enabled, component.DenyTags, component.AccessLists,
- _records.Convert(component.AccessKeys), component.AccessLog, component.AccessLogLimit);
+ _recordsSystem.Convert(component.AccessKeys), component.AccessLog, component.AccessLogLimit);
}
private void OnHandleState(EntityUid uid, AccessReaderComponent component, ref ComponentHandleState args)
/// <param name="accessor">The accessor to log</param>
private void LogAccess(Entity<AccessReaderComponent> ent, EntityUid accessor)
{
+ if (IsPaused(ent))
+ return;
+
if (ent.Comp.AccessLog.Count >= ent.Comp.AccessLogLimit)
ent.Comp.AccessLog.Dequeue();
Grabs the mind from the entity, if any.
command-description-mind-control =
Assumes control of an entity with the given player.
+command-description-addaccesslog =
+ Adds an access log to this entity. Do note that this bypasses the log's default limit and pause check.