2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/Weapon/CPowerBomb.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/CPlayerState.hpp"
|
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
#include "Runtime/GameGlobalObjects.hpp"
|
2022-02-25 07:45:25 +00:00
|
|
|
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
2018-09-10 01:04:57 +00:00
|
|
|
#include "Runtime/Particle/CElementGen.hpp"
|
2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/World/CDamageInfo.hpp"
|
|
|
|
#include "Runtime/World/CPlayer.hpp"
|
|
|
|
|
2022-02-21 09:04:16 +00:00
|
|
|
#include "Audio/SFX/Weapons.h"
|
2019-12-22 20:04:07 +00:00
|
|
|
|
2019-09-21 13:07:13 +00:00
|
|
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
2017-08-27 03:02:18 +00:00
|
|
|
|
2020-03-12 14:12:28 +00:00
|
|
|
#include <zeus/CColor.hpp>
|
2017-08-27 03:02:18 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2020-03-12 14:12:28 +00:00
|
|
|
constexpr zeus::CColor kFadeColor(COLOR(0xffffff7));
|
2018-09-10 01:04:57 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CPowerBomb::CPowerBomb(const TToken<CGenDescription>& particle, TUniqueId uid, TAreaId aid, TUniqueId playerId,
|
|
|
|
const zeus::CTransform& xf, const CDamageInfo& dInfo)
|
|
|
|
: CWeapon(
|
|
|
|
uid, aid, true, playerId, EWeaponType::PowerBomb, "PowerBomb", xf,
|
|
|
|
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid, EMaterialTypes::Immovable, EMaterialTypes::Trigger},
|
|
|
|
{EMaterialTypes::Projectile, EMaterialTypes::PowerBomb}),
|
|
|
|
{EMaterialTypes::Projectile, EMaterialTypes::PowerBomb}, dInfo, EProjectileAttrib::PowerBombs,
|
|
|
|
CModelData::CModelDataNull())
|
2018-09-10 01:04:57 +00:00
|
|
|
, x164_radiusIncrement(dInfo.GetRadius() / 2.5f)
|
2019-09-12 03:50:38 +00:00
|
|
|
, x168_particle(std::make_unique<CElementGen>(particle))
|
2018-12-08 05:30:43 +00:00
|
|
|
, x16c_radius(dInfo.GetRadius()) {
|
2022-11-10 22:08:28 +00:00
|
|
|
x168_particle->SetGlobalTranslation(xf.GetTranslation());
|
2018-09-10 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPowerBomb::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
2018-09-10 01:04:57 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPowerBomb::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
|
|
|
|
if (msg == EScriptObjectMessage::Registered) {
|
|
|
|
mgr.AddWeaponId(xec_ownerId, xf0_weaponType);
|
2022-11-10 22:08:28 +00:00
|
|
|
x110_origDamageInfo.SetRadius(0.f);
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (mgr.GetPlayerState()->IsPlayerAlive()) {
|
|
|
|
CSfxManager::AddEmitter(SFXsfx0710, GetTranslation(), {}, true, false, 0x7f, -1);
|
|
|
|
mgr.InformListeners(GetTranslation(), EListenNoiseType::BombExplode);
|
|
|
|
} else {
|
2022-11-10 22:08:28 +00:00
|
|
|
auto handle = CSfxManager::SfxStart(SFXsfx073F, 0x7f, 0x40, false, 0xFF, false, -1);
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.Player()->ApplySubmergedPitchBend(handle);
|
2018-09-10 01:04:57 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
} else if (msg == EScriptObjectMessage::Deleted) {
|
2022-11-10 22:08:28 +00:00
|
|
|
if (x15c_curTime <= 7.0f)
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.GetCameraFilterPass(6).DisableFilter(0.f);
|
2018-09-10 01:04:57 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.RemoveWeaponId(xec_ownerId, xf0_weaponType);
|
|
|
|
}
|
|
|
|
CActor::AcceptScriptMsg(msg, uid, mgr);
|
2018-09-10 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPowerBomb::Think(float dt, CStateManager& mgr) {
|
|
|
|
CWeapon::Think(dt, mgr);
|
|
|
|
if (x158_24_canStartFilter) {
|
|
|
|
if (x15c_curTime > 1.f && !x158_25_filterEnabled) {
|
2022-02-19 13:04:45 +00:00
|
|
|
mgr.GetCameraFilterPass(6).SetFilter(EFilterType::Add, EFilterShape::Fullscreen, 1.5f, kFadeColor, {});
|
2018-12-08 05:30:43 +00:00
|
|
|
x158_25_filterEnabled = true;
|
2018-09-10 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x15c_curTime > 2.5f)
|
|
|
|
x158_24_canStartFilter = false;
|
2020-09-23 23:32:15 +00:00
|
|
|
} else {
|
|
|
|
if (x15c_curTime > 3.75 && x158_25_filterEnabled) {
|
|
|
|
mgr.GetCameraFilterPass(6).DisableFilter(.5f);
|
|
|
|
x158_25_filterEnabled = false;
|
|
|
|
}
|
2018-09-10 01:04:57 +00:00
|
|
|
|
2020-09-23 23:32:15 +00:00
|
|
|
if (x15c_curTime > 7.f) {
|
|
|
|
if (x168_particle->IsSystemDeletable())
|
|
|
|
mgr.FreeScriptObject(GetUniqueId());
|
|
|
|
}
|
2018-09-10 01:04:57 +00:00
|
|
|
|
2020-09-23 23:32:15 +00:00
|
|
|
if (x15c_curTime > 30.f) {
|
|
|
|
mgr.FreeScriptObject(GetUniqueId());
|
|
|
|
return;
|
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2018-09-10 01:04:57 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x15c_curTime > 1.f && x15c_curTime < 4.f) {
|
|
|
|
x110_origDamageInfo.SetRadius(x160_curRadius);
|
|
|
|
ApplyDynamicDamage(GetTranslation(), mgr);
|
2020-09-23 23:32:15 +00:00
|
|
|
x160_curRadius += dt * x164_radiusIncrement;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2018-09-10 01:04:57 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x168_particle->Update(dt);
|
|
|
|
x15c_curTime += dt;
|
2018-09-10 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2021-06-07 19:29:18 +00:00
|
|
|
void CPowerBomb::AddToRenderer(const zeus::CFrustum&, CStateManager&) { g_Renderer->AddParticleGen(*x168_particle); }
|
2017-08-27 03:02:18 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
void CPowerBomb::ApplyDynamicDamage(const zeus::CVector3f& pos, metaforce::CStateManager& mgr) {
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.ApplyDamageToWorld(xec_ownerId, *this, pos, x12c_curDamageInfo, xf8_filter);
|
2017-08-27 03:02:18 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|