handle sounds when enabling/disabling

actorid
Marc Zinnschlag 15 years ago
parent d57c984517
commit 6f28bd9adf

@ -8,9 +8,12 @@
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwworld/environment.hpp"
#include "../mwrender/cellimp.hpp"
#include "../mwsound/soundmanager.hpp"
#include "containerutil.hpp"
namespace MWClass
@ -41,6 +44,17 @@ namespace MWClass
}
}
void Light::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
ptr.get<ESM::Light>();
if (!ref->base->sound.empty())
{
environment.mSoundManager->playSound3D (ptr, ref->base->sound, 1.0, 1.0, true);
}
}
std::string Light::getName (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =

@ -13,6 +13,11 @@ namespace MWClass
MWWorld::Environment& environment) const;
///< Add reference into a cell for rendering
virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< Enable reference; only does the non-rendering part
/// \attention This is not the same as the script instruction with the same name. References
/// should only be enabled while in an active cell.
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.

@ -392,7 +392,10 @@ namespace MWWorld
render->disable (reference.getRefData().getHandle());
if (mActiveCells.find (reference.getCell())!=mActiveCells.end())
{
Class::get (reference).disable (reference, mEnvironment);
mEnvironment.mSoundManager->stopSound3D (reference);
}
}
}
}
@ -620,7 +623,10 @@ namespace MWWorld
ptr.getRefData().setHandle ("");
if (mActiveCells.find (ptr.getCell())!=mActiveCells.end())
{
Class::get (ptr).disable (ptr, mEnvironment);
mEnvironment.mSoundManager->stopSound3D (ptr);
}
}
}
}

Loading…
Cancel
Save