From 733654d730dcab2d26ab5d7b2f789adc16ed7c40 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 4 Sep 2012 15:14:33 +0200 Subject: [PATCH] Issue #370: implemented target handling in action base class --- apps/openmw/mwworld/action.cpp | 15 ++++++++++----- apps/openmw/mwworld/action.hpp | 13 +++++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwworld/action.cpp b/apps/openmw/mwworld/action.cpp index 748f6aff7..efce2b129 100644 --- a/apps/openmw/mwworld/action.cpp +++ b/apps/openmw/mwworld/action.cpp @@ -6,7 +6,12 @@ #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() {} @@ -15,16 +20,16 @@ void MWWorld::Action::execute (const Ptr& actor) { 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::SoundManager::Play_NoTrack); } else { - MWBase::Environment::get().getSoundManager()->playSound3D (actor, mSoundId, 1.0, 1.0, - MWBase::SoundManager::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (mTarget.isEmpty() ? actor : mTarget, + mSoundId, 1.0, 1.0, + mTeleport ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal); } } diff --git a/apps/openmw/mwworld/action.hpp b/apps/openmw/mwworld/action.hpp index 511a7002d..c47565113 100644 --- a/apps/openmw/mwworld/action.hpp +++ b/apps/openmw/mwworld/action.hpp @@ -3,15 +3,16 @@ #include +#include "ptr.hpp" + namespace MWWorld { - class Ptr; - /// \brief Abstract base for actions class Action { std::string mSoundId; bool mTeleport; + Ptr mTarget; // not implemented Action (const Action& action); @@ -19,9 +20,13 @@ namespace MWWorld virtual void executeImp (const Ptr& actor) = 0; - public: + protected: - Action (bool teleport = false); + const Ptr& getTarget() const; + + public: + + Action (bool teleport = false, const Ptr& target = Ptr()); ///< \param teleport action will teleport the actor virtual ~Action();