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"
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,15 +3,16 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#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();
|
||||
|
|
Loading…
Reference in a new issue