Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpSoundManager.cpp
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | public: | ||||
virtual void Deserialize(const CParamNode& paramNode, IDeserializer& UNUSED(deserialize)) | virtual void Deserialize(const CParamNode& paramNode, IDeserializer& UNUSED(deserialize)) | ||||
{ | { | ||||
Init(paramNode); | Init(paramNode); | ||||
} | } | ||||
virtual void PlaySoundGroup(const std::wstring& name, entity_id_t source) | virtual void PlaySoundGroup(const std::wstring& name, entity_id_t source) | ||||
{ | { | ||||
if (!g_SoundManager || (source == INVALID_ENTITY)) | if (!ISoundManager::IsCreated() || (source == INVALID_ENTITY)) | ||||
return; | return; | ||||
int currentPlayer = GetSimContext().GetCurrentDisplayedPlayer(); | int currentPlayer = GetSimContext().GetCurrentDisplayedPlayer(); | ||||
CmpPtr<ICmpRangeManager> cmpRangeManager(GetSystemEntity()); | CmpPtr<ICmpRangeManager> cmpRangeManager(GetSystemEntity()); | ||||
if (!cmpRangeManager || (cmpRangeManager->GetLosVisibility(source, currentPlayer) != ICmpRangeManager::VIS_VISIBLE)) | if (!cmpRangeManager || (cmpRangeManager->GetLosVisibility(source, currentPlayer) != ICmpRangeManager::VIS_VISIBLE)) | ||||
return; | return; | ||||
CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), source); | CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), source); | ||||
if (!cmpPosition || !cmpPosition->IsInWorld()) | if (!cmpPosition || !cmpPosition->IsInWorld()) | ||||
return; | return; | ||||
bool playerOwned = false; | bool playerOwned = false; | ||||
CmpPtr<ICmpOwnership> cmpOwnership(GetSimContext(), source); | CmpPtr<ICmpOwnership> cmpOwnership(GetSimContext(), source); | ||||
if (cmpOwnership) | if (cmpOwnership) | ||||
playerOwned = cmpOwnership->GetOwner() == currentPlayer; | playerOwned = cmpOwnership->GetOwner() == currentPlayer; | ||||
CVector3D sourcePos = CVector3D(cmpPosition->GetPosition()); | CVector3D sourcePos = CVector3D(cmpPosition->GetPosition()); | ||||
g_SoundManager->PlayAsGroup(name, sourcePos, source, playerOwned); | ISoundManager::GetSoundManager()->PlayAsGroup(name, sourcePos, source, playerOwned); | ||||
} | } | ||||
virtual void PlaySoundGroupAtPosition(const std::wstring& name, const CFixedVector3D& sourcePos) | virtual void PlaySoundGroupAtPosition(const std::wstring& name, const CFixedVector3D& sourcePos) | ||||
{ | { | ||||
if (!g_SoundManager) | if (!ISoundManager::IsCreated()) | ||||
return; | return; | ||||
g_SoundManager->PlayAsGroup(name, CVector3D(sourcePos), INVALID_ENTITY, false); | ISoundManager::GetSoundManager()->PlayAsGroup(name, CVector3D(sourcePos), INVALID_ENTITY, false); | ||||
} | } | ||||
virtual void StopMusic() | virtual void StopMusic() | ||||
{ | { | ||||
if (!g_SoundManager) | if (!ISoundManager::IsCreated()) | ||||
return; | return; | ||||
g_SoundManager->Pause(true); | ISoundManager::GetSoundManager()->Pause(true); | ||||
} | } | ||||
}; | }; | ||||
REGISTER_COMPONENT_TYPE(SoundManager) | REGISTER_COMPONENT_TYPE(SoundManager) | ||||
Wildfire Games · Phabricator