metaforce/Runtime/World/CActor.cpp

227 lines
5.9 KiB
C++
Raw Normal View History

#include "CActor.hpp"
2016-04-22 20:22:45 +00:00
#include "CActorParameters.hpp"
#include "CStateManager.hpp"
#include "Collision/CMaterialList.hpp"
2016-04-29 10:08:46 +00:00
#include "Audio/CSfxManager.hpp"
2016-03-04 23:04:53 +00:00
namespace urde
{
2016-04-22 20:22:45 +00:00
static CMaterialList MakeActorMaterialList(const CMaterialList& materialList, const CActorParameters& params)
{
CMaterialList ret = materialList;
if (params.GetVisorParameters().x0_28_b3)
ret.Add(EMaterialTypes::Fourteen);
if (params.GetVisorParameters().x0_29_b4)
ret.Add(EMaterialTypes::Fifteen);
return ret;
}
2016-04-20 21:44:18 +00:00
CActor::CActor(TUniqueId uid, bool active, const std::string& name, const CEntityInfo& info,
2016-04-22 20:22:45 +00:00
const zeus::CTransform&, CModelData&& mData, const CMaterialList& list,
2016-05-03 08:27:28 +00:00
const CActorParameters& params, TUniqueId otherUid)
2016-04-29 10:08:46 +00:00
: CEntity(uid, info, active, name),
x68_material(MakeActorMaterialList(list, params)),
2016-05-03 08:27:28 +00:00
x70_(CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Nineteen}, {EMaterialTypes::Zero})),
xc6_(otherUid)
2016-04-22 20:22:45 +00:00
{
2016-05-03 08:27:28 +00:00
if (mData.x10_animData || mData.x1c_normalModel)
2016-04-22 20:22:45 +00:00
x64_modelData = std::make_unique<CModelData>(std::move(mData));
}
2016-04-29 10:08:46 +00:00
void CActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
{
switch(msg)
{
case EScriptObjectMessage::Activate:
{
if (!x30_24_active)
xbc_time = CGraphics::GetSecondsMod900();
}
break;
case EScriptObjectMessage::Decrement:
RemoveEmitter();
break;
case EScriptObjectMessage::InternalMessage11: // 33
2016-04-29 10:08:46 +00:00
{
/*
if (x94_simpleShadow)
2016-04-29 10:08:46 +00:00
AddMaterial(EMaterialTypes::ThirtyNine, mgr);
else
RemoveMaterial(EMaterialTypes::ThirtyNine, mgr);
*/
2016-04-29 10:08:46 +00:00
if (HasModelData() && x64_modelData->AnimationData())
{
TAreaId aid = GetAreaId();
//x64_modelData->AnimationData()->sub_8002AE6C(mgr, aid, x64_modelData->x0_particleScale);
2016-04-29 10:08:46 +00:00
}
}
break;
case EScriptObjectMessage::InternalMessage13: // 34
2016-04-29 10:08:46 +00:00
{
RemoveEmitter();
/* TODO: Not sure about this
if (HasModelData() && x64_modelData->AnimationData() && x64_modelData->x28_)
x64_modelData->AnimationData().GetParticleDB().GetActiveParticleLightIds(mgr);
*/
}
break;
case EScriptObjectMessage::InternalMessage14: // 35
2016-04-29 10:08:46 +00:00
{
for (const SConnection& conn : x20_conns)
{
if (conn.x0_state != EScriptObjectState::DFST)
continue;
const CActor* act = dynamic_cast<const CActor*>(mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId)));
if (act && xc6_ == kInvalidUniqueId)
xc6_ = act->GetUniqueId();
}
}
break;
case EScriptObjectMessage::InternalMessage16: // 37
2016-05-03 08:27:28 +00:00
SetInFluid(true, uid);
2016-04-29 10:08:46 +00:00
break;
case EScriptObjectMessage::InternalMessage18: // 39
2016-05-03 08:27:28 +00:00
SetInFluid(false, kInvalidUniqueId);
2016-04-29 10:08:46 +00:00
break;
default:break;
}
CEntity::AcceptScriptMsg(msg, uid, mgr);
}
2016-05-03 08:27:28 +00:00
zeus::CVector3f CActor::GetOrbitPosition(const CStateManager&)
{
return x34_transform.origin;
}
2016-04-29 10:08:46 +00:00
void CActor::RemoveEmitter()
{
if (x8c_sfxHandle)
{
CSfxManager::RemoveEmitter(*x8c_sfxHandle.get());
x88_sfxId = -1;
x8c_sfxHandle.reset();
}
}
2016-05-03 08:27:28 +00:00
EWeaponCollisionResponseTypes CActor::GetCollisionResponseType(const zeus::CVector3f&,
const zeus::CVector3f&, CWeaponMode&, int)
{
return EWeaponCollisionResponseTypes::Unknown13;
}
2016-04-22 20:22:45 +00:00
void CActor::RemoveMaterial(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, CStateManager& mgr)
{
2016-04-29 10:08:46 +00:00
x68_material.Remove(t1);
2016-04-22 20:22:45 +00:00
RemoveMaterial(t2, t3, t4, mgr);
}
void CActor::RemoveMaterial(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, CStateManager & mgr)
{
2016-04-29 10:08:46 +00:00
x68_material.Remove(t1);
2016-04-22 20:22:45 +00:00
RemoveMaterial(t2, t3, mgr);
}
void CActor::RemoveMaterial(EMaterialTypes t1, EMaterialTypes t2, CStateManager& mgr)
{
2016-04-29 10:08:46 +00:00
x68_material.Remove(t1);
2016-04-22 20:22:45 +00:00
}
void CActor::RemoveMaterial(EMaterialTypes t, CStateManager& mgr)
{
2016-04-29 10:08:46 +00:00
x68_material.Remove(t);
2016-04-22 20:22:45 +00:00
mgr.UpdateObjectInLists(*this);
}
void CActor::AddMaterial(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, EMaterialTypes t5, CStateManager& mgr)
{
2016-04-29 10:08:46 +00:00
x68_material.Add(t1);
2016-04-22 20:22:45 +00:00
AddMaterial(t2, t3, t4, t5, mgr);
}
void CActor::AddMaterial(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, CStateManager& mgr)
{
2016-04-29 10:08:46 +00:00
x68_material.Add(t1);
2016-04-22 20:22:45 +00:00
AddMaterial(t2, t3, t4, mgr);
}
void CActor::AddMaterial(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, CStateManager& mgr)
{
2016-04-29 10:08:46 +00:00
x68_material.Add(t1);
2016-04-22 20:22:45 +00:00
AddMaterial(t2, t3, mgr);
}
void CActor::AddMaterial(EMaterialTypes t1, EMaterialTypes t2, CStateManager& mgr)
{
2016-04-29 10:08:46 +00:00
x68_material.Add(t1);
2016-04-22 20:22:45 +00:00
AddMaterial(t2, mgr);
}
void CActor::AddMaterial(EMaterialTypes type, CStateManager& mgr)
2016-04-19 00:17:49 +00:00
{
2016-04-29 10:08:46 +00:00
x68_material.Add(type);
2016-04-22 20:22:45 +00:00
mgr.UpdateObjectInLists(*this);
2016-04-19 00:17:49 +00:00
}
2016-05-03 08:27:28 +00:00
void CActor::SetCallTouch(bool callTouch)
{
xe5_28_callTouch = callTouch;
}
bool CActor::GetCallTouch() const
{
return xe5_28_callTouch;
}
void CActor::SetUseInSortedList(bool use)
{
xe5_27_useInSortedLists = use;
}
bool CActor::GetUseInSortedLists() const
{
return xe5_27_useInSortedLists;
}
void CActor::SetInFluid(bool in, TUniqueId uid)
{
if (in)
{
xe6_26_inFluid = false;
xc4_fluidId = uid;
}
else
{
if (!xe6_26_inFluid)
return;
xe6_26_inFluid = true;
if (xe6_26_inFluid == 0)
xc4_fluidId = kInvalidUniqueId;
}
}
2016-04-29 10:08:46 +00:00
bool CActor::HasModelData() const
{
2016-05-03 08:27:28 +00:00
return bool(x64_modelData);
}
const CSfxHandle* CActor::GetSfxHandle() const
{
return x8c_sfxHandle.get();
}
void CActor::SetSfxPitchBend(s32 val)
{
xe6_30_enablePitchBend = true;
xc0_ = val;
if (x8c_sfxHandle == 0)
return;
CSfxManager::PitchBend(*x8c_sfxHandle.get(), val);
2016-04-29 10:08:46 +00:00
}
}