# Conflicts: # Content.Client/UserInterface/Controls/RadialContainer.cs # Content.Server/Lathe/LatheSystem.cs # Content.Server/Silicons/Laws/SiliconLawSystem.cs # Content.Shared/Inventory/InventorySystem.Relay.cs # Content.Shared/Materials/SharedMaterialReclaimerSystem.cs # Content.Shared/Medical/Cryogenics/SharedCryoPodSystem.cs # Content.Shared/VendingMachines/SharedVendingMachineSystem.cs # Content.Shared/Wieldable/SharedWieldableSystem.cs # Resources/Locale/en-US/_strings/station-events/events/radiation-storm.ftl # Resources/Locale/en-US/_strings/store/uplink-catalog.ftl # Resources/Prototypes/Atmospherics/gases.yml # Resources/Prototypes/Catalog/Fills/Lockers/heads.yml # Resources/Prototypes/Datasets/Names/borg.yml # Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml # Resources/Prototypes/Entities/Mobs/Player/silicon.yml # Resources/Prototypes/Entities/Objects/Misc/subdermal_implants.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml # Resources/Prototypes/Entities/Structures/Specific/Atmospherics/sensor.yml # Resources/ServerInfo/Guidebook/Engineering/AME.xml # Resources/ServerInfo/Guidebook/Engineering/AirlockSecurity.xml # Resources/ServerInfo/Guidebook/Engineering/Atmospherics.xml # Resources/ServerInfo/Guidebook/Engineering/Construction.xml # Resources/ServerInfo/Guidebook/Engineering/Engineering.xml # Resources/ServerInfo/Guidebook/Engineering/Fires.xml # Resources/ServerInfo/Guidebook/Engineering/NetworkConfigurator.xml # Resources/ServerInfo/Guidebook/Engineering/Networking.xml # Resources/ServerInfo/Guidebook/Engineering/Power.xml # Resources/ServerInfo/Guidebook/Engineering/RTG.xml # Resources/ServerInfo/Guidebook/Engineering/Shuttlecraft.xml # Resources/ServerInfo/Guidebook/Engineering/Singularity.xml # Resources/ServerInfo/Guidebook/Engineering/TEG.xml # Resources/ServerInfo/Guidebook/Security/CriminalRecords.xml # Resources/Textures/Clothing/OuterClothing/Vests/hazard.rsi/equipped-OUTERCLOTHING.png # Resources/Textures/Clothing/OuterClothing/Vests/hazard.rsi/icon.png # Resources/Textures/Clothing/OuterClothing/Vests/hazard.rsi/meta.json # Resources/Textures/Objects/Weapons/Guns/Rifles/lecter.rsi/equipped-BACKPACK.png # Resources/migration.yml
159 lines
5 KiB
C#
159 lines
5 KiB
C#
using System.Text.RegularExpressions;
|
||
using Content.Shared.StationRecords;
|
||
using Content.Shared.Weapons.Melee;
|
||
using Robust.Shared.GameStates;
|
||
using Robust.Shared.Prototypes;
|
||
using Robust.Shared.Serialization;
|
||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||
using Robust.Shared.Toolshed.Syntax;
|
||
|
||
namespace Content.Shared.Access.Components;
|
||
|
||
/// <summary>
|
||
/// Stores access levels necessary to "use" an entity
|
||
/// and allows checking if something or somebody is authorized with these access levels.
|
||
/// </summary>
|
||
[RegisterComponent, NetworkedComponent]
|
||
public sealed partial class AccessReaderComponent : Component
|
||
{
|
||
/// <summary>
|
||
/// Whether or not the accessreader is enabled.
|
||
/// If not, it will always let people through.
|
||
/// </summary>
|
||
[DataField]
|
||
public bool Enabled = true;
|
||
|
||
// Sunrise-start
|
||
|
||
/// <summary>
|
||
/// Именно от Group происходит проверка аварийных доступов
|
||
/// </summary>
|
||
[ViewVariables(VVAccess.ReadWrite)]
|
||
public ProtoId<AccessGroupPrototype> Group = string.Empty;
|
||
|
||
[ViewVariables(VVAccess.ReadWrite)]
|
||
[DataField]
|
||
public Dictionary<CurrentAlertLevel, ProtoId<AccessGroupPrototype>> AlertAccesses = new();
|
||
|
||
[Flags]
|
||
public enum CurrentAlertLevel : byte
|
||
{
|
||
blue,
|
||
red,
|
||
yellow,
|
||
gamma,
|
||
delta
|
||
}
|
||
// Sunrise-end
|
||
|
||
/// <summary>
|
||
/// The set of tags that will automatically deny an allowed check, if any of them are present.
|
||
/// </summary>
|
||
[ViewVariables(VVAccess.ReadWrite)]
|
||
[DataField]
|
||
public HashSet<ProtoId<AccessLevelPrototype>> DenyTags = new();
|
||
|
||
/// <summary>
|
||
/// 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.
|
||
/// </summary>
|
||
[DataField("access")] [ViewVariables(VVAccess.ReadWrite)]
|
||
public List<HashSet<ProtoId<AccessLevelPrototype>>> AccessLists = new();
|
||
|
||
/// <summary>
|
||
/// A list of <see cref="StationRecordKey"/>s that grant access. Only a single matching key is required to gain
|
||
/// access.
|
||
/// </summary>
|
||
[DataField]
|
||
public HashSet<StationRecordKey> AccessKeys = new();
|
||
|
||
/// <summary>
|
||
/// If specified, then this access reader will instead pull access requirements from entities contained in the
|
||
/// given container.
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// This effectively causes <see cref="DenyTags"/>, <see cref="AccessLists"/>, and <see cref="AccessKeys"/> to be
|
||
/// ignored, though <see cref="Enabled"/> is still respected. Access is denied if there are no valid entities or
|
||
/// they all deny access.
|
||
/// </remarks>
|
||
[DataField]
|
||
public string? ContainerAccessProvider;
|
||
|
||
/// <summary>
|
||
/// A list of past authentications
|
||
/// </summary>
|
||
[DataField]
|
||
public Queue<AccessRecord> AccessLog = new();
|
||
|
||
/// <summary>
|
||
/// A limit on the max size of <see cref="AccessLog"/>
|
||
/// </summary>
|
||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||
public int AccessLogLimit = 20;
|
||
|
||
/// <summary>
|
||
/// If true logging on successful access uses will be disabled.
|
||
/// Can be set by LOG wire.
|
||
/// </summary>
|
||
[DataField]
|
||
public bool LoggingDisabled;
|
||
|
||
/// <summary>
|
||
/// Whether or not emag interactions have an effect on this.
|
||
/// </summary>
|
||
[DataField]
|
||
public bool BreakOnAccessBreaker = true;
|
||
}
|
||
|
||
[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<ProtoId<AccessLevelPrototype>> DenyTags;
|
||
|
||
public List<HashSet<ProtoId<AccessLevelPrototype>>> AccessLists;
|
||
|
||
public ProtoId<AccessGroupPrototype> Group; // Sunrise-alertAccesses, нужно для связывания клиента с сервером
|
||
|
||
public List<(NetEntity, uint)> AccessKeys;
|
||
|
||
public Queue<AccessRecord> AccessLog;
|
||
|
||
public int AccessLogLimit;
|
||
|
||
public AccessReaderComponentState(bool enabled, HashSet<ProtoId<AccessLevelPrototype>> denyTags,
|
||
List<HashSet<ProtoId<AccessLevelPrototype>>> accessLists,
|
||
ProtoId<AccessGroupPrototype> group,
|
||
List<(NetEntity, uint)> accessKeys,
|
||
Queue<AccessRecord> accessLog,
|
||
int accessLogLimit) //Sunrise-edit
|
||
{
|
||
Enabled = enabled;
|
||
DenyTags = denyTags;
|
||
AccessLists = accessLists;
|
||
AccessKeys = accessKeys;
|
||
AccessLog = accessLog;
|
||
AccessLogLimit = accessLogLimit;
|
||
Group = group; // Sunrise-alertAccesses
|
||
}
|
||
}
|
||
|
||
public sealed class AccessReaderConfigurationChangedEvent : EntityEventArgs
|
||
{
|
||
public AccessReaderConfigurationChangedEvent()
|
||
{
|
||
}
|
||
}
|