Implement looping SFX and immediate rotation opcodes

This commit is contained in:
gamer147
2026-07-28 23:45:48 -04:00
parent d2ec834fc3
commit dad3ed4a4b
13 changed files with 112 additions and 28 deletions

View File

@@ -1608,12 +1608,14 @@ public sealed class GodotAdvHost : IHost
if (audio != null) _main.CallDeferred("LoadSoundEffect", audio.Bytes, audio.Name, channel);
}
public void StartSoundEffect(int channel)
public void StartSoundEffect(int channel) => StartSoundEffect(channel, 0);
public void StartSoundEffect(int channel, int startMode)
{
if ((uint)channel >= (uint)_sfxNames.Length || _sfxNames[channel] == null) return;
_timeline?.Event("sfx-start", new() { ["channel"] = channel,
["file"] = _sfxNames[channel] });
_main.CallDeferred("StartSoundEffect", channel);
["start_mode"] = startMode, ["file"] = _sfxNames[channel] });
_main.CallDeferred("StartSoundEffect", channel, startMode);
}
public void ScheduleSoundEffectStart(int channel, int startMode, long delayMs)

View File

@@ -1890,10 +1890,16 @@ public partial class Main : Godot.Control
_sfx[channel].Stream = stream;
}
public void StartSoundEffect(int channel)
public void StartSoundEffect(int channel) => StartSoundEffect(channel, 0);
public void StartSoundEffect(int channel, int startMode)
{
if ((uint)channel < (uint)_sfx.Length && _sfx[channel].Stream != null)
_sfx[channel].Play();
if ((uint)channel >= (uint)_sfx.Length || _sfx[channel].Stream == null) return;
if (_sfx[channel].Stream is AudioStreamWav wav)
wav.LoopMode = startMode == 0
? AudioStreamWav.LoopModeEnum.Disabled
: AudioStreamWav.LoopModeEnum.Forward;
_sfx[channel].Play();
}
public void ScheduleSoundEffectStart(int channel, int startMode, double realDelaySeconds)