/****************************************************************************
 * Copyright (c) 2024 MAK Technologies, Inc.
 * All rights reserved.
 ****************************************************************************/

/*********************************************************************
 **
 *t  diguySoundInstance
 **
 */

#pragma once

#ifdef SWIG
%module diguySoundInstance
#else
#define CPLUSPLUS_ONLY
#endif

#ifdef CPLUSPLUS_ONLY
class bdiSoundInstance;
class bdiScenarioCharacter;
#endif

#include <declspec_diguy.h>

/****************************************************************************/
class BDI_DECLSPEC_diguy diguySoundInstance
{
public:

   /*l
    **
    *b  Returns:
    **
    **    name of the sound used by the sound instance.
    **
    *b  Callable From:
    **
    *-    - C++
    *-    - Script
    */
   const char* get_name();

   /*l
    *b  Returns:
    **
    **    type name of the object; this value will never be NULL
    **
    *b  Callable From:
    **
    *-    - C++
    *-    - Script
    */
   const char* get_type_name();

   /*l
    *b  Description:
    **
    **    This function causes the sound to play immediately, starting from
    **    the specified time offset. The sound will continue until it has
    **    completed, or it is stopped.
    **
    *b  Returns:
    **
    **    0 on success, -1 on failure
    **
    *b  Callable From:
    **
    *-    - C++
    *-    - Script
    */
   int play(double offset = 0.0);

   /*l
    *b  Returns:
    **
    **    1 if the sound is playing; 0 if not
    **
    *b  Callable From:
    **
    *-    - C++
    *-    - Script
    */
   int get_is_playing();

   /*l
    *b  Returns:
    **
    **    1 if the sound is stopping; 0 if not
    **
    *b  Callable From:
    **
    *-    - C++
    *-    - Script
    */
   int get_is_stopping();

   /*l
    *b  Description:
    **
    **    This function causes this sound to stop.  It does not destroy the
    **    sound instance.  The sound instance can be played again if desired.
    **
    *b  Arguments
    **
    *a    rampdown_time - how long to take fading out the sound
    **
    ** *b  Returns:
    **
    **    0 on success, -1 on failure
    **
    *b  Callable From:
    **
    *-    - C++
    *-    - Script
    */
   int stop(float rampdown_time = 0.0f);

   /*l
    *b  Description:
    **
    **    This function causes the sound instance to be automatically
    **    deleted when the sound has completed.  No further calls
    **    through the diguySoundInstance object can or should
    **    be made, so this function should only be called once all
    **    durations, reps, etc. have been set.
    **
    *b  Returns:
    **
    **    0 on success, -1 on failure
    **
    *b  Callable From:
    **
    *-    - C++
    *-    - Script
    */
   int set_automatic_destroy_flag();

   /*l
    *b  Description:
    **
    **    This function sets whether the sound is "ambient" (it will
    **    be equally audible from everywhere within the world), or
    **    "3d" (it will move with the character.
    **
    *b  Arguments
    **
    *a    is_3d_sound_flag - pass 1 to make the sound 3d; pass 0 to make
     *a                       the sound ambient
    **
    *b  Callable From:
    **
    *-    - C++
    *-    - Script
    */
   void set_is_3d_sound_flag(int is_3d_sound_flag);

   /*l
    *b  Returns:
    **
    **    1 if the sound is 3d; 0 if not
    **
    *b  Callable From:
    **
    *-    - C++
    *-    - Script
    */
   int get_is_3d_sound_flag();


/**
 *x  The functions and variables past this point are for internal use only.
 **   No external access to them is expected or necessary.
 */
#ifdef CPLUSPLUS_ONLY

   bdiSoundInstance* get_scripted_object() { return m_scripted_object; }

private:

   void clear_scripted_object() { m_scripted_object = nullptr; }

   /*l
    **    A private constructor.
    */
   diguySoundInstance( bdiSoundInstance* scripted_object, bdiScenarioCharacter* character );

   /*l
    **    A private destructor.
    */
   virtual ~diguySoundInstance();

   /*l
    **    A pointer to internal data.
    */
   bdiSoundInstance* m_scripted_object;
   bdiScenarioCharacter* m_character;

   friend class bdiScenarioCharacter;
   friend class bdiSoundInstance;
   friend class bdiSoundFactory;
   friend class bdiSoundFactoryOpenAL;

#endif

};
