mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 06:53:52 +00:00
handle sounds when enabling/disabling
This commit is contained in:
parent
d57c984517
commit
6f28bd9adf
3 changed files with 25 additions and 0 deletions
|
@ -8,9 +8,12 @@
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/actiontake.hpp"
|
#include "../mwworld/actiontake.hpp"
|
||||||
#include "../mwworld/nullaction.hpp"
|
#include "../mwworld/nullaction.hpp"
|
||||||
|
#include "../mwworld/environment.hpp"
|
||||||
|
|
||||||
#include "../mwrender/cellimp.hpp"
|
#include "../mwrender/cellimp.hpp"
|
||||||
|
|
||||||
|
#include "../mwsound/soundmanager.hpp"
|
||||||
|
|
||||||
#include "containerutil.hpp"
|
#include "containerutil.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
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
|
std::string Light::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
||||||
|
|
|
@ -13,6 +13,11 @@ namespace MWClass
|
||||||
MWWorld::Environment& environment) const;
|
MWWorld::Environment& environment) const;
|
||||||
///< Add reference into a cell for rendering
|
///< 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;
|
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);
|
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||||
/// can return an empty string.
|
/// can return an empty string.
|
||||||
|
|
|
@ -392,7 +392,10 @@ namespace MWWorld
|
||||||
render->disable (reference.getRefData().getHandle());
|
render->disable (reference.getRefData().getHandle());
|
||||||
|
|
||||||
if (mActiveCells.find (reference.getCell())!=mActiveCells.end())
|
if (mActiveCells.find (reference.getCell())!=mActiveCells.end())
|
||||||
|
{
|
||||||
Class::get (reference).disable (reference, mEnvironment);
|
Class::get (reference).disable (reference, mEnvironment);
|
||||||
|
mEnvironment.mSoundManager->stopSound3D (reference);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -620,7 +623,10 @@ namespace MWWorld
|
||||||
ptr.getRefData().setHandle ("");
|
ptr.getRefData().setHandle ("");
|
||||||
|
|
||||||
if (mActiveCells.find (ptr.getCell())!=mActiveCells.end())
|
if (mActiveCells.find (ptr.getCell())!=mActiveCells.end())
|
||||||
|
{
|
||||||
Class::get (ptr).disable (ptr, mEnvironment);
|
Class::get (ptr).disable (ptr, mEnvironment);
|
||||||
|
mEnvironment.mSoundManager->stopSound3D (ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue