1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 21:42:13 +00:00
OpenMW/apps/openmw/mwworld/action.cpp

46 lines
1.2 KiB
C++
Raw Normal View History

2012-07-27 10:00:10 +00:00
#include "action.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
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)
{
if (!mSoundId.empty())
{
2012-09-04 18:56:28 +00:00
if (mKeepSound && actor.getRefData().getHandle()=="player")
2012-08-26 16:50:47 +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
{
bool local = mTarget.isEmpty() || !mTarget.isInCell(); // no usable target
MWBase::Environment::get().getSoundManager()->playSound3D (local ? actor : mTarget,
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-07-27 10:00:10 +00:00
executeImp (actor);
}
void MWWorld::Action::setSound (const std::string& id)
{
mSoundId = id;
}