Partial Weapon class implementing scoping behavior. Handles starting and ending a scope action: sets lens center, waits for scope-in delay, toggles IsScoping and viewmodel visibility, and plays optional scope in/out sounds.
namespace SWB.Base;
public partial class Weapon
{
public async virtual void OnScopeStart()
{
SetScopeLensCenter( DefaultScopeLensCenter );
await GameTask.DelaySeconds( ScopeInfo.ScopeInDelay );
if ( !this.IsValid() || !IsAiming || IsScoping || IsReloading ) return;
IsScoping = true;
ViewModelHandler.ShouldDraw = false;
if ( ScopeInfo.ScopeInSound is not null )
PlaySound( ScopeInfo.ScopeInSound );
}
public virtual void OnScopeEnd()
{
SetScopeLensCenter( DefaultScopeLensCenter );
if ( !IsScoping ) return;
IsScoping = false;
ViewModelHandler.ShouldDraw = true;
if ( ScopeInfo.ScopeOutSound is not null )
PlaySound( ScopeInfo.ScopeOutSound );
}
}