|
| 1 | +#ifndef _CTARGETRETICLES |
| 2 | +#define _CTARGETRETICLES |
| 3 | + |
| 4 | +#include "types.h" |
| 5 | + |
| 6 | +#include "MetroidPrime/TGameTypes.hpp" |
| 7 | +#include "MetroidPrime/Player/CPlayerState.hpp" |
| 8 | + |
| 9 | +#include "Kyoto/Math/CQuaternion.hpp" |
| 10 | +#include "Kyoto/Math/CVector3f.hpp" |
| 11 | +#include "Kyoto/TToken.hpp" |
| 12 | + |
| 13 | +#include "rstl/vector.hpp" |
| 14 | + |
| 15 | +class CActor; |
| 16 | +class CMatrix3f; |
| 17 | +class CModel; |
| 18 | +class CScriptGrapplePoint; |
| 19 | +class CStateManager; |
| 20 | + |
| 21 | +enum EReticleState { |
| 22 | + kRS_Combat, |
| 23 | + kRS_Scan, |
| 24 | + kRS_XRay, |
| 25 | + kRS_Thermal, |
| 26 | + kRS_Four, |
| 27 | + kRS_Unspecified, |
| 28 | +}; |
| 29 | + |
| 30 | +class CTargetReticleRenderState { |
| 31 | +public: |
| 32 | + CTargetReticleRenderState(TUniqueId target, float radiusWorld, CVector3f positionWorld, |
| 33 | + float factor, float minVpClampScale, bool orbitZoneIdlePosition); |
| 34 | + |
| 35 | + static void InterpolateWithClamp(const CTargetReticleRenderState& a, |
| 36 | + CTargetReticleRenderState& out, |
| 37 | + const CTargetReticleRenderState& b, float t); |
| 38 | + |
| 39 | + void SetTargetId(TUniqueId id) { x0_target = id; } |
| 40 | + void SetFactor(float factor) { x14_factor = factor; } |
| 41 | + void SetIsOrbitZoneIdlePosition(bool orbit) { x1c_orbitZoneIdlePosition = orbit; } |
| 42 | + void SetRadiusWorld(float radius) { x4_radiusWorld = radius; } |
| 43 | + void SetTargetPositionWorld(const CVector3f& position) { x8_positionWorld = position; } |
| 44 | + void SetMinViewportClampScale(float scale) { x18_minVpClampScale = scale; } |
| 45 | + |
| 46 | + TUniqueId GetTargetId() const { return x0_target; } |
| 47 | + float GetRadiusWorld() const { return x4_radiusWorld; } |
| 48 | + const CVector3f& GetTargetPositionWorld() const { return x8_positionWorld; } |
| 49 | + float GetFactor() const { return x14_factor; } |
| 50 | + float GetMinViewportClampScale() const { return x18_minVpClampScale; } |
| 51 | + bool GetIsOrbitZoneIdlePosition() const { return x1c_orbitZoneIdlePosition; } |
| 52 | + |
| 53 | +private: |
| 54 | + TUniqueId x0_target; |
| 55 | + float x4_radiusWorld; |
| 56 | + CVector3f x8_positionWorld; |
| 57 | + float x14_factor; |
| 58 | + float x18_minVpClampScale; |
| 59 | + bool x1c_orbitZoneIdlePosition; |
| 60 | +}; |
| 61 | + |
| 62 | +CHECK_SIZEOF(CTargetReticleRenderState, 0x20) |
| 63 | + |
| 64 | +class CCompoundTargetReticle { |
| 65 | +public: |
| 66 | + struct SOuterItemInfo { |
| 67 | + TCachedToken< CModel > x0_model; |
| 68 | + float xc_offshootBaseAngle; |
| 69 | + float x10_rotAng; |
| 70 | + float x14_baseAngle; |
| 71 | + float x18_offshootAngleDelta; |
| 72 | + |
| 73 | + explicit SOuterItemInfo(const char* modelName); |
| 74 | + }; |
| 75 | + |
| 76 | + explicit CCompoundTargetReticle(const CStateManager& mgr); |
| 77 | + ~CCompoundTargetReticle(); |
| 78 | + |
| 79 | + void SetLeadingOrientation(const CQuaternion& o) { x0_leadingOrientation = o; } |
| 80 | + bool CheckLoadComplete(); |
| 81 | + EReticleState GetDesiredReticleState(const CStateManager& mgr) const; |
| 82 | + void Update(float dt, const CStateManager& mgr); |
| 83 | + void UpdateCurrLockOnGroup(float dt, const CStateManager& mgr); |
| 84 | + void UpdateNextLockOnGroup(float dt, const CStateManager& mgr); |
| 85 | + void UpdateOrbitZoneGroup(float dt, const CStateManager& mgr); |
| 86 | + void Draw(const CStateManager& mgr, bool hideLockon) const; |
| 87 | + void DrawGrappleGroup(const CMatrix3f& rot, const CStateManager& mgr, bool hideLockon) const; |
| 88 | + void DrawGrapplePoint(const CScriptGrapplePoint& point, float t, const CStateManager& mgr, |
| 89 | + const CMatrix3f& rot, bool zEqual) const; |
| 90 | + void DrawCurrLockOnGroup(const CMatrix3f& rot, const CStateManager& mgr) const; |
| 91 | + void DrawNextLockOnGroup(const CMatrix3f& rot, const CStateManager& mgr) const; |
| 92 | + void DrawOrbitZoneGroup(const CMatrix3f& rot, const CStateManager& mgr) const; |
| 93 | + void UpdateTargetParameters(CTargetReticleRenderState& state, const CStateManager& mgr); |
| 94 | + float CalculateRadiusWorld(const CActor& actor, const CStateManager& mgr) const; |
| 95 | + CVector3f CalculatePositionWorld(const CActor& actor, const CStateManager& mgr) const; |
| 96 | + CVector3f CalculateOrbitZoneReticlePosition(const CStateManager& mgr, bool lag) const; |
| 97 | + static bool IsGrappleTarget(TUniqueId id, const CStateManager& mgr); |
| 98 | + static float CalculateClampedScale(CVector3f pos, float scale, float clampMin, |
| 99 | + float clampMax, const CStateManager& mgr); |
| 100 | + void Touch() const; |
| 101 | + |
| 102 | + TUniqueId GetTargetId() const { return xf0_targetId; } |
| 103 | + TUniqueId GetNextTargetId() const { return xf2_nextTargetId; } |
| 104 | + const CTargetReticleRenderState& GetCurrGroupInterp() const { return x10c_currGroupInterp; } |
| 105 | + const CTargetReticleRenderState& GetNextGroupInterp() const { return x174_nextGroupInterp; } |
| 106 | + bool GetIsOrbitZoneIdlePosition() const { return x10c_currGroupInterp.GetIsOrbitZoneIdlePosition(); } |
| 107 | + |
| 108 | +private: |
| 109 | + CQuaternion x0_leadingOrientation; |
| 110 | + CQuaternion x10_laggingOrientation; |
| 111 | + EReticleState x20_prevState; |
| 112 | + EReticleState x24_nextState; |
| 113 | + mutable int x28_noDrawTicks; |
| 114 | + float x2c_overshootOffsetHalf; |
| 115 | + float x30_premultOvershootOffset; |
| 116 | + TCachedToken< CModel > x34_crosshairs; |
| 117 | + TCachedToken< CModel > x40_seeker; |
| 118 | + TCachedToken< CModel > x4c_lockConfirm; |
| 119 | + TCachedToken< CModel > x58_targetFlower; |
| 120 | + TCachedToken< CModel > x64_missileBracket; |
| 121 | + TCachedToken< CModel > x70_innerBeamIcon; |
| 122 | + TCachedToken< CModel > x7c_lockFire; |
| 123 | + TCachedToken< CModel > x88_lockDagger; |
| 124 | + TCachedToken< CModel > x94_grapple; |
| 125 | + TCachedToken< CModel > xa0_chargeTickFirst; |
| 126 | + TCachedToken< CModel > xac_xrayRetRing; |
| 127 | + TCachedToken< CModel > xb8_thermalReticle; |
| 128 | + SOuterItemInfo xc4_chargeGauge; |
| 129 | + rstl::vector< SOuterItemInfo > xe0_outerBeamIconSquares; |
| 130 | + TUniqueId xf0_targetId; |
| 131 | + TUniqueId xf2_nextTargetId; |
| 132 | + CVector3f xf4_targetPos; |
| 133 | + CVector3f x100_laggingTargetPos; |
| 134 | + CTargetReticleRenderState x10c_currGroupInterp; |
| 135 | + CTargetReticleRenderState x12c_currGroupA; |
| 136 | + CTargetReticleRenderState x14c_currGroupB; |
| 137 | + float x16c_currGroupDur; |
| 138 | + float x170_currGroupTimer; |
| 139 | + CTargetReticleRenderState x174_nextGroupInterp; |
| 140 | + CTargetReticleRenderState x194_nextGroupA; |
| 141 | + CTargetReticleRenderState x1b4_nextGroupB; |
| 142 | + float x1d4_nextGroupDur; |
| 143 | + float x1d8_nextGroupTimer; |
| 144 | + TUniqueId x1dc_grapplePoint0; |
| 145 | + TUniqueId x1de_grapplePoint1; |
| 146 | + float x1e0_grapplePoint0T; |
| 147 | + float x1e4_grapplePoint1T; |
| 148 | + float x1e8_crosshairsScale; |
| 149 | + float x1ec_seekerAngle; |
| 150 | + float x1f0_xrayRetAngle; |
| 151 | + bool x1f4_missileActive; |
| 152 | + float x1f8_missileBracketTimer; |
| 153 | + float x1fc_missileBracketScaleTimer; |
| 154 | + CPlayerState::EBeamId x200_beam; |
| 155 | + float x204_chargeGaugeOvershootTimer; |
| 156 | + float x208_lockonTimer; |
| 157 | + float x20c_unk; |
| 158 | + float x210_lockFireTimer; |
| 159 | + float x214_fullChargeFadeTimer; |
| 160 | + bool x218_beamShot; |
| 161 | + bool x219_missileShot; |
| 162 | + bool x21a_fullyCharged; |
| 163 | +}; |
| 164 | + |
| 165 | +CHECK_SIZEOF(CCompoundTargetReticle, 0x21C) |
| 166 | + |
| 167 | +class COrbitPointMarker { |
| 168 | +public: |
| 169 | + COrbitPointMarker(); |
| 170 | + ~COrbitPointMarker(); |
| 171 | + |
| 172 | + bool CheckLoadComplete(); |
| 173 | + void Update(float dt, const CStateManager& mgr); |
| 174 | + void Draw(const CStateManager& mgr) const; |
| 175 | + void ResetInterpolationTimer(float time); |
| 176 | + bool IsInterpolating() const { return x20_interpTimer > 0.f; } |
| 177 | + |
| 178 | +private: |
| 179 | + float x0_zOffset; |
| 180 | + bool x4_camRelZPos; |
| 181 | + float x8_lagAzimuth; |
| 182 | + float xc_azimuth; |
| 183 | + CVector3f x10_lagTargetPos; |
| 184 | + bool x1c_lastFreeOrbit; |
| 185 | + float x20_interpTimer; |
| 186 | + float x24_curTime; |
| 187 | + TCachedToken< CModel > x28_orbitPointModel; |
| 188 | +}; |
| 189 | + |
| 190 | +CHECK_SIZEOF(COrbitPointMarker, 0x34) |
| 191 | + |
| 192 | +class CTargetingManager { |
| 193 | +public: |
| 194 | + explicit CTargetingManager(const CStateManager& mgr); |
| 195 | + |
| 196 | + bool CheckLoadComplete(); |
| 197 | + void Update(float dt, const CStateManager& mgr); |
| 198 | + void Draw(const CStateManager& mgr, bool hideLockon) const; |
| 199 | + void Touch() const; |
| 200 | + |
| 201 | + CCompoundTargetReticle& CompoundTargetReticle() { return x0_targetReticle; } |
| 202 | + const CCompoundTargetReticle& GetCompoundTargetReticle() const { return x0_targetReticle; } |
| 203 | + |
| 204 | +private: |
| 205 | + CCompoundTargetReticle x0_targetReticle; |
| 206 | + COrbitPointMarker x21c_orbitPointMarker; |
| 207 | +}; |
| 208 | + |
| 209 | +CHECK_SIZEOF(CTargetingManager, 0x250) |
| 210 | + |
| 211 | +#endif // _CTARGETRETICLES |
0 commit comments