Fires now play a sound effect. (#6138)
This commit is contained in:
committed by
GitHub
parent
0990389a20
commit
daef343c2c
@@ -20,7 +20,6 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
{
|
||||
SubscribeLocalEvent<AirtightComponent, ComponentInit>(OnAirtightInit);
|
||||
SubscribeLocalEvent<AirtightComponent, ComponentShutdown>(OnAirtightShutdown);
|
||||
SubscribeLocalEvent<AirtightComponent, MapInitEvent>(OnMapInit);
|
||||
SubscribeLocalEvent<AirtightComponent, AnchorStateChangedEvent>(OnAirtightPositionChanged);
|
||||
SubscribeLocalEvent<AirtightComponent, RotateEvent>(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<TransformComponent>(uid);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -21,6 +21,10 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
/// List of gas reactions ordered by priority.
|
||||
/// </summary>
|
||||
public IEnumerable<GasReactionPrototype> GasReactions => _gasReactions!;
|
||||
|
||||
/// <summary>
|
||||
/// Cached array of gas specific heats.
|
||||
/// </summary>
|
||||
public float[] GasSpecificHeats => _gasSpecificHeats;
|
||||
|
||||
private void InitializeGases()
|
||||
@@ -36,11 +40,17 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the heat capacity for a gas mixture.
|
||||
/// </summary>
|
||||
public float GetHeatCapacity(GasMixture mixture)
|
||||
{
|
||||
return GetHeatCapacityCalculation(mixture.Moles, mixture.Immutable);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the heat capacity for a gas mixture, using the archived values.
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the thermal energy for a gas mixture.
|
||||
/// </summary>
|
||||
public float GetThermalEnergy(GasMixture mixture)
|
||||
{
|
||||
return mixture.Temperature * GetHeatCapacity(mixture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the thermal energy for a gas mixture, using a cached heat capacity value.
|
||||
/// </summary>
|
||||
public float GetThermalEnergy(GasMixture mixture, float cachedHeatCapacity)
|
||||
{
|
||||
return mixture.Temperature * cachedHeatCapacity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Merges the <see cref="giver"/> gas mixture into the <see cref="receiver"/> gas mixture.
|
||||
/// The <see cref="giver"/> gas mixture is not modified by this method.
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shares gas between two gas mixtures. Part of LINDA.
|
||||
/// </summary>
|
||||
public float Share(GasMixture receiver, GasMixture sharer, int atmosAdjacentTurfs)
|
||||
{
|
||||
var temperatureDelta = receiver.TemperatureArchived - sharer.TemperatureArchived;
|
||||
@@ -169,6 +192,9 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shares temperature between two mixtures, taking a conduction coefficient into account.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shares temperature between a gas mixture and an abstract sharer, taking a conduction coefficient into account.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scrubs specified gases from a gas mixture into a <see cref="destination"/> gas mixture.
|
||||
/// </summary>
|
||||
public void ScrubInto(GasMixture mixture, GasMixture destination, IReadOnlyCollection<Gas> filterGases)
|
||||
{
|
||||
var buffer = new GasMixture(mixture.Volume){Temperature = mixture.Temperature};
|
||||
@@ -284,6 +316,9 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
Merge(destination, buffer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs reactions for a given gas mixture on an optional holder.
|
||||
/// </summary>
|
||||
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];
|
||||
|
||||
@@ -9,23 +9,29 @@ 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)));
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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?
|
||||
}
|
||||
|
||||
|
||||
@@ -381,12 +381,6 @@ namespace Content.Shared.CCVar
|
||||
public static readonly CVarDef<bool> SpaceWind =
|
||||
CVarDef.Create("atmos.space_wind", true, CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// The sound that plays when space wind occurs.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<string> SpaceWindSound =
|
||||
CVarDef.Create("atmos.space_wind_sound", "/Audio/Effects/space_wind.ogg", CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Whether monstermos tile equalization is enabled.
|
||||
/// </summary>
|
||||
|
||||
BIN
Resources/Audio/Effects/fire.ogg
Normal file
BIN
Resources/Audio/Effects/fire.ogg
Normal file
Binary file not shown.
@@ -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/
|
||||
|
||||
Reference in New Issue
Block a user