diff --git a/Content.IntegrationTests/Tests/Lobby/CharacterCreationTest.cs b/Content.IntegrationTests/Tests/Lobby/CharacterCreationTest.cs index fcae9955d8..461a1fc30b 100644 --- a/Content.IntegrationTests/Tests/Lobby/CharacterCreationTest.cs +++ b/Content.IntegrationTests/Tests/Lobby/CharacterCreationTest.cs @@ -4,7 +4,6 @@ using Content.Client.Lobby; using Content.Client.Preferences; using Content.Client.State; using Content.Server.GameTicking; -using Content.Server.Interfaces; using Content.Server.Preferences; using Content.Server.Preferences.Managers; using Content.Shared; diff --git a/Content.Server/Administration/Commands/SetAdminOOC.cs b/Content.Server/Administration/Commands/SetAdminOOC.cs index 7dc3544e72..20e69eb341 100644 --- a/Content.Server/Administration/Commands/SetAdminOOC.cs +++ b/Content.Server/Administration/Commands/SetAdminOOC.cs @@ -1,6 +1,5 @@ using Content.Server.Database; -using Content.Server.Interfaces; using Content.Server.Preferences.Managers; using Content.Shared.Administration; using Robust.Server.Player; diff --git a/Content.Server/Administration/Commands/SetOutfitCommand.cs b/Content.Server/Administration/Commands/SetOutfitCommand.cs index 9b46a69610..6337a9fb05 100644 --- a/Content.Server/Administration/Commands/SetOutfitCommand.cs +++ b/Content.Server/Administration/Commands/SetOutfitCommand.cs @@ -1,6 +1,5 @@ using Content.Server.Administration.UI; using Content.Server.EUI; -using Content.Server.Interfaces; using Content.Server.Inventory.Components; using Content.Server.Items; using Content.Server.PDA; diff --git a/Content.Server/Commands/Atmos/AddAtmosCommand.cs b/Content.Server/Atmos/Commands/AddAtmosCommand.cs similarity index 97% rename from Content.Server/Commands/Atmos/AddAtmosCommand.cs rename to Content.Server/Atmos/Commands/AddAtmosCommand.cs index 16304113a8..4759998b1a 100644 --- a/Content.Server/Commands/Atmos/AddAtmosCommand.cs +++ b/Content.Server/Atmos/Commands/AddAtmosCommand.cs @@ -6,7 +6,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Map; -namespace Content.Server.Commands.Atmos +namespace Content.Server.Atmos.Commands { [AdminCommand(AdminFlags.Debug)] public class AddAtmosCommand : IConsoleCommand diff --git a/Content.Server/Commands/Atmos/AddGasCommand.cs b/Content.Server/Atmos/Commands/AddGasCommand.cs similarity index 93% rename from Content.Server/Commands/Atmos/AddGasCommand.cs rename to Content.Server/Atmos/Commands/AddGasCommand.cs index f8c96ff37c..61438b748f 100644 --- a/Content.Server/Commands/Atmos/AddGasCommand.cs +++ b/Content.Server/Atmos/Commands/AddGasCommand.cs @@ -1,15 +1,13 @@ using Content.Server.Administration; -using Content.Server.Atmos.Components; using Content.Server.Atmos.EntitySystems; using Content.Shared.Administration; using Content.Shared.Atmos; using Robust.Shared.Console; using Robust.Shared.GameObjects; -using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; -namespace Content.Server.Commands.Atmos +namespace Content.Server.Atmos.Commands { [AdminCommand(AdminFlags.Debug)] public class AddGasCommand : IConsoleCommand diff --git a/Content.Server/Commands/Atmos/AddUnsimulatedAtmosCommand.cs b/Content.Server/Atmos/Commands/AddUnsimulatedAtmosCommand.cs similarity index 97% rename from Content.Server/Commands/Atmos/AddUnsimulatedAtmosCommand.cs rename to Content.Server/Atmos/Commands/AddUnsimulatedAtmosCommand.cs index 442012da7f..67541a5361 100644 --- a/Content.Server/Commands/Atmos/AddUnsimulatedAtmosCommand.cs +++ b/Content.Server/Atmos/Commands/AddUnsimulatedAtmosCommand.cs @@ -6,7 +6,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Map; -namespace Content.Server.Commands.Atmos +namespace Content.Server.Atmos.Commands { [AdminCommand(AdminFlags.Debug)] public class AddUnsimulatedAtmosCommand : IConsoleCommand diff --git a/Content.Server/Commands/Atmos/DeleteGasCommand.cs b/Content.Server/Atmos/Commands/DeleteGasCommand.cs similarity index 98% rename from Content.Server/Commands/Atmos/DeleteGasCommand.cs rename to Content.Server/Atmos/Commands/DeleteGasCommand.cs index 4a318e5e9b..a06da56564 100644 --- a/Content.Server/Commands/Atmos/DeleteGasCommand.cs +++ b/Content.Server/Atmos/Commands/DeleteGasCommand.cs @@ -1,6 +1,5 @@ using System; using Content.Server.Administration; -using Content.Server.Atmos.Components; using Content.Server.Atmos.EntitySystems; using Content.Shared.Administration; using Content.Shared.Atmos; @@ -10,7 +9,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Map; -namespace Content.Server.Commands.Atmos +namespace Content.Server.Atmos.Commands { [AdminCommand(AdminFlags.Debug)] public class DeleteGasCommand : IConsoleCommand diff --git a/Content.Server/Commands/Atmos/FillGasCommand.cs b/Content.Server/Atmos/Commands/FillGasCommand.cs similarity index 94% rename from Content.Server/Commands/Atmos/FillGasCommand.cs rename to Content.Server/Atmos/Commands/FillGasCommand.cs index e133200bc8..d2b25313fc 100644 --- a/Content.Server/Commands/Atmos/FillGasCommand.cs +++ b/Content.Server/Atmos/Commands/FillGasCommand.cs @@ -1,5 +1,4 @@ using Content.Server.Administration; -using Content.Server.Atmos.Components; using Content.Server.Atmos.EntitySystems; using Content.Shared.Administration; using Content.Shared.Atmos; @@ -8,7 +7,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Map; -namespace Content.Server.Commands.Atmos +namespace Content.Server.Atmos.Commands { [AdminCommand(AdminFlags.Debug)] public class FillGas : IConsoleCommand diff --git a/Content.Server/Commands/Atmos/FixGridAtmos.cs b/Content.Server/Atmos/Commands/FixGridAtmos.cs similarity index 95% rename from Content.Server/Commands/Atmos/FixGridAtmos.cs rename to Content.Server/Atmos/Commands/FixGridAtmos.cs index e41570e781..0d49cc5fcb 100644 --- a/Content.Server/Commands/Atmos/FixGridAtmos.cs +++ b/Content.Server/Atmos/Commands/FixGridAtmos.cs @@ -1,6 +1,4 @@ using Content.Server.Administration; -using Content.Server.Atmos; -using Content.Server.Atmos.Components; using Content.Server.Atmos.EntitySystems; using Content.Shared.Administration; using Content.Shared.Atmos; @@ -9,7 +7,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Map; -namespace Content.Server.Commands.Atmos +namespace Content.Server.Atmos.Commands { [AdminCommand(AdminFlags.Debug)] public class FixGridAtmos : IConsoleCommand diff --git a/Content.Server/Commands/Atmos/ListGasesCommand.cs b/Content.Server/Atmos/Commands/ListGasesCommand.cs similarity index 95% rename from Content.Server/Commands/Atmos/ListGasesCommand.cs rename to Content.Server/Atmos/Commands/ListGasesCommand.cs index 3694b3e2a5..6fad4670fe 100644 --- a/Content.Server/Commands/Atmos/ListGasesCommand.cs +++ b/Content.Server/Atmos/Commands/ListGasesCommand.cs @@ -4,7 +4,7 @@ using Content.Shared.Administration; using Robust.Shared.Console; using Robust.Shared.GameObjects; -namespace Content.Server.Commands.Atmos +namespace Content.Server.Atmos.Commands { [AdminCommand(AdminFlags.Debug)] public class ListGasesCommand : IConsoleCommand diff --git a/Content.Server/Commands/Atmos/RemoveGasCommand.cs b/Content.Server/Atmos/Commands/RemoveGasCommand.cs similarity index 93% rename from Content.Server/Commands/Atmos/RemoveGasCommand.cs rename to Content.Server/Atmos/Commands/RemoveGasCommand.cs index 206aeb1f54..bd5cee5a7b 100644 --- a/Content.Server/Commands/Atmos/RemoveGasCommand.cs +++ b/Content.Server/Atmos/Commands/RemoveGasCommand.cs @@ -1,14 +1,12 @@ using Content.Server.Administration; -using Content.Server.Atmos.Components; using Content.Server.Atmos.EntitySystems; using Content.Shared.Administration; using Robust.Shared.Console; using Robust.Shared.GameObjects; -using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; -namespace Content.Server.Commands.Atmos +namespace Content.Server.Atmos.Commands { [AdminCommand(AdminFlags.Debug)] public class RemoveGasCommand : IConsoleCommand diff --git a/Content.Server/Commands/Atmos/SetAtmosTemperatureCommand.cs b/Content.Server/Atmos/Commands/SetAtmosTemperatureCommand.cs similarity index 95% rename from Content.Server/Commands/Atmos/SetAtmosTemperatureCommand.cs rename to Content.Server/Atmos/Commands/SetAtmosTemperatureCommand.cs index a9bf0bf681..af12a8a752 100644 --- a/Content.Server/Commands/Atmos/SetAtmosTemperatureCommand.cs +++ b/Content.Server/Atmos/Commands/SetAtmosTemperatureCommand.cs @@ -1,5 +1,4 @@ using Content.Server.Administration; -using Content.Server.Atmos.Components; using Content.Server.Atmos.EntitySystems; using Content.Shared.Administration; using Content.Shared.Atmos; @@ -8,7 +7,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Map; -namespace Content.Server.Commands.Atmos +namespace Content.Server.Atmos.Commands { [AdminCommand(AdminFlags.Debug)] public class SetAtmosTemperatureCommand : IConsoleCommand diff --git a/Content.Server/Commands/Atmos/SetTemperatureCommand.cs b/Content.Server/Atmos/Commands/SetTemperatureCommand.cs similarity index 93% rename from Content.Server/Commands/Atmos/SetTemperatureCommand.cs rename to Content.Server/Atmos/Commands/SetTemperatureCommand.cs index f497b1b835..5b7ad506e2 100644 --- a/Content.Server/Commands/Atmos/SetTemperatureCommand.cs +++ b/Content.Server/Atmos/Commands/SetTemperatureCommand.cs @@ -1,15 +1,13 @@ using Content.Server.Administration; -using Content.Server.Atmos.Components; using Content.Server.Atmos.EntitySystems; using Content.Shared.Administration; using Content.Shared.Atmos; using Robust.Shared.Console; using Robust.Shared.GameObjects; -using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; -namespace Content.Server.Commands.Atmos +namespace Content.Server.Atmos.Commands { [AdminCommand(AdminFlags.Debug)] public class SetTemperatureCommand : IConsoleCommand diff --git a/Content.Server/Commands/Atmos/ShowAtmosCommand.cs b/Content.Server/Atmos/Commands/ShowAtmosCommand.cs similarity index 96% rename from Content.Server/Commands/Atmos/ShowAtmosCommand.cs rename to Content.Server/Atmos/Commands/ShowAtmosCommand.cs index f408be6917..6e6a176628 100644 --- a/Content.Server/Commands/Atmos/ShowAtmosCommand.cs +++ b/Content.Server/Atmos/Commands/ShowAtmosCommand.cs @@ -5,7 +5,7 @@ using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.GameObjects; -namespace Content.Server.Commands.Atmos +namespace Content.Server.Atmos.Commands { [AdminCommand(AdminFlags.Debug)] public class ShowAtmos : IConsoleCommand diff --git a/Content.Server/Atmos/Components/AirtightComponent.cs b/Content.Server/Atmos/Components/AirtightComponent.cs index 4e0eb577a8..ef543e940f 100644 --- a/Content.Server/Atmos/Components/AirtightComponent.cs +++ b/Content.Server/Atmos/Components/AirtightComponent.cs @@ -11,159 +11,37 @@ using Robust.Shared.ViewVariables; namespace Content.Server.Atmos.Components { [RegisterComponent] - public class AirtightComponent : Component, IMapInit + public class AirtightComponent : Component { - [Dependency] private readonly IMapManager _mapManager = default!; - - private (GridId, Vector2i) _lastPosition; - public override string Name => "Airtight"; + public (GridId Grid, Vector2i Tile) LastPosition { get; set; } + [DataField("airBlockedDirection", customTypeSerializer: typeof(FlagSerializer))] [ViewVariables] - private int _initialAirBlockedDirection = (int) AtmosDirection.All; + public int InitialAirBlockedDirection { get; set; } = (int) AtmosDirection.All; [ViewVariables] - private int _currentAirBlockedDirection; + public int CurrentAirBlockedDirection; [DataField("airBlocked")] - private bool _airBlocked = true; + public bool AirBlocked { get; set; } = true; [DataField("fixVacuum")] - private bool _fixVacuum = true; + public bool FixVacuum { get; set; } = true; [ViewVariables] [DataField("rotateAirBlocked")] - private bool _rotateAirBlocked = true; + public bool RotateAirBlocked { get; set; } = true; [ViewVariables] [DataField("fixAirBlockedDirectionInitialize")] - private bool _fixAirBlockedDirectionInitialize = true; + public bool FixAirBlockedDirectionInitialize { get; set; } = true; [ViewVariables] [DataField("noAirWhenFullyAirBlocked")] - public bool NoAirWhenFullyAirBlocked { get; } = true; + public bool NoAirWhenFullyAirBlocked { get; set; } = true; - [ViewVariables(VVAccess.ReadWrite)] - public bool AirBlocked - { - get => _airBlocked; - set - { - _airBlocked = value; - - UpdatePosition(); - } - } - - public AtmosDirection AirBlockedDirection - { - get => (AtmosDirection)_currentAirBlockedDirection; - set - { - _currentAirBlockedDirection = (int) value; - _initialAirBlockedDirection = (int)Rotate(AirBlockedDirection, -Owner.Transform.LocalRotation); - - UpdatePosition(); - } - } - - [ViewVariables] - public bool FixVacuum => _fixVacuum; - - protected override void Initialize() - { - base.Initialize(); - - if (_fixAirBlockedDirectionInitialize) - RotateEvent(new RotateEvent(Owner, Angle.Zero, Owner.Transform.WorldRotation)); - - // Adding this component will immediately anchor the entity, because the atmos system - // requires airtight entities to be anchored for performance. - Owner.Transform.Anchored = true; - - UpdatePosition(); - } - - public void RotateEvent(RotateEvent ev) - { - if (!_rotateAirBlocked || ev.Sender != Owner || _initialAirBlockedDirection == (int)AtmosDirection.Invalid) - return; - - _currentAirBlockedDirection = (int) Rotate((AtmosDirection)_initialAirBlockedDirection, ev.NewRotation); - UpdatePosition(); - } - - private AtmosDirection Rotate(AtmosDirection myDirection, Angle myAngle) - { - var newAirBlockedDirs = AtmosDirection.Invalid; - - if (myAngle == Angle.Zero) - return myDirection; - - // TODO ATMOS MULTIZ When we make multiZ atmos, special case this. - for (var i = 0; i < Atmospherics.Directions; i++) - { - var direction = (AtmosDirection) (1 << i); - if (!myDirection.IsFlagSet(direction)) continue; - var angle = direction.ToAngle(); - angle += myAngle; - newAirBlockedDirs |= angle.ToAtmosDirectionCardinal(); - } - - return newAirBlockedDirs; - } - - public void MapInit() - { - UpdatePosition(); - } - - protected override void Shutdown() - { - base.Shutdown(); - - _airBlocked = false; - - InvalidatePosition(_lastPosition.Item1, _lastPosition.Item2); - - if (_fixVacuum) - { - EntitySystem.Get().FixVacuum(_lastPosition.Item1, _lastPosition.Item2); - } - } - - public void AnchorStateChanged() - { - var gridId = Owner.Transform.GridID; - var coords = Owner.Transform.Coordinates; - - var grid = _mapManager.GetGrid(gridId); - var tilePos = grid.TileIndicesFor(coords); - - // Update and invalidate new position. - _lastPosition = (gridId, tilePos); - InvalidatePosition(gridId, tilePos); - } - - private void UpdatePosition() - { - if (!Owner.Transform.Anchored || !Owner.Transform.GridID.IsValid()) - return; - - var grid = _mapManager.GetGrid(Owner.Transform.GridID); - _lastPosition = (Owner.Transform.GridID, grid.TileIndicesFor(Owner.Transform.Coordinates)); - InvalidatePosition(_lastPosition.Item1, _lastPosition.Item2); - } - - private void InvalidatePosition(GridId gridId, Vector2i pos) - { - if (!gridId.IsValid()) - return; - - var atmosphereSystem = EntitySystem.Get(); - atmosphereSystem.UpdateAdjacent(gridId, pos); - atmosphereSystem.InvalidateTile(gridId, pos); - } + public AtmosDirection AirBlockedDirection => (AtmosDirection)CurrentAirBlockedDirection; } } diff --git a/Content.Server/Atmos/Components/FirelockComponent.cs b/Content.Server/Atmos/Components/FirelockComponent.cs index fde0c1353d..b1849cd757 100644 --- a/Content.Server/Atmos/Components/FirelockComponent.cs +++ b/Content.Server/Atmos/Components/FirelockComponent.cs @@ -28,7 +28,7 @@ namespace Content.Server.Atmos.Components _doorComponent.Close(); if (Owner.TryGetComponent(out AirtightComponent? airtight)) { - airtight.AirBlocked = true; + EntitySystem.Get().SetAirblocked(airtight, true); } return true; } diff --git a/Content.Server/Atmos/Components/GasMixtureHolderComponent.cs b/Content.Server/Atmos/Components/GasMixtureHolderComponent.cs index 3293839aa8..50b5af62f8 100644 --- a/Content.Server/Atmos/Components/GasMixtureHolderComponent.cs +++ b/Content.Server/Atmos/Components/GasMixtureHolderComponent.cs @@ -1,5 +1,4 @@ -using Content.Server.Interfaces; -using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; diff --git a/Content.Server/Atmos/Components/GasTankComponent.cs b/Content.Server/Atmos/Components/GasTankComponent.cs index e98aaed7b9..2d0f7105b8 100644 --- a/Content.Server/Atmos/Components/GasTankComponent.cs +++ b/Content.Server/Atmos/Components/GasTankComponent.cs @@ -3,7 +3,6 @@ using System; using Content.Server.Atmos.EntitySystems; using Content.Server.Body.Respiratory; using Content.Server.Explosion; -using Content.Server.Interfaces; using Content.Server.NodeContainer; using Content.Server.NodeContainer.Nodes; using Content.Server.UserInterface; diff --git a/Content.Server/Atmos/EntitySystems/AirtightSystem.cs b/Content.Server/Atmos/EntitySystems/AirtightSystem.cs index f933e893b1..a1fea661a1 100644 --- a/Content.Server/Atmos/EntitySystems/AirtightSystem.cs +++ b/Content.Server/Atmos/EntitySystems/AirtightSystem.cs @@ -1,26 +1,121 @@ using Content.Server.Atmos.Components; +using Content.Shared.Atmos; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Map; +using Robust.Shared.Maths; namespace Content.Server.Atmos.EntitySystems { [UsedImplicitly] public class AirtightSystem : EntitySystem { + [Dependency] private readonly IMapManager _mapManager = default!; + public override void Initialize() { + SubscribeLocalEvent(OnAirtightInit); + SubscribeLocalEvent(OnAirtightShutdown); + SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnAirtightPositionChanged); SubscribeLocalEvent(OnAirtightRotated); } - private void OnAirtightPositionChanged(EntityUid uid, AirtightComponent component, AnchorStateChangedEvent args) + private void OnAirtightInit(EntityUid uid, AirtightComponent airtight, ComponentInit args) { - component.AnchorStateChanged(); + if (airtight.FixAirBlockedDirectionInitialize) + OnAirtightRotated(uid, airtight, new RotateEvent(airtight.Owner, Angle.Zero, airtight.Owner.Transform.WorldRotation)); + + // Adding this component will immediately anchor the entity, because the atmos system + // requires airtight entities to be anchored for performance. + airtight.Owner.Transform.Anchored = true; + + UpdatePosition(airtight); + } + + private void OnAirtightShutdown(EntityUid uid, AirtightComponent airtight, ComponentShutdown args) + { + SetAirblocked(airtight, false); + + InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2); + + if (airtight.FixVacuum) + { + Get().FixVacuum(airtight.LastPosition.Item1, airtight.LastPosition.Item2); + } + } + + private void OnMapInit(EntityUid uid, AirtightComponent airtight, MapInitEvent args) + { + } + + private void OnAirtightPositionChanged(EntityUid uid, AirtightComponent airtight, AnchorStateChangedEvent args) + { + var gridId = airtight.Owner.Transform.GridID; + var coords = airtight.Owner.Transform.Coordinates; + + var grid = _mapManager.GetGrid(gridId); + var tilePos = grid.TileIndicesFor(coords); + + // Update and invalidate new position. + airtight.LastPosition = (gridId, tilePos); + InvalidatePosition(gridId, tilePos); } private void OnAirtightRotated(EntityUid uid, AirtightComponent airtight, RotateEvent ev) { - airtight.RotateEvent(ev); + if (!airtight.RotateAirBlocked || airtight.InitialAirBlockedDirection == (int)AtmosDirection.Invalid) + return; + + airtight.CurrentAirBlockedDirection = (int) Rotate((AtmosDirection)airtight.InitialAirBlockedDirection, ev.NewRotation); + UpdatePosition(airtight); + } + + public void SetAirblocked(AirtightComponent airtight, bool airblocked) + { + airtight.AirBlocked = airblocked; + UpdatePosition(airtight); + } + + public void UpdatePosition(AirtightComponent airtight) + { + if (!airtight.Owner.Transform.Anchored || !airtight.Owner.Transform.GridID.IsValid()) + return; + + var grid = _mapManager.GetGrid(airtight.Owner.Transform.GridID); + airtight.LastPosition = (airtight.Owner.Transform.GridID, grid.TileIndicesFor(airtight.Owner.Transform.Coordinates)); + InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2); + } + + public void InvalidatePosition(GridId gridId, Vector2i pos) + { + if (!gridId.IsValid()) + return; + + var atmosphereSystem = Get(); + atmosphereSystem.UpdateAdjacent(gridId, pos); + atmosphereSystem.InvalidateTile(gridId, pos); + } + + private AtmosDirection Rotate(AtmosDirection myDirection, Angle myAngle) + { + var newAirBlockedDirs = AtmosDirection.Invalid; + + if (myAngle == Angle.Zero) + return myDirection; + + // TODO ATMOS MULTIZ: When we make multiZ atmos, special case this. + for (var i = 0; i < Atmospherics.Directions; i++) + { + var direction = (AtmosDirection) (1 << i); + if (!myDirection.IsFlagSet(direction)) continue; + var angle = direction.ToAngle(); + angle += myAngle; + newAirBlockedDirs |= angle.ToAtmosDirectionCardinal(); + } + + return newAirBlockedDirs; } } } diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Gases.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Gases.cs index bcf7989db8..ba11dd0740 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Gases.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Gases.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Linq; using Content.Server.Atmos.Reactions; -using Content.Server.Interfaces; using Content.Shared.Atmos; using Robust.Shared.IoC; using Robust.Shared.Maths; diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs index 8aba21897a..41424c990a 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs @@ -246,6 +246,9 @@ namespace Content.Server.Atmos.EntitySystems var isAirBlocked = IsTileAirBlocked(mapGrid, indices); + tile.BlockedAirflow = GetBlockedDirections(mapGrid, indices); + UpdateAdjacent(mapGrid, gridAtmosphere, tile); + if (IsTileSpace(mapGrid, indices) && !isAirBlocked) { tile.Air = new GasMixture(volume); @@ -293,11 +296,8 @@ namespace Content.Server.Atmos.EntitySystems // Then we activate the tile again. AddActiveTile(gridAtmosphere, tile); - tile.BlockedAirflow = GetBlockedDirections(mapGrid, indices); - // TODO ATMOS: Query all the contents of this tile (like walls) and calculate the correct thermal conductivity tile.ThermalConductivity = tile.Tile?.Tile.GetContentTileDefinition().ThermalConductivity ?? 0.5f; - UpdateAdjacent(mapGrid, gridAtmosphere, tile); InvalidateVisuals(mapGrid.Index, indices); for (var i = 0; i < Atmospherics.Directions; i++) @@ -993,11 +993,25 @@ namespace Content.Server.Atmos.EntitySystems public IEnumerable GetAdjacentTileMixtures(GridAtmosphereComponent gridAtmosphere, Vector2i tile, bool includeBlocked = false, bool invalidate = false) { if (!gridAtmosphere.Tiles.TryGetValue(tile, out var tileAtmosphere)) - yield break; + return Enumerable.Empty(); - for (var i = 0; i < tileAtmosphere.AdjacentTiles.Length; i++) + return GetAdjacentTileMixtures(gridAtmosphere, tileAtmosphere, includeBlocked, invalidate); + } + + /// + /// Gets all tile gas mixtures adjacent to a specific tile, and optionally invalidates them. + /// Does not return the tile in question, only the adjacent ones. + /// + /// Grid Atmosphere where the tile is. + /// Tile Atmosphere in question. + /// Whether to include tiles in directions the tile is air-blocked in. + /// Whether to invalidate all adjacent tiles. + /// All adjacent tile gas mixtures to the tile in question + private IEnumerable GetAdjacentTileMixtures(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, bool includeBlocked = false, bool invalidate = false) + { + for (var i = 0; i < tile.AdjacentTiles.Length; i++) { - var adjacentTile = tileAtmosphere.AdjacentTiles[i]; + var adjacentTile = tile.AdjacentTiles[i]; // TileAtmosphere has nullable disabled, so just in case... // ReSharper disable once ConditionIsAlwaysTrueOrFalse @@ -1007,7 +1021,7 @@ namespace Content.Server.Atmos.EntitySystems if (!includeBlocked) { var direction = (AtmosDirection) (1 << i); - if (tileAtmosphere.BlockedAirflow.IsFlagSet(direction)) + if (tile.BlockedAirflow.IsFlagSet(direction)) continue; } @@ -1465,7 +1479,7 @@ namespace Content.Server.Atmos.EntitySystems if (!gridAtmosphere.Tiles.TryGetValue(tile, out var tileAtmosphere)) return; - var adjacent = GetAdjacentTileMixtures(gridAtmosphere, tile, invalidate:true).ToArray(); + var adjacent = GetAdjacentTileMixtures(gridAtmosphere, tileAtmosphere, false, true).ToArray(); tileAtmosphere.Air = new GasMixture(GetVolumeForTiles(tileAtmosphere.GridIndex, 1)) {Temperature = Atmospherics.T20C}; diff --git a/Content.Server/Atmos/GasMixture.cs b/Content.Server/Atmos/GasMixture.cs index 1aa28daf63..dddad7366f 100644 --- a/Content.Server/Atmos/GasMixture.cs +++ b/Content.Server/Atmos/GasMixture.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Runtime.CompilerServices; using Content.Server.Atmos.EntitySystems; using Content.Server.Atmos.Reactions; -using Content.Server.Interfaces; using Content.Shared.Atmos; using Robust.Shared.GameObjects; using Robust.Shared.Maths; diff --git a/Content.Server/Interfaces/IGasMixtureHolder.cs b/Content.Server/Atmos/IGasMixtureHolder.cs similarity index 82% rename from Content.Server/Interfaces/IGasMixtureHolder.cs rename to Content.Server/Atmos/IGasMixtureHolder.cs index bd34555949..c8bcb60391 100644 --- a/Content.Server/Interfaces/IGasMixtureHolder.cs +++ b/Content.Server/Atmos/IGasMixtureHolder.cs @@ -1,8 +1,7 @@ -using Content.Server.Atmos; -using Content.Server.Atmos.EntitySystems; +using Content.Server.Atmos.EntitySystems; using Robust.Shared.GameObjects; -namespace Content.Server.Interfaces +namespace Content.Server.Atmos { public interface IGasMixtureHolder { diff --git a/Content.Server/Interfaces/IGasReactionEffect.cs b/Content.Server/Atmos/IGasReactionEffect.cs similarity index 71% rename from Content.Server/Interfaces/IGasReactionEffect.cs rename to Content.Server/Atmos/IGasReactionEffect.cs index 1f2d7495db..3431897920 100644 --- a/Content.Server/Interfaces/IGasReactionEffect.cs +++ b/Content.Server/Atmos/IGasReactionEffect.cs @@ -1,9 +1,7 @@ -using Content.Server.Atmos; using Content.Server.Atmos.EntitySystems; using Content.Server.Atmos.Reactions; -using Robust.Server.GameObjects; -namespace Content.Server.Interfaces +namespace Content.Server.Atmos { public interface IGasReactionEffect { diff --git a/Content.Server/Atmos/Reactions/GasReactionPrototype.cs b/Content.Server/Atmos/Reactions/GasReactionPrototype.cs index 82cdd8cbb9..c782ca6ac6 100644 --- a/Content.Server/Atmos/Reactions/GasReactionPrototype.cs +++ b/Content.Server/Atmos/Reactions/GasReactionPrototype.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using Content.Server.Atmos.EntitySystems; -using Content.Server.Interfaces; using Content.Shared.Atmos; using Robust.Server.GameObjects; using Robust.Shared.Prototypes; diff --git a/Content.Server/Atmos/Reactions/PlasmaFireReaction.cs b/Content.Server/Atmos/Reactions/PlasmaFireReaction.cs index 7b4da18625..b43000e8a1 100644 --- a/Content.Server/Atmos/Reactions/PlasmaFireReaction.cs +++ b/Content.Server/Atmos/Reactions/PlasmaFireReaction.cs @@ -1,7 +1,6 @@ using System; using Content.Server.Atmos.EntitySystems; using Content.Server.Coordinates.Helpers; -using Content.Server.Interfaces; using Content.Shared.Atmos; using JetBrains.Annotations; using Robust.Server.GameObjects; diff --git a/Content.Server/Atmos/Reactions/TritiumFireReaction.cs b/Content.Server/Atmos/Reactions/TritiumFireReaction.cs index ffbcb16671..57d46d9863 100644 --- a/Content.Server/Atmos/Reactions/TritiumFireReaction.cs +++ b/Content.Server/Atmos/Reactions/TritiumFireReaction.cs @@ -1,6 +1,5 @@ using Content.Server.Atmos.EntitySystems; using Content.Server.Coordinates.Helpers; -using Content.Server.Interfaces; using Content.Shared.Atmos; using JetBrains.Annotations; using Robust.Server.GameObjects; diff --git a/Content.Server/Atmos/Reactions/WaterVaporReaction.cs b/Content.Server/Atmos/Reactions/WaterVaporReaction.cs index d1935f10a8..7e19ffafce 100644 --- a/Content.Server/Atmos/Reactions/WaterVaporReaction.cs +++ b/Content.Server/Atmos/Reactions/WaterVaporReaction.cs @@ -1,6 +1,5 @@ using Content.Server.Atmos.EntitySystems; using Content.Server.Fluids.Components; -using Content.Server.Interfaces; using Content.Shared.Chemistry.Reagent; using Content.Shared.Chemistry.Solution; using Content.Shared.Maps; diff --git a/Content.Server/Atmos/TileAtmosphere.cs b/Content.Server/Atmos/TileAtmosphere.cs index a6249a0a30..5bcfc710b4 100644 --- a/Content.Server/Atmos/TileAtmosphere.cs +++ b/Content.Server/Atmos/TileAtmosphere.cs @@ -1,6 +1,5 @@ #nullable disable warnings #nullable enable annotations -using Content.Server.Interfaces; using Content.Shared.Atmos; using Content.Shared.Maps; using Robust.Shared.Map; diff --git a/Content.Server/Body/Circulatory/BloodstreamComponent.cs b/Content.Server/Body/Circulatory/BloodstreamComponent.cs index 2b50d039a5..df90cd6fc6 100644 --- a/Content.Server/Body/Circulatory/BloodstreamComponent.cs +++ b/Content.Server/Body/Circulatory/BloodstreamComponent.cs @@ -3,7 +3,6 @@ using System.Linq; using Content.Server.Atmos; using Content.Server.Atmos.EntitySystems; using Content.Server.Chemistry.Components; -using Content.Server.Interfaces; using Content.Server.Metabolism; using Content.Shared.Atmos; using Content.Shared.Body.Networks; diff --git a/Content.Server/Commands/DONT_PUT_NEW_COMMANDS_HERE_ATMOS_LEFTOVER b/Content.Server/Commands/DONT_PUT_NEW_COMMANDS_HERE_ATMOS_LEFTOVER deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs b/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs index ea5d423c3d..241dc48324 100644 --- a/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs +++ b/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs @@ -4,7 +4,6 @@ using System.Linq; using Content.Server.Atmos; using Content.Server.Atmos.EntitySystems; using Content.Server.Disposal.Tube.Components; -using Content.Server.Interfaces; using Content.Server.Items; using Content.Shared.Atmos; using Content.Shared.Body.Components; diff --git a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs index 4563f0925c..bef8039e29 100644 --- a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs +++ b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs @@ -9,7 +9,6 @@ using Content.Server.Construction.Components; using Content.Server.Disposal.Tube.Components; using Content.Server.DoAfter; using Content.Server.Hands.Components; -using Content.Server.Interfaces; using Content.Server.Power.Components; using Content.Server.UserInterface; using Content.Shared.ActionBlocker; diff --git a/Content.Server/Doors/Components/ServerDoorComponent.cs b/Content.Server/Doors/Components/ServerDoorComponent.cs index 278e8f8695..8449074d65 100644 --- a/Content.Server/Doors/Components/ServerDoorComponent.cs +++ b/Content.Server/Doors/Components/ServerDoorComponent.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Content.Server.Access; using Content.Server.Access.Components; using Content.Server.Atmos.Components; +using Content.Server.Atmos.EntitySystems; using Content.Server.Construction.Components; using Content.Server.Hands.Components; using Content.Server.Stunnable.Components; @@ -313,7 +314,7 @@ namespace Content.Server.Doors.Components { if (Owner.TryGetComponent(out AirtightComponent? airtight)) { - airtight.AirBlocked = false; + EntitySystem.Get().SetAirblocked(airtight, false); } base.OnPartialOpen(); Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new AccessReaderChangeMessage(Owner, false)); @@ -441,7 +442,7 @@ namespace Content.Server.Doors.Components if (becomeairtight && Owner.TryGetComponent(out AirtightComponent? airtight)) { - airtight.AirBlocked = true; + EntitySystem.Get().SetAirblocked(airtight, true); } Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new AccessReaderChangeMessage(Owner, true)); diff --git a/Content.Server/Interfaces/DONT_PUT_STUFF_HERE_ATMOS_LEFTOVER b/Content.Server/Interfaces/DONT_PUT_STUFF_HERE_ATMOS_LEFTOVER deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/Content.Server/NodeContainer/NodeGroups/PipeNet.cs b/Content.Server/NodeContainer/NodeGroups/PipeNet.cs index a1ce417ef3..a8ffb13814 100644 --- a/Content.Server/NodeContainer/NodeGroups/PipeNet.cs +++ b/Content.Server/NodeContainer/NodeGroups/PipeNet.cs @@ -4,7 +4,6 @@ using System.Linq; using Content.Server.Atmos; using Content.Server.Atmos.Components; using Content.Server.Atmos.EntitySystems; -using Content.Server.Interfaces; using Content.Server.NodeContainer.Nodes; using Content.Shared.Atmos; using Robust.Shared.GameObjects; diff --git a/Content.Server/NodeContainer/Nodes/PipeNode.cs b/Content.Server/NodeContainer/Nodes/PipeNode.cs index 6f72cc0ffc..83495e05de 100644 --- a/Content.Server/NodeContainer/Nodes/PipeNode.cs +++ b/Content.Server/NodeContainer/Nodes/PipeNode.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using Content.Server.Atmos; using Content.Server.Atmos.EntitySystems; -using Content.Server.Interfaces; using Content.Server.NodeContainer.EntitySystems; using Content.Server.NodeContainer.NodeGroups; using Content.Shared.Atmos; diff --git a/Resources/Locale/en-US/game-objects/components/atmos/firelock-component.ftl b/Resources/Locale/en-US/atmos/firelock-component.ftl similarity index 100% rename from Resources/Locale/en-US/game-objects/components/atmos/firelock-component.ftl rename to Resources/Locale/en-US/atmos/firelock-component.ftl diff --git a/Resources/Locale/en-US/game-objects/components/atmos/flammable-component.ftl b/Resources/Locale/en-US/atmos/flammable-component.ftl similarity index 100% rename from Resources/Locale/en-US/game-objects/components/atmos/flammable-component.ftl rename to Resources/Locale/en-US/atmos/flammable-component.ftl diff --git a/Resources/Locale/en-US/game-objects/components/atmos/gas-analyzer-component.ftl b/Resources/Locale/en-US/atmos/gas-analyzer-component.ftl similarity index 100% rename from Resources/Locale/en-US/game-objects/components/atmos/gas-analyzer-component.ftl rename to Resources/Locale/en-US/atmos/gas-analyzer-component.ftl diff --git a/Resources/Locale/en-US/game-objects/components/atmos/gas-canister-component.ftl b/Resources/Locale/en-US/atmos/gas-canister-component.ftl similarity index 100% rename from Resources/Locale/en-US/game-objects/components/atmos/gas-canister-component.ftl rename to Resources/Locale/en-US/atmos/gas-canister-component.ftl diff --git a/Resources/Locale/en-US/game-objects/components/atmos/gas-tank-component.ftl b/Resources/Locale/en-US/atmos/gas-tank-component.ftl similarity index 100% rename from Resources/Locale/en-US/game-objects/components/atmos/gas-tank-component.ftl rename to Resources/Locale/en-US/atmos/gas-tank-component.ftl diff --git a/Resources/Locale/en-US/game-objects/DONT_PUT_STUFF_HERE_ATMOS_LEFTOVER b/Resources/Locale/en-US/game-objects/DONT_PUT_STUFF_HERE_ATMOS_LEFTOVER deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/SpaceStation14.sln.DotSettings b/SpaceStation14.sln.DotSettings index 5b58264536..5ff7f8d1e5 100644 --- a/SpaceStation14.sln.DotSettings +++ b/SpaceStation14.sln.DotSettings @@ -177,6 +177,7 @@ True True True + True True True True