mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
Communications console & screens overhaul (#5954)
* i'm going insane from screens * some wiring * screemes * holy shit adhd lock-in * incomplete * its FUCKING DONE * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * zeta * mrrrp * test fix * fix arrivals * fix misnetwork * Fix iteration outline. Fixed all headers showing if all options where hidden. Added access requirement to keycard auth mechnism. Added countdown. Fixed ninja and fugitive. Fixed AI and aghost. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Vanessa <vanessalouwagie@gmail.com>
This commit is contained in:
co-authored by
pre-commit-ci[bot]
Vanessa
parent
bd1e4224cd
commit
a635429d3e
+124
@@ -0,0 +1,124 @@
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Electrocution;
|
||||
using Content.Shared.Station;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared._DV.KeycardAuthenticationDevice;
|
||||
|
||||
public abstract class SharedDVStationKeycardAuthenticationDeviceSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] protected readonly SharedStationSystem Station = default!;
|
||||
[Dependency] private readonly SharedElectrocutionSystem _electrocution = default!;
|
||||
[Dependency] private readonly SharedChatSystem _chat = default!;
|
||||
[Dependency] private readonly AccessReaderSystem _accessReader = default!;
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var query = EntityQueryEnumerator<DVStationKeycardAuthenticationDeviceComponent>();
|
||||
while (query.MoveNext(out var uid, out var keycard))
|
||||
{
|
||||
if (keycard.SwipesStartedAt is not { } startedAt || _timing.CurTime <= startedAt + keycard.SwipeWindow)
|
||||
continue;
|
||||
|
||||
StopSwipes((uid, keycard), true);
|
||||
}
|
||||
}
|
||||
|
||||
private void StopSwipes(Entity<DVStationKeycardAuthenticationDeviceComponent> station, bool failed)
|
||||
{
|
||||
station.Comp.SwipesStartedAt = null;
|
||||
station.Comp.Swipes = 0;
|
||||
station.Comp.SwipingFor = null;
|
||||
if (failed)
|
||||
{
|
||||
station.Comp.AccessibleAfter = _timing.CurTime + station.Comp.FailureDelay;
|
||||
_chat.DispatchStationAnnouncement(station,
|
||||
Loc.GetString(station.Comp.FailureAnnouncement),
|
||||
Loc.GetString(station.Comp.FailureAnnouncementSender),
|
||||
announcementSound: new SoundPathSpecifier("/Audio/_DV/Announcements/attention.ogg"),
|
||||
colorOverride: station.Comp.FailureAnnouncementColor);
|
||||
}
|
||||
Dirty(station);
|
||||
|
||||
var query = EntityQueryEnumerator<DVStationKeycardAuthenticationDeviceAlreadySwipedComponent>();
|
||||
while (query.MoveNext(out var uid, out _))
|
||||
{
|
||||
if (failed)
|
||||
{
|
||||
_electrocution.TryDoElectrocution(uid,
|
||||
null,
|
||||
10,
|
||||
station.Comp.FailureElectrocutionDuration,
|
||||
true,
|
||||
ignoreInsulation: true);
|
||||
}
|
||||
RemCompDeferred<DVStationKeycardAuthenticationDeviceAlreadySwipedComponent>(uid);
|
||||
}
|
||||
}
|
||||
|
||||
private void Swipe(Entity<DVStationKeycardAuthenticationDeviceComponent> station, EntityUid user, DVStationKeycardAction action)
|
||||
{
|
||||
if (!station.Comp.ActionThresholds.TryGetValue(action, out var threshold))
|
||||
return;
|
||||
|
||||
station.Comp.SwipesStartedAt ??= _timing.CurTime;
|
||||
station.Comp.SwipingFor = action;
|
||||
station.Comp.Swipes++;
|
||||
AddComp<DVStationKeycardAuthenticationDeviceAlreadySwipedComponent>(user);
|
||||
Dirty(station);
|
||||
|
||||
if (station.Comp.Swipes >= threshold)
|
||||
{
|
||||
StopSwipes(station, false);
|
||||
DoAction(station, action);
|
||||
}
|
||||
}
|
||||
|
||||
private void DoAction(Entity<DVStationKeycardAuthenticationDeviceComponent> station, DVStationKeycardAction action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case DVStationKeycardAction.Mayday:
|
||||
Mayday(station);
|
||||
break;
|
||||
|
||||
case DVStationKeycardAction.Scuttling:
|
||||
Scuttling(station);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Mayday(Entity<DVStationKeycardAuthenticationDeviceComponent> station)
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void Scuttling(Entity<DVStationKeycardAuthenticationDeviceComponent> station)
|
||||
{
|
||||
}
|
||||
|
||||
public void TrySwipe(EntityUid user, EntityUid console, DVStationKeycardAction action)
|
||||
{
|
||||
if (HasComp<DVStationKeycardAuthenticationDeviceAlreadySwipedComponent>(console))
|
||||
return;
|
||||
|
||||
if (Station.GetOwningStation(user) is not { } station || !TryComp<DVStationKeycardAuthenticationDeviceComponent>(station, out var keycard))
|
||||
return;
|
||||
|
||||
if (TryComp<AccessReaderComponent>(console, out var accessReader) && !_accessReader.IsAllowed(user, console, accessReader))
|
||||
return;
|
||||
|
||||
if (keycard.SwipingFor is { } swipingFor && swipingFor != action)
|
||||
return;
|
||||
|
||||
if (_timing.CurTime <= keycard.AccessibleAfter)
|
||||
return;
|
||||
|
||||
Swipe((station, keycard), user, action);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user