Adds UIs for volume and pressure pumps (#5155)
* Adds UIs for volume and pressure pumps * Update Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs * Update Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs Co-authored-by: ike709 <ike709@github.com>
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
using System;
|
||||
using Content.Server.Atmos.Piping.Binary.Components;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.NodeContainer;
|
||||
using Content.Server.NodeContainer.Nodes;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Atmos.Piping;
|
||||
using Content.Shared.Atmos.Piping.Binary.Components;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
@@ -16,6 +20,8 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
||||
[UsedImplicitly]
|
||||
public class GasPressurePumpSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private UserInterfaceSystem _userInterfaceSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -23,6 +29,10 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
||||
SubscribeLocalEvent<GasPressurePumpComponent, AtmosDeviceUpdateEvent>(OnPumpUpdated);
|
||||
SubscribeLocalEvent<GasPressurePumpComponent, AtmosDeviceDisabledEvent>(OnPumpLeaveAtmosphere);
|
||||
SubscribeLocalEvent<GasPressurePumpComponent, ExaminedEvent>(OnExamined);
|
||||
SubscribeLocalEvent<GasPressurePumpComponent, InteractHandEvent>(OnPumpInteractHand);
|
||||
// Bound UI subscriptions
|
||||
SubscribeLocalEvent<GasPressurePumpComponent, GasPressurePumpChangeOutputPressureMessage>(OnOutputPressureChangeMessage);
|
||||
SubscribeLocalEvent<GasPressurePumpComponent, GasPressurePumpToggleStatusMessage>(OnToggleStatusMessage);
|
||||
}
|
||||
|
||||
private void OnExamined(EntityUid uid, GasPressurePumpComponent pump, ExaminedEvent args)
|
||||
@@ -79,5 +89,37 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPumpInteractHand(EntityUid uid, GasPressurePumpComponent component, InteractHandEvent args)
|
||||
{
|
||||
if (!args.User.TryGetComponent(out ActorComponent? actor))
|
||||
return;
|
||||
|
||||
_userInterfaceSystem.TryOpen(uid, GasPressurePumpUiKey.Key, actor.PlayerSession);
|
||||
DirtyUI(uid, component);
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnToggleStatusMessage(EntityUid uid, GasPressurePumpComponent pump, GasPressurePumpToggleStatusMessage args)
|
||||
{
|
||||
pump.Enabled = args.Enabled;
|
||||
DirtyUI(uid, pump);
|
||||
}
|
||||
|
||||
private void OnOutputPressureChangeMessage(EntityUid uid, GasPressurePumpComponent pump, GasPressurePumpChangeOutputPressureMessage args)
|
||||
{
|
||||
pump.TargetPressure = Math.Clamp(args.Pressure, 0f, Atmospherics.MaxOutputPressure);
|
||||
DirtyUI(uid, pump);
|
||||
|
||||
}
|
||||
|
||||
private void DirtyUI(EntityUid uid, GasPressurePumpComponent? pump)
|
||||
{
|
||||
if (!Resolve(uid, ref pump))
|
||||
return;
|
||||
|
||||
_userInterfaceSystem.TrySetUiState(uid, GasPressurePumpUiKey.Key,
|
||||
new GasPressurePumpBoundUserInterfaceState(pump.Owner.Name, pump.TargetPressure, pump.Enabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user