Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Content.Client/Shuttles/Systems/ShuttleConsoleLockSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Shared.Shuttles.Systems;
using Content.Shared.Shuttles.Components;
using Content.Shared.Access.Components;
using Content.Shared.UserInterface;

namespace Content.Client.Shuttles.Systems;

Expand All @@ -17,4 +18,17 @@ public override bool TryUnlock(EntityUid console, EntityUid idCard, ShuttleConso
// Prediction only
return false;
}
}

/// <summary>
/// Client extension of OnUIOpenAttempt. Prevents UI flashing open on client.
/// </summary>
protected override void OnUIOpenAttempt(EntityUid uid,
ShuttleConsoleLockComponent component,
ActivatableUIOpenAttemptEvent args)
{
base.OnUIOpenAttempt(uid, component, args);

if(Timing.IsFirstTimePredicted && args.Cancelled)
Popup.PopupEntity(Loc.GetString("shuttle-console-locked"), uid, args.User);
}
}
16 changes: 0 additions & 16 deletions Content.Server/Shuttles/Systems/ShuttleConsoleLockSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Content.Shared._NF.Shipyard.Components;
using Content.Server.Shuttles.Components;
using Content.Server.Hands.Systems;
using Content.Shared.UserInterface;
using Robust.Shared.Audio.Systems;
using Content.Shared.Verbs;
using Robust.Shared.Utility;
Expand Down Expand Up @@ -36,7 +35,6 @@ public override void Initialize()
base.Initialize();
SubscribeLocalEvent<ShuttleConsoleLockComponent, ComponentInit>(OnShuttleConsoleLockInit);
SubscribeLocalEvent<ShuttleConsoleLockComponent, GetVerbsEvent<AlternativeVerb>>(AddUnlockVerb);
SubscribeLocalEvent<ShuttleConsoleLockComponent, ActivatableUIOpenAttemptEvent>(OnUIOpenAttempt);
SubscribeLocalEvent<PdaComponent, AfterInteractEvent>(OnPdaAfterInteract);
SubscribeLocalEvent<ShuttleConsoleLockComponent, AfterInteractUsingEvent>(OnAfterInteractUsing);
SubscribeLocalEvent<ShuttleDeedComponent, ComponentInit>(OnShuttleDeedInit);
Expand Down Expand Up @@ -535,20 +533,6 @@ private bool TryLockWithVoucher(EntityUid console, EntityUid voucher, ShuttleCon
return true;
}

/// <summary>
/// Prevents using the console UI if it's locked
/// </summary>
private void OnUIOpenAttempt(EntityUid uid,
ShuttleConsoleLockComponent component,
ActivatableUIOpenAttemptEvent args)
{
if (GetEffectiveLockState(uid, component))
{
Popup.PopupEntity(Loc.GetString("shuttle-console-locked"), uid, args.User);
args.Cancel();
}
}

/// <summary>
/// Finds all ID cards accessible to a user (in hands or worn)
/// </summary>
Expand Down
13 changes: 13 additions & 0 deletions Content.Shared/Shuttles/Systems/SharedShuttleConsoleLockSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Shared.Access.Components;
using Content.Shared.Shuttles.Components;
using Content.Shared._NF.Shipyard.Components;
using Content.Shared.UserInterface;
using Content.Shared.Popups;
using Robust.Shared.Timing;
using Content.Shared.Examine;
Expand All @@ -22,6 +23,7 @@ public override void Initialize()
base.Initialize();
SubscribeLocalEvent<ShuttleConsoleLockComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<ShuttleConsoleLockComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<ShuttleConsoleLockComponent, ActivatableUIOpenAttemptEvent>(OnUIOpenAttempt);
}

private void OnStartup(EntityUid uid, ShuttleConsoleLockComponent component, ComponentStartup args)
Expand Down Expand Up @@ -58,6 +60,17 @@ public bool GetEffectiveLockState(EntityUid console, ShuttleConsoleLockComponent
return component.Locked;
}

/// <summary>
/// Prevents using the console UI if it's locked
/// </summary>
protected virtual void OnUIOpenAttempt(EntityUid uid,
ShuttleConsoleLockComponent component,
ActivatableUIOpenAttemptEvent args)
{
if (GetEffectiveLockState(uid, component))
args.Cancel();
}

protected void UpdateAppearance(EntityUid uid, ShuttleConsoleLockComponent? component = null)
{
if (!Resolve(uid, ref component))
Expand Down
Loading