using Content.Shared.Access.Systems;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
namespace Content.Shared.Access.Components;
///
/// Simple mutable access provider found on ID cards and such.
///
[RegisterComponent, NetworkedComponent]
[Access(typeof(SharedAccessSystem))]
[AutoGenerateComponentState]
public sealed partial class AccessComponent : Component
{
///
/// True if the access provider is enabled and can grant access.
///
[DataField, ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public bool Enabled = true;
[DataField]
[Access(typeof(SharedAccessSystem), Other = AccessPermissions.ReadExecute)] // FIXME Friends
[AutoNetworkedField]
public HashSet> Tags = new();
///
/// Access Groups. These are added to the tags during map init. After map init this will have no effect.
///
[DataField(readOnly: true)]
[AutoNetworkedField]
public HashSet> Groups = new();
}
///
/// Event raised on an entity to find additional entities which provide access.
///
[ByRefEvent]
public struct GetAdditionalAccessEvent
{
public HashSet Entities = new();
public GetAdditionalAccessEvent()
{
}
}
[ByRefEvent]
public record struct GetAccessTagsEvent(HashSet> Tags, IPrototypeManager PrototypeManager)
{
public void AddGroup(ProtoId group)
{
if (!PrototypeManager.Resolve(group, out var groupPrototype))
return;
Tags.UnionWith(groupPrototype.Tags);
}
}