Genpop Closets & IDs (#36392)
* Genpop IDs and Lockers * placeholder generation, no ui yet. * UI * Fix time offset * fix meta.jsons * big speller * Scarkyo review * Add turnstile prototypes * make IDs recyclable --------- Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com> Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com>
This commit is contained in:
@@ -9,12 +9,15 @@ using Content.Shared.PDA;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.StatusIcon;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared.Access.Systems;
|
||||
|
||||
public abstract class SharedIdCardSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly SharedAccessSystem _access = default!;
|
||||
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
@@ -256,4 +259,49 @@ public abstract class SharedIdCardSystem : EntitySystem
|
||||
return $"{idCardComponent.FullName} ({CultureInfo.CurrentCulture.TextInfo.ToTitleCase(idCardComponent.LocalizedJobTitle ?? string.Empty)})"
|
||||
.Trim();
|
||||
}
|
||||
|
||||
public void SetExpireTime(Entity<ExpireIdCardComponent?> ent, TimeSpan time)
|
||||
{
|
||||
if (!Resolve(ent, ref ent.Comp))
|
||||
return;
|
||||
ent.Comp.ExpireTime = time;
|
||||
Dirty(ent);
|
||||
}
|
||||
|
||||
public void SetPermanent(Entity<ExpireIdCardComponent?> ent, bool val)
|
||||
{
|
||||
if (!Resolve(ent, ref ent.Comp))
|
||||
return;
|
||||
ent.Comp.Permanent = val;
|
||||
Dirty(ent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marks an <see cref="ExpireIdCardComponent"/> as expired, setting the accesses.
|
||||
/// </summary>
|
||||
public virtual void ExpireId(Entity<ExpireIdCardComponent> ent)
|
||||
{
|
||||
if (ent.Comp.Expired)
|
||||
return;
|
||||
|
||||
_access.TrySetTags(ent, ent.Comp.ExpiredAccess);
|
||||
ent.Comp.Expired = true;
|
||||
Dirty(ent);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
var query = EntityQueryEnumerator<ExpireIdCardComponent>();
|
||||
while (query.MoveNext(out var uid, out var comp))
|
||||
{
|
||||
if (comp.Expired || comp.Permanent)
|
||||
continue;
|
||||
|
||||
if (_timing.CurTime < comp.ExpireTime)
|
||||
continue;
|
||||
|
||||
ExpireId((uid, comp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user