v0.11.0.9
This commit is contained in:
@@ -57,65 +57,9 @@ namespace Barotrauma
|
||||
{
|
||||
if (entity == null) { return; }
|
||||
|
||||
if (sounds.Count > 0 && playSound)
|
||||
if (playSound)
|
||||
{
|
||||
if (soundChannel == null || !soundChannel.IsPlaying)
|
||||
{
|
||||
if (soundSelectionMode == SoundSelectionMode.All)
|
||||
{
|
||||
foreach (RoundSound sound in sounds)
|
||||
{
|
||||
if (sound?.Sound == null)
|
||||
{
|
||||
string errorMsg = $"Error in StatusEffect.ApplyProjSpecific1 (sound \"{sound?.Filename ?? "unknown"}\" was null)\n" + Environment.StackTrace.CleanupStackTrace();
|
||||
GameAnalyticsManager.AddErrorEventOnce("StatusEffect.ApplyProjSpecific:SoundNull1" + Environment.StackTrace.CleanupStackTrace(), GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
return;
|
||||
}
|
||||
soundChannel = SoundPlayer.PlaySound(sound.Sound, worldPosition, sound.Volume, sound.Range, hullGuess: hull);
|
||||
if (soundChannel != null) { soundChannel.Looping = loopSound; }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int selectedSoundIndex;
|
||||
if (soundSelectionMode == SoundSelectionMode.ItemSpecific && entity is Item item)
|
||||
{
|
||||
selectedSoundIndex = item.ID % sounds.Count;
|
||||
}
|
||||
else if (soundSelectionMode == SoundSelectionMode.CharacterSpecific && entity is Character user)
|
||||
{
|
||||
selectedSoundIndex = user.ID % sounds.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedSoundIndex = Rand.Int(sounds.Count);
|
||||
}
|
||||
var selectedSound = sounds[selectedSoundIndex];
|
||||
if (selectedSound?.Sound == null)
|
||||
{
|
||||
string errorMsg = $"Error in StatusEffect.ApplyProjSpecific2 (sound \"{selectedSound?.Filename ?? "unknown"}\" was null)\n" + Environment.StackTrace.CleanupStackTrace();
|
||||
GameAnalyticsManager.AddErrorEventOnce("StatusEffect.ApplyProjSpecific:SoundNull2" + Environment.StackTrace.CleanupStackTrace(), GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
return;
|
||||
}
|
||||
if (selectedSound.Sound.Disposed)
|
||||
{
|
||||
Submarine.ReloadRoundSound(selectedSound);
|
||||
}
|
||||
soundChannel = SoundPlayer.PlaySound(selectedSound.Sound, worldPosition, selectedSound.Volume, selectedSound.Range, hullGuess: hull);
|
||||
if (soundChannel != null) { soundChannel.Looping = loopSound; }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
soundChannel.Position = new Vector3(worldPosition, 0.0f);
|
||||
}
|
||||
|
||||
if (soundChannel != null && soundChannel.Looping)
|
||||
{
|
||||
ActiveLoopingSounds.Add(this);
|
||||
soundEmitter = entity;
|
||||
loopStartTime = Timing.TotalTime;
|
||||
}
|
||||
PlaySound(entity, hull, worldPosition);
|
||||
}
|
||||
|
||||
foreach (ParticleEmitter emitter in particleEmitters)
|
||||
@@ -151,6 +95,69 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private void PlaySound(Entity entity, Hull hull, Vector2 worldPosition)
|
||||
{
|
||||
if (sounds.Count == 0) return;
|
||||
|
||||
if (soundChannel == null || !soundChannel.IsPlaying)
|
||||
{
|
||||
if (soundSelectionMode == SoundSelectionMode.All)
|
||||
{
|
||||
foreach (RoundSound sound in sounds)
|
||||
{
|
||||
if (sound?.Sound == null)
|
||||
{
|
||||
string errorMsg = $"Error in StatusEffect.ApplyProjSpecific1 (sound \"{sound?.Filename ?? "unknown"}\" was null)\n" + Environment.StackTrace.CleanupStackTrace();
|
||||
GameAnalyticsManager.AddErrorEventOnce("StatusEffect.ApplyProjSpecific:SoundNull1" + Environment.StackTrace.CleanupStackTrace(), GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
return;
|
||||
}
|
||||
soundChannel = SoundPlayer.PlaySound(sound.Sound, worldPosition, sound.Volume, sound.Range, hullGuess: hull);
|
||||
if (soundChannel != null) { soundChannel.Looping = loopSound; }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int selectedSoundIndex;
|
||||
if (soundSelectionMode == SoundSelectionMode.ItemSpecific && entity is Item item)
|
||||
{
|
||||
selectedSoundIndex = item.ID % sounds.Count;
|
||||
}
|
||||
else if (soundSelectionMode == SoundSelectionMode.CharacterSpecific && entity is Character user)
|
||||
{
|
||||
selectedSoundIndex = user.ID % sounds.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedSoundIndex = Rand.Int(sounds.Count);
|
||||
}
|
||||
var selectedSound = sounds[selectedSoundIndex];
|
||||
if (selectedSound?.Sound == null)
|
||||
{
|
||||
string errorMsg = $"Error in StatusEffect.ApplyProjSpecific2 (sound \"{selectedSound?.Filename ?? "unknown"}\" was null)\n" + Environment.StackTrace.CleanupStackTrace();
|
||||
GameAnalyticsManager.AddErrorEventOnce("StatusEffect.ApplyProjSpecific:SoundNull2" + Environment.StackTrace.CleanupStackTrace(), GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
return;
|
||||
}
|
||||
if (selectedSound.Sound.Disposed)
|
||||
{
|
||||
Submarine.ReloadRoundSound(selectedSound);
|
||||
}
|
||||
soundChannel = SoundPlayer.PlaySound(selectedSound.Sound, worldPosition, selectedSound.Volume, selectedSound.Range, hullGuess: hull);
|
||||
if (soundChannel != null) { soundChannel.Looping = loopSound; }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
soundChannel.Position = new Vector3(worldPosition, 0.0f);
|
||||
}
|
||||
|
||||
if (soundChannel != null && soundChannel.Looping)
|
||||
{
|
||||
ActiveLoopingSounds.Add(this);
|
||||
soundEmitter = entity;
|
||||
loopStartTime = Timing.TotalTime;
|
||||
}
|
||||
}
|
||||
|
||||
static partial void UpdateAllProjSpecific(float deltaTime)
|
||||
{
|
||||
bool doMuffleCheck = Timing.TotalTime > LastMuffleCheckTime + 0.2;
|
||||
|
||||
Reference in New Issue
Block a user