using Content.Shared.StationRecords;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
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]
public sealed partial class AccessReaderComponent : Component
{
///
/// Whether or not the accessreader is enabled.
/// If not, it will always let people through.
///
[DataField("enabled")]
public bool Enabled = true;
///
/// The set of tags that will automatically deny an allowed check, if any of them are present.
///
[DataField("denyTags", customTypeSerializer: typeof(PrototypeIdHashSetSerializer))]
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();
///
/// A list of s that grant access. Only a single matching key is required tp gaim
/// access.
///
[DataField("accessKeys")]
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("containerAccessProvider")]
public string? ContainerAccessProvider;
}
[Serializable, NetSerializable]
public sealed class AccessReaderComponentState : ComponentState
{
public bool Enabled;
public HashSet DenyTags;
public List> AccessLists;
public HashSet AccessKeys;
public AccessReaderComponentState(bool enabled, HashSet denyTags, List> accessLists, HashSet accessKeys)
{
Enabled = enabled;
DenyTags = denyTags;
AccessLists = accessLists;
AccessKeys = accessKeys;
}
}