fix gateway destinations (#20172)
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -20,7 +20,7 @@ public sealed class GatewayBoundUserInterface : BoundUserInterface
|
||||
_window = new GatewayWindow();
|
||||
_window.OpenPortal += destination =>
|
||||
{
|
||||
SendMessage(new GatewayOpenPortalMessage(EntMan.GetNetEntity(destination)));
|
||||
SendMessage(new GatewayOpenPortalMessage(destination));
|
||||
};
|
||||
_window.OnClose += Close;
|
||||
_window?.OpenCentered();
|
||||
@@ -29,8 +29,11 @@ public sealed class GatewayBoundUserInterface : BoundUserInterface
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
_window?.Dispose();
|
||||
_window = null;
|
||||
if (disposing)
|
||||
{
|
||||
_window?.Dispose();
|
||||
_window = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
|
||||
@@ -16,12 +16,11 @@ namespace Content.Client.Gateway.UI;
|
||||
public sealed partial class GatewayWindow : FancyWindow,
|
||||
IComputerWindow<EmergencyConsoleBoundUserInterfaceState>
|
||||
{
|
||||
private readonly IEntityManager _entManager;
|
||||
private readonly IGameTiming _timing;
|
||||
|
||||
public event Action<EntityUid>? OpenPortal;
|
||||
public event Action<NetEntity>? OpenPortal;
|
||||
private List<(NetEntity, string, TimeSpan, bool)> _destinations = default!;
|
||||
private EntityUid? _current;
|
||||
private NetEntity? _current;
|
||||
private TimeSpan _nextClose;
|
||||
private TimeSpan _lastOpen;
|
||||
private List<Label> _readyLabels = default!;
|
||||
@@ -31,14 +30,13 @@ public sealed partial class GatewayWindow : FancyWindow,
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
var dependencies = IoCManager.Instance!;
|
||||
_entManager = dependencies.Resolve<IEntityManager>();
|
||||
_timing = dependencies.Resolve<IGameTiming>();
|
||||
}
|
||||
|
||||
public void UpdateState(GatewayBoundUserInterfaceState state)
|
||||
{
|
||||
_destinations = state.Destinations;
|
||||
_current = _entManager.GetEntity(state.Current);
|
||||
_current = state.Current;
|
||||
_nextClose = state.NextClose;
|
||||
_lastOpen = state.LastOpen;
|
||||
|
||||
@@ -67,7 +65,7 @@ public sealed partial class GatewayWindow : FancyWindow,
|
||||
var now = _timing.CurTime;
|
||||
foreach (var dest in _destinations)
|
||||
{
|
||||
var uid = _entManager.GetEntity(dest.Item1);
|
||||
var ent = dest.Item1;
|
||||
var name = dest.Item2;
|
||||
var nextReady = dest.Item3;
|
||||
var busy = dest.Item4;
|
||||
@@ -94,17 +92,17 @@ public sealed partial class GatewayWindow : FancyWindow,
|
||||
var openButton = new Button()
|
||||
{
|
||||
Text = Loc.GetString("gateway-window-open-portal"),
|
||||
Pressed = uid == _current,
|
||||
Pressed = ent == _current,
|
||||
ToggleMode = true,
|
||||
Disabled = _current != null || busy || now < nextReady
|
||||
};
|
||||
|
||||
openButton.OnPressed += args =>
|
||||
{
|
||||
OpenPortal?.Invoke(uid);
|
||||
OpenPortal?.Invoke(ent);
|
||||
};
|
||||
|
||||
if (uid == _entManager.GetEntity(state.Current))
|
||||
if (ent == _current)
|
||||
{
|
||||
openButton.AddStyleClass(StyleBase.ButtonCaution);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public sealed partial class GatewayComponent : Component
|
||||
/// Every other gateway destination on the server.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Added on
|
||||
/// Added on startup and when a new destination portal is created.
|
||||
/// </remarks>
|
||||
[ViewVariables]
|
||||
public HashSet<EntityUid> Destinations = new();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.Gateway.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.Gateway;
|
||||
using Content.Shared.Teleportation.Components;
|
||||
using Content.Shared.Teleportation.Systems;
|
||||
@@ -13,6 +14,7 @@ namespace Content.Server.Gateway.Systems;
|
||||
|
||||
public sealed class GatewaySystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly AccessReaderSystem _accessReader = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly LinkedEntitySystem _linkedEntity = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
@@ -66,7 +68,7 @@ public sealed class GatewaySystem : EntitySystem
|
||||
|
||||
private void UpdateUserInterface(EntityUid uid, GatewayComponent comp)
|
||||
{
|
||||
var destinations = new List<(NetEntity, String, TimeSpan, bool)>();
|
||||
var destinations = new List<(NetEntity, string, TimeSpan, bool)>();
|
||||
foreach (var destUid in comp.Destinations)
|
||||
{
|
||||
var dest = Comp<GatewayDestinationComponent>(destUid);
|
||||
@@ -88,6 +90,14 @@ public sealed class GatewaySystem : EntitySystem
|
||||
|
||||
private void OnOpenPortal(EntityUid uid, GatewayComponent comp, GatewayOpenPortalMessage args)
|
||||
{
|
||||
if (args.Session.AttachedEntity == null)
|
||||
return;
|
||||
|
||||
// if the gateway has an access reader check it before allowing opening
|
||||
var user = args.Session.AttachedEntity.Value;
|
||||
if (!_accessReader.IsAllowed(user, uid))
|
||||
return;
|
||||
|
||||
// can't link if portal is already open on either side, the destination is invalid or on cooldown
|
||||
var desto = GetEntity(args.Destination);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user