2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 21:07:42 +00:00

Update hecl, implement CScriptPickup

This commit is contained in:
2017-10-14 22:44:07 -07:00
parent 651d0a27c2
commit 5941a61ae6
7 changed files with 102 additions and 20 deletions

View File

@@ -10,6 +10,7 @@
#include "CGameOptions.hpp"
#include "MP1/CSamusHud.hpp"
#include "GuiSys/CStringTable.hpp"
#include "Camera/CFirstPersonCamera.hpp"
namespace urde
{
@@ -51,20 +52,97 @@ void CScriptPickup::Think(float dt, CStateManager& mgr)
if (!GetActive())
return;
if (x278_ >= 0.f)
{
CPhysicsActor::Stop();
x278_ -= dt;
return;
}
else
x270_ += dt;
if (x28c_25_ && (x270_ - x26c_) < 2.f)
x270_ = zeus::max(2.f * dt - x270_, (2.f - x26c_) - FLT_EPSILON);
CModelFlags drawFlags{0, 0, 3, zeus::CColor(1.f, 1.f, 1.f, 1.f)};
if (x268_ != 0.f)
{
x270_ += dt;
if (x270_ < x268_)
{
drawFlags = CModelFlags(5, 0, 3, zeus::CColor(1.f, 1.f, x270_ / x268_));
drawFlags.x2_flags &= 0xFFFC;
drawFlags.x2_flags |= 1;
}
else
x268_ = 0.f;
}
else if (x26c_ != 0.f)
{
float alpha = 1.f;
if (x26c_ < 2.f)
alpha = 1.f - (x26c_ / x270_);
else if ((x270_ - x26c_) < 2.f)
alpha = (x270_ - x26c_) * 0.5f;
drawFlags = CModelFlags(5, 0, 3, zeus::CColor(1.f, 1.f, 1.f, alpha));
drawFlags.x2_flags &= 0xFFFC;
drawFlags.x2_flags |= 1;
}
xb4_drawFlags = drawFlags;
if (x64_modelData)
{
if (x64_modelData->HasAnimData())
{
SAdvancementDeltas deltas = UpdateAnimation(dt, mgr, true);
MoveToOR(deltas.x0_posDelta, dt);
RotateToOR(deltas.xc_rotDelta, dt);
}
if (x28c_25_)
{
zeus::CVector3f posVec =
GetTranslation() - mgr.GetPlayer().GetTranslation() + (2.f * zeus::CVector3f::skUp);
posVec = (20.f * (0.5f * zeus::max(2.f, x274_ + dt))) * posVec.normalized();
float chargeFactor = 0.f;
if (x28c_26_ && mgr.GetPlayer().GetPlayerGun()->IsCharging())
chargeFactor = mgr.GetPlayer().GetPlayerGun()->GetChargeBeamFactor();
if (chargeFactor < CPlayerGun::skTractorBeamFactor)
{
x28c_26_ = false;
x28c_25_ = false;
posVec.zeroOut();
}
SetVelocityOR(posVec);
}
else if (x28c_24_)
{
float chargeFactor = mgr.GetPlayer().GetPlayerGun()->IsCharging()
? mgr.GetPlayer().GetPlayerGun()->GetChargeBeamFactor()
: 0.f;
if (chargeFactor > CPlayerGun::skTractorBeamFactor)
{
zeus::CVector3f posVec =
(GetTranslation() - mgr.GetCameraManager()->GetFirstPersonCamera()->GetTranslation()).normalized();
float relFov = zeus::CRelAngle(zeus::degToRad(g_tweakGame->GetFirstPersonFOV()));
if (mgr.GetCameraManager()->GetFirstPersonCamera()->GetTransform().upVector().dot(posVec) >
std::cos(relFov) && posVec.magSquared() < (30.f * 30.f))
{
x28c_25_ = true;
x28c_26_ = true;
x274_ = 0.f;
}
}
}
}
if (x26c_ != 0.f && x270_ > x26c_)
mgr.FreeScriptObject(GetUniqueId());
}
void CScriptPickup::Touch(CActor& act, CStateManager& mgr)
@@ -101,16 +179,18 @@ void CScriptPickup::Touch(CActor& act, CStateManager& mgr)
if (total == colRate)
{
CPersistentOptions& opts = g_GameState->SystemOptions();
mgr.sub_80043F2C(mgr.GetHUDMessageFrameCount() + 1,
g_ResFactory->GetResourceIdByName(opts.GetAllItemsCollected() ?
"STRG_AllPickupsFound_2" :
"STRG_AllPickupsFound_1")->id, 0.f);
mgr.QueueMessage(mgr.GetHUDMessageFrameCount() + 1,
g_ResFactory
->GetResourceIdByName(opts.GetAllItemsCollected() ? "STRG_AllPickupsFound_2"
: "STRG_AllPickupsFound_1")
->id,
0.f);
opts.SetAllItemsCollected(true);
}
}
if (x258_itemType == CPlayerState::EItemType::PowerBombs &&
g_GameState->SystemOptions().GetShowPowerBombAmmoMessage())
g_GameState->SystemOptions().GetShowPowerBombAmmoMessage())
{
g_GameState->SystemOptions().IncrementPowerBombAmmoCount();
MP1::CSamusHud::DisplayHudMemo(g_MainStringTable->GetString(109), {0.5f, true, false, false});