Reconstruct lab story, interactions, patrol and jet pack practice flow
This commit is contained in:
1 parent
58424120bb
commit
c929f942e1
84 files changed
+7957
-305
No files matched your search
@@ -0,0 +1,61 @@
|
||||
using GamePort.Assets;
|
||||
|
||||
namespace GamePort.Audio;
|
||||
|
||||
/// <summary>Independent original music and sequential speech streams.</summary>
|
||||
public sealed class SceneAudio : IDisposable
|
||||
{
|
||||
private readonly PreparedEntityResources resources;
|
||||
private SdlAudio? music, speech;
|
||||
private readonly List<SdlAudio> effects = [];
|
||||
private readonly Dictionary<string, SdlAudio> loops = new(StringComparer.OrdinalIgnoreCase);
|
||||
public int EffectCount => effects.Count;
|
||||
public int LoopCount => loops.Count;
|
||||
public int QueuedEffectBytes => effects.Sum(effect => effect.QueuedBytes) + loops.Values.Sum(effect => effect.QueuedBytes);
|
||||
public int QueuedMusicBytes => music?.QueuedBytes ?? 0;
|
||||
public int QueuedSpeechBytes => speech?.QueuedBytes ?? 0;
|
||||
public SceneAudio(PreparedEntityResources resources) => this.resources = resources;
|
||||
public void Music(string database, int id)
|
||||
{
|
||||
music?.Dispose(); music = null;
|
||||
if (resources.Wave(database, id) is { } wave) music = new(wave.Path, true);
|
||||
}
|
||||
public void Speech(string database, int id)
|
||||
{
|
||||
StopSpeech();
|
||||
var wave = resources.Wave(database, id) ?? throw new FileNotFoundException($"Missing prepared speech: {database}:{id}");
|
||||
speech = new(wave.Path);
|
||||
}
|
||||
public void StopSpeech() { speech?.Dispose(); speech = null; }
|
||||
// Default current bank set by Jimmy PostLoad423642..656; positional attenuation
|
||||
// and original channel/volume policy are separate unrecovered consumers.
|
||||
public void Effect(int id, string? loopOwner = null)
|
||||
{
|
||||
var wave = resources.Wave("SoundEffects.omt", id)
|
||||
?? throw new FileNotFoundException($"Missing original default sound effect {id}");
|
||||
if (loopOwner == null) effects.Add(new(wave.Path));
|
||||
else
|
||||
{
|
||||
StopLoop(loopOwner);
|
||||
loops.Add(loopOwner, new(wave.Path, true));
|
||||
}
|
||||
}
|
||||
public void StopLoop(string owner)
|
||||
{
|
||||
if (loops.Remove(owner, out var stream)) stream.Dispose();
|
||||
}
|
||||
public void StopEffects()
|
||||
{
|
||||
foreach (var effect in effects) effect.Dispose();
|
||||
foreach (var effect in loops.Values) effect.Dispose();
|
||||
effects.Clear(); loops.Clear();
|
||||
}
|
||||
public void Pump()
|
||||
{
|
||||
music?.Pump(); speech?.Pump();
|
||||
foreach (var effect in loops.Values) effect.Pump();
|
||||
for (var i = effects.Count - 1; i >= 0; i--)
|
||||
if (effects[i].QueuedBytes == 0) { effects[i].Dispose(); effects.RemoveAt(i); }
|
||||
}
|
||||
public void Dispose() { StopEffects(); StopSpeech(); music?.Dispose(); music = null; }
|
||||
}
|
||||
Reference in new issue
Block a user