diff --git a/Content.Server/Atmos/EntitySystems/AirtightSystem.cs b/Content.Server/Atmos/EntitySystems/AirtightSystem.cs index 50849a64b6..4199bcea69 100644 --- a/Content.Server/Atmos/EntitySystems/AirtightSystem.cs +++ b/Content.Server/Atmos/EntitySystems/AirtightSystem.cs @@ -20,7 +20,6 @@ namespace Content.Server.Atmos.EntitySystems { SubscribeLocalEvent(OnAirtightInit); SubscribeLocalEvent(OnAirtightShutdown); - SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnAirtightPositionChanged); SubscribeLocalEvent(OnAirtightRotated); } @@ -58,10 +57,6 @@ namespace Content.Server.Atmos.EntitySystems RaiseLocalEvent(new AirtightChanged(airtight)); } - private void OnMapInit(EntityUid uid, AirtightComponent airtight, MapInitEvent args) - { - } - private void OnAirtightPositionChanged(EntityUid uid, AirtightComponent airtight, ref AnchorStateChangedEvent args) { var xform = EntityManager.GetComponent(uid); diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.CVars.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.CVars.cs index df9fbd7c1e..067c4581ab 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.CVars.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.CVars.cs @@ -9,7 +9,6 @@ namespace Content.Server.Atmos.EntitySystems [Dependency] private readonly IConfigurationManager _cfg = default!; public bool SpaceWind { get; private set; } - public string? SpaceWindSound { get; private set; } public bool MonstermosEqualization { get; private set; } public bool MonstermosDepressurization { get; private set; } public bool MonstermosRipTiles { get; private set; } @@ -24,7 +23,6 @@ namespace Content.Server.Atmos.EntitySystems private void InitializeCVars() { _cfg.OnValueChanged(CCVars.SpaceWind, value => SpaceWind = value, true); - _cfg.OnValueChanged(CCVars.SpaceWindSound, value => SpaceWindSound = value, true); _cfg.OnValueChanged(CCVars.MonstermosEqualization, value => MonstermosEqualization = value, true); _cfg.OnValueChanged(CCVars.MonstermosDepressurization, value => MonstermosDepressurization = value, true); _cfg.OnValueChanged(CCVars.MonstermosRipTiles, value => MonstermosRipTiles = value, true); diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Gases.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Gases.cs index 8fa2447e36..8c4136f184 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Gases.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Gases.cs @@ -21,6 +21,10 @@ namespace Content.Server.Atmos.EntitySystems /// List of gas reactions ordered by priority. /// public IEnumerable GasReactions => _gasReactions!; + + /// + /// Cached array of gas specific heats. + /// public float[] GasSpecificHeats => _gasSpecificHeats; private void InitializeGases() @@ -36,11 +40,17 @@ namespace Content.Server.Atmos.EntitySystems } } + /// + /// Calculates the heat capacity for a gas mixture. + /// public float GetHeatCapacity(GasMixture mixture) { return GetHeatCapacityCalculation(mixture.Moles, mixture.Immutable); } + /// + /// Calculates the heat capacity for a gas mixture, using the archived values. + /// public float GetHeatCapacityArchived(GasMixture mixture) { return GetHeatCapacityCalculation(mixture.MolesArchived, mixture.Immutable); @@ -60,16 +70,26 @@ namespace Content.Server.Atmos.EntitySystems return MathF.Max(NumericsHelpers.HorizontalAdd(tmp), Atmospherics.MinimumHeatCapacity); } + /// + /// Calculates the thermal energy for a gas mixture. + /// public float GetThermalEnergy(GasMixture mixture) { return mixture.Temperature * GetHeatCapacity(mixture); } + /// + /// Calculates the thermal energy for a gas mixture, using a cached heat capacity value. + /// public float GetThermalEnergy(GasMixture mixture, float cachedHeatCapacity) { return mixture.Temperature * cachedHeatCapacity; } + /// + /// Merges the gas mixture into the gas mixture. + /// The gas mixture is not modified by this method. + /// public void Merge(GasMixture receiver, GasMixture giver) { if (receiver.Immutable) return; @@ -88,6 +108,9 @@ namespace Content.Server.Atmos.EntitySystems NumericsHelpers.Add(receiver.Moles, giver.Moles); } + /// + /// Shares gas between two gas mixtures. Part of LINDA. + /// public float Share(GasMixture receiver, GasMixture sharer, int atmosAdjacentTurfs) { var temperatureDelta = receiver.TemperatureArchived - sharer.TemperatureArchived; @@ -169,6 +192,9 @@ namespace Content.Server.Atmos.EntitySystems } + /// + /// Shares temperature between two mixtures, taking a conduction coefficient into account. + /// public float TemperatureShare(GasMixture receiver, GasMixture sharer, float conductionCoefficient) { var temperatureDelta = receiver.TemperatureArchived - sharer.TemperatureArchived; @@ -192,6 +218,9 @@ namespace Content.Server.Atmos.EntitySystems return sharer.Temperature; } + /// + /// Shares temperature between a gas mixture and an abstract sharer, taking a conduction coefficient into account. + /// public float TemperatureShare(GasMixture receiver, float conductionCoefficient, float sharerTemperature, float sharerHeatCapacity) { var temperatureDelta = receiver.TemperatureArchived - sharerTemperature; @@ -271,6 +300,9 @@ namespace Content.Server.Atmos.EntitySystems return true; } + /// + /// Scrubs specified gases from a gas mixture into a gas mixture. + /// public void ScrubInto(GasMixture mixture, GasMixture destination, IReadOnlyCollection filterGases) { var buffer = new GasMixture(mixture.Volume){Temperature = mixture.Temperature}; @@ -284,6 +316,9 @@ namespace Content.Server.Atmos.EntitySystems Merge(destination, buffer); } + /// + /// Performs reactions for a given gas mixture on an optional holder. + /// public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder) { var reaction = ReactionResult.NoReaction; @@ -300,7 +335,7 @@ namespace Content.Server.Atmos.EntitySystems var doReaction = true; for (var i = 0; i < prototype.MinimumRequirements.Length; i++) { - if(i > Atmospherics.TotalNumberOfGases) + if(i >= Atmospherics.TotalNumberOfGases) throw new IndexOutOfRangeException("Reaction Gas Minimum Requirements Array Prototype exceeds total number of gases!"); var req = prototype.MinimumRequirements[i]; diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs index 73056d60f0..09a2a47446 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs @@ -9,25 +9,31 @@ using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.Physics; using Robust.Shared.Player; +using Robust.Shared.ViewVariables; namespace Content.Server.Atmos.EntitySystems { public partial class AtmosphereSystem { + private const int SpaceWindSoundCooldownCycles = 75; + private int _spaceWindSoundCooldown = 0; + [ViewVariables(VVAccess.ReadWrite)] + public string? SpaceWindSound { get; private set; } = "/Audio/Effects/space_wind.ogg"; + private void HighPressureMovements(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile) { // TODO ATMOS finish this - if(tile.PressureDifference > 15) + // Don't play the space wind sound on tiles that are on fire... + if(tile.PressureDifference > 15 && !tile.Hotspot.Valid) { - if(_spaceWindSoundCooldown == 0) + if(_spaceWindSoundCooldown == 0 && !string.IsNullOrEmpty(SpaceWindSound)) { var coordinates = tile.GridIndices.ToEntityCoordinates(tile.GridIndex, _mapManager); - if(!string.IsNullOrEmpty(SpaceWindSound)) - SoundSystem.Play(Filter.Pvs(coordinates), SpaceWindSound, coordinates, - AudioHelpers.WithVariation(0.125f).WithVolume(MathHelper.Clamp(tile.PressureDifference / 10, 10, 100))); + SoundSystem.Play(Filter.Pvs(coordinates), SpaceWindSound, coordinates, + AudioHelpers.WithVariation(0.125f).WithVolume(MathHelper.Clamp(tile.PressureDifference / 10, 10, 100))); } } @@ -51,8 +57,7 @@ namespace Content.Server.Atmos.EntitySystems // TODO ATMOS Do space wind graphics here! } - _spaceWindSoundCooldown++; - if (_spaceWindSoundCooldown > 75) + if (_spaceWindSoundCooldown++ > SpaceWindSoundCooldownCycles) _spaceWindSoundCooldown = 0; } diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Hotspot.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Hotspot.cs index 7bb0c5baff..a77f8f0391 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Hotspot.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Hotspot.cs @@ -1,9 +1,15 @@ using Content.Server.Atmos.Components; using Content.Server.Atmos.Reactions; using Content.Shared.Atmos; +using Content.Shared.Audio; using Robust.Server.GameObjects; +using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.IoC; +using Robust.Shared.Map; +using Robust.Shared.Maths; +using Robust.Shared.Player; +using Robust.Shared.ViewVariables; namespace Content.Server.Atmos.EntitySystems { @@ -11,6 +17,13 @@ namespace Content.Server.Atmos.EntitySystems { [Dependency] private readonly IEntityLookup _lookup = default!; + private const int HotspotSoundCooldownCycles = 200; + + private int _hotspotSoundCooldown = 0; + + [ViewVariables(VVAccess.ReadWrite)] + public string? HotspotSound { get; private set; } = "/Audio/Effects/fire.ogg"; + private void ProcessHotspot(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile) { if (!tile.Hotspot.Valid) @@ -70,6 +83,19 @@ namespace Content.Server.Atmos.EntitySystems if (tile.Hotspot.Temperature > tile.MaxFireTemperatureSustained) tile.MaxFireTemperatureSustained = tile.Hotspot.Temperature; + if (_hotspotSoundCooldown++ == 0 && !string.IsNullOrEmpty(HotspotSound)) + { + var coordinates = tile.GridIndices.ToEntityCoordinates(tile.GridIndex, _mapManager); + // A few details on the audio parameters for fire. + // The greater the fire state, the lesser the pitch variation. + // The greater the fire state, the greater the volume. + SoundSystem.Play(Filter.Pvs(coordinates), HotspotSound, coordinates, + AudioHelpers.WithVariation(0.15f/tile.Hotspot.State).WithVolume(-5f + 5f * tile.Hotspot.State)); + } + + if (_hotspotSoundCooldown > HotspotSoundCooldownCycles) + _hotspotSoundCooldown = 0; + // TODO ATMOS Maybe destroy location here? } diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 1b6bda71b8..f56b5bbab4 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -381,12 +381,6 @@ namespace Content.Shared.CCVar public static readonly CVarDef SpaceWind = CVarDef.Create("atmos.space_wind", true, CVar.SERVERONLY); - /// - /// The sound that plays when space wind occurs. - /// - public static readonly CVarDef SpaceWindSound = - CVarDef.Create("atmos.space_wind_sound", "/Audio/Effects/space_wind.ogg", CVar.SERVERONLY); - /// /// Whether monstermos tile equalization is enabled. /// diff --git a/Resources/Audio/Effects/fire.ogg b/Resources/Audio/Effects/fire.ogg new file mode 100644 index 0000000000..04b5eb34ef Binary files /dev/null and b/Resources/Audio/Effects/fire.ogg differ diff --git a/Resources/Audio/Effects/license.txt b/Resources/Audio/Effects/license.txt index 8cba3cecd0..edac43a6ec 100644 --- a/Resources/Audio/Effects/license.txt +++ b/Resources/Audio/Effects/license.txt @@ -14,3 +14,5 @@ voteding.ogg taken from "Bike, Bell Ding, Single, 01-01.wav" by InspectorJ (www. poster_broken.ogg taken from https://github.com/tgstation/tgstation/blob/2834383245d2129a106acef3afd17b81e1e64777/sound/items/poster_ripped.ogg poster_being_set.ogg taken from https://github.com/tgstation/tgstation/blob/2834383245d2129a106acef3afd17b81e1e64777/sound/items/poster_ripped.ogg + +fire.ogg taken and edited from https://freesound.org/people/raremess/sounds/222557/