2016-04-20 21:44:18 +00:00
|
|
|
#include "CScriptSound.hpp"
|
|
|
|
#include "Character/CModelData.hpp"
|
|
|
|
#include "Collision/CMaterialList.hpp"
|
2017-07-07 12:23:20 +00:00
|
|
|
#include "CStateManager.hpp"
|
|
|
|
#include "CWorld.hpp"
|
2016-04-20 21:44:18 +00:00
|
|
|
#include "CActorParameters.hpp"
|
2017-01-15 03:07:01 +00:00
|
|
|
#include "TCastTo.hpp"
|
2016-04-20 21:44:18 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
2017-01-24 17:23:10 +00:00
|
|
|
bool CScriptSound::sFirstInFrame = false;
|
2016-04-20 21:44:18 +00:00
|
|
|
|
2017-01-24 17:23:10 +00:00
|
|
|
CScriptSound::CScriptSound(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf,
|
|
|
|
s16 soundId, bool active, float f1, float f2, float f3, u32 w1, u32 w2, u32 w3, u32 w4,
|
2017-08-29 13:17:52 +00:00
|
|
|
u32 w5, u32 w6, bool b1, bool b2, bool autoStart, bool b4, bool b5, bool b6, bool b7, u32 w7)
|
2017-01-24 17:23:10 +00:00
|
|
|
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::Unknown),
|
|
|
|
CActorParameters::None(), kInvalidUniqueId)
|
|
|
|
, xfc_(f3)
|
|
|
|
, x100_soundId(CSfxManager::TranslateSFXID(soundId))
|
|
|
|
, x104_(f1)
|
|
|
|
, x108_(f2)
|
|
|
|
, x10c_(w1)
|
|
|
|
, x10e_(w2)
|
|
|
|
, x110_(w3)
|
|
|
|
, x112_(w4)
|
|
|
|
, x114_(w5)
|
|
|
|
, x116_(w6)
|
|
|
|
, x118_(w7 + 8192)
|
2016-04-20 21:44:18 +00:00
|
|
|
{
|
2017-01-25 04:40:19 +00:00
|
|
|
x11c_25_ = b1;
|
|
|
|
x11c_26_ = b2;
|
2017-08-29 13:17:52 +00:00
|
|
|
x11c_27_autoStart = autoStart;
|
2017-01-25 04:40:19 +00:00
|
|
|
x11c_28_ = b4;
|
|
|
|
x11c_29_ = b5;
|
|
|
|
x11c_30_ = b6;
|
|
|
|
x11d_24_ = b7;
|
2017-01-24 17:23:10 +00:00
|
|
|
if (x11c_30_ && (!x11c_26_ || !x11c_25_))
|
|
|
|
x11c_30_ = false;
|
2016-04-20 21:44:18 +00:00
|
|
|
}
|
|
|
|
|
2017-01-24 17:23:10 +00:00
|
|
|
void CScriptSound::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
|
|
|
|
|
|
|
void CScriptSound::PreThink(float dt, CStateManager& mgr)
|
2017-01-15 03:07:01 +00:00
|
|
|
{
|
2017-01-24 17:23:10 +00:00
|
|
|
CEntity::PreThink(dt, mgr);
|
|
|
|
sFirstInFrame = true;
|
|
|
|
x11d_25_ = false;
|
2017-01-15 03:07:01 +00:00
|
|
|
}
|
|
|
|
|
2017-07-07 12:23:20 +00:00
|
|
|
void CScriptSound::Think(float dt, CStateManager& mgr)
|
|
|
|
{
|
|
|
|
}
|
2017-01-24 17:23:10 +00:00
|
|
|
|
|
|
|
void CScriptSound::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
|
|
|
|
{
|
|
|
|
CActor::AcceptScriptMsg(msg, uid, mgr);
|
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
{
|
2017-03-24 05:30:16 +00:00
|
|
|
case EScriptObjectMessage::Registered:
|
2017-01-24 17:23:10 +00:00
|
|
|
{
|
2017-08-29 13:17:52 +00:00
|
|
|
if (GetActive() && x11c_27_autoStart)
|
|
|
|
x11c_24_ = true;
|
|
|
|
x11c_31_ = mgr.GetIsGeneratingObject();
|
2017-01-24 17:23:10 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EScriptObjectMessage::Play:
|
|
|
|
{
|
2017-08-29 13:17:52 +00:00
|
|
|
if (GetActive())
|
|
|
|
PlaySound(mgr);
|
2017-01-24 17:23:10 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EScriptObjectMessage::Stop:
|
|
|
|
{
|
2017-08-29 13:17:52 +00:00
|
|
|
if (GetActive())
|
|
|
|
StopSound(mgr);
|
2017-01-24 17:23:10 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EScriptObjectMessage::Deactivate:
|
|
|
|
{
|
2017-08-29 13:17:52 +00:00
|
|
|
if (GetActive())
|
|
|
|
StopSound(mgr);
|
2017-01-24 17:23:10 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EScriptObjectMessage::Activate:
|
|
|
|
{
|
2017-08-29 13:17:52 +00:00
|
|
|
if(GetActive())
|
|
|
|
x11c_24_ = true;
|
2017-01-24 17:23:10 +00:00
|
|
|
}
|
|
|
|
break;
|
2017-02-14 04:27:20 +00:00
|
|
|
case EScriptObjectMessage::Deleted:
|
2017-01-24 17:23:10 +00:00
|
|
|
{
|
2017-08-29 13:17:52 +00:00
|
|
|
if (!x11c_30_)
|
|
|
|
StopSound(mgr);
|
2017-01-24 17:23:10 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-29 13:17:52 +00:00
|
|
|
void CScriptSound::PlaySound(CStateManager&)
|
|
|
|
{
|
|
|
|
}
|
2017-01-24 17:23:10 +00:00
|
|
|
|
2017-07-07 12:23:20 +00:00
|
|
|
void CScriptSound::StopSound(CStateManager& mgr)
|
2017-01-24 17:23:10 +00:00
|
|
|
{
|
2017-08-29 13:17:52 +00:00
|
|
|
x11c_24_ = false;
|
2017-07-07 12:23:20 +00:00
|
|
|
if (x11c_30_ && x11c_26_)
|
|
|
|
{
|
|
|
|
mgr.WorldNC()->StopSound(x100_soundId);
|
|
|
|
xec_sfxHandle.reset();
|
|
|
|
}
|
|
|
|
else if (xec_sfxHandle)
|
|
|
|
{
|
2017-07-07 13:41:53 +00:00
|
|
|
CSfxManager::RemoveEmitter(*xec_sfxHandle.get());
|
2017-07-07 12:23:20 +00:00
|
|
|
xec_sfxHandle.reset();
|
|
|
|
}
|
2017-01-24 17:23:10 +00:00
|
|
|
}
|
2016-04-20 21:44:18 +00:00
|
|
|
}
|