anchor.diff:  {$I KaM_Remake.inc}
   interface
   uses
  +  Generics.Collections,
     OpenAL,
     KM_ResSound,
     KM_Defaults, KM_CommonClasses, KM_CommonTypes, KM_Points;
  
positive.code:     Attenuate: Boolean;
      Loc: TKMPoint;
      HandIndex: TKMHandID;
    end;
  
    TKMScriptSoundsManager = class
    private
      fListener: TKMPointF;
      fLastScriptUID: Integer; //Last Unique ID for playing sound from script
      fCount: Integer;
      fScriptSounds: array of TKMScriptSound;
      function CanPlay(aIndex: Integer): Boolean; overload;
      function CanPlay(aScriptSound: TKMScriptSound): Boolean; overload;
      function StartSound(aIndex: Integer): Integer; overload;
      function StartSound(var aScriptSound: TKMScriptSound): Integer; overload;
      procedure StopSound(aIndex: Integer);
      procedure RemoveSoundByIndex(aIndex: Integer);
      function GetCount: Integer;
    public
      constructor Create;
      destructor Destroy; override;
      property Count: Integer read GetCount;
  
      procedure Save(SaveStream: TKMemoryStream);
      procedure Load(LoadStream: TKMemoryStream);
  
      function AddSound(aHandIndex: TKMHandID; const aSoundName: AnsiString; aSoundFormat: TKMAudioFormat; aLoc: TKMPoint;
                        aAttenuate: Boolean; aVolume: Single; aRadius: Single; aFadeMusic, aLooped: Boolean): Integer;
      procedure RemoveLoopSoundByUID(aScriptIndex: Integer);
      procedure RemoveSoundByUID(aScriptUID: Integer; aLoopedOnly: Boolean = False);
      procedure UpdateListener(X,Y: Single);
  
negative.code: procedure TKMScriptSoundsManager.RemoveSoundByIndex(aIndex: Integer);
  begin
    StopSound(aIndex);
    fScriptSounds.Delete(aIndex);
  end;
  
  
  