* PipeNode * Pipe prototypes * Fixes Default NodeGroup not being registered by NodeGroupFactory * GasNet * PumpComponent * IPipeNet * PipeComponent * misc naming, yaml * PipeComponent rework * PipeNet gas transfer from pipes * PipeNet correctly combines gas on combining with other group * Client ignores piping components * AfterRemake * PipeNet remake simplification * IGasMixtureHolder on PipeComponent, IPipeNet * PipeContainerComponent * BasePump * DebugPump * IgnoredComponent fix * Pipe LocalAir and Air * comments * Pump fix * PipeNet fix * name simplification * PipeDirection name changes * BaseVentComponent and DebugVentComponent * Moves Pipe to own file * DebugVentComponent moved to own file * BaseScrubberComponent * DebugScrubberComponent * IgnoredComponents update * scrubber prototype * vent prototype fix * comments * Removes vent and scrubber PipeDirection check * PipeContainer, Pipe, and PipeNode refactor * Yaml cleanup * pump prototype fix * Removes AssumeAir usage from old IGasMixtureHolders * Simplfies Vent & Scrubber to use AtmosHelper methods * Vents and scrubbers invalidate the coordinate they changed the gas of * UpdatedPipingComponent * ScrubberComponent renamed to SiphonComponent * Removes PumpSystem * Removes framTime from UpdatedPiping * PipeNetDevices * PipeNetDevice updated by GridAtmosphereComponent * PipeNets react from update in GridAtmosphereComponent * GridAtmosphereComponent stores PipeNets/PipeNetDevices to be updated in queue * diff fix * Removes debug gas starting in pipes * type safety in IPipeNet when combining groups * null checks * GridAtmos stores PipeNets and PipeNetDevices in List * comments * rogue curly bracket * ProcessPipeNets update fix * RemovePipeNet fix * PipeNet update() unique index * fix diff * Integration test fixes * Error Logging * error fix Co-authored-by: py01 <pyronetics01@gmail.com>
101 lines
2.9 KiB
C#
101 lines
2.9 KiB
C#
using Content.Server.Atmos;
|
|
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
|
|
using Content.Server.GameObjects.EntitySystems;
|
|
using Content.Server.Interfaces;
|
|
using Robust.Shared.GameObjects.Systems;
|
|
using Robust.Shared.ViewVariables;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups
|
|
{
|
|
public interface IPipeNet : IGasMixtureHolder
|
|
{
|
|
/// <summary>
|
|
/// Causes gas in the PipeNet to react.
|
|
/// </summary>
|
|
void Update();
|
|
}
|
|
|
|
[NodeGroup(NodeGroupID.Pipe)]
|
|
public class PipeNet : BaseNodeGroup, IPipeNet
|
|
{
|
|
[ViewVariables]
|
|
public GasMixture Air { get; set; } = new GasMixture();
|
|
|
|
public static readonly IPipeNet NullNet = new NullPipeNet();
|
|
|
|
[ViewVariables]
|
|
private readonly List<PipeNode> _pipes = new List<PipeNode>();
|
|
|
|
[ViewVariables]
|
|
private IGridAtmosphereComponent _gridAtmos;
|
|
|
|
public override void Initialize(Node sourceNode)
|
|
{
|
|
base.Initialize(sourceNode);
|
|
_gridAtmos = EntitySystem.Get<AtmosphereSystem>()
|
|
.GetGridAtmosphere(GridId);
|
|
_gridAtmos?.AddPipeNet(this);
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
Air.React(this);
|
|
}
|
|
|
|
protected override void OnAddNode(Node node)
|
|
{
|
|
if (!(node is PipeNode pipeNode))
|
|
return;
|
|
_pipes.Add(pipeNode);
|
|
pipeNode.JoinPipeNet(this);
|
|
Air.Volume += pipeNode.Volume;
|
|
Air.Merge(pipeNode.LocalAir);
|
|
pipeNode.LocalAir.Clear();
|
|
}
|
|
|
|
protected override void OnRemoveNode(Node node)
|
|
{
|
|
RemoveFromGridAtmos();
|
|
if (!(node is PipeNode pipeNode))
|
|
return;
|
|
var pipeAir = pipeNode.LocalAir;
|
|
pipeAir.Merge(Air);
|
|
pipeAir.Multiply(pipeNode.Volume / Air.Volume);
|
|
_pipes.Remove(pipeNode);
|
|
}
|
|
|
|
protected override void OnGivingNodesForCombine(INodeGroup newGroup)
|
|
{
|
|
if (!(newGroup is IPipeNet newPipeNet))
|
|
return;
|
|
newPipeNet.Air.Merge(Air);
|
|
Air.Clear();
|
|
}
|
|
|
|
protected override void AfterRemake(IEnumerable<INodeGroup> newGroups)
|
|
{
|
|
foreach (var newGroup in newGroups)
|
|
{
|
|
if (!(newGroup is IPipeNet newPipeNet))
|
|
continue;
|
|
newPipeNet.Air.Merge(Air);
|
|
var newPipeNetGas = newPipeNet.Air;
|
|
newPipeNetGas.Multiply(newPipeNetGas.Volume / Air.Volume);
|
|
}
|
|
RemoveFromGridAtmos();
|
|
}
|
|
|
|
private void RemoveFromGridAtmos()
|
|
{
|
|
_gridAtmos.RemovePipeNet(this);
|
|
}
|
|
|
|
private class NullPipeNet : IPipeNet
|
|
{
|
|
GasMixture IGasMixtureHolder.Air { get; set; } = new GasMixture();
|
|
public void Update() { }
|
|
}
|
|
}
|
|
}
|