2015-11-02 18:45:39 +00:00
|
|
|
#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"
|
2015-11-02 18:45:39 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
namespace urde
|
2015-11-02 18:45:39 +00:00
|
|
|
{
|
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)
|
2016-12-29 21:38:59 +00:00
|
|
|
ret.Add(EMaterialTypes::Mud);
|
2016-04-22 20:22:45 +00:00
|
|
|
if (params.GetVisorParameters().x0_29_b4)
|
2016-12-29 21:38:59 +00:00
|
|
|
ret.Add(EMaterialTypes::Glass);
|
2016-04-22 20:22:45 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
CActor::CActor(TUniqueId uid, bool active, const std::string& name, const CEntityInfo& info, const zeus::CTransform&,
|
|
|
|
CModelData&& mData, const CMaterialList& list, const CActorParameters& params, TUniqueId otherUid)
|
|
|
|
: CEntity(uid, info, active, name)
|
2017-01-04 04:08:30 +00:00
|
|
|
, x68_material(MakeActorMaterialList(list, params))
|
|
|
|
, x70_materialFilter(CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {EMaterialTypes::Unknown}))
|
2016-12-19 18:27:58 +00:00
|
|
|
, 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)
|
|
|
|
{
|
2016-12-19 18:27:58 +00:00
|
|
|
switch (msg)
|
2016-04-29 10:08:46 +00:00
|
|
|
{
|
|
|
|
case EScriptObjectMessage::Activate:
|
|
|
|
{
|
|
|
|
if (!x30_24_active)
|
|
|
|
xbc_time = CGraphics::GetSecondsMod900();
|
|
|
|
}
|
2016-12-19 18:27:58 +00:00
|
|
|
break;
|
2016-04-29 10:08:46 +00:00
|
|
|
case EScriptObjectMessage::Decrement:
|
|
|
|
RemoveEmitter();
|
|
|
|
break;
|
2016-07-25 06:24:57 +00:00
|
|
|
case EScriptObjectMessage::InternalMessage11: // 33
|
2016-04-29 10:08:46 +00:00
|
|
|
{
|
2016-12-29 21:38:59 +00:00
|
|
|
if (x98_scanObjectInfo)
|
|
|
|
AddMaterial(EMaterialTypes::Scannable, mgr);
|
2016-04-29 10:08:46 +00:00
|
|
|
else
|
2016-12-29 21:38:59 +00:00
|
|
|
RemoveMaterial(EMaterialTypes::Scannable, mgr);
|
2016-07-25 06:24:57 +00:00
|
|
|
|
2016-04-29 10:08:46 +00:00
|
|
|
if (HasModelData() && x64_modelData->AnimationData())
|
|
|
|
{
|
2016-07-25 06:24:57 +00:00
|
|
|
TAreaId aid = GetAreaId();
|
2016-12-19 18:27:58 +00:00
|
|
|
// x64_modelData->AnimationData()->sub_8002AE6C(mgr, aid, x64_modelData->x0_particleScale);
|
2016-04-29 10:08:46 +00:00
|
|
|
}
|
|
|
|
}
|
2016-12-19 18:27:58 +00:00
|
|
|
break;
|
2016-07-26 02:33:32 +00:00
|
|
|
case EScriptObjectMessage::InternalMessage12: // 34
|
2016-04-29 10:08:46 +00:00
|
|
|
{
|
|
|
|
RemoveEmitter();
|
2016-11-20 21:53:15 +00:00
|
|
|
#if 0
|
|
|
|
if (HasModelData() && x64_modelData->AnimationData() && x64_modelData->GetNormalModel())
|
|
|
|
x64_modelData->AnimationData()->GetParticleDB().GetActiveParticleLightIds(mgr);
|
|
|
|
#endif
|
2016-04-29 10:08:46 +00:00
|
|
|
}
|
2016-12-19 18:27:58 +00:00
|
|
|
break;
|
2016-07-26 02:33:32 +00:00
|
|
|
case EScriptObjectMessage::InternalMessage13: // 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();
|
|
|
|
}
|
|
|
|
}
|
2016-12-19 18:27:58 +00:00
|
|
|
break;
|
2016-07-26 02:33:32 +00:00
|
|
|
case EScriptObjectMessage::InternalMessage15: // 37
|
2016-05-03 08:27:28 +00:00
|
|
|
SetInFluid(true, uid);
|
2016-04-29 10:08:46 +00:00
|
|
|
break;
|
2016-07-26 02:33:32 +00:00
|
|
|
case EScriptObjectMessage::InternalMessage17: // 39
|
2016-05-03 08:27:28 +00:00
|
|
|
SetInFluid(false, kInvalidUniqueId);
|
2016-04-29 10:08:46 +00:00
|
|
|
break;
|
2016-12-19 18:27:58 +00:00
|
|
|
default:
|
|
|
|
break;
|
2016-04-29 10:08:46 +00:00
|
|
|
}
|
|
|
|
CEntity::AcceptScriptMsg(msg, uid, mgr);
|
|
|
|
}
|
|
|
|
|
2016-11-20 21:53:15 +00:00
|
|
|
void CActor::CalculateRenderBounds()
|
2016-08-31 00:33:59 +00:00
|
|
|
{
|
2016-11-20 21:53:15 +00:00
|
|
|
if (x64_modelData && (x64_modelData->AnimationData() || x64_modelData->GetNormalModel()))
|
|
|
|
x9c_aabox = x64_modelData->GetBounds(x34_transform);
|
|
|
|
else
|
|
|
|
x9c_aabox = zeus::CAABox(x34_transform.origin, x34_transform.origin);
|
2016-08-31 00:33:59 +00:00
|
|
|
}
|
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
CHealthInfo* CActor::HealthInfo() { return nullptr; }
|
2016-08-31 00:33:59 +00:00
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
const CDamageVulnerability* CActor::GetDamageVulnerability() const { return nullptr; }
|
2016-08-31 00:33:59 +00:00
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
const CDamageVulnerability* CActor::GetDamageVulnerability(const zeus::CVector3f&, const zeus::CVector3f&,
|
|
|
|
const CDamageInfo&) const
|
2016-08-31 00:33:59 +00:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
rstl::optional_object<zeus::CAABox> CActor::GetTouchBounds() const { return {}; }
|
2016-08-31 00:33:59 +00:00
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
void CActor::Touch(CActor&, CStateManager&) {}
|
2016-08-31 00:33:59 +00:00
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
zeus::CVector3f CActor::GetOrbitPosition(const CStateManager&) const { return x34_transform.origin; }
|
2016-08-31 00:33:59 +00:00
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
zeus::CVector3f CActor::GetAimPosition(const CStateManager&, float) const { return x34_transform.origin; }
|
2016-05-03 08:27:28 +00:00
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
zeus::CVector3f CActor::GetHomingPosition(const CStateManager& mgr, float f) const { return GetAimPosition(mgr, f); }
|
2016-08-31 00:33:59 +00:00
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
zeus::CVector3f CActor::GetScanObjectIndicatorPosition(const CStateManager&) { return {}; }
|
2016-08-31 00:33:59 +00:00
|
|
|
|
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-10-31 22:56:44 +00:00
|
|
|
const zeus::CTransform CActor::GetScaledLocatorTransform(const std::string& segName) const
|
|
|
|
{
|
|
|
|
return x64_modelData->GetScaledLocatorTransform(segName);
|
|
|
|
}
|
|
|
|
|
|
|
|
const zeus::CTransform CActor::GetLocatorTransform(const std::string& segName) const
|
|
|
|
{
|
|
|
|
return x64_modelData->GetLocatorTransform(segName);
|
|
|
|
}
|
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
EWeaponCollisionResponseTypes CActor::GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&,
|
|
|
|
CWeaponMode&, int)
|
2016-05-03 08:27:28 +00:00
|
|
|
{
|
|
|
|
return EWeaponCollisionResponseTypes::Unknown13;
|
|
|
|
}
|
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
void CActor::FluidFXThink(CActor::EFluidState, CScriptWater&, CStateManager&) {}
|
2016-08-31 00:33:59 +00:00
|
|
|
|
|
|
|
void CActor::OnScanStateChanged(EScanState state, CStateManager& mgr)
|
|
|
|
{
|
2016-11-22 20:43:16 +00:00
|
|
|
if (state == EScanState::Start)
|
|
|
|
SendScriptMsgs(EScriptObjectState::ScanStart, mgr, EScriptObjectMessage::None);
|
|
|
|
else if (state == EScanState::Processing)
|
|
|
|
SendScriptMsgs(EScriptObjectState::ScanProcessing, mgr, EScriptObjectMessage::None);
|
|
|
|
else if (state == EScanState::Done)
|
2016-08-31 00:33:59 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::ScanDone, mgr, EScriptObjectMessage::None);
|
|
|
|
}
|
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
zeus::CAABox CActor::GetSortingBounds(const CStateManager&) const { return x9c_aabox; }
|
2016-08-31 00:33:59 +00:00
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
void CActor::DoUserAnimEvent(CStateManager&, CInt32POINode&, EUserEventType) {}
|
2016-08-31 00:33:59 +00:00
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
void CActor::RemoveMaterial(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4,
|
|
|
|
CStateManager& mgr)
|
2016-04-22 20:22:45 +00:00
|
|
|
{
|
2017-01-04 04:08:30 +00:00
|
|
|
x68_material.Remove(t1);
|
2016-04-22 20:22:45 +00:00
|
|
|
RemoveMaterial(t2, t3, t4, mgr);
|
|
|
|
}
|
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
void CActor::RemoveMaterial(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, CStateManager& mgr)
|
2016-04-22 20:22:45 +00:00
|
|
|
{
|
2017-01-04 04:08:30 +00:00
|
|
|
x68_material.Remove(t1);
|
2016-04-22 20:22:45 +00:00
|
|
|
RemoveMaterial(t2, t3, mgr);
|
|
|
|
}
|
|
|
|
|
2017-01-04 04:08:30 +00:00
|
|
|
void CActor::RemoveMaterial(EMaterialTypes t1, EMaterialTypes t2, CStateManager& mgr) { x68_material.Remove(t1); }
|
2016-04-22 20:22:45 +00:00
|
|
|
|
|
|
|
void CActor::RemoveMaterial(EMaterialTypes t, CStateManager& mgr)
|
|
|
|
{
|
2017-01-04 04:08:30 +00:00
|
|
|
x68_material.Remove(t);
|
2016-04-22 20:22:45 +00:00
|
|
|
mgr.UpdateObjectInLists(*this);
|
|
|
|
}
|
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
void CActor::AddMaterial(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, EMaterialTypes t5,
|
|
|
|
CStateManager& mgr)
|
2016-04-22 20:22:45 +00:00
|
|
|
{
|
2017-01-04 04:08:30 +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)
|
|
|
|
{
|
2017-01-04 04:08:30 +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)
|
|
|
|
{
|
2017-01-04 04:08:30 +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)
|
|
|
|
{
|
2017-01-04 04:08:30 +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
|
|
|
{
|
2017-01-04 04:08:30 +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-12-19 18:27:58 +00:00
|
|
|
void CActor::SetCallTouch(bool callTouch) { xe5_28_callTouch = callTouch; }
|
2016-05-03 08:27:28 +00:00
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
bool CActor::GetCallTouch() const { return xe5_28_callTouch; }
|
2016-05-03 08:27:28 +00:00
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
void CActor::SetUseInSortedList(bool use) { xe5_27_useInSortedLists = use; }
|
2016-05-03 08:27:28 +00:00
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
bool CActor::GetUseInSortedLists() const { return xe5_27_useInSortedLists; }
|
2016-05-03 08:27:28 +00:00
|
|
|
|
|
|
|
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-12-19 18:27:58 +00:00
|
|
|
bool CActor::HasModelData() const { return bool(x64_modelData); }
|
2016-05-03 08:27:28 +00:00
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
const CSfxHandle* CActor::GetSfxHandle() const { return x8c_sfxHandle.get(); }
|
2016-05-03 08:27:28 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
void CActor::SetTranslation(const zeus::CVector3f& tr)
|
2016-09-01 04:10:08 +00:00
|
|
|
{
|
|
|
|
x34_transform.origin = tr;
|
|
|
|
xe4_27_ = true;
|
|
|
|
xe4_28_ = true;
|
|
|
|
xe4_29_ = true;
|
|
|
|
}
|
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
void CActor::SetAddedToken(u32 tok) { xcc_addedToken = tok; }
|
2016-11-20 21:53:15 +00:00
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
float CActor::GetPitch() const { return zeus::CQuaternion(x34_transform.buildMatrix3f()).pitch(); }
|
2016-10-31 22:56:44 +00:00
|
|
|
|
2016-12-19 18:27:58 +00:00
|
|
|
float CActor::GetYaw() const { return zeus::CQuaternion(x34_transform.buildMatrix3f()).yaw(); }
|
2015-11-02 18:45:39 +00:00
|
|
|
}
|