Add a debug overlay for accessreaders (#9681)
> didnt pjb have issues with doing the control stuff in an overlay and just wanted direct texture draw I ended up doing dis.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Access.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||
|
||||
namespace Content.Shared.Access.Components
|
||||
@@ -6,12 +7,12 @@ namespace Content.Shared.Access.Components
|
||||
/// <summary>
|
||||
/// Simple mutable access provider found on ID cards and such.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[Access(typeof(AccessSystem))]
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
[Access(typeof(SharedAccessSystem))]
|
||||
public sealed class AccessComponent : Component
|
||||
{
|
||||
[DataField("tags", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<AccessLevelPrototype>))]
|
||||
[Access(typeof(AccessSystem), Other = AccessPermissions.ReadExecute)] // FIXME Friends
|
||||
[Access(typeof(SharedAccessSystem), Other = AccessPermissions.ReadExecute)] // FIXME Friends
|
||||
public HashSet<string> Tags = new();
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Access.Systems
|
||||
{
|
||||
public sealed class AccessSystem : EntitySystem
|
||||
public abstract class SharedAccessSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
@@ -13,6 +15,28 @@ namespace Content.Shared.Access.Systems
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<AccessComponent, MapInitEvent>(OnAccessInit);
|
||||
SubscribeLocalEvent<AccessComponent, ComponentGetState>(OnAccessGetState);
|
||||
SubscribeLocalEvent<AccessComponent, ComponentHandleState>(OnAccessHandleState);
|
||||
}
|
||||
|
||||
private void OnAccessHandleState(EntityUid uid, AccessComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not AccessComponentState state) return;
|
||||
|
||||
// Don't do = because prediction and refs
|
||||
component.Tags.Clear();
|
||||
component.Groups.Clear();
|
||||
component.Tags.UnionWith(state.Tags);
|
||||
component.Groups.UnionWith(state.Groups);
|
||||
}
|
||||
|
||||
private void OnAccessGetState(EntityUid uid, AccessComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new AccessComponentState()
|
||||
{
|
||||
Tags = component.Tags,
|
||||
Groups = component.Groups,
|
||||
};
|
||||
}
|
||||
|
||||
private void OnAccessInit(EntityUid uid, AccessComponent component, MapInitEvent args)
|
||||
@@ -38,6 +62,7 @@ namespace Content.Shared.Access.Systems
|
||||
|
||||
access.Tags.Clear();
|
||||
access.Tags.UnionWith(newTags);
|
||||
Dirty(access);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -55,6 +80,7 @@ namespace Content.Shared.Access.Systems
|
||||
access.Tags.UnionWith(proto.Tags);
|
||||
}
|
||||
|
||||
Dirty(access);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -85,5 +111,12 @@ namespace Content.Shared.Access.Systems
|
||||
TryAddGroups(uid, prototype.ExtendedAccessGroups, access);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class AccessComponentState : ComponentState
|
||||
{
|
||||
public HashSet<string> Tags = new();
|
||||
public HashSet<string> Groups = new();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user