CPlayerGun: Rename EMissileState; minor CMotionState::Update fix

This commit is contained in:
Luke Street 2020-04-19 00:26:53 -04:00
parent a3e0c42794
commit e50d363e88
5 changed files with 42 additions and 44 deletions

View File

@ -220,7 +220,7 @@ void CCompoundTargetReticle::Update(float dt, const CStateManager& mgr) {
std::max(x214_fullChargeFadeTimer - dt / g_tweakTargeting->GetFullChargeFadeDuration(), 0.f);
}
const bool missileActive = gun->GetMissleMode() == CPlayerGun::EMissleMode::Active;
const bool missileActive = gun->GetMissleMode() == CPlayerGun::EMissileMode::Active;
if (missileActive != x1f4_missileActive) {
if (x1f8_missileBracketTimer != 0.f) {
x1f8_missileBracketTimer = FLT_EPSILON - x1f8_missileBracketTimer;

View File

@ -139,7 +139,7 @@ void CSamusHud::InitializeFrameGlueMutable(const CStateManager& mgr) {
CPlayerState& playerState = *mgr.GetPlayerState();
CPlayerGun& gun = *player.GetPlayerGun();
float chargeFactor = gun.IsCharging() ? gun.GetChargeBeamFactor() : 0.f;
bool missilesActive = gun.GetMissleMode() == CPlayerGun::EMissleMode::Active;
bool missilesActive = gun.GetMissleMode() == CPlayerGun::EMissileMode::Active;
bool lockedOnObj = player.GetOrbitTargetId() != kInvalidUniqueId;
switch (x2bc_nextState) {
@ -477,7 +477,7 @@ void CSamusHud::UpdateMissile(float dt, const CStateManager& mgr, bool init) {
u32 numMissles = playerState.GetItemAmount(CPlayerState::EItemType::Missiles);
u32 missileCap = playerState.GetItemCapacity(CPlayerState::EItemType::Missiles);
CPlayerGun::EMissleMode missileMode = gun.GetMissleMode();
CPlayerGun::EMissileMode missileMode = gun.GetMissleMode();
float chargeFactor = gun.IsCharging() ? gun.GetChargeBeamFactor() : 0.f;
if (x294_missileIntf)
@ -491,7 +491,7 @@ void CSamusHud::UpdateMissile(float dt, const CStateManager& mgr, bool init) {
if (numMissles != x2d8_missileAmount)
x294_missileIntf->SetNumMissiles(numMissles, mgr);
if (missileMode != x2ec_missileMode)
x294_missileIntf->SetIsMissilesActive(missileMode == CPlayerGun::EMissleMode::Active);
x294_missileIntf->SetIsMissilesActive(missileMode == CPlayerGun::EMissileMode::Active);
}
x2d8_missileAmount = numMissles;
x2ec_missileMode = missileMode;

View File

@ -101,7 +101,7 @@ class CSamusHud {
bool x2e0_27_energyLow : 1;
u32 x2e4_ = 0;
u32 x2e8_ = 0;
CPlayerGun::EMissleMode x2ec_missileMode = CPlayerGun::EMissleMode::Inactive;
CPlayerGun::EMissileMode x2ec_missileMode = CPlayerGun::EMissileMode::Inactive;
float x2f0_visorBeamMenuAlpha = 1.f;
zeus::CVector3f x2f8_fpCamDir;
zeus::CVector3f x304_basewidgetIdlePos;

View File

@ -501,7 +501,7 @@ void CPlayerGun::ResetCharge(CStateManager& mgr, bool resetBeam) {
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
}
}
@ -587,7 +587,7 @@ void CPlayerGun::Reset(CStateManager& mgr, bool b1) {
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
}
} else {
x2f8_stateFlags &= ~0x7;
@ -784,7 +784,7 @@ void CPlayerGun::CancelFiring(CStateManager& mgr) {
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
}
if (x32c_chargePhase != EChargePhase::NotCharging) {
x72c_currentBeam->ActivateCharge(false, false);
@ -820,8 +820,7 @@ void CPlayerGun::StopContinuousBeam(CStateManager& mgr, bool b1) {
} else if (x833_28_phazonBeamActive) {
if (static_cast<CPhazonBeam*>(x72c_currentBeam)->IsFiring())
static_cast<CPhazonBeam*>(x72c_currentBeam)->StopBeam(mgr, b1);
} else if (x310_currentBeam == CPlayerState::EBeamId::Plasma) // Plasma
{
} else if (x310_currentBeam == CPlayerState::EBeamId::Plasma) {
if (static_cast<CPlasmaBeam*>(x72c_currentBeam)->IsFiring())
static_cast<CPlasmaBeam*>(x72c_currentBeam)->StopBeam(mgr, b1);
}
@ -839,35 +838,34 @@ void CPlayerGun::CMotionState::Update(bool firing, float dt, zeus::CTransform& x
if (x0_24_extendParabola && x20_state == EMotionState::LockOn) {
float extendT = xc_curExtendDist / gGunExtendDistance;
xf = xf * zeus::CTransform::RotateZ(zeus::degToRad(extendT * -4.f * (extendT - 1.f) * 15.f));
} else {
if (x24_fireState == EFireState::StartFire || x24_fireState == EFireState::Firing) {
if (std::fabs(x14_rotationT - 1.f) < 0.1f) {
x18_startRotation = x1c_endRotation;
x14_rotationT = 0.f;
if (x24_fireState == EFireState::StartFire) {
x1c_endRotation = mgr.GetActiveRandom()->Next() % 15;
x1c_endRotation *= (mgr.GetActiveRandom()->Next() % 100) > 45 ? 1.f : -1.f;
} else {
x1c_endRotation = 0.f;
if (x18_startRotation == x1c_endRotation) {
x10_curRotation = x1c_endRotation;
x24_fireState = EFireState::NotFiring;
}
}
xf = xf * zeus::CTransform(zeus::CMatrix3f::RotateZ(zeus::degToRad(extendT * -4.f * (extendT - 1.f) * 15.f)),
{0.f, xc_curExtendDist, 0.f});
} else if (x24_fireState == EFireState::StartFire || x24_fireState == EFireState::Firing) {
if (std::fabs(x14_rotationT - 1.f) < 0.1f) {
x18_startRotation = x1c_endRotation;
x14_rotationT = 0.f;
if (x24_fireState == EFireState::StartFire) {
x1c_endRotation = mgr.GetActiveRandom()->Next() % 15;
x1c_endRotation *= (mgr.GetActiveRandom()->Next() % 100) > 45 ? 1.f : -1.f;
} else {
x10_curRotation = (x1c_endRotation - x18_startRotation) * x14_rotationT + x18_startRotation;
x1c_endRotation = 0.f;
if (x18_startRotation == x1c_endRotation) {
x10_curRotation = x1c_endRotation;
x24_fireState = EFireState::NotFiring;
}
}
x14_rotationT += (1.f - x14_rotationT) * 0.8f * (10.f * dt);
zeus::CTransform tmpXf =
zeus::CQuaternion::fromAxisAngle(xf.basis[1], zeus::degToRad(x10_curRotation)).toTransform() *
xf.getRotation();
tmpXf.origin = xf.origin;
xf = tmpXf * zeus::CTransform::Translate(0.f, xc_curExtendDist, 0.f);
} else {
xf = xf * zeus::CTransform::Translate(0.f, xc_curExtendDist, 0.f);
x10_curRotation = (x1c_endRotation - x18_startRotation) * x14_rotationT + x18_startRotation;
}
x14_rotationT += (1.f - x14_rotationT) * 0.8f * (10.f * dt);
zeus::CTransform tmpXf =
zeus::CQuaternion::fromAxisAngle(xf.frontVector(), zeus::degToRad(x10_curRotation)).toTransform() *
xf.getRotation();
tmpXf.origin = xf.origin;
xf = tmpXf * zeus::CTransform::Translate(0.f, xc_curExtendDist, 0.f);
} else {
xf = xf * zeus::CTransform::Translate(0.f, xc_curExtendDist, 0.f);
}
switch (x20_state) {
@ -1272,7 +1270,7 @@ void CPlayerGun::UpdateAuxWeapons(float dt, const zeus::CTransform& targetXf, CS
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
}
} else if (x833_28_phazonBeamActive) {
static_cast<CPhazonBeam*>(x72c_currentBeam)->UpdateBeam(dt, targetXf, x418_beamLocalXf.origin, mgr);
@ -1581,7 +1579,7 @@ void CPlayerGun::UpdateWeaponFire(float dt, const CPlayerState& playerState, CSt
x2f8_stateFlags &= ~0x1;
x2f8_stateFlags |= 0x6;
x318_comboAmmoIdx = 1;
x31c_missileMode = EMissleMode::Active;
x31c_missileMode = EMissileMode::Active;
}
FireSecondary(dt, mgr);
} else {
@ -1875,7 +1873,7 @@ void CPlayerGun::Update(float grappleSwingT, float cameraBobT, float dt, CStateM
x2f8_stateFlags &= ~0x1;
x2f8_stateFlags |= 0x6;
x318_comboAmmoIdx = 1;
x31c_missileMode = EMissleMode::Active;
x31c_missileMode = EMissileMode::Active;
break;
case ENextState::ExitMissile:
if ((x2f8_stateFlags & 0x8) != 0x8) {
@ -1883,7 +1881,7 @@ void CPlayerGun::Update(float grappleSwingT, float cameraBobT, float dt, CStateM
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
x390_cooldown = x72c_currentBeam->GetWeaponInfo().x0_coolDown;
break;
case ENextState::MissileReload:
@ -1905,7 +1903,7 @@ void CPlayerGun::Update(float grappleSwingT, float cameraBobT, float dt, CStateM
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
break;
case ENextState::EnterPhazonBeam:
if (x75c_phazonBeam->IsLoaded())
@ -1970,7 +1968,7 @@ void CPlayerGun::Update(float grappleSwingT, float cameraBobT, float dt, CStateM
zeus::CAABox aabb = x72c_currentBeam->GetBounds().getTransformedAABox(x4a8_gunWorldXf);
mgr.BuildNearList(nearList, aabb, sAimFilter, &player);
TUniqueId bestId = kInvalidUniqueId;
zeus::CVector3f dir = x4a8_gunWorldXf.basis[1].normalized();
zeus::CVector3f dir = x4a8_gunWorldXf.frontVector().normalized();
zeus::CVector3f pos = dir * -0.5f + x4a8_gunWorldXf.origin;
CRayCastResult result = mgr.RayWorldIntersection(bestId, pos, dir, 3.5f, sAimFilter, nearList);
x833_29_pointBlankWorldSurface = result.IsValid();

View File

@ -35,7 +35,7 @@ struct CFinalInput;
class CPlayerGun {
public:
static float skTractorBeamFactor;
enum class EMissleMode { Inactive, Active };
enum class EMissileMode { Inactive, Active };
enum class EBWeapon { Bomb, PowerBomb };
enum class EPhazonBeamState { Inactive, Entering, Exiting, Active };
enum class EChargePhase {
@ -141,7 +141,7 @@ private:
CPlayerState::EBeamId x310_currentBeam = CPlayerState::EBeamId::Power;
CPlayerState::EBeamId x314_nextBeam = CPlayerState::EBeamId::Power;
u32 x318_comboAmmoIdx = 0;
EMissleMode x31c_missileMode = EMissleMode::Inactive;
EMissileMode x31c_missileMode = EMissileMode::Inactive;
CPlayerState::EBeamId x320_currentAuxBeam = CPlayerState::EBeamId::Power;
EIdleState x324_idleState = EIdleState::Four;
float x328_animSfxPitch = 0.f;
@ -323,7 +323,7 @@ public:
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
void AsyncLoadSuit(CStateManager& mgr);
void TouchModel(const CStateManager& stateMgr);
EMissleMode GetMissleMode() const { return x31c_missileMode; }
EMissileMode GetMissleMode() const { return x31c_missileMode; }
bool IsFidgeting() const { return x833_24_notFidgeting; }
bool IsCharging() const { return x834_24_charging; }
float GetChargeBeamFactor() const { return x340_chargeBeamFactor; }