2018-10-06 20:42:33 -07:00
|
|
|
#pragma once
|
2016-12-22 11:57:21 -08:00
|
|
|
|
2019-09-23 12:00:23 -07:00
|
|
|
#include <cstdint>
|
|
|
|
#include <memory>
|
|
|
|
#include <optional>
|
|
|
|
#include <string_view>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Runtime/GCNTypes.hpp"
|
|
|
|
#include "Runtime/rstl.hpp"
|
|
|
|
#include "Runtime/Graphics/Shaders/CColoredStripShader.hpp"
|
|
|
|
#include "Runtime/Weapon/CBeamInfo.hpp"
|
|
|
|
#include "Runtime/Weapon/CBeamProjectile.hpp"
|
|
|
|
#include "Runtime/World/CDamageInfo.hpp"
|
|
|
|
|
|
|
|
#include <zeus/CColor.hpp>
|
2016-12-22 11:57:21 -08:00
|
|
|
|
2021-04-10 01:42:06 -07:00
|
|
|
namespace metaforce {
|
2018-12-07 21:30:43 -08:00
|
|
|
class CPlasmaProjectile : public CBeamProjectile {
|
2019-01-02 19:47:28 -08:00
|
|
|
public:
|
2020-09-27 11:10:07 -07:00
|
|
|
struct PlayerEffectResources : rstl::reserved_vector<CAssetId, 8> {
|
2021-06-07 12:29:18 -07:00
|
|
|
PlayerEffectResources(CAssetId a = {}, CAssetId b = {}, CAssetId c = {}, CAssetId d = {}, CAssetId e = {},
|
|
|
|
CAssetId f = {}, CAssetId g = {}, CAssetId h = {})
|
2020-04-12 04:29:58 -07:00
|
|
|
: rstl::reserved_vector<CAssetId, 8>({a, b, c, d, e, f, g, h}) {}
|
2019-01-02 19:47:28 -08:00
|
|
|
};
|
2020-09-27 11:10:07 -07:00
|
|
|
static PlayerEffectResources LoadPlayerEffectResources(CInputStream& in) {
|
|
|
|
u32 propCount = in.readUint32();
|
|
|
|
CAssetId a{in};
|
|
|
|
CAssetId b{in};
|
|
|
|
CAssetId c{in};
|
|
|
|
CAssetId d{in};
|
|
|
|
CAssetId e{in};
|
|
|
|
CAssetId f{in};
|
|
|
|
CAssetId g{in};
|
|
|
|
CAssetId h{in};
|
|
|
|
return {a, b, c, d, e, f, g, h};
|
|
|
|
}
|
2021-06-07 12:29:18 -07:00
|
|
|
|
2019-01-02 19:47:28 -08:00
|
|
|
private:
|
|
|
|
std::vector<TUniqueId> x468_lights;
|
|
|
|
s32 x478_beamAttributes;
|
|
|
|
float x47c_lifeTime;
|
|
|
|
float x480_pulseSpeed;
|
|
|
|
float x484_shutdownTime;
|
|
|
|
float x488_expansionSpeed;
|
|
|
|
float x48c_;
|
|
|
|
zeus::CColor x490_innerColor;
|
|
|
|
zeus::CColor x494_outerColor;
|
|
|
|
CDamageInfo x498_phazonDamage;
|
2021-06-07 12:29:18 -07:00
|
|
|
enum class EExpansionState { Inactive, Attack, Sustain, Release, Done };
|
2019-01-02 19:47:28 -08:00
|
|
|
EExpansionState x4b4_expansionState = EExpansionState::Inactive;
|
|
|
|
float x4b8_beamWidth = 0.f;
|
|
|
|
float x4bc_lifeTimer = 0.f;
|
|
|
|
float x4c0_expansionT = 0.f;
|
|
|
|
float x4c4_expansion = 0.f;
|
|
|
|
float x4c8_beamAngle = 0.f;
|
|
|
|
float x4cc_energyPulseStartY = 0.f;
|
|
|
|
float x4d0_shutdownTimer = 0.f;
|
|
|
|
float x4d4_contactPulseTimer = 0.f;
|
|
|
|
float x4d8_energyPulseTimer = 0.f;
|
|
|
|
float x4dc_playerEffectPulseTimer = 0.f;
|
|
|
|
float x4e0_playerDamageDuration = 0.f;
|
|
|
|
float x4e4_playerDamageTimer = 0.f;
|
|
|
|
TLockedToken<CTexture> x4e8_texture;
|
|
|
|
TLockedToken<CTexture> x4f4_glowTexture;
|
|
|
|
TCachedToken<CGenDescription> x500_contactFxDesc;
|
|
|
|
TCachedToken<CGenDescription> x50c_pulseFxDesc;
|
|
|
|
std::unique_ptr<CElementGen> x518_contactGen;
|
|
|
|
std::unique_ptr<CElementGen> x51c_pulseGen;
|
|
|
|
std::unique_ptr<CElementGen> x520_weaponGen;
|
|
|
|
CAssetId x524_freezeSteamTxtr;
|
|
|
|
CAssetId x528_freezeIceTxtr;
|
|
|
|
TToken<CElectricDescription> x52c_visorElectric; // Used to be optional
|
2021-06-07 12:29:18 -07:00
|
|
|
TToken<CGenDescription> x538_visorParticle; // Used to be optional
|
2019-01-02 19:47:28 -08:00
|
|
|
u16 x544_freezeSfx;
|
|
|
|
u16 x546_electricSfx;
|
2020-04-19 21:57:50 -07:00
|
|
|
bool x548_24_ : 1 = false;
|
|
|
|
bool x548_25_enableEnergyPulse : 1 = true;
|
|
|
|
bool x548_26_firing : 1 = false;
|
|
|
|
bool x548_27_texturesLoaded : 1 = false;
|
2020-04-10 21:49:02 -07:00
|
|
|
bool x548_28_drawOwnerFirst : 1;
|
2020-04-19 21:57:50 -07:00
|
|
|
bool x548_29_activePlayerPhazon : 1 = false;
|
2019-01-02 19:47:28 -08:00
|
|
|
|
|
|
|
struct RenderObjects {
|
|
|
|
CColoredStripShader m_beamStrip1;
|
|
|
|
CColoredStripShader m_beamStrip2;
|
|
|
|
CColoredStripShader m_beamStrip3;
|
|
|
|
CColoredStripShader m_beamStrip4;
|
2019-01-05 00:34:09 -08:00
|
|
|
CColoredStripShader m_beamStrip1Sub;
|
|
|
|
CColoredStripShader m_beamStrip2Sub;
|
|
|
|
CColoredStripShader m_beamStrip3Sub;
|
|
|
|
CColoredStripShader m_beamStrip4Sub;
|
2019-01-02 19:47:28 -08:00
|
|
|
CColoredStripShader m_motionBlurStrip;
|
2022-02-15 21:21:24 -08:00
|
|
|
RenderObjects(std::shared_ptr<aurora::gfx::TextureHandle> tex,
|
|
|
|
std::shared_ptr<aurora::gfx::TextureHandle> glowTex);
|
2019-01-02 19:47:28 -08:00
|
|
|
};
|
2020-04-09 18:17:17 -07:00
|
|
|
std::optional<RenderObjects> m_renderObjs;
|
2019-01-02 19:47:28 -08:00
|
|
|
|
|
|
|
void SetLightsActive(bool active, CStateManager& mgr);
|
|
|
|
void CreatePlasmaLights(u32 sourceId, const CLight& l, CStateManager& mgr);
|
|
|
|
void DeletePlasmaLights(CStateManager& mgr);
|
|
|
|
void UpdateLights(float expansion, float dt, CStateManager& mgr);
|
|
|
|
void UpdateEnergyPulse(float dt);
|
2020-04-09 18:17:17 -07:00
|
|
|
void RenderMotionBlur();
|
2021-06-07 12:29:18 -07:00
|
|
|
void RenderBeam(s32 subdivs, float width, const zeus::CColor& color, s32 flags, CColoredStripShader& shader) const;
|
2019-01-02 19:47:28 -08:00
|
|
|
float UpdateBeamState(float dt, CStateManager& mgr);
|
2019-06-11 19:05:17 -07:00
|
|
|
void MakeBillboardEffect(const std::optional<TToken<CGenDescription>>& particle,
|
2021-06-07 12:29:18 -07:00
|
|
|
const std::optional<TToken<CElectricDescription>>& electric, std::string_view name,
|
|
|
|
CStateManager& mgr);
|
2019-01-02 19:47:28 -08:00
|
|
|
void UpdatePlayerEffects(float dt, CStateManager& mgr);
|
2021-06-07 12:29:18 -07:00
|
|
|
|
2016-12-22 11:57:21 -08:00
|
|
|
public:
|
2021-05-26 07:00:57 -07:00
|
|
|
DEFINE_ENTITY
|
2018-12-07 21:30:43 -08:00
|
|
|
CPlasmaProjectile(const TToken<CWeaponDescription>& wDesc, std::string_view name, EWeaponType wType,
|
|
|
|
const CBeamInfo& bInfo, const zeus::CTransform& xf, EMaterialTypes matType,
|
2019-01-02 19:47:28 -08:00
|
|
|
const CDamageInfo& dInfo, TUniqueId uid, TAreaId aid, TUniqueId owner,
|
2020-09-27 11:10:07 -07:00
|
|
|
const PlayerEffectResources& res, bool growingBeam, EProjectileAttrib attribs);
|
2017-01-14 19:07:01 -08:00
|
|
|
|
2019-08-09 05:45:18 -07:00
|
|
|
void Accept(IVisitor& visitor) override;
|
|
|
|
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) override;
|
|
|
|
void ResetBeam(CStateManager& mgr, bool fullReset) override;
|
|
|
|
void UpdateFx(const zeus::CTransform& xf, float dt, CStateManager& mgr) override;
|
|
|
|
void Fire(const zeus::CTransform& xf, CStateManager& mgr, bool b) override;
|
|
|
|
void Touch(CActor& other, CStateManager& mgr) override;
|
|
|
|
bool CanRenderUnsorted(const CStateManager& mgr) const override;
|
2020-04-05 04:54:02 -07:00
|
|
|
void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override;
|
2020-04-09 10:28:20 -07:00
|
|
|
void Render(CStateManager& mgr) override;
|
2020-10-06 17:44:02 -07:00
|
|
|
zeus::CColor GetInnerColor() const { return x490_innerColor; }
|
|
|
|
zeus::CColor GetOuterColor() const { return x494_outerColor; }
|
2020-10-08 20:35:24 -07:00
|
|
|
bool IsFiring() const { return x548_26_firing; }
|
2016-12-22 11:57:21 -08:00
|
|
|
};
|
2021-04-10 01:42:06 -07:00
|
|
|
} // namespace metaforce
|