Make manual valves work (#6121)
* Make manual valves work * Change some GasValveSystem lookups
This commit is contained in:
18
Content.Client/Atmos/Visualizers/GasValveVisualizer.cs
Normal file
18
Content.Client/Atmos/Visualizers/GasValveVisualizer.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using Content.Shared.Atmos.Piping;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
|
namespace Content.Client.Atmos.Visualizers
|
||||||
|
{
|
||||||
|
[UsedImplicitly]
|
||||||
|
public class GasValveVisualizer : EnabledAtmosDeviceVisualizer
|
||||||
|
{
|
||||||
|
protected override object LayerMap => Layers.Enabled;
|
||||||
|
protected override Enum DataKey => FilterVisuals.Enabled;
|
||||||
|
|
||||||
|
enum Layers : byte
|
||||||
|
{
|
||||||
|
Enabled,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
using Content.Shared.Interaction;
|
|
||||||
using Content.Shared.Sound;
|
using Content.Shared.Sound;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
@@ -15,11 +14,13 @@ namespace Content.Server.Atmos.Piping.Binary.Components
|
|||||||
[DataField("open")]
|
[DataField("open")]
|
||||||
public bool Open { get; set; } = true;
|
public bool Open { get; set; } = true;
|
||||||
|
|
||||||
[DataField("pipe")]
|
[DataField("inlet")]
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
public string InletName { get; set; } = "inlet";
|
||||||
public string PipeName { get; } = "pipe";
|
|
||||||
|
[DataField("outlet")]
|
||||||
|
public string OutletName { get; set; } = "outlet";
|
||||||
|
|
||||||
[DataField("valveSound")]
|
[DataField("valveSound")]
|
||||||
public SoundSpecifier _valveSound { get; } = new SoundCollectionSpecifier("valveSqueak");
|
public SoundSpecifier ValveSound { get; } = new SoundCollectionSpecifier("valveSqueak");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class GasValveSystem : EntitySystem
|
public class GasValveSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
@@ -31,7 +33,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
|||||||
|
|
||||||
private void OnExamined(EntityUid uid, GasValveComponent valve, ExaminedEvent args)
|
private void OnExamined(EntityUid uid, GasValveComponent valve, ExaminedEvent args)
|
||||||
{
|
{
|
||||||
if (!EntityManager.GetComponent<TransformComponent>(valve.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
|
if (!Comp<TransformComponent>(valve.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Loc.TryGetString("gas-valve-system-examined", out var str,
|
if (Loc.TryGetString("gas-valve-system-examined", out var str,
|
||||||
@@ -49,21 +51,34 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
|||||||
|
|
||||||
private void OnActivate(EntityUid uid, GasValveComponent component, ActivateInWorldEvent args)
|
private void OnActivate(EntityUid uid, GasValveComponent component, ActivateInWorldEvent args)
|
||||||
{
|
{
|
||||||
if (args.User.InRangeUnobstructed(args.Target) && Get<ActionBlockerSystem>().CanInteract(args.User))
|
if (args.User.InRangeUnobstructed(args.Target) && _actionBlockerSystem.CanInteract(args.User))
|
||||||
{
|
{
|
||||||
Toggle(uid, component);
|
Toggle(uid, component);
|
||||||
SoundSystem.Play(Filter.Pvs(component.Owner), component._valveSound.GetSound(), component.Owner, AudioHelpers.WithVariation(0.25f));
|
SoundSystem.Play(Filter.Pvs(component.Owner), component.ValveSound.GetSound(), component.Owner, AudioHelpers.WithVariation(0.25f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Set(EntityUid uid, GasValveComponent component, bool value)
|
public void Set(EntityUid uid, GasValveComponent component, bool value)
|
||||||
{
|
{
|
||||||
component.Open = value;
|
component.Open = value;
|
||||||
|
if (TryComp(uid, out NodeContainerComponent? nodeContainer)
|
||||||
if (EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)
|
&& nodeContainer.TryGetNode(component.InletName, out PipeNode? inlet)
|
||||||
&& nodeContainer.TryGetNode(component.PipeName, out PipeNode? pipe))
|
&& nodeContainer.TryGetNode(component.OutletName, out PipeNode? outlet))
|
||||||
{
|
{
|
||||||
pipe.ConnectionsEnabled = component.Open;
|
if (TryComp<AppearanceComponent>(component.Owner,out var appearance))
|
||||||
|
{
|
||||||
|
appearance.SetData(FilterVisuals.Enabled, component.Open);
|
||||||
|
}
|
||||||
|
if (component.Open)
|
||||||
|
{
|
||||||
|
inlet.AddAlwaysReachable(outlet);
|
||||||
|
outlet.AddAlwaysReachable(inlet);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inlet.RemoveAlwaysReachable(outlet);
|
||||||
|
outlet.RemoveAlwaysReachable(inlet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,26 @@ namespace Content.Server.NodeContainer.Nodes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public PipeDirection CurrentPipeDirection { get; private set; }
|
public PipeDirection CurrentPipeDirection { get; private set; }
|
||||||
|
|
||||||
|
private HashSet<PipeNode>? _alwaysReachable;
|
||||||
|
|
||||||
|
public void AddAlwaysReachable(PipeNode pipeNode)
|
||||||
|
{
|
||||||
|
if (NodeGroup == null) return;
|
||||||
|
if (pipeNode.NodeGroupID != NodeGroupID) return;
|
||||||
|
_alwaysReachable ??= new();
|
||||||
|
_alwaysReachable.Add(pipeNode);
|
||||||
|
EntitySystem.Get<NodeGroupSystem>().QueueRemakeGroup((BaseNodeGroup) NodeGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveAlwaysReachable(PipeNode pipeNode)
|
||||||
|
{
|
||||||
|
if (_alwaysReachable == null) return;
|
||||||
|
if (NodeGroup == null) return;
|
||||||
|
if (pipeNode.NodeGroupID != NodeGroupID) return;
|
||||||
|
_alwaysReachable.Remove(pipeNode);
|
||||||
|
EntitySystem.Get<NodeGroupSystem>().QueueRemakeGroup((BaseNodeGroup) NodeGroup);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The directions in which this node is connected to other nodes.
|
/// The directions in which this node is connected to other nodes.
|
||||||
/// Used by <see cref="PipeVisualState"/>.
|
/// Used by <see cref="PipeVisualState"/>.
|
||||||
@@ -144,6 +164,24 @@ namespace Content.Server.NodeContainer.Nodes
|
|||||||
yield return pipe;
|
yield return pipe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(_alwaysReachable != null)
|
||||||
|
{
|
||||||
|
var remQ = new RemQueue<PipeNode>();
|
||||||
|
foreach(var pipe in _alwaysReachable)
|
||||||
|
{
|
||||||
|
if (pipe.Deleting)
|
||||||
|
{
|
||||||
|
remQ.Add(pipe);
|
||||||
|
}
|
||||||
|
yield return pipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(var pipe in remQ)
|
||||||
|
{
|
||||||
|
_alwaysReachable.Remove(pipe);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -116,20 +116,29 @@
|
|||||||
- sprite: Structures/Piping/Atmospherics/pipe.rsi
|
- sprite: Structures/Piping/Atmospherics/pipe.rsi
|
||||||
state: pipeStraight
|
state: pipeStraight
|
||||||
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
||||||
- state: pumpPassiveGate
|
- state: pumpManualValve
|
||||||
map: [ "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer" ]
|
map: [ "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer", "enum.GasValveVisualizer+Layers.Enabled" ]
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
visuals:
|
||||||
- type: SubFloorShowLayerVisualizer
|
- type: SubFloorShowLayerVisualizer
|
||||||
- type: PipeConnectorVisualizer
|
- type: PipeConnectorVisualizer
|
||||||
- type: PipeColorVisualizer
|
- type: PipeColorVisualizer
|
||||||
|
- type: GasValveVisualizer
|
||||||
|
disabledState: pumpManualValve
|
||||||
|
enabledState: pumpManualValveOn
|
||||||
- type: GasValve
|
- type: GasValve
|
||||||
- type: NodeContainer
|
- type: NodeContainer
|
||||||
nodes:
|
nodes:
|
||||||
pipe:
|
inlet:
|
||||||
!type:PipeNode
|
!type:PipeNode
|
||||||
nodeGroupID: Pipe
|
nodeGroupID: Pipe
|
||||||
pipeDirection: Longitudinal
|
pipeDirection: North
|
||||||
|
volume: 100
|
||||||
|
outlet:
|
||||||
|
!type:PipeNode
|
||||||
|
nodeGroupID: Pipe
|
||||||
|
pipeDirection: South
|
||||||
|
volume: 100
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: GasBinaryBase
|
parent: GasBinaryBase
|
||||||
|
|||||||
@@ -15,6 +15,10 @@
|
|||||||
"name":"pumpManualValve",
|
"name":"pumpManualValve",
|
||||||
"directions":4
|
"directions":4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name":"pumpManualValveOn",
|
||||||
|
"directions":4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name":"pumpPassiveGate",
|
"name":"pumpPassiveGate",
|
||||||
"directions":4
|
"directions":4
|
||||||
@@ -42,4 +46,4 @@
|
|||||||
"delays":[ [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ], [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ], [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ], [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ] ]
|
"delays":[ [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ], [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ], [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ], [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ] ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Reference in New Issue
Block a user