mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 03:07:41 +00:00
Finish CPlayerGun
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
#include "GameGlobalObjects.hpp"
|
||||
#include "CSimplePool.hpp"
|
||||
#include "Character/CPrimitive.hpp"
|
||||
#include "Audio/CSfxManager.hpp"
|
||||
#include "CStateManager.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
@@ -78,5 +80,83 @@ void get_token_vector(CAnimData& animData, int animIdx, std::vector<CToken>& tok
|
||||
primitive_set_to_token_vector(animData, prims, tokensOut, preLock);
|
||||
}
|
||||
|
||||
void do_sound_event(std::pair<u16, CSfxHandle>& sfxHandle, float& pitch, bool doPitchBend, u32 soundId,
|
||||
float weight, u32 flags, float falloff, float maxDist, float minVol, float maxVol,
|
||||
const zeus::CVector3f& posToCam, const zeus::CVector3f& pos, TAreaId aid,
|
||||
CStateManager& mgr)
|
||||
{
|
||||
if (posToCam.magSquared() >= maxDist * maxDist)
|
||||
return;
|
||||
|
||||
u16 useSfxId = CSfxManager::TranslateSFXID(u16(soundId));
|
||||
u32 useFlags = 0x1; // Continuous parameter update
|
||||
if ((flags & 0x8) != 0)
|
||||
useFlags |= 0x8; // Doppler effect
|
||||
bool useAcoustics = (flags & 0x80) == 0;
|
||||
|
||||
CAudioSys::C3DEmitterParmData parms;
|
||||
parms.x0_pos = pos;
|
||||
parms.xc_dir = zeus::CVector3f::skUp;
|
||||
parms.x18_maxDist = maxDist;
|
||||
parms.x1c_distComp = falloff;
|
||||
parms.x20_flags = useFlags;
|
||||
parms.x24_sfxId = useSfxId;
|
||||
parms.x26_maxVol = maxVol;
|
||||
parms.x27_minVol = minVol;
|
||||
parms.x28_important = false;
|
||||
parms.x29_prio = 0x7f;
|
||||
|
||||
if (mgr.GetActiveRandom()->Float() <= weight)
|
||||
{
|
||||
if ((soundId & 0x80000000) != 0)
|
||||
{
|
||||
if (!sfxHandle.second)
|
||||
{
|
||||
CSfxHandle hnd;
|
||||
if ((soundId & 0x40000000) != 0)
|
||||
hnd = CSfxManager::SfxStart(useSfxId, 1.f, 0.f, true, 0x7f, true, aid);
|
||||
else
|
||||
hnd = CSfxManager::AddEmitter(parms, useAcoustics, 0x7f, true, aid);
|
||||
if (hnd)
|
||||
{
|
||||
sfxHandle.first = useSfxId;
|
||||
sfxHandle.second = hnd;
|
||||
if (doPitchBend)
|
||||
CSfxManager::PitchBend(hnd, pitch);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sfxHandle.first == useSfxId)
|
||||
{
|
||||
CSfxManager::UpdateEmitter(sfxHandle.second, parms.x0_pos, parms.xc_dir, parms.x26_maxVol);
|
||||
}
|
||||
else if ((flags & 0x4) != 0) // Pausable
|
||||
{
|
||||
CSfxManager::RemoveEmitter(sfxHandle.second);
|
||||
CSfxHandle hnd = CSfxManager::AddEmitter(parms, useAcoustics, 0x7f, true, aid);
|
||||
if (hnd)
|
||||
{
|
||||
sfxHandle.first = useSfxId;
|
||||
sfxHandle.second = hnd;
|
||||
if (doPitchBend)
|
||||
CSfxManager::PitchBend(hnd, pitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CSfxHandle hnd;
|
||||
if ((soundId & 0x40000000) != 0)
|
||||
hnd = CSfxManager::SfxStart(useSfxId, 1.f, 0.f, true, 0x7f, false, aid);
|
||||
else
|
||||
hnd = CSfxManager::AddEmitter(parms, useAcoustics, 0x7f, false, aid);
|
||||
if (doPitchBend)
|
||||
CSfxManager::PitchBend(hnd, pitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user