2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-12-22 19:57:21 +00:00
|
|
|
|
2019-09-22 21:52:05 +00:00
|
|
|
#include <optional>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Runtime/CToken.hpp"
|
|
|
|
#include "Runtime/RetroTypes.hpp"
|
|
|
|
#include "Runtime/Collision/CMaterialList.hpp"
|
|
|
|
#include "Runtime/Collision/CRayCastResult.hpp"
|
|
|
|
#include "Runtime/Weapon/CProjectileWeapon.hpp"
|
|
|
|
#include "Runtime/Weapon/CWeapon.hpp"
|
|
|
|
#include "Runtime/Weapon/CWeaponMode.hpp"
|
|
|
|
#include "Runtime/World/CDamageInfo.hpp"
|
|
|
|
|
|
|
|
#include <zeus/CAABox.hpp>
|
|
|
|
#include <zeus/CVector3f.hpp>
|
2016-12-22 19:57:21 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-12-22 19:57:21 +00:00
|
|
|
class CGenDescription;
|
|
|
|
class CWeaponDescription;
|
2018-02-09 07:12:26 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CProjectileTouchResult {
|
|
|
|
TUniqueId x0_id;
|
2019-06-12 02:05:17 +00:00
|
|
|
std::optional<CRayCastResult> x4_result;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2018-02-09 07:12:26 +00:00
|
|
|
public:
|
2020-09-26 05:34:13 +00:00
|
|
|
CProjectileTouchResult(TUniqueId id, const std::optional<CRayCastResult>& result) : x0_id(id), x4_result(result) {}
|
2018-12-08 05:30:43 +00:00
|
|
|
TUniqueId GetActorId() const { return x0_id; }
|
|
|
|
bool HasRayCastResult() const { return x4_result.operator bool(); }
|
|
|
|
const CRayCastResult& GetRayCastResult() const { return *x4_result; }
|
2018-02-09 07:12:26 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CGameProjectile : public CWeapon {
|
2018-02-11 05:27:00 +00:00
|
|
|
protected:
|
2019-06-12 02:05:17 +00:00
|
|
|
std::optional<TLockedToken<CGenDescription>> x158_visorParticle;
|
2018-12-08 05:30:43 +00:00
|
|
|
u16 x168_visorSfx;
|
|
|
|
CProjectileWeapon x170_projectile;
|
2019-01-03 03:47:28 +00:00
|
|
|
zeus::CVector3f x298_previousPos;
|
2018-12-08 05:30:43 +00:00
|
|
|
float x2a4_projExtent;
|
|
|
|
float x2a8_homingDt = 0.03f;
|
|
|
|
double x2b0_targetHomingTime = 0.0;
|
|
|
|
double x2b8_curHomingTime = x2a8_homingDt;
|
|
|
|
TUniqueId x2c0_homingTargetId;
|
|
|
|
TUniqueId x2c2_lastResolvedObj = kInvalidUniqueId;
|
2020-09-26 14:38:22 +00:00
|
|
|
TUniqueId x2c4_hitProjectileOwner = kInvalidUniqueId;
|
2018-12-08 05:30:43 +00:00
|
|
|
TUniqueId x2c6_pendingDamagee = kInvalidUniqueId;
|
|
|
|
TUniqueId x2c8_projectileLight = kInvalidUniqueId;
|
|
|
|
CAssetId x2cc_wpscId;
|
|
|
|
std::vector<CProjectileTouchResult> x2d0_touchResults;
|
|
|
|
float x2e0_minHomingDist = 0.f;
|
2020-04-20 04:57:50 +00:00
|
|
|
bool x2e4_24_active : 1 = true;
|
2020-04-11 04:49:02 +00:00
|
|
|
bool x2e4_25_startedUnderwater : 1;
|
|
|
|
bool x2e4_26_waterUpdate : 1;
|
|
|
|
bool x2e4_27_inWater : 1;
|
|
|
|
bool x2e4_28_sendProjectileCollideMsg : 1;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2016-12-22 19:57:21 +00:00
|
|
|
public:
|
2021-05-26 14:00:57 +00:00
|
|
|
DEFINE_ENTITY
|
2018-12-08 05:30:43 +00:00
|
|
|
CGameProjectile(bool active, const TToken<CWeaponDescription>&, std::string_view name, EWeaponType wType,
|
|
|
|
const zeus::CTransform& xf, EMaterialTypes excludeMat, const CDamageInfo& dInfo, TUniqueId uid,
|
|
|
|
TAreaId aid, TUniqueId owner, TUniqueId homingTarget, EProjectileAttrib attribs, bool underwater,
|
2020-04-11 04:49:02 +00:00
|
|
|
const zeus::CVector3f& scale, std::optional<TLockedToken<CGenDescription>> visorParticle,
|
|
|
|
u16 visorSfx, bool sendCollideMsg);
|
2016-12-22 19:57:21 +00:00
|
|
|
|
2019-08-09 12:45:18 +00:00
|
|
|
void Accept(IVisitor& visitor) override;
|
2018-12-08 05:30:43 +00:00
|
|
|
virtual void ResolveCollisionWithActor(const CRayCastResult& res, CActor& act, CStateManager& mgr);
|
2019-08-09 12:45:18 +00:00
|
|
|
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override;
|
2020-09-26 05:34:13 +00:00
|
|
|
void Render(CStateManager& mgr) override;
|
2018-12-08 05:30:43 +00:00
|
|
|
static EProjectileAttrib GetBeamAttribType(EWeaponType wType);
|
|
|
|
void DeleteProjectileLight(CStateManager&);
|
|
|
|
void CreateProjectileLight(std::string_view, const CLight&, CStateManager&);
|
|
|
|
void Chase(float dt, CStateManager& mgr);
|
|
|
|
void UpdateHoming(float dt, CStateManager& mgr);
|
|
|
|
void UpdateProjectileMovement(float dt, CStateManager& mgr);
|
|
|
|
CRayCastResult DoCollisionCheck(TUniqueId& idOut, CStateManager& mgr);
|
|
|
|
void ApplyDamageToActors(CStateManager& mgr, const CDamageInfo& dInfo);
|
2019-08-14 05:57:13 +00:00
|
|
|
void FluidFXThink(EFluidState state, CScriptWater& water, CStateManager& mgr) override;
|
2018-12-08 05:30:43 +00:00
|
|
|
CRayCastResult RayCollisionCheckWithWorld(TUniqueId& idOut, const zeus::CVector3f& start, const zeus::CVector3f& end,
|
2021-06-07 00:07:45 +00:00
|
|
|
float mag, const EntityList& nearList,
|
2018-12-08 05:30:43 +00:00
|
|
|
CStateManager& mgr);
|
2019-06-12 02:05:17 +00:00
|
|
|
CProjectileTouchResult CanCollideWith(CActor& act, CStateManager& mgr) const;
|
2020-04-03 05:39:48 +00:00
|
|
|
CProjectileTouchResult CanCollideWithComplexCollision(const CActor& act, const CStateManager& mgr) const;
|
2019-06-12 02:05:17 +00:00
|
|
|
CProjectileTouchResult CanCollideWithGameObject(CActor& act, CStateManager& mgr) const;
|
2020-04-03 05:39:48 +00:00
|
|
|
CProjectileTouchResult CanCollideWithTrigger(const CActor& act, const CStateManager& mgr) const;
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CAABox GetProjectileBounds() const;
|
2019-08-09 12:45:18 +00:00
|
|
|
std::optional<zeus::CAABox> GetTouchBounds() const override;
|
2019-03-24 05:45:47 +00:00
|
|
|
CProjectileWeapon& ProjectileWeapon() { return x170_projectile; }
|
|
|
|
const CProjectileWeapon& GetProjectileWeapon() const { return x170_projectile; }
|
2018-12-08 05:30:43 +00:00
|
|
|
TUniqueId GetHomingTargetId() const { return x2c0_homingTargetId; }
|
2019-01-03 03:47:28 +00:00
|
|
|
zeus::CVector3f GetPreviousPos() const { return x298_previousPos; }
|
2020-03-06 15:16:55 +00:00
|
|
|
void SetMinHomingDistance(float dist) { x2e0_minHomingDist = dist; }
|
2020-09-26 14:38:22 +00:00
|
|
|
void SetHitProjectileOwner(TUniqueId id) { x2c4_hitProjectileOwner = id; }
|
2016-12-22 19:57:21 +00:00
|
|
|
};
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|