using Content.Shared.Access.Systems;
using Content.Shared.StationRecords;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Shared.Access.Components;
///
/// Stores access levels necessary to "use" an entity
/// and allows checking if something or somebody is authorized with these access levels.
///
[RegisterComponent, NetworkedComponent]
[Access(typeof(AccessReaderSystem))]
public sealed partial class AccessReaderComponent : Component
{
///
/// Whether or not the access reader is enabled.
/// If not, it will always let people through.
///
[DataField]
public bool Enabled = true;
///
/// The set of tags that will automatically deny an allowed check, if any of them are present.
///
[DataField]
public HashSet> DenyTags = new();
///
/// List of access groups that grant access to this reader. Only a single matching group is required to gain access.
/// A group matches if it is a subset of the set being checked against.
///
[DataField("access")]
public List>> AccessLists = new();
///
/// An unmodified copy of the original list of the access groups that grant access to this reader.
///
///
/// If null, the access lists of this entity have not been modified yet.
///
[DataField]
public List>>? AccessListsOriginal = null;
///
/// A list of s that grant access. Only a single matching key is required to gain access.
///
[DataField]
public HashSet AccessKeys = new();
///
/// If specified, then this access reader will instead pull access requirements from entities contained in the
/// given container.
///
///
/// This effectively causes , , and to be
/// ignored, though is still respected. Access is denied if there are no valid entities or
/// they all deny access.
///
[DataField]
public string? ContainerAccessProvider;
///
/// A list of past authentications.
///
[DataField]
public Queue AccessLog = new();
///
/// A limit on the max size of
///
[DataField]
public int AccessLogLimit = 20;
///
/// If true logging on successful access uses will be disabled.
/// Can be set by LOG wire.
///
[DataField]
public bool LoggingDisabled;
///
/// Whether or not emag interactions have an effect on this.
///
[DataField]
public bool BreakOnAccessBreaker = true;
///
/// The examination text associated with this component.
///
///
/// The text can be supplied with the 'access' variable to populate it
/// with a comma separated list of the access levels contained in .
///
[DataField]
public LocId ExaminationText = "access-reader-examination";
}
[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
{
public bool Enabled;
public HashSet> DenyTags;
public List>> AccessLists;
public List>>? AccessListsOriginal;
public List<(NetEntity, uint)> AccessKeys;
public Queue AccessLog;
public int AccessLogLimit;
public AccessReaderComponentState(
bool enabled,
HashSet> denyTags,
List>> accessLists,
List>>? accessListsOriginal,
List<(NetEntity, uint)> accessKeys,
Queue accessLog,
int accessLogLimit)
{
Enabled = enabled;
DenyTags = denyTags;
AccessLists = accessLists;
AccessListsOriginal = accessListsOriginal;
AccessKeys = accessKeys;
AccessLog = accessLog;
AccessLogLimit = accessLogLimit;
}
}
///
/// Raised after the settings on the access reader are changed.
///
public sealed class AccessReaderConfigurationChangedEvent : EntityEventArgs;
///
/// Raised before the settings on the access reader are changed. Can be cancelled.
///
public sealed class AccessReaderConfigurationAttemptEvent : CancellableEntityEventArgs;