Merge branch 'master' into 2020-08-19-firelocks
# Conflicts: # Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs # Content.Shared/Maps/TurfHelpers.cs # SpaceStation14.sln.DotSettings
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Server.Interfaces.GameObjects.Components.Items;
|
||||
using Content.Server.Utility;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.GameObjects.Components;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.Interfaces;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Server.GameObjects.Components.UserInterface;
|
||||
using Robust.Server.Interfaces.GameObjects;
|
||||
@@ -24,7 +24,6 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
[RegisterComponent]
|
||||
public class GasAnalyzerComponent : SharedGasAnalyzerComponent, IAfterInteract, IDropped, IUse
|
||||
{
|
||||
[Dependency] private readonly IServerNotifyManager _notifyManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
private GasAnalyzerDanger _pressureDanger;
|
||||
@@ -207,17 +206,14 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
|
||||
if (!player.TryGetComponent(out IHandsComponent? handsComponent))
|
||||
{
|
||||
_notifyManager.PopupMessage(Owner.Transform.GridPosition, player,
|
||||
Loc.GetString("You have no hands."));
|
||||
Owner.PopupMessage(player, Loc.GetString("You have no hands."));
|
||||
return;
|
||||
}
|
||||
|
||||
var activeHandEntity = handsComponent.GetActiveHand?.Owner;
|
||||
if (activeHandEntity == null || !activeHandEntity.TryGetComponent(out GasAnalyzerComponent? gasAnalyzer))
|
||||
{
|
||||
_notifyManager.PopupMessage(serverMsg.Session.AttachedEntity,
|
||||
serverMsg.Session.AttachedEntity,
|
||||
Loc.GetString("You need a Gas Analyzer in your hand!"));
|
||||
serverMsg.Session.AttachedEntity.PopupMessage(Loc.GetString("You need a Gas Analyzer in your hand!"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -231,7 +227,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
{
|
||||
if (!eventArgs.CanReach)
|
||||
{
|
||||
_notifyManager.PopupMessage(eventArgs.User, eventArgs.User, Loc.GetString("You can't reach there!"));
|
||||
eventArgs.User.PopupMessage(Loc.GetString("You can't reach there!"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,7 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components.Map;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.Interfaces.Timing;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.ViewVariables;
|
||||
@@ -32,6 +29,8 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
public class GridAtmosphereComponent : Component, IGridAtmosphereComponent
|
||||
{
|
||||
[Robust.Shared.IoC.Dependency] private IMapManager _mapManager = default!;
|
||||
[Robust.Shared.IoC.Dependency] private ITileDefinitionManager _tileDefinitionManager = default!;
|
||||
[Robust.Shared.IoC.Dependency] private IServerEntityManager _serverEntityManager = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Check current execution time every n instances processed.
|
||||
@@ -70,7 +69,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
private double _excitedGroupLastProcess;
|
||||
|
||||
[ViewVariables]
|
||||
private readonly Dictionary<MapIndices, TileAtmosphere> _tiles = new Dictionary<MapIndices, TileAtmosphere>(1000);
|
||||
protected readonly Dictionary<MapIndices, TileAtmosphere> Tiles = new Dictionary<MapIndices, TileAtmosphere>(1000);
|
||||
|
||||
[ViewVariables]
|
||||
private readonly HashSet<TileAtmosphere> _activeTiles = new HashSet<TileAtmosphere>(1000);
|
||||
@@ -154,23 +153,13 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void PryTile(MapIndices indices)
|
||||
public virtual void PryTile(MapIndices indices)
|
||||
{
|
||||
if (!Owner.TryGetComponent(out IMapGridComponent? mapGridComponent)) return;
|
||||
if (IsSpace(indices) || IsAirBlocked(indices)) return;
|
||||
|
||||
var mapGrid = mapGridComponent.Grid;
|
||||
var tile = mapGrid.GetTileRef(indices).Tile;
|
||||
|
||||
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
|
||||
var tileDef = (ContentTileDefinition)tileDefinitionManager[tile.TypeId];
|
||||
|
||||
var underplating = tileDefinitionManager["underplating"];
|
||||
mapGrid.SetTile(indices, new Tile(underplating.TileId));
|
||||
|
||||
//Actually spawn the relevant tile item at the right position and give it some offset to the corner.
|
||||
var tileItem = IoCManager.Resolve<IServerEntityManager>().SpawnEntity(tileDef.ItemDropPrototypeName, new GridCoordinates(indices.X, indices.Y, mapGrid));
|
||||
tileItem.Transform.WorldPosition += (0.2f, 0.2f);
|
||||
indices.PryTile(mapGrid.Index, _mapManager, _tileDefinitionManager, _serverEntityManager);
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
@@ -185,17 +174,17 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
RepopulateTiles();
|
||||
}
|
||||
|
||||
public void RepopulateTiles()
|
||||
public virtual void RepopulateTiles()
|
||||
{
|
||||
if (!Owner.TryGetComponent(out IMapGridComponent? mapGrid)) return;
|
||||
|
||||
foreach (var tile in mapGrid.Grid.GetAllTiles())
|
||||
{
|
||||
if(!_tiles.ContainsKey(tile.GridIndices))
|
||||
_tiles.Add(tile.GridIndices, new TileAtmosphere(this, tile.GridIndex, tile.GridIndices, new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.T20C}));
|
||||
if(!Tiles.ContainsKey(tile.GridIndices))
|
||||
Tiles.Add(tile.GridIndices, new TileAtmosphere(this, tile.GridIndex, tile.GridIndices, new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.T20C}));
|
||||
}
|
||||
|
||||
foreach (var (_, tile) in _tiles.ToArray())
|
||||
foreach (var (_, tile) in Tiles.ToArray())
|
||||
{
|
||||
tile.UpdateAdjacent();
|
||||
tile.UpdateVisuals();
|
||||
@@ -203,12 +192,12 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Invalidate(MapIndices indices)
|
||||
public virtual void Invalidate(MapIndices indices)
|
||||
{
|
||||
_invalidatedCoords.Add(indices);
|
||||
}
|
||||
|
||||
private void Revalidate()
|
||||
protected virtual void Revalidate()
|
||||
{
|
||||
if (!Owner.TryGetComponent(out IMapGridComponent? mapGrid)) return;
|
||||
|
||||
@@ -219,14 +208,14 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
if (tile == null)
|
||||
{
|
||||
tile = new TileAtmosphere(this, mapGrid.Grid.Index, indices, new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.T20C});
|
||||
_tiles[indices] = tile;
|
||||
Tiles[indices] = tile;
|
||||
}
|
||||
|
||||
if (IsSpace(indices))
|
||||
{
|
||||
tile.Air = new GasMixture(GetVolumeForCells(1));
|
||||
tile.Air.MarkImmutable();
|
||||
_tiles[indices] = tile;
|
||||
Tiles[indices] = tile;
|
||||
|
||||
} else if (IsAirBlocked(indices))
|
||||
{
|
||||
@@ -271,18 +260,18 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void FixVacuum(MapIndices indices)
|
||||
public virtual void FixVacuum(MapIndices indices)
|
||||
{
|
||||
if (!Owner.TryGetComponent(out IMapGridComponent? mapGrid)) return;
|
||||
var tile = GetTile(indices);
|
||||
if (tile?.GridIndex != mapGrid.Grid.Index) return;
|
||||
var adjacent = GetAdjacentTiles(indices);
|
||||
tile.Air = new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.T20C};
|
||||
_tiles[indices] = tile;
|
||||
Tiles[indices] = tile;
|
||||
|
||||
var ratio = 1f / adjacent.Count;
|
||||
|
||||
foreach (var (direction, adj) in adjacent)
|
||||
foreach (var (_, adj) in adjacent)
|
||||
{
|
||||
var mix = adj.Air.RemoveRatio(ratio);
|
||||
tile.Air.Merge(mix);
|
||||
@@ -292,17 +281,17 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddActiveTile(TileAtmosphere? tile)
|
||||
public virtual void AddActiveTile(TileAtmosphere? tile)
|
||||
{
|
||||
if (!Owner.TryGetComponent(out IMapGridComponent? mapGrid)) return;
|
||||
if (tile?.GridIndex != mapGrid.Grid.Index || tile?.Air == null) return;
|
||||
if (tile?.GridIndex != mapGrid.Grid.Index) return;
|
||||
tile.Excited = true;
|
||||
_activeTiles.Add(tile);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void RemoveActiveTile(TileAtmosphere? tile)
|
||||
public virtual void RemoveActiveTile(TileAtmosphere? tile)
|
||||
{
|
||||
if (tile == null) return;
|
||||
_activeTiles.Remove(tile);
|
||||
@@ -312,7 +301,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHotspotTile(TileAtmosphere? tile)
|
||||
public virtual void AddHotspotTile(TileAtmosphere? tile)
|
||||
{
|
||||
if (!Owner.TryGetComponent(out IMapGridComponent? mapGrid)) return;
|
||||
if (tile?.GridIndex != mapGrid.Grid.Index || tile?.Air == null) return;
|
||||
@@ -321,20 +310,20 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void RemoveHotspotTile(TileAtmosphere? tile)
|
||||
public virtual void RemoveHotspotTile(TileAtmosphere? tile)
|
||||
{
|
||||
if (tile == null) return;
|
||||
_hotspotTiles.Remove(tile);
|
||||
}
|
||||
|
||||
public void AddSuperconductivityTile(TileAtmosphere? tile)
|
||||
public virtual void AddSuperconductivityTile(TileAtmosphere? tile)
|
||||
{
|
||||
if (!Owner.TryGetComponent(out IMapGridComponent? mapGrid)) return;
|
||||
if (tile?.GridIndex != mapGrid.Grid.Index) return;
|
||||
_superconductivityTiles.Add(tile);
|
||||
}
|
||||
|
||||
public void RemoveSuperconductivityTile(TileAtmosphere? tile)
|
||||
public virtual void RemoveSuperconductivityTile(TileAtmosphere? tile)
|
||||
{
|
||||
if (tile == null) return;
|
||||
_superconductivityTiles.Remove(tile);
|
||||
@@ -342,7 +331,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHighPressureDelta(TileAtmosphere? tile)
|
||||
public virtual void AddHighPressureDelta(TileAtmosphere? tile)
|
||||
{
|
||||
if (!Owner.TryGetComponent(out IMapGridComponent? mapGrid)) return;
|
||||
if (tile?.GridIndex != mapGrid.Grid.Index) return;
|
||||
@@ -351,21 +340,21 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool HasHighPressureDelta(TileAtmosphere tile)
|
||||
public virtual bool HasHighPressureDelta(TileAtmosphere tile)
|
||||
{
|
||||
return _highPressureDelta.Contains(tile);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddExcitedGroup(ExcitedGroup excitedGroup)
|
||||
public virtual void AddExcitedGroup(ExcitedGroup excitedGroup)
|
||||
{
|
||||
_excitedGroups.Add(excitedGroup);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void RemoveExcitedGroup(ExcitedGroup excitedGroup)
|
||||
public virtual void RemoveExcitedGroup(ExcitedGroup excitedGroup)
|
||||
{
|
||||
_excitedGroups.Remove(excitedGroup);
|
||||
}
|
||||
@@ -401,7 +390,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
{
|
||||
if (!Owner.TryGetComponent(out IMapGridComponent? mapGrid)) return null;
|
||||
|
||||
if (_tiles.TryGetValue(indices, out var tile)) return tile;
|
||||
if (Tiles.TryGetValue(indices, out var tile)) return tile;
|
||||
|
||||
// We don't have that tile!
|
||||
if (IsSpace(indices) && createSpace)
|
||||
@@ -454,7 +443,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Update(float frameTime)
|
||||
public virtual void Update(float frameTime)
|
||||
{
|
||||
_timer += frameTime;
|
||||
|
||||
@@ -554,7 +543,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
UpdateCounter++;
|
||||
}
|
||||
|
||||
public bool ProcessTileEqualize(bool resumed = false)
|
||||
public virtual bool ProcessTileEqualize(bool resumed = false)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
|
||||
@@ -581,7 +570,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ProcessActiveTiles(bool resumed = false)
|
||||
public virtual bool ProcessActiveTiles(bool resumed = false)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
|
||||
@@ -608,7 +597,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ProcessExcitedGroups(bool resumed = false)
|
||||
public virtual bool ProcessExcitedGroups(bool resumed = false)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
|
||||
@@ -642,7 +631,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ProcessHighPressureDelta(bool resumed = false)
|
||||
public virtual bool ProcessHighPressureDelta(bool resumed = false)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
|
||||
@@ -672,7 +661,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ProcessHotspots(bool resumed = false)
|
||||
protected virtual bool ProcessHotspots(bool resumed = false)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
|
||||
@@ -699,7 +688,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ProcessSuperconductivity(bool resumed = false)
|
||||
protected virtual bool ProcessSuperconductivity(bool resumed = false)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
|
||||
@@ -726,7 +715,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ProcessPipeNets(bool resumed = false)
|
||||
protected virtual bool ProcessPipeNets(bool resumed = false)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
|
||||
@@ -753,7 +742,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ProcessPipeNetDevices(bool resumed = false)
|
||||
protected virtual bool ProcessPipeNetDevices(bool resumed = false)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
|
||||
@@ -761,7 +750,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
_currentRunPipeNetDevice = new Queue<PipeNetDeviceComponent>(_pipeNetDevices);
|
||||
|
||||
var number = 0;
|
||||
while (_currentRunPipeNet.Count > 0)
|
||||
while (_currentRunPipeNetDevice.Count > 0)
|
||||
{
|
||||
var device = _currentRunPipeNetDevice.Dequeue();
|
||||
device.Update();
|
||||
@@ -810,11 +799,11 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
!serializer.TryReadDataField("tiles", out Dictionary<MapIndices, int>? tiles))
|
||||
return;
|
||||
|
||||
_tiles.Clear();
|
||||
Tiles.Clear();
|
||||
|
||||
foreach (var (indices, mix) in tiles!)
|
||||
{
|
||||
_tiles.Add(indices, new TileAtmosphere(this, gridId, indices, (GasMixture)uniqueMixes![mix].Clone()));
|
||||
Tiles.Add(indices, new TileAtmosphere(this, gridId, indices, (GasMixture)uniqueMixes![mix].Clone()));
|
||||
Invalidate(indices);
|
||||
}
|
||||
}
|
||||
@@ -823,7 +812,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
var uniqueMixes = new List<GasMixture>();
|
||||
var uniqueMixHash = new Dictionary<GasMixture, int>();
|
||||
var tiles = new Dictionary<MapIndices, int>();
|
||||
foreach (var (indices, tile) in _tiles)
|
||||
foreach (var (indices, tile) in Tiles)
|
||||
{
|
||||
if (tile.Air == null) continue;
|
||||
|
||||
@@ -846,7 +835,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
|
||||
public IEnumerator<TileAtmosphere> GetEnumerator()
|
||||
{
|
||||
return _tiles.Values.GetEnumerator();
|
||||
return Tiles.Values.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
@@ -855,7 +844,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void BurnTile(MapIndices gridIndices)
|
||||
public virtual void BurnTile(MapIndices gridIndices)
|
||||
{
|
||||
// TODO ATMOS
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.GameObjects.Components.NodeContainer;
|
||||
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
|
||||
using Content.Shared.GameObjects.Components.Atmos;
|
||||
using Content.Shared.GameObjects.Atmos;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
@@ -13,6 +16,21 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
|
||||
/// </summary>
|
||||
public abstract class BasePumpComponent : PipeNetDeviceComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// If the pump is currently pumping.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool PumpEnabled
|
||||
{
|
||||
get => _pumpEnabled;
|
||||
set
|
||||
{
|
||||
_pumpEnabled = value;
|
||||
UpdateAppearance();
|
||||
}
|
||||
}
|
||||
private bool _pumpEnabled = true;
|
||||
|
||||
/// <summary>
|
||||
/// Needs to be same <see cref="PipeDirection"/> as that of a <see cref="Pipe"/> on this entity.
|
||||
/// </summary>
|
||||
@@ -31,6 +49,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
|
||||
[ViewVariables]
|
||||
private PipeNode _outletPipe;
|
||||
|
||||
private AppearanceComponent _appearance;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
@@ -56,13 +76,23 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
|
||||
Logger.Error($"{typeof(BasePumpComponent)} on entity {Owner.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}.");
|
||||
return;
|
||||
}
|
||||
Owner.TryGetComponent(out _appearance);
|
||||
UpdateAppearance();
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (!PumpEnabled)
|
||||
return;
|
||||
|
||||
PumpGas(_inletPipe.Air, _outletPipe.Air);
|
||||
}
|
||||
|
||||
protected abstract void PumpGas(GasMixture inletGas, GasMixture outletGas);
|
||||
|
||||
private void UpdateAppearance()
|
||||
{
|
||||
_appearance?.SetData(PumpVisuals.VisualState, new PumpVisualState(_inletDirection, _outletDirection, _inletPipe.ConduitLayer, _outletPipe.ConduitLayer, PumpEnabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
using Content.Server.Atmos;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Atmos.Piping
|
||||
{
|
||||
/// <summary>
|
||||
/// Placeholder example of pump functionality.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(BasePumpComponent))]
|
||||
public class DebugPumpComponent : BasePumpComponent
|
||||
{
|
||||
public override string Name => "DebugPump";
|
||||
|
||||
protected override void PumpGas(GasMixture inletGas, GasMixture outletGas)
|
||||
{
|
||||
outletGas.Merge(inletGas);
|
||||
inletGas.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using Content.Server.Atmos;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using System;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Atmos.Piping.Pumps
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(BasePumpComponent))]
|
||||
public class PressurePumpComponent : BasePumpComponent
|
||||
{
|
||||
public override string Name => "PressurePump";
|
||||
|
||||
/// <summary>
|
||||
/// The pressure this pump will try to bring its oulet too.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public int PressurePumpTarget
|
||||
{
|
||||
get => _pressurePumpTarget;
|
||||
set => _pressurePumpTarget = Math.Clamp(value, 0, MaxPressurePumpTarget);
|
||||
}
|
||||
private int _pressurePumpTarget;
|
||||
|
||||
/// <summary>
|
||||
/// Max value <see cref="PressurePumpTarget"/> can be set to.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public int MaxPressurePumpTarget
|
||||
{
|
||||
get => _maxPressurePumpTarget;
|
||||
set => Math.Max(value, 0);
|
||||
}
|
||||
private int _maxPressurePumpTarget;
|
||||
|
||||
/// <summary>
|
||||
/// Every upate, this pump will only increase the outlet pressure by this fraction of the amount needed to reach the <see cref="PressurePumpTarget"/>.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float TransferRatio
|
||||
{
|
||||
get => _transferRatio;
|
||||
set => _transferRatio = Math.Clamp(value, 0, 1);
|
||||
}
|
||||
private float _transferRatio;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(ref _pressurePumpTarget, "startingPressurePumpTarget", 0);
|
||||
serializer.DataField(ref _maxPressurePumpTarget, "maxPressurePumpTarget", 100);
|
||||
serializer.DataField(ref _transferRatio, "transferRatio", 0.5f);
|
||||
}
|
||||
|
||||
protected override void PumpGas(GasMixture inletGas, GasMixture outletGas)
|
||||
{
|
||||
var goalDiff = PressurePumpTarget - outletGas.Pressure;
|
||||
var realGoalPressureDiff = goalDiff * TransferRatio;
|
||||
var realTargetPressure = outletGas.Pressure + realGoalPressureDiff;
|
||||
var realCappedTargetPressure = Math.Max(realTargetPressure, outletGas.Pressure); //no lowering the outlet's pressure
|
||||
inletGas.PumpGasTo(outletGas, realCappedTargetPressure);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using Content.Server.Atmos;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Atmos.Piping.Pumps
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(BasePumpComponent))]
|
||||
public class VolumePumpComponent : BasePumpComponent
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public int VolumePumpRate
|
||||
{
|
||||
get => _volumePumpRate;
|
||||
set => _volumePumpRate = Math.Clamp(value, 0, MaxVolumePumpRate);
|
||||
}
|
||||
private int _volumePumpRate;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public int MaxVolumePumpRate
|
||||
{
|
||||
get => _maxVolumePumpRate;
|
||||
set => Math.Max(value, 0);
|
||||
}
|
||||
private int _maxVolumePumpRate;
|
||||
|
||||
public override string Name => "VolumePump";
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(ref _volumePumpRate, "startingVolumePumpRate", 0);
|
||||
serializer.DataField(ref _maxVolumePumpRate, "maxVolumePumpRate", 100);
|
||||
}
|
||||
|
||||
protected override void PumpGas(GasMixture inletGas, GasMixture outletGas)
|
||||
{
|
||||
var volumeRatio = Math.Clamp(VolumePumpRate / inletGas.Volume, 0, 1);
|
||||
outletGas.Merge(inletGas.RemoveRatio(volumeRatio));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components.Map;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Atmos
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(IGridAtmosphereComponent))]
|
||||
[ComponentReference(typeof(GridAtmosphereComponent))]
|
||||
[Serializable]
|
||||
public class UnsimulatedGridAtmosphereComponent : GridAtmosphereComponent, IGridAtmosphereComponent
|
||||
{
|
||||
public override string Name => "UnsimulatedGridAtmosphere";
|
||||
|
||||
public override void PryTile(MapIndices indices) { }
|
||||
|
||||
public override void RepopulateTiles()
|
||||
{
|
||||
if (!Owner.TryGetComponent(out IMapGridComponent? mapGrid)) return;
|
||||
|
||||
foreach (var tile in mapGrid.Grid.GetAllTiles())
|
||||
{
|
||||
if(!Tiles.ContainsKey(tile.GridIndices))
|
||||
Tiles.Add(tile.GridIndices, new TileAtmosphere(this, tile.GridIndex, tile.GridIndices, new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.T20C}));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Invalidate(MapIndices indices) { }
|
||||
|
||||
protected override void Revalidate() { }
|
||||
|
||||
public override void FixVacuum(MapIndices indices) { }
|
||||
|
||||
public override void AddActiveTile(TileAtmosphere? tile) { }
|
||||
|
||||
public override void RemoveActiveTile(TileAtmosphere? tile) { }
|
||||
|
||||
public override void AddHotspotTile(TileAtmosphere? tile) { }
|
||||
|
||||
public override void RemoveHotspotTile(TileAtmosphere? tile) { }
|
||||
|
||||
public override void AddSuperconductivityTile(TileAtmosphere? tile) { }
|
||||
|
||||
public override void RemoveSuperconductivityTile(TileAtmosphere? tile) { }
|
||||
|
||||
public override void AddHighPressureDelta(TileAtmosphere? tile) { }
|
||||
|
||||
public override bool HasHighPressureDelta(TileAtmosphere tile)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void AddExcitedGroup(ExcitedGroup excitedGroup) { }
|
||||
|
||||
public override void RemoveExcitedGroup(ExcitedGroup excitedGroup) { }
|
||||
|
||||
public override void Update(float frameTime) { }
|
||||
|
||||
public override bool ProcessTileEqualize(bool resumed = false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool ProcessActiveTiles(bool resumed = false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool ProcessExcitedGroups(bool resumed = false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool ProcessHighPressureDelta(bool resumed = false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override bool ProcessHotspots(bool resumed = false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override bool ProcessSuperconductivity(bool resumed = false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override bool ProcessPipeNets(bool resumed = false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override bool ProcessPipeNetDevices(bool resumed = false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user