From b85a66c2ee26e53915b288016c6be501ec113cf9 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Thu, 6 Oct 2022 11:53:35 +0300 Subject: [PATCH] Add CPlayerGun::CPlayerGun Former-commit-id: 835ea5361fe2660313cf398f83c099e537339810 --- include/MetroidPrime/CActorLights.hpp | 2 + include/MetroidPrime/CAnimRes.hpp | 9 +- include/MetroidPrime/CModelData.hpp | 3 +- include/MetroidPrime/Player/CPlayerGun.hpp | 7 ++ src/MetroidPrime/Player/CPlayerGun.cpp | 110 +++++++++++++++++++++ 5 files changed, 129 insertions(+), 2 deletions(-) diff --git a/include/MetroidPrime/CActorLights.hpp b/include/MetroidPrime/CActorLights.hpp index 606bfed0..94ec4dc3 100644 --- a/include/MetroidPrime/CActorLights.hpp +++ b/include/MetroidPrime/CActorLights.hpp @@ -17,6 +17,8 @@ class CAABox; class CActorLights { public: + CActorLights(uint areaUpdateFramePeriod, const CVector3f& actorPosBias, int maxDynamicLights, int maxAreaLights, + bool ambientChannelOverflow, bool layer2, bool disableWorldLights, float positionUpdateThreshold); ~CActorLights(); void BuildConstantAmbientLighting(); diff --git a/include/MetroidPrime/CAnimRes.hpp b/include/MetroidPrime/CAnimRes.hpp index 56f2b1dc..51036a75 100644 --- a/include/MetroidPrime/CAnimRes.hpp +++ b/include/MetroidPrime/CAnimRes.hpp @@ -15,7 +15,14 @@ private: CVector3f x8_scale; bool x14_canLoop; int x18_defaultAnim; + +public: + // CAnimRes() + // : x4_charIdx(-1), x14_canLoop(false), x8_scale(????), x18_defaultAnim(-1) {} + + CAnimRes(CAssetId ancs, int charIdx, const CVector3f& scale, const int defaultAnim, bool loop) + : x0_ancsId(ancs), x4_charIdx(charIdx), x8_scale(scale), x14_canLoop(loop), x18_defaultAnim(defaultAnim) {} }; CHECK_SIZEOF(CAnimRes, 0x1c) -#endif \ No newline at end of file +#endif diff --git a/include/MetroidPrime/CModelData.hpp b/include/MetroidPrime/CModelData.hpp index ebf9a079..8d33dbf6 100644 --- a/include/MetroidPrime/CModelData.hpp +++ b/include/MetroidPrime/CModelData.hpp @@ -17,6 +17,7 @@ class CAABox; class CActorLights; class CAnimData; +class CAnimRes; class CFrustumPlanes; class CModel; class CModelFlags; @@ -47,7 +48,7 @@ public: bool HasNormalModel() const { return x1c_normalModel; } CModelData(); - // __ct__10CModelDataFRC8CAnimRes + CModelData(const CAnimRes&); // __ct__10CModelDataFRC10CStaticRes CModelData(const CModelData& other); ~CModelData(); diff --git a/include/MetroidPrime/Player/CPlayerGun.hpp b/include/MetroidPrime/Player/CPlayerGun.hpp index fd0b6ab0..2fe5bef4 100644 --- a/include/MetroidPrime/Player/CPlayerGun.hpp +++ b/include/MetroidPrime/Player/CPlayerGun.hpp @@ -4,8 +4,10 @@ #include "types.h" #include "MetroidPrime/CActorLights.hpp" +#include "MetroidPrime/CModelData.hpp" #include "MetroidPrime/Player/CFidget.hpp" #include "MetroidPrime/Player/CPlayerCameraBob.hpp" +#include "MetroidPrime/Player/CPlayerState.hpp" #include "Kyoto/Audio/CSfxHandle.hpp" #include "Kyoto/Math/CAABox.hpp" @@ -16,6 +18,8 @@ #include "rstl/single_ptr.hpp" #include "rstl/vector.hpp" +#include "math.h" + enum EChargeState { kCS_Normal, kCS_Charged, @@ -33,6 +37,7 @@ class CPlasmaBeam; class CPhazonBeam; class CElementGen; class CWorldShadow; +class CGenDescription; class CPlayerGun { static float skTractorBeamFactor; @@ -85,6 +90,8 @@ public: kIS_Four, }; + CPlayerGun(TUniqueId); + bool IsCharging() const { return x834_24_charging; } float GetChargeBeamFactor() const { return x834_24_charging ? x340_chargeBeamFactor : 0.f; } diff --git a/src/MetroidPrime/Player/CPlayerGun.cpp b/src/MetroidPrime/Player/CPlayerGun.cpp index 122b4369..9547522a 100644 --- a/src/MetroidPrime/Player/CPlayerGun.cpp +++ b/src/MetroidPrime/Player/CPlayerGun.cpp @@ -1 +1,111 @@ #include "MetroidPrime/Player/CPlayerGun.hpp" + +#include "MetroidPrime/CAnimRes.hpp" +#include "MetroidPrime/Tweaks/CTweakPlayerGun.hpp" +#include "MetroidPrime/Tweaks/CTweakGunRes.hpp" + +CPlayerGun::CPlayerGun(TUniqueId uid) +: x0_lights(8, CVector3f::Zero(), 4, 4, false, false, false, 0.1) +, x2ec_lastFireButtonStates(0) +, x2f0_pressedFireButtonStates(0) +, x2f4_fireButtonStates(0) +, x2f8_stateFlags(0x1) +, x2fc_fidgetAnimBits(0) +, x300_remainingMissiles(0) +, x304_(0) +, x308_bombCount(3) +, x30c_rapidFireShots(0) +, x310_currentBeam(CPlayerState::kBI_Power) +, x314_nextBeam(CPlayerState::kBI_Power) +, x318_comboAmmoIdx(0) +, x31c_missileMode(kMM_Inactive) +, x320_currentAuxBeam(CPlayerState::kBI_Power) +, x324_idleState(kIS_Four) +, x328_animSfxPitch(0.f) +, x32c_chargePhase(kCP_NotCharging) +, x330_chargeState(kCS_Normal) +, x334_(0) +, x338_nextState(kNS_StatusQuo) +, x33c_phazonBeamState(kKBS_Inactive) +, x340_chargeBeamFactor(0.f) +, x344_comboXferTimer(0.f) +, x348_chargeCooldownTimer(0.f) +, x34c_shakeX(0.f) +, x350_shakeZ(0.f) +, x35c_bombTime(0.f) +, x360_(0.f) +, x364_gunStrikeCoolTimer(0.f) +, x368_idleWanderDelayTimer(0.f) +, x36c_(1.f) +, x370_gunMotionSpeedMult(1.f) +, x374_(0.f) +, x378_shotSmokeStartTimer(0.f) +, x37c_rapidFireShotsDecayTimer(0.f) +, x380_shotSmokeTimer(0.f) +, x384_gunStrikeDelayTimer(0.f) +, x388_enterFreeLookDelayTimer(0.f) +, x38c_muzzleEffectVisTimer(0.f) +, x390_cooldown(0.f) +, x394_damageTimer(0.f) +, x398_damageAmt(0.f) +, x39c_phazonMorphT(0.f) +, x3a0_missileExitTimer(0.f) +, x3dc_damageLocation(0.f, 0.f, 0.f) +, x3e8_xf(CTransform4f::Identity()) +, x418_beamLocalXf(CTransform4f::Identity()) +, x448_elbowWorldXf(CTransform4f::Identity()) +, x478_assistAimXf(CTransform4f::Identity()) +, x4a8_gunWorldXf(CTransform4f::Identity()) +, x4d8_gunLocalXf(CTransform4f::Identity()) +, x508_elbowLocalXf(CTransform4f::Identity()) +, x538_playerId(uid) +, x53a_powerBomb(kInvalidUniqueId) +, x53c_lightId(kInvalidUniqueId) +, x550_camBob(CPlayerCameraBob::kCBT_One, CPlayerCameraBob::GetCameraBobExtent(), + CPlayerCameraBob::GetCameraBobPeriod()) +, x658_(1) +, x65c_(0.f) +, x660_(0.f) +, x664_(0.f) +, x678_morph(gpTweakPlayerGun->GetGunTransformTime(), gpTweakPlayerGun->GetHoloHoldTime()) +, x6c8_hologramClipCube(CVector3f(-0.29329199f, 0.f, -0.2481945f), + CVector3f(0.29329199f, 1.292392f, 0.2481945f)) +, x6e0_rightHandModel(CAnimRes(gpTweakGunRes->xc_rightHand, 0, CVector3f(3.f, 3.f, 3.f), 0, true)) +, x72c_currentBeam(nullptr) +, x730_outgoingBeam(nullptr) +, x734_loadingBeam(nullptr) +, x738_nextBeam(nullptr) +, x830_chargeRumbleHandle(-1) +, x832_24_coolingCharge(false) +, x832_25_chargeEffectVisible(false) +, x832_26_comboFiring(false) +, x832_27_chargeAnimStarted(false) +, x832_28_readyForShot(false) +, x832_29_lockedOn(false) +, x832_30_requestReturnToDefault(false) +, x832_31_inRestPose(true) +, x833_24_notFidgeting(true) +, x833_25_(false) +, x833_26_(false) +, x833_27_(false) +, x833_28_phazonBeamActive(false) +, x833_29_pointBlankWorldSurface(false) +, x833_30_canShowAuxMuzzleEffect(true) +, x833_31_inFreeLook(false) +, x834_24_charging(false) +, x834_25_gunMotionFidgeting(false) +, x834_26_animPlaying(false) +, x834_27_underwater(false) +, x834_28_requestImmediateRecharge(false) +, x834_29_frozen(false) +, x834_30_inBigStrike(false) +, x834_31_gunMotionInFidgetBasePosition(false) +, x835_24_canFirePhazon(false) +, x835_25_inPhazonBeam(false) +, x835_26_phazonBeamMorphing(false) +, x835_27_intoPhazonBeam(false) +, x835_28_bombReady(false) +, x835_29_powerBombReady(false) +// , x835_30_inPhazonPool(false) +// , x835_31_actorAttached(false) +{}