mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-27 04:40:26 +00:00
Merge pull request #2955 from elsid/sound_npc_animation
Use pointer to Sound to stop sounds started by NpcAnimation
This commit is contained in:
commit
49489b31f7
2 changed files with 16 additions and 7 deletions
|
@ -349,6 +349,8 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group> par
|
||||||
mPartPriorities[i] = 0;
|
mPartPriorities[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::fill(mSounds.begin(), mSounds.end(), nullptr);
|
||||||
|
|
||||||
updateNpcBase();
|
updateNpcBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -756,10 +758,10 @@ void NpcAnimation::removeIndividualPart(ESM::PartReferenceType type)
|
||||||
mPartslots[type] = -1;
|
mPartslots[type] = -1;
|
||||||
|
|
||||||
mObjectParts[type].reset();
|
mObjectParts[type].reset();
|
||||||
if (!mSoundIds[type].empty() && !mSoundsDisabled)
|
if (mSounds[type] != nullptr && !mSoundsDisabled)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->stopSound3D(mPtr, mSoundIds[type]);
|
MWBase::Environment::get().getSoundManager()->stopSound(mSounds[type]);
|
||||||
mSoundIds[type].clear();
|
mSounds[type] = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -838,10 +840,10 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g
|
||||||
MWWorld::ConstContainerStoreIterator csi = inv.getSlot(group < 0 ? MWWorld::InventoryStore::Slot_Helmet : group);
|
MWWorld::ConstContainerStoreIterator csi = inv.getSlot(group < 0 ? MWWorld::InventoryStore::Slot_Helmet : group);
|
||||||
if (csi != inv.end())
|
if (csi != inv.end())
|
||||||
{
|
{
|
||||||
mSoundIds[type] = csi->getClass().getSound(*csi);
|
const auto soundId = csi->getClass().getSound(*csi);
|
||||||
if (!mSoundIds[type].empty())
|
if (!soundId.empty())
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D(mPtr, mSoundIds[type],
|
mSounds[type] = MWBase::Environment::get().getSoundManager()->playSound3D(mPtr, soundId,
|
||||||
1.0f, 1.0f, MWSound::Type::Sfx, MWSound::PlayMode::Loop
|
1.0f, 1.0f, MWSound::Type::Sfx, MWSound::PlayMode::Loop
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,19 @@
|
||||||
#include "actoranimation.hpp"
|
#include "actoranimation.hpp"
|
||||||
#include "weaponanimation.hpp"
|
#include "weaponanimation.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
namespace ESM
|
namespace ESM
|
||||||
{
|
{
|
||||||
struct NPC;
|
struct NPC;
|
||||||
struct BodyPart;
|
struct BodyPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace MWSound
|
||||||
|
{
|
||||||
|
class Sound;
|
||||||
|
}
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -40,7 +47,7 @@ private:
|
||||||
|
|
||||||
// Bounded Parts
|
// Bounded Parts
|
||||||
PartHolderPtr mObjectParts[ESM::PRT_Count];
|
PartHolderPtr mObjectParts[ESM::PRT_Count];
|
||||||
std::string mSoundIds[ESM::PRT_Count];
|
std::array<MWSound::Sound*, ESM::PRT_Count> mSounds;
|
||||||
|
|
||||||
const ESM::NPC *mNpc;
|
const ESM::NPC *mNpc;
|
||||||
std::string mHeadModel;
|
std::string mHeadModel;
|
||||||
|
|
Loading…
Reference in a new issue