Move Access & AccessReader to shared. (#5798)
* git mv * Move Access Component & system. - Name space changes - Rename AccessReader to AccessReaderComponent - Also need an abstract TryGetSlot function for SharedInventoryComponent * better TryGetSlot * Ah yes, tests exist.
This commit is contained in:
24
Content.Shared/Access/Components/AccessComponent.cs
Normal file
24
Content.Shared/Access/Components/AccessComponent.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.Access.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple mutable access provider found on ID cards and such.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[Friend(typeof(AccessSystem))]
|
||||
public class AccessComponent : Component
|
||||
{
|
||||
public override string Name => "Access";
|
||||
|
||||
[DataField("tags", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<AccessLevelPrototype>))]
|
||||
[ViewVariables]
|
||||
public HashSet<string> Tags = new();
|
||||
}
|
||||
}
|
||||
37
Content.Shared/Access/Components/AccessReaderComponent.cs
Normal file
37
Content.Shared/Access/Components/AccessReaderComponent.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
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]
|
||||
public class AccessReaderComponent : Component
|
||||
{
|
||||
public override string Name => "AccessReader";
|
||||
|
||||
/// <summary>
|
||||
/// Whether this reader is enabled or not. If disabled, all access
|
||||
/// checks will pass.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool Enabled = true;
|
||||
|
||||
/// <summary>
|
||||
/// The set of tags that will automatically deny an allowed check, if any of them are present.
|
||||
/// </summary>
|
||||
public HashSet<string> DenyTags = new();
|
||||
|
||||
/// <summary>
|
||||
/// List of access lists to check allowed against. For an access check to pass
|
||||
/// there has to be an access list that is a subset of the access in the checking list.
|
||||
/// </summary>
|
||||
[DataField("access")]
|
||||
[ViewVariables]
|
||||
public List<HashSet<string>> AccessLists = new();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user