codeAPI Reference

ReloadSoundEntry record struct

calendar_today May 12, 2026 schedule ~1 min read person PatrickJr verified 50

ReloadSoundEntry Record Struct

Defines a timed sound event to play during s&box weapon reload animations.

Properties

  • Time (float) - Seconds after reload starts to play this sound
  • Sound (SoundEvent) - The sound event to play

Usage

Used in ViewModel to define multiple timed sounds during reload sequences:

CSHARP
[Property, Group( "Reload Sounds" )]
public List<ReloadSoundEntry> ReloadSoundEvents { get; set; } = new();

The ViewModel plays these sounds asynchronously during reload using Task.DelaySeconds():

CSHARP
private async Task PlaySoundsAsync( List<ReloadSoundEntry> events, CancellationToken ct )
{
    var sorted = events.OrderBy( e => e.Time ).ToList();
    var elapsed = 0f;

    foreach ( var entry in sorted )
    {
        var delay = entry.Time - elapsed;

        if ( delay > 0f )
            await Task.DelaySeconds( delay, ct );

        if ( ct.IsCancellationRequested )
            return;

        if ( entry.Sound is not null )
            GameObject.PlaySound( entry.Sound );

        elapsed = entry.Time;
    }
}
  • ReloadSoundEvents - Timed sounds for standard reload
  • IncrementalReloadSoundEvents - Timed sounds for each incremental reload cycle
  • IncrementalReloadStartSounds - Timed sounds when starting incremental reload
  • IncrementalReloadFinishSounds - Timed sounds when finishing incremental reload

Location

File: d:\GitHubStuff\sandbox\code\Game\Weapon\WeaponModel\ViewModel.cs

Was this helpful?