forked from teamnwah/openmw-tes3coop
Issue #370: implemented target handling in action base class
This commit is contained in:
parent
1cecab6e3d
commit
733654d730
2 changed files with 19 additions and 9 deletions
|
@ -6,7 +6,12 @@
|
||||||
|
|
||||||
#include "../mwbase/soundmanager.hpp"
|
#include "../mwbase/soundmanager.hpp"
|
||||||
|
|
||||||
MWWorld::Action::Action (bool teleport) : mTeleport (teleport)
|
const MWWorld::Ptr& MWWorld::Action::getTarget() const
|
||||||
|
{
|
||||||
|
return mTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWWorld::Action::Action (bool teleport, const Ptr& target) : mTeleport (teleport), mTarget (target)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
MWWorld::Action::~Action() {}
|
MWWorld::Action::~Action() {}
|
||||||
|
@ -15,16 +20,16 @@ void MWWorld::Action::execute (const Ptr& actor)
|
||||||
{
|
{
|
||||||
if (!mSoundId.empty())
|
if (!mSoundId.empty())
|
||||||
{
|
{
|
||||||
if (mTeleport == true)
|
if (mTeleport && actor.getRefData().getHandle()=="player")
|
||||||
{
|
{
|
||||||
//this is a teleport action, so we need to call playSound
|
|
||||||
MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0,
|
MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0,
|
||||||
MWBase::SoundManager::Play_NoTrack);
|
MWBase::SoundManager::Play_NoTrack);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (actor, mSoundId, 1.0, 1.0,
|
MWBase::Environment::get().getSoundManager()->playSound3D (mTarget.isEmpty() ? actor : mTarget,
|
||||||
MWBase::SoundManager::Play_NoTrack);
|
mSoundId, 1.0, 1.0,
|
||||||
|
mTeleport ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,15 +3,16 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "ptr.hpp"
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
class Ptr;
|
|
||||||
|
|
||||||
/// \brief Abstract base for actions
|
/// \brief Abstract base for actions
|
||||||
class Action
|
class Action
|
||||||
{
|
{
|
||||||
std::string mSoundId;
|
std::string mSoundId;
|
||||||
bool mTeleport;
|
bool mTeleport;
|
||||||
|
Ptr mTarget;
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
Action (const Action& action);
|
Action (const Action& action);
|
||||||
|
@ -19,9 +20,13 @@ namespace MWWorld
|
||||||
|
|
||||||
virtual void executeImp (const Ptr& actor) = 0;
|
virtual void executeImp (const Ptr& actor) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
const Ptr& getTarget() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Action (bool teleport = false);
|
Action (bool teleport = false, const Ptr& target = Ptr());
|
||||||
///< \param teleport action will teleport the actor
|
///< \param teleport action will teleport the actor
|
||||||
|
|
||||||
virtual ~Action();
|
virtual ~Action();
|
||||||
|
|
Loading…
Reference in a new issue