2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/World/CScriptSteam.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
#include "Runtime/World/CPlayer.hpp"
|
|
|
|
|
2019-09-21 13:07:13 +00:00
|
|
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
2017-02-28 07:31:14 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2017-02-28 07:31:14 +00:00
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
CScriptSteam::CScriptSteam(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CVector3f& pos,
|
2017-02-28 07:31:14 +00:00
|
|
|
const zeus::CAABox& aabb, const CDamageInfo& dInfo, const zeus::CVector3f& orientedForce,
|
2018-09-20 18:17:09 +00:00
|
|
|
ETriggerFlags flags, bool active, CAssetId texture, float f1, float f2, float f3, float f4,
|
|
|
|
bool b1)
|
2017-02-28 07:31:14 +00:00
|
|
|
: CScriptTrigger(uid, name, info, pos, aabb, dInfo, orientedForce, flags, active, false, false)
|
2018-09-20 18:17:09 +00:00
|
|
|
, x150_(b1)
|
|
|
|
, x154_texture(texture)
|
|
|
|
, x158_(f1)
|
|
|
|
, x15c_alphaInDur(f2 / f1)
|
2018-12-08 05:30:43 +00:00
|
|
|
, x160_alphaOutDur(f3 / f1) {
|
|
|
|
float r3 = (aabb.max.z() < aabb.max.y() ? aabb.max.z() : aabb.max.y());
|
|
|
|
r3 = (r3 < aabb.max.x() ? r3 : aabb.max.x());
|
2017-02-28 07:31:14 +00:00
|
|
|
|
2020-05-07 15:50:21 +00:00
|
|
|
if (zeus::close_enough(f4, 0.f)) {
|
2018-12-08 05:30:43 +00:00
|
|
|
r3 = (r3 < f2 ? r3 : f4);
|
2020-05-07 15:50:21 +00:00
|
|
|
}
|
2018-09-20 18:17:09 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x164_ = r3;
|
|
|
|
x168_ = 1.f / x164_;
|
2018-09-20 18:17:09 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptSteam::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
2018-09-20 18:17:09 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptSteam::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
|
2020-05-07 15:50:21 +00:00
|
|
|
if (msg == EScriptObjectMessage::Deactivate) {
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.Player()->SetVisorSteam(0.f, x158_, x160_alphaOutDur, CAssetId(), x150_);
|
2020-05-07 15:50:21 +00:00
|
|
|
}
|
2018-09-20 18:17:09 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CScriptTrigger::AcceptScriptMsg(msg, uid, mgr);
|
2018-09-20 18:17:09 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptSteam::Think(float dt, CStateManager& mgr) {
|
2020-05-07 15:50:21 +00:00
|
|
|
if (!GetActive()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-05-07 15:50:21 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
CScriptTrigger::Think(dt, mgr);
|
|
|
|
|
|
|
|
if (x148_28_playerTriggerProc && mgr.GetCameraManager()->GetFluidCounter() == 0) {
|
2020-05-07 15:50:21 +00:00
|
|
|
const zeus::CVector3f eyePos = mgr.GetPlayer().GetEyePosition();
|
|
|
|
const zeus::CVector3f posDiff = (GetTranslation() - eyePos);
|
|
|
|
const float mag = posDiff.magnitude();
|
|
|
|
const float distance = (mag >= x164_ ? 0.f : std::cos((1.5707964f * mag) * x168_) * x158_);
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.Player()->SetVisorSteam(distance, x15c_alphaInDur, x160_alphaOutDur, x154_texture, x150_);
|
2020-05-07 15:50:21 +00:00
|
|
|
if (x150_) {
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.GetEnvFxManager()->SetSplashRate(2.f * distance);
|
2020-05-07 15:50:21 +00:00
|
|
|
}
|
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.Player()->SetVisorSteam(0.f, x15c_alphaInDur, x160_alphaOutDur, CAssetId(), x150_);
|
2020-05-07 15:50:21 +00:00
|
|
|
}
|
2017-02-28 07:31:14 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|