Fix gas mixer visuals (#6534)
This commit is contained in:
@@ -1,12 +1,11 @@
|
|||||||
|
using Content.Server.Atmos.Piping.Trinary.EntitySystems;
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
|
|
||||||
namespace Content.Server.Atmos.Piping.Trinary.Components
|
namespace Content.Server.Atmos.Piping.Trinary.Components
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class GasMixerComponent : Component
|
[Friend(typeof(GasMixerSystem))]
|
||||||
|
public sealed class GasMixerComponent : Component
|
||||||
{
|
{
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public bool Enabled = true;
|
public bool Enabled = true;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using System;
|
|
||||||
using Content.Server.Administration.Logs;
|
using Content.Server.Administration.Logs;
|
||||||
using Content.Server.Atmos.EntitySystems;
|
using Content.Server.Atmos.EntitySystems;
|
||||||
using Content.Server.Atmos.Piping.Components;
|
using Content.Server.Atmos.Piping.Components;
|
||||||
@@ -6,20 +5,18 @@ using Content.Server.Atmos.Piping.Trinary.Components;
|
|||||||
using Content.Server.NodeContainer;
|
using Content.Server.NodeContainer;
|
||||||
using Content.Server.NodeContainer.Nodes;
|
using Content.Server.NodeContainer.Nodes;
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
|
using Content.Shared.Atmos.Piping;
|
||||||
using Content.Shared.Atmos.Piping.Trinary.Components;
|
using Content.Shared.Atmos.Piping.Trinary.Components;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Localization;
|
|
||||||
|
|
||||||
namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
|
namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
|
||||||
{
|
{
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class GasMixerSystem : EntitySystem
|
public sealed class GasMixerSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private UserInterfaceSystem _userInterfaceSystem = default!;
|
[Dependency] private UserInterfaceSystem _userInterfaceSystem = default!;
|
||||||
[Dependency] private AdminLogSystem _adminLogSystem = default!;
|
[Dependency] private AdminLogSystem _adminLogSystem = default!;
|
||||||
@@ -29,6 +26,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
|
SubscribeLocalEvent<GasMixerComponent, ComponentInit>(OnInit);
|
||||||
SubscribeLocalEvent<GasMixerComponent, AtmosDeviceUpdateEvent>(OnMixerUpdated);
|
SubscribeLocalEvent<GasMixerComponent, AtmosDeviceUpdateEvent>(OnMixerUpdated);
|
||||||
SubscribeLocalEvent<GasMixerComponent, InteractHandEvent>(OnMixerInteractHand);
|
SubscribeLocalEvent<GasMixerComponent, InteractHandEvent>(OnMixerInteractHand);
|
||||||
// Bound UI subscriptions
|
// Bound UI subscriptions
|
||||||
@@ -37,6 +35,11 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
|
|||||||
SubscribeLocalEvent<GasMixerComponent, GasMixerToggleStatusMessage>(OnToggleStatusMessage);
|
SubscribeLocalEvent<GasMixerComponent, GasMixerToggleStatusMessage>(OnToggleStatusMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnInit(EntityUid uid, GasMixerComponent component, ComponentInit args)
|
||||||
|
{
|
||||||
|
UpdateAppearance(uid, component);
|
||||||
|
}
|
||||||
|
|
||||||
private void OnMixerUpdated(EntityUid uid, GasMixerComponent mixer, AtmosDeviceUpdateEvent args)
|
private void OnMixerUpdated(EntityUid uid, GasMixerComponent mixer, AtmosDeviceUpdateEvent args)
|
||||||
{
|
{
|
||||||
// TODO ATMOS: Cache total moles since it's expensive.
|
// TODO ATMOS: Cache total moles since it's expensive.
|
||||||
@@ -137,12 +140,21 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
|
|||||||
new GasMixerBoundUserInterfaceState(EntityManager.GetComponent<MetaDataComponent>(mixer.Owner).EntityName, mixer.TargetPressure, mixer.Enabled, mixer.InletOneConcentration));
|
new GasMixerBoundUserInterfaceState(EntityManager.GetComponent<MetaDataComponent>(mixer.Owner).EntityName, mixer.TargetPressure, mixer.Enabled, mixer.InletOneConcentration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateAppearance(EntityUid uid, GasMixerComponent? mixer = null, AppearanceComponent? appearance = null)
|
||||||
|
{
|
||||||
|
if (!Resolve(uid, ref mixer, ref appearance, false))
|
||||||
|
return;
|
||||||
|
|
||||||
|
appearance.SetData(FilterVisuals.Enabled, mixer.Enabled);
|
||||||
|
}
|
||||||
|
|
||||||
private void OnToggleStatusMessage(EntityUid uid, GasMixerComponent mixer, GasMixerToggleStatusMessage args)
|
private void OnToggleStatusMessage(EntityUid uid, GasMixerComponent mixer, GasMixerToggleStatusMessage args)
|
||||||
{
|
{
|
||||||
mixer.Enabled = args.Enabled;
|
mixer.Enabled = args.Enabled;
|
||||||
_adminLogSystem.Add(LogType.AtmosPowerChanged, LogImpact.Medium,
|
_adminLogSystem.Add(LogType.AtmosPowerChanged, LogImpact.Medium,
|
||||||
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the power on {ToPrettyString(uid):device} to {args.Enabled}");
|
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the power on {ToPrettyString(uid):device} to {args.Enabled}");
|
||||||
DirtyUI(uid, mixer);
|
DirtyUI(uid, mixer);
|
||||||
|
UpdateAppearance(uid, mixer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnOutputPressureChangeMessage(EntityUid uid, GasMixerComponent mixer, GasMixerChangeOutputPressureMessage args)
|
private void OnOutputPressureChangeMessage(EntityUid uid, GasMixerComponent mixer, GasMixerChangeOutputPressureMessage args)
|
||||||
|
|||||||
@@ -116,12 +116,15 @@
|
|||||||
rotation: -90
|
rotation: -90
|
||||||
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
||||||
- state: gasMixer
|
- state: gasMixer
|
||||||
map: [ "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer" ]
|
map: [ "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer", "enum.GasFilterVisualizer+Layers.Enabled" ]
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
visuals:
|
||||||
- type: SubFloorShowLayerVisualizer
|
- type: SubFloorShowLayerVisualizer
|
||||||
- type: PipeConnectorVisualizer
|
- type: PipeConnectorVisualizer
|
||||||
- type: PipeColorVisualizer
|
- type: PipeColorVisualizer
|
||||||
|
- type: GasFilterVisualizer
|
||||||
|
disabledState: gasMixer
|
||||||
|
enabledState: gasMixerOn
|
||||||
- type: UserInterface
|
- type: UserInterface
|
||||||
interfaces:
|
interfaces:
|
||||||
- key: enum.GasMixerUiKey.Key
|
- key: enum.GasMixerUiKey.Key
|
||||||
@@ -150,6 +153,14 @@
|
|||||||
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
||||||
- state: gasMixerF
|
- state: gasMixerF
|
||||||
map: [ "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer", "enum.GasFilterVisualizer+Layers.Enabled" ]
|
map: [ "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer", "enum.GasFilterVisualizer+Layers.Enabled" ]
|
||||||
|
- type: Appearance
|
||||||
|
visuals:
|
||||||
|
- type: SubFloorShowLayerVisualizer
|
||||||
|
- type: PipeConnectorVisualizer
|
||||||
|
- type: PipeColorVisualizer
|
||||||
|
- type: GasFilterVisualizer
|
||||||
|
disabledState: gasMixerF
|
||||||
|
enabledState: gasMixerFOn
|
||||||
- type: Flippable
|
- type: Flippable
|
||||||
mirrorEntity: GasMixer
|
mirrorEntity: GasMixer
|
||||||
- type: NodeContainer
|
- type: NodeContainer
|
||||||
|
|||||||
Reference in New Issue
Block a user