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, ComponentInit>(OnAirtightInit);
|
||||||
SubscribeLocalEvent<AirtightComponent, ComponentShutdown>(OnAirtightShutdown);
|
SubscribeLocalEvent<AirtightComponent, ComponentShutdown>(OnAirtightShutdown);
|
||||||
SubscribeLocalEvent<AirtightComponent, MapInitEvent>(OnMapInit);
|
|
||||||
SubscribeLocalEvent<AirtightComponent, AnchorStateChangedEvent>(OnAirtightPositionChanged);
|
SubscribeLocalEvent<AirtightComponent, AnchorStateChangedEvent>(OnAirtightPositionChanged);
|
||||||
SubscribeLocalEvent<AirtightComponent, RotateEvent>(OnAirtightRotated);
|
SubscribeLocalEvent<AirtightComponent, RotateEvent>(OnAirtightRotated);
|
||||||
}
|
}
|
||||||
@@ -58,10 +57,6 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
RaiseLocalEvent(new AirtightChanged(airtight));
|
RaiseLocalEvent(new AirtightChanged(airtight));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMapInit(EntityUid uid, AirtightComponent airtight, MapInitEvent args)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnAirtightPositionChanged(EntityUid uid, AirtightComponent airtight, ref AnchorStateChangedEvent args)
|
private void OnAirtightPositionChanged(EntityUid uid, AirtightComponent airtight, ref AnchorStateChangedEvent args)
|
||||||
{
|
{
|
||||||
var xform = EntityManager.GetComponent<TransformComponent>(uid);
|
var xform = EntityManager.GetComponent<TransformComponent>(uid);
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||||
|
|
||||||
public bool SpaceWind { get; private set; }
|
public bool SpaceWind { get; private set; }
|
||||||
public string? SpaceWindSound { get; private set; }
|
|
||||||
public bool MonstermosEqualization { get; private set; }
|
public bool MonstermosEqualization { get; private set; }
|
||||||
public bool MonstermosDepressurization { get; private set; }
|
public bool MonstermosDepressurization { get; private set; }
|
||||||
public bool MonstermosRipTiles { get; private set; }
|
public bool MonstermosRipTiles { get; private set; }
|
||||||
@@ -24,7 +23,6 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
private void InitializeCVars()
|
private void InitializeCVars()
|
||||||
{
|
{
|
||||||
_cfg.OnValueChanged(CCVars.SpaceWind, value => SpaceWind = value, true);
|
_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.MonstermosEqualization, value => MonstermosEqualization = value, true);
|
||||||
_cfg.OnValueChanged(CCVars.MonstermosDepressurization, value => MonstermosDepressurization = value, true);
|
_cfg.OnValueChanged(CCVars.MonstermosDepressurization, value => MonstermosDepressurization = value, true);
|
||||||
_cfg.OnValueChanged(CCVars.MonstermosRipTiles, value => MonstermosRipTiles = 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.
|
/// List of gas reactions ordered by priority.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<GasReactionPrototype> GasReactions => _gasReactions!;
|
public IEnumerable<GasReactionPrototype> GasReactions => _gasReactions!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Cached array of gas specific heats.
|
||||||
|
/// </summary>
|
||||||
public float[] GasSpecificHeats => _gasSpecificHeats;
|
public float[] GasSpecificHeats => _gasSpecificHeats;
|
||||||
|
|
||||||
private void InitializeGases()
|
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)
|
public float GetHeatCapacity(GasMixture mixture)
|
||||||
{
|
{
|
||||||
return GetHeatCapacityCalculation(mixture.Moles, mixture.Immutable);
|
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)
|
public float GetHeatCapacityArchived(GasMixture mixture)
|
||||||
{
|
{
|
||||||
return GetHeatCapacityCalculation(mixture.MolesArchived, mixture.Immutable);
|
return GetHeatCapacityCalculation(mixture.MolesArchived, mixture.Immutable);
|
||||||
@@ -60,16 +70,26 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
return MathF.Max(NumericsHelpers.HorizontalAdd(tmp), Atmospherics.MinimumHeatCapacity);
|
return MathF.Max(NumericsHelpers.HorizontalAdd(tmp), Atmospherics.MinimumHeatCapacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calculates the thermal energy for a gas mixture.
|
||||||
|
/// </summary>
|
||||||
public float GetThermalEnergy(GasMixture mixture)
|
public float GetThermalEnergy(GasMixture mixture)
|
||||||
{
|
{
|
||||||
return mixture.Temperature * GetHeatCapacity(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)
|
public float GetThermalEnergy(GasMixture mixture, float cachedHeatCapacity)
|
||||||
{
|
{
|
||||||
return mixture.Temperature * 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)
|
public void Merge(GasMixture receiver, GasMixture giver)
|
||||||
{
|
{
|
||||||
if (receiver.Immutable) return;
|
if (receiver.Immutable) return;
|
||||||
@@ -88,6 +108,9 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
NumericsHelpers.Add(receiver.Moles, giver.Moles);
|
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)
|
public float Share(GasMixture receiver, GasMixture sharer, int atmosAdjacentTurfs)
|
||||||
{
|
{
|
||||||
var temperatureDelta = receiver.TemperatureArchived - sharer.TemperatureArchived;
|
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)
|
public float TemperatureShare(GasMixture receiver, GasMixture sharer, float conductionCoefficient)
|
||||||
{
|
{
|
||||||
var temperatureDelta = receiver.TemperatureArchived - sharer.TemperatureArchived;
|
var temperatureDelta = receiver.TemperatureArchived - sharer.TemperatureArchived;
|
||||||
@@ -192,6 +218,9 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
return sharer.Temperature;
|
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)
|
public float TemperatureShare(GasMixture receiver, float conductionCoefficient, float sharerTemperature, float sharerHeatCapacity)
|
||||||
{
|
{
|
||||||
var temperatureDelta = receiver.TemperatureArchived - sharerTemperature;
|
var temperatureDelta = receiver.TemperatureArchived - sharerTemperature;
|
||||||
@@ -271,6 +300,9 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
return true;
|
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)
|
public void ScrubInto(GasMixture mixture, GasMixture destination, IReadOnlyCollection<Gas> filterGases)
|
||||||
{
|
{
|
||||||
var buffer = new GasMixture(mixture.Volume){Temperature = mixture.Temperature};
|
var buffer = new GasMixture(mixture.Volume){Temperature = mixture.Temperature};
|
||||||
@@ -284,6 +316,9 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
Merge(destination, buffer);
|
Merge(destination, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs reactions for a given gas mixture on an optional holder.
|
||||||
|
/// </summary>
|
||||||
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder)
|
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder)
|
||||||
{
|
{
|
||||||
var reaction = ReactionResult.NoReaction;
|
var reaction = ReactionResult.NoReaction;
|
||||||
@@ -300,7 +335,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
var doReaction = true;
|
var doReaction = true;
|
||||||
for (var i = 0; i < prototype.MinimumRequirements.Length; i++)
|
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!");
|
throw new IndexOutOfRangeException("Reaction Gas Minimum Requirements Array Prototype exceeds total number of gases!");
|
||||||
|
|
||||||
var req = prototype.MinimumRequirements[i];
|
var req = prototype.MinimumRequirements[i];
|
||||||
|
|||||||
@@ -9,25 +9,31 @@ using Robust.Shared.Map;
|
|||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Server.Atmos.EntitySystems
|
namespace Content.Server.Atmos.EntitySystems
|
||||||
{
|
{
|
||||||
public partial class AtmosphereSystem
|
public partial class AtmosphereSystem
|
||||||
{
|
{
|
||||||
|
private const int SpaceWindSoundCooldownCycles = 75;
|
||||||
|
|
||||||
private int _spaceWindSoundCooldown = 0;
|
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)
|
private void HighPressureMovements(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile)
|
||||||
{
|
{
|
||||||
// TODO ATMOS finish this
|
// 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);
|
var coordinates = tile.GridIndices.ToEntityCoordinates(tile.GridIndex, _mapManager);
|
||||||
if(!string.IsNullOrEmpty(SpaceWindSound))
|
SoundSystem.Play(Filter.Pvs(coordinates), SpaceWindSound, coordinates,
|
||||||
SoundSystem.Play(Filter.Pvs(coordinates), SpaceWindSound, coordinates,
|
AudioHelpers.WithVariation(0.125f).WithVolume(MathHelper.Clamp(tile.PressureDifference / 10, 10, 100)));
|
||||||
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!
|
// TODO ATMOS Do space wind graphics here!
|
||||||
}
|
}
|
||||||
|
|
||||||
_spaceWindSoundCooldown++;
|
if (_spaceWindSoundCooldown++ > SpaceWindSoundCooldownCycles)
|
||||||
if (_spaceWindSoundCooldown > 75)
|
|
||||||
_spaceWindSoundCooldown = 0;
|
_spaceWindSoundCooldown = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
using Content.Server.Atmos.Components;
|
using Content.Server.Atmos.Components;
|
||||||
using Content.Server.Atmos.Reactions;
|
using Content.Server.Atmos.Reactions;
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
|
using Content.Shared.Audio;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
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
|
namespace Content.Server.Atmos.EntitySystems
|
||||||
{
|
{
|
||||||
@@ -11,6 +17,13 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IEntityLookup _lookup = default!;
|
[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)
|
private void ProcessHotspot(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile)
|
||||||
{
|
{
|
||||||
if (!tile.Hotspot.Valid)
|
if (!tile.Hotspot.Valid)
|
||||||
@@ -70,6 +83,19 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
if (tile.Hotspot.Temperature > tile.MaxFireTemperatureSustained)
|
if (tile.Hotspot.Temperature > tile.MaxFireTemperatureSustained)
|
||||||
tile.MaxFireTemperatureSustained = tile.Hotspot.Temperature;
|
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?
|
// TODO ATMOS Maybe destroy location here?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -381,12 +381,6 @@ namespace Content.Shared.CCVar
|
|||||||
public static readonly CVarDef<bool> SpaceWind =
|
public static readonly CVarDef<bool> SpaceWind =
|
||||||
CVarDef.Create("atmos.space_wind", true, CVar.SERVERONLY);
|
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>
|
/// <summary>
|
||||||
/// Whether monstermos tile equalization is enabled.
|
/// Whether monstermos tile equalization is enabled.
|
||||||
/// </summary>
|
/// </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_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
|
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