2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2017-09-10 00:36:21 +00:00
|
|
|
|
2020-04-11 23:36:52 +00:00
|
|
|
#include <array>
|
2019-09-22 21:52:05 +00:00
|
|
|
#include <memory>
|
2020-06-26 02:37:45 +00:00
|
|
|
#include <optional>
|
2019-09-22 21:52:05 +00:00
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
2020-06-26 02:37:45 +00:00
|
|
|
#include <zeus/CFrustum.hpp>
|
|
|
|
|
2019-09-22 21:52:05 +00:00
|
|
|
#include "Runtime/rstl.hpp"
|
|
|
|
#include "Runtime/Weapon/CGameProjectile.hpp"
|
2017-09-10 00:36:21 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2020-06-26 02:37:45 +00:00
|
|
|
class CCollisionPrimitive;
|
|
|
|
class CCollisionInfoList;
|
|
|
|
class CCollisionInfo;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
class CNewFlameThrower : public CGameProjectile {
|
2020-06-26 02:37:45 +00:00
|
|
|
struct Contact {
|
|
|
|
Contact(float contact, u32 remainingTime) : contact(contact), remainingTime(remainingTime) {}
|
|
|
|
float contact;
|
|
|
|
u32 remainingTime;
|
|
|
|
bool operator<(Contact const& o) const { return contact < o.contact; }
|
|
|
|
};
|
|
|
|
struct Cube {
|
|
|
|
Cube(zeus::CVector3f center, float bounds) : center(center), bounds(bounds) {}
|
|
|
|
zeus::CVector3f center;
|
|
|
|
float bounds;
|
|
|
|
};
|
|
|
|
enum class EFlameState {
|
|
|
|
Default,
|
|
|
|
FireStart,
|
|
|
|
FireActive,
|
|
|
|
FireStopTimer,
|
|
|
|
FireWaitForParticlesDone
|
|
|
|
};
|
|
|
|
|
2020-04-11 19:35:44 +00:00
|
|
|
CRandom16 x2e8_rand{99};
|
2020-06-26 02:37:45 +00:00
|
|
|
float x2ec_particlesDoneTimer = 0.f;
|
|
|
|
float x2f0_flamesDoneTimer = 0.f;
|
|
|
|
zeus::CVector3f x2f4_lastParticleCollisionLoc;
|
|
|
|
bool x300_wasPointAdded = false;
|
2018-12-08 05:30:43 +00:00
|
|
|
TCachedToken<CGenDescription> x304_mainFire;
|
|
|
|
TCachedToken<CGenDescription> x310_mainSmoke;
|
|
|
|
TCachedToken<CGenDescription> x31c_secondarySmoke;
|
|
|
|
TCachedToken<CGenDescription> x328_secondaryFire;
|
|
|
|
TCachedToken<CGenDescription> x334_secondarySparks;
|
|
|
|
TCachedToken<CSwooshDescription> x340_swooshCenter;
|
|
|
|
TCachedToken<CSwooshDescription> x34c_swooshFire;
|
|
|
|
std::unique_ptr<CElementGen> x358_mainFireGen;
|
|
|
|
std::unique_ptr<CElementGen> x35c_mainSmokeGen;
|
|
|
|
std::unique_ptr<CElementGen> x360_secondarySmokeGen;
|
|
|
|
std::unique_ptr<CElementGen> x364_secondaryFireGen;
|
|
|
|
std::unique_ptr<CElementGen> x368_secondarySparksGen;
|
|
|
|
std::unique_ptr<CParticleSwoosh> x36c_swooshCenterGen;
|
|
|
|
std::unique_ptr<CParticleSwoosh> x370_swooshFireGen;
|
2020-06-26 02:37:45 +00:00
|
|
|
EFlameState x374_flameState = EFlameState::Default;
|
|
|
|
TAreaId x378_currentLitArea = kInvalidAreaId;
|
2020-04-20 04:57:50 +00:00
|
|
|
bool x37c_24_renderAuxEffects : 1 = false;
|
|
|
|
bool x37c_25_firing : 1 = false;
|
2020-06-26 02:37:45 +00:00
|
|
|
bool x37c_26_runningSlowish : 1 = false;
|
|
|
|
bool x37c_27_newPointAdded : 1 = true;
|
|
|
|
bool x37c_28_activeLighting : 1 = false;
|
|
|
|
rstl::reserved_vector<std::vector<Contact>, 3> x380_flameContactPoints;
|
|
|
|
int x3b4_numSmokeParticlesSpawned = 0;
|
2018-12-08 05:30:43 +00:00
|
|
|
rstl::reserved_vector<TUniqueId, 4> x3b8_lightIds;
|
2020-06-26 02:37:45 +00:00
|
|
|
|
|
|
|
// std::array<std::unique_ptr<CTexturedQuadFilter>, 5> beam_filters;
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void DeleteLightObjects(CStateManager& mgr);
|
|
|
|
void CreateLightObjects(CStateManager& mgr);
|
|
|
|
void EnableFx(CStateManager& mgr);
|
2020-06-26 02:37:45 +00:00
|
|
|
void UpdateLights(CStateManager& mgr);
|
|
|
|
bool UpdateParticleCollisions(float dt, CStateManager &mgr,
|
|
|
|
rstl::reserved_vector<Cube, 32> &collisions_out);
|
|
|
|
bool CanDamageActor(CActor &hit_actor, CStateManager &mgr);
|
|
|
|
void AddContactPoint(CCollisionInfo const& cinfo, u32 time);
|
|
|
|
int SortAndFindOverlappingPoints(Cube const& box);
|
|
|
|
bool FindCollisionInNearList(CStateManager &mgr, rstl::reserved_vector<TUniqueId, 1024> const &near_list,
|
|
|
|
CCollisionPrimitive const& coll, TUniqueId &first_coll_out,
|
|
|
|
CCollisionInfoList& collisions);
|
|
|
|
void DecrementContactPointTimers();
|
|
|
|
void SetLightsActive(CStateManager &mgr, bool active);
|
|
|
|
void UpdateFlameState(float dt, CStateManager &mgr);
|
|
|
|
void SetWorldLighting(CStateManager &mgr, TAreaId area, float speed, float target);
|
|
|
|
// void RenderParticles(std::array<CElementGen *, 5> const& elem_gens);
|
|
|
|
|
|
|
|
// void LoadParticleGenQuads();
|
|
|
|
bool loaded_textures = false;
|
2017-09-10 00:36:21 +00:00
|
|
|
|
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
// Resinfo:
|
|
|
|
// NFTMainFire
|
|
|
|
// NFTMainSmoke
|
|
|
|
// NFTSwooshCenter
|
|
|
|
// NFTSwooshFire
|
|
|
|
// NFTSecondarySmoke
|
|
|
|
// NFTSecondaryFire
|
|
|
|
// NFTSecondarySparks
|
|
|
|
// <invalid>
|
2021-05-26 14:00:57 +00:00
|
|
|
DEFINE_ENTITY
|
2018-12-08 05:30:43 +00:00
|
|
|
CNewFlameThrower(const TToken<CWeaponDescription>& desc, std::string_view name, EWeaponType wType,
|
2020-04-11 23:36:52 +00:00
|
|
|
const std::array<CAssetId, 8>& resInfo, const zeus::CTransform& xf, EMaterialTypes matType,
|
2018-12-08 05:30:43 +00:00
|
|
|
const CDamageInfo& dInfo, TUniqueId uid, TAreaId aid, TUniqueId owner, EProjectileAttrib attribs);
|
|
|
|
void StartFiring(const zeus::CTransform& xf, CStateManager& mgr);
|
|
|
|
bool CanRenderAuxEffects() const { return x37c_24_renderAuxEffects; }
|
|
|
|
bool IsFiring() const { return x37c_25_firing; }
|
|
|
|
bool AreEffectsFinished() const;
|
|
|
|
void UpdateFx(const zeus::CTransform& xf, float dt, CStateManager& mgr);
|
|
|
|
void Reset(CStateManager& mgr, bool deactivate);
|
2020-06-26 02:37:45 +00:00
|
|
|
void Render(CStateManager& mgr) override;
|
|
|
|
void Think(float dt, CStateManager &mgr) override;
|
|
|
|
std::optional<zeus::CAABox> GetTouchBounds() const override { return {}; }
|
|
|
|
void Accept(IVisitor& visitor) override;
|
|
|
|
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager &mgr) override;
|
|
|
|
void AddToRenderer(zeus::CFrustum const& planes, CStateManager& mgr) override;
|
2017-09-10 00:36:21 +00:00
|
|
|
};
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|