2019-11-24 15:01:07 +00:00
|
|
|
#include "Runtime/World/CDestroyableRock.hpp"
|
2020-01-06 04:24:54 +00:00
|
|
|
#include "Runtime/World/CActorParameters.hpp"
|
|
|
|
#include "Runtime/CPlayerState.hpp"
|
|
|
|
#include "Runtime/CStateManager.hpp"
|
2019-11-24 15:01:07 +00:00
|
|
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2017-03-31 19:51:40 +00:00
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
CDestroyableRock::CDestroyableRock(TUniqueId id, bool active, std::string_view name, const CEntityInfo& info,
|
2018-12-08 05:30:43 +00:00
|
|
|
const zeus::CTransform& xf, CModelData&& modelData, float mass,
|
|
|
|
const CHealthInfo& health, const CDamageVulnerability& vulnerability,
|
|
|
|
const CMaterialList& matList, CAssetId fsm, const CActorParameters& actParams,
|
2020-01-06 04:24:54 +00:00
|
|
|
const CStaticRes& phazonModel, s32 w1)
|
2018-12-08 05:30:43 +00:00
|
|
|
: CAi(id, active, name, info, xf, std::move(modelData), modelData.GetBounds(), mass, health, vulnerability, matList,
|
2020-01-06 04:24:54 +00:00
|
|
|
fsm, actParams, 0.3f, 0.8f)
|
|
|
|
, x2d8_phazonModel(phazonModel)
|
|
|
|
, x32c_thermalMag(actParams.GetThermalMag())
|
|
|
|
, x338_healthInfo(health)
|
|
|
|
, x341_(w1 != 0) {
|
|
|
|
/* This is now in UsePhazonModel
|
|
|
|
x2d8_phazonModel->SetSortThermal(true);
|
|
|
|
*/
|
|
|
|
CreateShadow(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDestroyableRock::Accept(urde::IVisitor& visitor) { visitor.Visit(this); }
|
|
|
|
void CDestroyableRock::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) {
|
|
|
|
if (GetActive()) {
|
|
|
|
if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::Thermal) {
|
|
|
|
xb4_drawFlags = CModelFlags(0, 0, 1, zeus::skWhite);
|
|
|
|
} else {
|
2020-09-13 04:07:39 +00:00
|
|
|
u8 r;
|
|
|
|
u8 g;
|
|
|
|
u8 b;
|
|
|
|
u8 a;
|
|
|
|
x330_.toRGBA8(r, g, b, a);
|
|
|
|
if ((r & g & b) == 0xFF) {
|
2020-01-06 04:24:54 +00:00
|
|
|
xb4_drawFlags = CModelFlags(0, 0, 3, zeus::skWhite);
|
|
|
|
} else {
|
|
|
|
x330_.a() = 1.f;
|
2020-03-01 01:11:41 +00:00
|
|
|
xb4_drawFlags = CModelFlags(2, 0, 3, x330_);
|
2020-01-06 04:24:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CActor::PreRender(mgr, frustum);
|
|
|
|
}
|
|
|
|
void CDestroyableRock::Think(float dt, CStateManager& mgr) {
|
2020-09-13 04:07:39 +00:00
|
|
|
if (!GetActive()) {
|
2020-01-06 04:24:54 +00:00
|
|
|
return;
|
2020-09-13 04:07:39 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-01-06 04:24:54 +00:00
|
|
|
float damageMag = x32c_thermalMag;
|
|
|
|
if (x324_ > 0.f) {
|
2020-09-13 04:07:39 +00:00
|
|
|
x324_ = std::max(0.f, x324_ - dt);
|
|
|
|
zeus::CColor tmpColor = zeus::CColor(0.5, 0.f, 0.f, 1.f);
|
|
|
|
// TODO: Use skBlack once CModelFlags is properly reverse engineered
|
|
|
|
x330_ = zeus::CColor::lerp(/*zeus::skBlack*/ zeus::skWhite, tmpColor, x324_);
|
2020-01-06 04:24:54 +00:00
|
|
|
damageMag = ((x335_usePhazonModel ? 0.5f : 0.25f) * x324_) + damageMag;
|
|
|
|
}
|
|
|
|
xd0_damageMag = damageMag;
|
|
|
|
CEntity::Think(dt, mgr);
|
2019-11-24 15:01:07 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|