Dewarns access (#16666)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
TemporalOroboros
2023-07-22 21:19:51 -07:00
committed by GitHub
parent 415701fd74
commit df1dcb74ac
27 changed files with 438 additions and 407 deletions

View File

@@ -2,5 +2,6 @@ namespace Content.Server.Access.Components
{
[RegisterComponent]
public sealed class AgentIDCardComponent : Component
{}
{
}
}

View File

@@ -4,5 +4,4 @@ namespace Content.Server.Access.Systems;
public sealed class AccessSystem : SharedAccessSystem
{
}

View File

@@ -18,6 +18,7 @@ namespace Content.Server.Access.Systems
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
public override void Initialize()
{
@@ -112,7 +113,7 @@ namespace Content.Server.Access.Systems
if (player != null)
{
_adminLogger.Add(LogType.Identity, LogImpact.Low,
$"{ToPrettyString(player.Value):player} has changed the job title of {ToPrettyString(id.Owner):entity} to {jobTitle} ");
$"{ToPrettyString(player.Value):player} has changed the job title of {ToPrettyString(uid):entity} to {jobTitle} ");
}
return true;
}
@@ -149,7 +150,7 @@ namespace Content.Server.Access.Systems
if (player != null)
{
_adminLogger.Add(LogType.Identity, LogImpact.Low,
$"{ToPrettyString(player.Value):player} has changed the name of {ToPrettyString(id.Owner):entity} to {fullName} ");
$"{ToPrettyString(player.Value):player} has changed the name of {ToPrettyString(uid):entity} to {fullName} ");
}
return true;
}
@@ -174,7 +175,7 @@ namespace Content.Server.Access.Systems
: Loc.GetString("access-id-card-component-owner-full-name-job-title-text",
("fullName", id.FullName),
("jobSuffix", jobSuffix));
EntityManager.GetComponent<MetaDataComponent>(id.Owner).EntityName = val;
_metaSystem.SetEntityName(uid, val);
}
}
}

View File

@@ -21,9 +21,8 @@ public sealed class IdExaminableSystem : EntitySystem
private void OnGetExamineVerbs(EntityUid uid, IdExaminableComponent component, GetVerbsEvent<ExamineVerb> args)
{
var detailsRange = _examineSystem.IsInDetailsRange(args.User, uid);
var info = GetInfo(component.Owner) ?? Loc.GetString("id-examinable-component-verb-no-id");
var info = GetInfo(uid) ?? Loc.GetString("id-examinable-component-verb-no-id");
var verb = new ExamineVerb()
{
@@ -36,7 +35,7 @@ public sealed class IdExaminableSystem : EntitySystem
Category = VerbCategory.Examine,
Disabled = !detailsRange,
Message = Loc.GetString("id-examinable-component-verb-disabled"),
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/character.svg.192dpi.png"))
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/character.svg.192dpi.png"))
};
args.Verbs.Add(verb);
@@ -47,12 +46,13 @@ public sealed class IdExaminableSystem : EntitySystem
if (_inventorySystem.TryGetSlotEntity(uid, "id", out var idUid))
{
// PDA
if (EntityManager.TryGetComponent(idUid, out PdaComponent? pda) && pda.ContainedId is not null)
if (EntityManager.TryGetComponent(idUid, out PdaComponent? pda) &&
TryComp<IdCardComponent>(pda.ContainedId, out var id))
{
return GetNameAndJob(pda.ContainedId);
return GetNameAndJob(id);
}
// ID Card
if (EntityManager.TryGetComponent(idUid, out IdCardComponent? id))
if (EntityManager.TryGetComponent(idUid, out id))
{
return GetNameAndJob(id);
}

View File

@@ -26,15 +26,16 @@ namespace Content.Server.Access.Systems
{
// Go over all ID cards and make sure they're correctly configured for extended access.
foreach (var card in EntityQuery<PresetIdCardComponent>())
var query = EntityQueryEnumerator<PresetIdCardComponent>();
while (query.MoveNext(out var uid, out var card))
{
var station = _stationSystem.GetOwningStation(card.Owner);
var station = _stationSystem.GetOwningStation(uid);
// If we're not on an extended access station, the ID is already configured correctly from MapInit.
if (station == null || !Comp<StationJobsComponent>(station.Value).ExtendedAccess)
return;
SetupIdAccess(card.Owner, card, true);
SetupIdAccess(uid, card, true);
}
}
@@ -45,7 +46,7 @@ namespace Content.Server.Access.Systems
// or may not yet know whether it is on extended access (players not spawned yet).
// PlayerJobsAssigned makes sure extended access is configured correctly in that case.
var station = _stationSystem.GetOwningStation(id.Owner);
var station = _stationSystem.GetOwningStation(uid);
var extended = false;
if (station != null)
extended = Comp<StationJobsComponent>(station.Value).ExtendedAccess;