2012-07-27 10:00:10 +00:00
|
|
|
|
|
|
|
#include "action.hpp"
|
|
|
|
|
2012-07-27 10:19:25 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
2012-08-26 14:47:45 +00:00
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
2012-08-09 12:33:21 +00:00
|
|
|
#include "../mwbase/soundmanager.hpp"
|
2012-07-27 10:19:25 +00:00
|
|
|
|
2012-09-04 13:14:33 +00:00
|
|
|
const MWWorld::Ptr& MWWorld::Action::getTarget() const
|
|
|
|
{
|
|
|
|
return mTarget;
|
|
|
|
}
|
|
|
|
|
2012-09-04 18:56:28 +00:00
|
|
|
MWWorld::Action::Action (bool keepSound, const Ptr& target) : mKeepSound (keepSound), mTarget (target)
|
2012-08-26 16:50:47 +00:00
|
|
|
{}
|
2012-07-27 10:00:10 +00:00
|
|
|
|
|
|
|
MWWorld::Action::~Action() {}
|
|
|
|
|
|
|
|
void MWWorld::Action::execute (const Ptr& actor)
|
|
|
|
{
|
2012-07-27 10:19:25 +00:00
|
|
|
if (!mSoundId.empty())
|
2012-08-19 23:11:50 +00:00
|
|
|
{
|
2012-09-04 18:56:28 +00:00
|
|
|
if (mKeepSound && actor.getRefData().getHandle()=="player")
|
2012-08-26 16:50:47 +00:00
|
|
|
{
|
2012-09-04 13:21:56 +00:00
|
|
|
// sound moves with player when teleporting
|
2012-08-26 16:50:47 +00:00
|
|
|
MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0,
|
|
|
|
MWBase::SoundManager::Play_NoTrack);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-04 13:21:56 +00:00
|
|
|
bool local = mTarget.isEmpty() || !mTarget.isInCell(); // no usable target
|
|
|
|
|
|
|
|
MWBase::Environment::get().getSoundManager()->playSound3D (local ? actor : mTarget,
|
2012-09-04 13:14:33 +00:00
|
|
|
mSoundId, 1.0, 1.0,
|
2012-09-04 18:56:28 +00:00
|
|
|
mKeepSound ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal);
|
2012-08-26 16:50:47 +00:00
|
|
|
}
|
2012-08-19 23:11:50 +00:00
|
|
|
}
|
2012-07-27 10:19:25 +00:00
|
|
|
|
2012-07-27 10:00:10 +00:00
|
|
|
executeImp (actor);
|
|
|
|
}
|
2012-07-27 10:19:25 +00:00
|
|
|
|
2012-08-26 14:47:45 +00:00
|
|
|
void MWWorld::Action::setSound (const std::string& id)
|
2012-07-27 10:19:25 +00:00
|
|
|
{
|
|
|
|
mSoundId = id;
|
|
|
|
}
|