Issue #351: Added sound playing to Action

This commit is contained in:
Marc Zinnschlag 2012-07-27 12:19:25 +02:00
parent 78fe6fdce5
commit 8b08928dae
2 changed files with 19 additions and 0 deletions

View file

@ -1,11 +1,24 @@
#include "action.hpp" #include "action.hpp"
#include "../mwbase/environment.hpp"
#include "../mwsound/soundmanager.hpp"
MWWorld::Action::Action() {} MWWorld::Action::Action() {}
MWWorld::Action::~Action() {} MWWorld::Action::~Action() {}
void MWWorld::Action::execute (const Ptr& actor) void MWWorld::Action::execute (const Ptr& actor)
{ {
if (!mSoundId.empty())
MWBase::Environment::get().getSoundManager()->playSound3D (actor, mSoundId, 1.0, 1.0,
MWSound::Play_NoTrack);
executeImp (actor); executeImp (actor);
} }
void MWWorld::Action::setSound (const std::string& id)
{
mSoundId = id;
}

View file

@ -1,6 +1,8 @@
#ifndef GAME_MWWORLD_ACTION_H #ifndef GAME_MWWORLD_ACTION_H
#define GAME_MWWORLD_ACTION_H #define GAME_MWWORLD_ACTION_H
#include <string>
namespace MWWorld namespace MWWorld
{ {
class Ptr; class Ptr;
@ -8,6 +10,8 @@ namespace MWWorld
/// \brief Abstract base for actions /// \brief Abstract base for actions
class Action class Action
{ {
std::string mSoundId;
// not implemented // not implemented
Action (const Action& action); Action (const Action& action);
Action& operator= (const Action& action); Action& operator= (const Action& action);
@ -21,6 +25,8 @@ namespace MWWorld
virtual ~Action(); virtual ~Action();
void execute (const Ptr& actor); void execute (const Ptr& actor);
void setSound (const std::string& id);
}; };
} }