Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 11, 2011, 1:03:47 PM (13 years ago)
Author:
landauf
Message:

detached AmbientSound from BaseObject - AmbientSound can not be placed directly in a level file anymore
instead added WorldAmbientSound, a BaseObject which can be placed in a level file to create and control ambient sound

with this change, the level can be destroyed completely because WorldAmbientSound can be deleted immediately at the end of the level, while the AmbientSound remains active until it faded out.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/sound/AmbientSound.cc

    r6417 r7854  
    2929#include "AmbientSound.h"
    3030
    31 #include "core/CoreIncludes.h"
    32 #include "core/EventIncludes.h"
    3331#include "core/GameMode.h"
    3432#include "core/Resource.h"
    35 #include "core/XMLPort.h"
    3633#include "SoundManager.h"
    3734
    3835namespace orxonox
    3936{
    40     CreateFactory(AmbientSound);
    41 
    42     AmbientSound::AmbientSound(BaseObject* creator)
    43         : BaseObject(creator)
    44         , Synchronisable(creator)
    45         , bPlayOnLoad_(false)
     37    AmbientSound::AmbientSound()
     38        : bPlayOnLoad_(false)
    4639    {
    47         RegisterObject(AmbientSound);
    48 
    4940        // Ambient sounds always fade in
    5041        this->setVolume(0);
    51         this->registerVariables();
    5242    }
    5343
     
    5949            SoundManager::getInstance().unregisterAmbientSound(this);
    6050        }
    61     }
    62 
    63     void AmbientSound::registerVariables()
    64     {
    65         registerVariable(ambientSource_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::ambientSourceChanged));
    66         registerVariable(bLooping_,      ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::loopingChanged));
    67         registerVariable(pitch_,         ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::pitchChanged));
    68         registerVariable(bPlayOnLoad_,   ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::playOnLoadChanged));
    69     }
    70 
    71     void AmbientSound::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    72     {
    73         SUPER(AmbientSound, XMLPort, xmlelement, mode);
    74         BaseSound::XMLPortExtern(xmlelement, mode);
    75         XMLPortParam(AmbientSound, "ambientSource", setAmbientSource, getAmbientSource, xmlelement, mode);
    76         XMLPortParam(AmbientSound, "playOnLoad", setPlayOnLoad, getPlayOnLoad, xmlelement, mode);
    77     }
    78 
    79     void AmbientSound::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
    80     {
    81         SUPER(AmbientSound, XMLEventPort, xmlelement, mode);
    82         XMLPortEventState(AmbientSound, BaseObject, "play", play, xmlelement, mode);
    8351    }
    8452
     
    132100            this->play();
    133101    }
    134 
    135     void AmbientSound::changedActivity()
    136     {
    137         SUPER(AmbientSound, changedActivity);
    138         if (this->isActive())
    139             this->play();
    140         else
    141             this->stop();
    142     }
    143102}
Note: See TracChangeset for help on using the changeset viewer.