diff --git a/Runtime/Weapon/CPlayerGun.cpp b/Runtime/Weapon/CPlayerGun.cpp index e5116ae27..578d423c8 100644 --- a/Runtime/Weapon/CPlayerGun.cpp +++ b/Runtime/Weapon/CPlayerGun.cpp @@ -16,12 +16,109 @@ #include "Runtime/Weapon/CPowerBomb.hpp" namespace urde { +namespace { +std::array kVerticalAngleTable{-30.f, 0.f, 30.f}; +std::array kHorizontalAngleTable{30.f, 30.f, 30.f}; +std::array kVerticalVarianceTable{30.f, 30.f, 30.f}; -static const zeus::CVector3f sGunScale(2.f); +constexpr zeus::CVector3f sGunScale(2.f); -static float kVerticalAngleTable[] = {-30.f, 0.f, 30.f}; -static float kHorizontalAngleTable[] = {30.f, 30.f, 30.f}; -static float kVerticalVarianceTable[] = {30.f, 30.f, 30.f}; +constexpr std::array skBeamAnimIds{ + 0, + 1, + 2, + 1, +}; + +constexpr std::array skBeamArr{ + CPlayerState::EItemType::PowerBeam, + CPlayerState::EItemType::IceBeam, + CPlayerState::EItemType::WaveBeam, + CPlayerState::EItemType::PlasmaBeam, +}; + +constexpr std::array skBeamComboArr{ + CPlayerState::EItemType::SuperMissile, + CPlayerState::EItemType::IceSpreader, + CPlayerState::EItemType::Wavebuster, + CPlayerState::EItemType::Flamethrower, +}; + +constexpr std::array mBeamCtrlCmd{ + ControlMapper::ECommands::PowerBeam, + ControlMapper::ECommands::IceBeam, + ControlMapper::ECommands::WaveBeam, + ControlMapper::ECommands::PlasmaBeam, +}; + +constexpr std::array skFromMissileSound{ + SFXwpn_from_missile_power, + SFXwpn_from_missile_ice, + SFXwpn_from_missile_wave, + SFXwpn_from_missile_plasma, +}; + +constexpr std::array skFromBeamSound{ + SFXsfx0000, + SFXwpn_from_beam_ice, + SFXwpn_from_beam_wave, + SFXwpn_from_beam_plasma, +}; + +constexpr std::array skToMissileSound{ + SFXwpn_to_missile_power, + SFXwpn_to_missile_ice, + SFXwpn_to_missile_wave, + SFXwpn_to_missile_plasma, +}; + +constexpr std::array skIntoBeamSound{ + SFXsfx0000, + SFXwpn_into_beam_ice, + SFXwpn_into_beam_wave, + SFXwpn_into_beam_plasma, +}; + +constexpr float kChargeSpeed = 1.f / CPlayerState::GetMissileComboChargeFactor(); +constexpr float kChargeFxStart = 1.f / CPlayerState::GetMissileComboChargeFactor(); +constexpr float kChargeAnimStart = 0.25f / CPlayerState::GetMissileComboChargeFactor(); +constexpr float kChargeStart = 0.025f / CPlayerState::GetMissileComboChargeFactor(); + +constexpr std::array skBeamChargeUpSound{ + SFXwpn_chargeup_power, + SFXwpn_chargeup_ice, + SFXwpn_chargeup_wave, + SFXwpn_chargeup_plasma, +}; + +constexpr std::array skItemArr{ + CPlayerState::EItemType::Invalid, + CPlayerState::EItemType::Missiles, +}; + +constexpr std::array skItemEmptySound{ + SFXsfx0000, + SFXwpn_empty_action, +}; + +constexpr std::array chargeShakeTbl{ + -0.001f, + 0.f, + 0.001f, +}; +constexpr CMaterialFilter sAimFilter = + CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {EMaterialTypes::ProjectilePassthrough}); + +const std::array kThermalFlags{{ + {0, 0, 3, zeus::skWhite}, + {5, 0, 3, zeus::CColor(0.f, 0.5f)}, + {0, 0, 3, zeus::skWhite}, + {0, 0, 3, zeus::skWhite}, +}}; + +const CModelFlags kHandThermalFlag = {7, 0, 3, zeus::skWhite}; +const CModelFlags kHandHoloFlag = {1, 0, 3, zeus::CColor(0.75f, 0.5f, 0.f, 1.f)}; +} // Anonymous namespace float CPlayerGun::CMotionState::gGunExtendDistance = 0.125f; float CPlayerGun::skTractorBeamFactor = 0.5f / CPlayerState::GetMissileComboChargeFactor(); @@ -204,8 +301,6 @@ void CPlayerGun::SetGunLightActive(bool active, CStateManager& mgr) { } } -static const u32 skBeamAnimIds[] = {0, 1, 2, 1}; - void CPlayerGun::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) { const CPlayer& player = mgr.GetPlayer(); bool isUnmorphed = player.GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed; @@ -213,11 +308,11 @@ void CPlayerGun::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CSt case EScriptObjectMessage::Registered: { CreateGunLight(mgr); x320_currentAuxBeam = x314_nextBeam = x310_currentBeam = mgr.GetPlayerState()->GetCurrentBeam(); - x72c_currentBeam = x738_nextBeam = x760_selectableBeams[int(x310_currentBeam)]; + x72c_currentBeam = x738_nextBeam = x760_selectableBeams[size_t(x310_currentBeam)]; x72c_currentBeam->Load(mgr, true); x72c_currentBeam->SetRainSplashGenerator(x748_rainSplashGenerator.get()); x744_auxWeapon->Load(x310_currentBeam, mgr); - CAnimPlaybackParms parms(skBeamAnimIds[int(mgr.GetPlayerState()->GetCurrentBeam())], -1, 1.f, true); + const CAnimPlaybackParms parms(skBeamAnimIds[size_t(mgr.GetPlayerState()->GetCurrentBeam())], -1, 1.f, true); x6e0_rightHandModel.GetAnimationData()->SetAnimation(parms, false); break; } @@ -401,28 +496,13 @@ bool CPlayerGun::ExitMissile() { return false; } -static const CPlayerState::EItemType skBeamArr[] = {CPlayerState::EItemType::PowerBeam, - CPlayerState::EItemType::IceBeam, CPlayerState::EItemType::WaveBeam, - CPlayerState::EItemType::PlasmaBeam}; - -static const CPlayerState::EItemType skBeamComboArr[] = { - CPlayerState::EItemType::SuperMissile, CPlayerState::EItemType::IceSpreader, CPlayerState::EItemType::Wavebuster, - CPlayerState::EItemType::Flamethrower}; - -static const ControlMapper::ECommands mBeamCtrlCmd[] = { - ControlMapper::ECommands::PowerBeam, - ControlMapper::ECommands::IceBeam, - ControlMapper::ECommands::WaveBeam, - ControlMapper::ECommands::PlasmaBeam, -}; - void CPlayerGun::HandleBeamChange(const CFinalInput& input, CStateManager& mgr) { - CPlayerState& playerState = *mgr.GetPlayerState(); + const CPlayerState& playerState = *mgr.GetPlayerState(); float maxBeamInput = 0.f; CPlayerState::EBeamId selectBeam = CPlayerState::EBeamId::Invalid; - for (int i = 0; i < 4; ++i) { + for (size_t i = 0; i < skBeamArr.size(); ++i) { if (playerState.HasPowerUp(skBeamArr[i])) { - float inputVal = ControlMapper::GetAnalogInput(mBeamCtrlCmd[i], input); + const float inputVal = ControlMapper::GetAnalogInput(mBeamCtrlCmd[i], input); if (inputVal > 0.65f && inputVal > maxBeamInput) { maxBeamInput = inputVal; selectBeam = CPlayerState::EBeamId(i); @@ -434,7 +514,7 @@ void CPlayerGun::HandleBeamChange(const CFinalInput& input, CStateManager& mgr) return; x833_25_ = true; - if (x310_currentBeam != selectBeam && playerState.HasPowerUp(skBeamArr[int(selectBeam)])) { + if (x310_currentBeam != selectBeam && playerState.HasPowerUp(skBeamArr[size_t(selectBeam)])) { x314_nextBeam = selectBeam; u32 flags = 0; if ((x2f8_stateFlags & 0x10) == 0x10) @@ -449,7 +529,7 @@ void CPlayerGun::HandleBeamChange(const CFinalInput& input, CStateManager& mgr) x72c_currentBeam->EnableSecondaryFx(CGunWeapon::ESecondaryFxType::None); x338_nextState = ENextState::ChangeWeapon; x2e4_invalidSfx.reset(); - } else if (playerState.HasPowerUp(skBeamArr[int(selectBeam)])) { + } else if (playerState.HasPowerUp(skBeamArr[size_t(selectBeam)])) { if (ExitMissile()) { if (!CSfxManager::IsPlaying(x2e4_invalidSfx)) x2e4_invalidSfx = NWeaponTypes::play_sfx(SFXwpn_empty_action, x834_27_underwater, false, 0.165f); @@ -488,24 +568,20 @@ void CPlayerGun::Reset(CStateManager& mgr, bool b1) { void CPlayerGun::ResetBeamParams(CStateManager& mgr, const CPlayerState& playerState, bool playSelectionSfx) { StopContinuousBeam(mgr, true); - if (playerState.ItemEnabled(CPlayerState::EItemType::ChargeBeam)) + if (playerState.ItemEnabled(CPlayerState::EItemType::ChargeBeam)) { ResetCharge(mgr, false); - CAnimPlaybackParms parms(skBeamAnimIds[int(x314_nextBeam)], -1, 1.f, true); + } + const CAnimPlaybackParms parms(skBeamAnimIds[size_t(x314_nextBeam)], -1, 1.f, true); x6e0_rightHandModel.GetAnimationData()->SetAnimation(parms, false); Reset(mgr, false); - if (playSelectionSfx) + if (playSelectionSfx) { CSfxManager::SfxStart(SFXwpn_morph_out_wipe, 1.f, 0.f, true, 0x7f, false, kInvalidAreaId); + } x2ec_lastFireButtonStates &= ~0x1; x320_currentAuxBeam = x310_currentBeam; x833_30_canShowAuxMuzzleEffect = true; } -static const u16 skFromMissileSound[] = {SFXwpn_from_missile_power, SFXwpn_from_missile_ice, SFXwpn_from_missile_wave, - SFXwpn_from_missile_plasma}; -static const u16 skFromBeamSound[] = {SFXsfx0000, SFXwpn_from_beam_ice, SFXwpn_from_beam_wave, SFXwpn_from_beam_plasma}; -static const u16 skToMissileSound[] = {SFXwpn_to_missile_power, SFXwpn_to_missile_ice, SFXwpn_to_missile_wave, - SFXwpn_to_missile_plasma}; - void CPlayerGun::PlayAnim(NWeaponTypes::EGunAnimType type, bool loop) { if (x338_nextState != ENextState::ChangeWeapon) x72c_currentBeam->PlayAnim(type, loop); @@ -514,17 +590,17 @@ void CPlayerGun::PlayAnim(NWeaponTypes::EGunAnimType type, bool loop) { switch (type) { case NWeaponTypes::EGunAnimType::FromMissile: x2f8_stateFlags &= ~0x4; - sfx = skFromMissileSound[int(x310_currentBeam)]; + sfx = skFromMissileSound[size_t(x310_currentBeam)]; break; case NWeaponTypes::EGunAnimType::MissileReload: sfx = SFXwpn_reload_missile; break; case NWeaponTypes::EGunAnimType::FromBeam: - sfx = skFromBeamSound[int(x310_currentBeam)]; + sfx = skFromBeamSound[size_t(x310_currentBeam)]; break; case NWeaponTypes::EGunAnimType::ToMissile: x2f8_stateFlags &= ~0x1; - sfx = skToMissileSound[int(x310_currentBeam)]; + sfx = skToMissileSound[size_t(x310_currentBeam)]; break; default: break; @@ -800,7 +876,7 @@ void CPlayerGun::ChangeWeapon(const CPlayerState& playerState, CStateManager& mg if (x730_outgoingBeam != nullptr && x72c_currentBeam != x730_outgoingBeam) x730_outgoingBeam->Unload(mgr); - x734_loadingBeam = x760_selectableBeams[int(x314_nextBeam)]; + x734_loadingBeam = x760_selectableBeams[size_t(x314_nextBeam)]; if (x734_loadingBeam && x72c_currentBeam != x734_loadingBeam) { x734_loadingBeam->Load(mgr, false); x744_auxWeapon->Load(x314_nextBeam, mgr); @@ -894,8 +970,6 @@ void CPlayerGun::CGunMorph::StartWipe(EDir dir) { x24_24_morphing = true; } -static const u16 skIntoBeamSound[] = {SFXsfx0000, SFXwpn_into_beam_ice, SFXwpn_into_beam_wave, SFXwpn_into_beam_plasma}; - void CPlayerGun::ProcessGunMorph(float dt, CStateManager& mgr) { bool isUnmorphed = mgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed; switch (x678_morph.GetGunState()) { @@ -909,7 +983,7 @@ void CPlayerGun::ProcessGunMorph(float dt, CStateManager& mgr) { x310_currentBeam = x314_nextBeam; x320_currentAuxBeam = x314_nextBeam; x833_30_canShowAuxMuzzleEffect = true; - x72c_currentBeam = x760_selectableBeams[int(x314_nextBeam)]; + x72c_currentBeam = x760_selectableBeams[size_t(x314_nextBeam)]; x738_nextBeam = x72c_currentBeam; x678_morph.SetWeaponChanged(); mgr.GetPlayerState()->SetCurrentBeam(x314_nextBeam); @@ -935,8 +1009,9 @@ void CPlayerGun::ProcessGunMorph(float dt, CStateManager& mgr) { x730_outgoingBeam->Unload(mgr); x730_outgoingBeam = nullptr; } - if (isUnmorphed) - NWeaponTypes::play_sfx(skIntoBeamSound[int(x310_currentBeam)], x834_27_underwater, false, 0.165f); + if (isUnmorphed) { + NWeaponTypes::play_sfx(skIntoBeamSound[size_t(x310_currentBeam)], x834_27_underwater, false, 0.165f); + } x72c_currentBeam->SetRainSplashGenerator(x748_rainSplashGenerator.get()); x72c_currentBeam->EnableFx(true); PlayAnim(NWeaponTypes::EGunAnimType::ToBeam, false); @@ -969,12 +1044,13 @@ void CPlayerGun::SetPhazonBeamFeedback(bool active) { } void CPlayerGun::StartPhazonBeamTransition(bool active, CStateManager& mgr, CPlayerState& playerState) { - if (x833_28_phazonBeamActive == active) + if (x833_28_phazonBeamActive == active) { return; - x760_selectableBeams[int(x310_currentBeam)]->Unload(mgr); - x760_selectableBeams[int(x310_currentBeam)] = active ? x75c_phazonBeam.get() : x738_nextBeam; + } + x760_selectableBeams[size_t(x310_currentBeam)]->Unload(mgr); + x760_selectableBeams[size_t(x310_currentBeam)] = active ? x75c_phazonBeam.get() : x738_nextBeam; ResetBeamParams(mgr, playerState, false); - x72c_currentBeam = x760_selectableBeams[int(x310_currentBeam)]; + x72c_currentBeam = x760_selectableBeams[size_t(x310_currentBeam)]; x833_28_phazonBeamActive = active; SetPhazonBeamFeedback(active); x72c_currentBeam->SetRainSplashGenerator(x748_rainSplashGenerator.get()); @@ -1052,20 +1128,12 @@ void CPlayerGun::EnableChargeFx(EChargeState state, CStateManager& mgr) { x338_nextState = ENextState::StatusQuo; x833_30_canShowAuxMuzzleEffect = true; - x800_auxMuzzleGenerators[int(x320_currentAuxBeam)] = - std::make_unique(x7c0_auxMuzzleEffects[int(x320_currentAuxBeam)]); + x800_auxMuzzleGenerators[size_t(x320_currentAuxBeam)] = + std::make_unique(x7c0_auxMuzzleEffects[size_t(x320_currentAuxBeam)]); - x800_auxMuzzleGenerators[int(x320_currentAuxBeam)]->SetParticleEmission(true); + x800_auxMuzzleGenerators[size_t(x320_currentAuxBeam)]->SetParticleEmission(true); } -static constexpr float kChargeSpeed = 1.f / CPlayerState::GetMissileComboChargeFactor(); -static constexpr float kChargeFxStart = 1.f / CPlayerState::GetMissileComboChargeFactor(); -static constexpr float kChargeAnimStart = 0.25f / CPlayerState::GetMissileComboChargeFactor(); -static constexpr float kChargeStart = 0.025f / CPlayerState::GetMissileComboChargeFactor(); - -static const u16 skBeamChargeUpSound[] = {SFXwpn_chargeup_power, SFXwpn_chargeup_ice, SFXwpn_chargeup_wave, - SFXwpn_chargeup_plasma}; - void CPlayerGun::UpdateChargeState(float dt, CStateManager& mgr) { switch (x32c_chargePhase) { case EChargePhase::ChargeRequested: @@ -1077,16 +1145,19 @@ void CPlayerGun::UpdateChargeState(float dt, CStateManager& mgr) { break; case EChargePhase::AnimAndSfx: if (!x832_27_chargeAnimStarted) { - if (x340_chargeBeamFactor > kChargeStart && x832_25_chargeEffectVisible) + if (x340_chargeBeamFactor > kChargeStart && x832_25_chargeEffectVisible) { x832_25_chargeEffectVisible = false; + } if (x340_chargeBeamFactor > kChargeAnimStart) { PlayAnim(NWeaponTypes::EGunAnimType::ChargeUp, false); - if (!x2e0_chargeSfx) + if (!x2e0_chargeSfx) { x2e0_chargeSfx = - NWeaponTypes::play_sfx(skBeamChargeUpSound[int(x310_currentBeam)], x834_27_underwater, true, 0.165f); - if (x830_chargeRumbleHandle == -1) + NWeaponTypes::play_sfx(skBeamChargeUpSound[size_t(x310_currentBeam)], x834_27_underwater, true, 0.165f); + } + if (x830_chargeRumbleHandle == -1) { x830_chargeRumbleHandle = mgr.GetRumbleManager().Rumble(mgr, ERumbleFxId::PlayerGunCharge, 1.f, ERumblePriority::Three); + } x832_27_chargeAnimStarted = true; } } else { @@ -1208,16 +1279,17 @@ void CPlayerGun::DoUserAnimEvent(float dt, CStateManager& mgr, const CInt32POINo void CPlayerGun::DoUserAnimEvents(float dt, CStateManager& mgr) { zeus::CVector3f posToCam = mgr.GetCameraManager()->GetCurrentCamera(mgr)->GetTranslation() - x3e8_xf.origin; const CAnimData& animData = *x72c_currentBeam->GetSolidModelData().GetAnimationData(); - for (int i = 0; i < animData.GetPassedSoundPOICount(); ++i) { + for (size_t i = 0; i < animData.GetPassedSoundPOICount(); ++i) { const CSoundPOINode& node = CAnimData::g_SoundPOINodes[i]; if (node.GetPoiType() != EPOIType::Sound || - (node.GetCharacterIndex() != -1 && animData.x204_charIdx != node.GetCharacterIndex())) + (node.GetCharacterIndex() != -1 && animData.x204_charIdx != node.GetCharacterIndex())) { continue; + } NWeaponTypes::do_sound_event(x670_animSfx, x328_animSfxPitch, false, node.GetSfxId(), node.GetWeight(), node.GetFlags(), node.GetFalloff(), node.GetMaxDist(), 0.16f, 1.f, posToCam, x3e8_xf.origin, mgr.GetPlayer().GetAreaIdAlways(), mgr); } - for (int i = 0; i < animData.GetPassedIntPOICount(); ++i) { + for (size_t i = 0; i < animData.GetPassedIntPOICount(); ++i) { const CInt32POINode& node = CAnimData::g_Int32POINodes[i]; switch (node.GetPoiType()) { case EPOIType::UserEvent: @@ -1257,11 +1329,6 @@ void CPlayerGun::CancelLockOn() { } } -static const CPlayerState::EItemType skItemArr[] = {CPlayerState::EItemType::Invalid, - CPlayerState::EItemType::Missiles}; - -static const u16 skItemEmptySound[] = {SFXsfx0000, SFXwpn_empty_action}; - void CPlayerGun::FireSecondary(float dt, CStateManager& mgr) { if (mgr.GetCameraManager()->IsInCinematicCamera()) return; @@ -1364,7 +1431,7 @@ void CPlayerGun::ProcessChargeState(u32 releasedStates, u32 pressedStates, CStat } } else if (mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::Missiles) && (pressedStates & 0x2) != 0) { if (x32c_chargePhase >= EChargePhase::FxGrown) { - if (mgr.GetPlayerState()->HasPowerUp(skBeamComboArr[int(x310_currentBeam)])) + if (mgr.GetPlayerState()->HasPowerUp(skBeamComboArr[size_t(x310_currentBeam)])) ActivateCombo(mgr); } else if (x32c_chargePhase == EChargePhase::NotCharging) { FireSecondary(dt, mgr); @@ -1568,15 +1635,20 @@ void CPlayerGun::AsyncLoadFidget(CStateManager& mgr) { } bool CPlayerGun::IsFidgetLoaded() const { - int loadFlags = 0; - if ((x2fc_fidgetAnimBits & 0x1) == 0x1 && x73c_gunMotion->GunController().IsFidgetLoaded()) + u32 loadFlags = 0; + if ((x2fc_fidgetAnimBits & 0x1) == 0x1 && x73c_gunMotion->GunController().IsFidgetLoaded()) { loadFlags |= 0x1; - if ((x2fc_fidgetAnimBits & 0x2) == 0x2 && x72c_currentBeam->IsFidgetLoaded()) + } + if ((x2fc_fidgetAnimBits & 0x2) == 0x2 && x72c_currentBeam->IsFidgetLoaded()) { loadFlags |= 0x2; - if ((x2fc_fidgetAnimBits & 0x4) == 0x4) - if (CGunController* gc = x740_grappleArm->GunController()) - if (gc->IsFidgetLoaded()) + } + if ((x2fc_fidgetAnimBits & 0x4) == 0x4) { + if (CGunController* gc = x740_grappleArm->GunController()) { + if (gc->IsFidgetLoaded()) { loadFlags |= 0x4; + } + } + } return x2fc_fidgetAnimBits == loadFlags; } @@ -1711,10 +1783,6 @@ void CPlayerGun::UpdateGunIdle(bool inStrikeCooldown, float camBobT, float dt, C } } -static const float chargeShakeTbl[] = {-0.001f, 0.f, 0.001f}; -static const CMaterialFilter sAimFilter = - CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {EMaterialTypes::ProjectilePassthrough}); - void CPlayerGun::Update(float grappleSwingT, float cameraBobT, float dt, CStateManager& mgr) { CPlayer& player = mgr.GetPlayer(); CPlayerState& playerState = *mgr.GetPlayerState(); @@ -1898,7 +1966,7 @@ void CPlayerGun::Update(float grappleSwingT, float cameraBobT, float dt, CStateM bool emitting = x833_30_canShowAuxMuzzleEffect ? x344_comboXferTimer < 1.f : false; zeus::CVector3f scale((emitting && x832_26_comboFiring) ? (1.f - x344_comboXferTimer) * 2.f : 2.f); x72c_currentBeam->UpdateMuzzleFx(advDt, scale, x418_beamLocalXf.origin, emitting); - CElementGen& gen = *x800_auxMuzzleGenerators[int(x320_currentAuxBeam)]; + CElementGen& gen = *x800_auxMuzzleGenerators[size_t(x320_currentAuxBeam)]; gen.SetGlobalOrientAndTrans(x418_beamLocalXf); gen.SetGlobalScale(scale); gen.SetParticleEmission(emitting); @@ -2026,11 +2094,6 @@ void CPlayerGun::PreRender(const CStateManager& mgr, const zeus::CFrustum& frust g_Renderer->AllocatePhazonSuitMaskTexture(); } -static const CModelFlags kThermalFlags[] = {{0, 0, 3, zeus::skWhite}, - {5, 0, 3, zeus::CColor(0.f, 0.5f)}, - {0, 0, 3, zeus::skWhite}, - {0, 0, 3, zeus::skWhite}}; - void CPlayerGun::RenderEnergyDrainEffects(const CStateManager& mgr) const { if (TCastToConstPtr player = mgr.GetObjectById(x538_playerId)) { for (const auto& source : player->GetEnergyDrain().GetEnergyDrainSources()) { @@ -2081,45 +2144,49 @@ void CPlayerGun::DrawClipCube(const zeus::CAABox& aabb) const { m_aaboxShader.draw(zeus::skClear); } -static const CModelFlags kHandThermalFlag = {7, 0, 3, zeus::skWhite}; -static const CModelFlags kHandHoloFlag = {1, 0, 3, zeus::CColor(0.75f, 0.5f, 0.f, 1.f)}; - void CPlayerGun::Render(const CStateManager& mgr, const zeus::CVector3f& pos, const CModelFlags& flags) const { SCOPED_GRAPHICS_DEBUG_GROUP("CPlayerGun::Render", zeus::skMagenta); CGraphics::CProjectionState projState = CGraphics::GetProjectionState(); CModelFlags useFlags = flags; - if (x0_lights.HasShadowLight()) + if (x0_lights.HasShadowLight()) { useFlags.m_extendedShader = EExtendedShader::LightingCubeReflectionWorldShadow; + } CModelFlags beamFlags = useFlags; - if (mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Thermal) - beamFlags = kThermalFlags[int(x310_currentBeam)]; - else if (x835_26_phazonBeamMorphing) + if (mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Thermal) { + beamFlags = kThermalFlags[size_t(x310_currentBeam)]; + } else if (x835_26_phazonBeamMorphing) { beamFlags.x4_color = zeus::CColor::lerp(zeus::skWhite, zeus::skBlack, x39c_phazonMorphT); + } const CGameCamera* cam = mgr.GetCameraManager()->GetCurrentCamera(mgr); CGraphics::SetDepthRange(DEPTH_GUN, DEPTH_WORLD); zeus::CTransform offsetWorldXf = zeus::CTransform::Translate(pos) * x4a8_gunWorldXf; zeus::CTransform elbowOffsetXf = offsetWorldXf * x508_elbowLocalXf; - if (x32c_chargePhase != EChargePhase::NotCharging && (x2f8_stateFlags & 0x10) != 0x10) + if (x32c_chargePhase != EChargePhase::NotCharging && (x2f8_stateFlags & 0x10) != 0x10) { offsetWorldXf.origin += zeus::CVector3f(x34c_shakeX, 0.f, x350_shakeZ); + } zeus::CTransform oldViewMtx = CGraphics::g_ViewMatrix; CGraphics::SetViewPointMatrix(offsetWorldXf.inverse() * oldViewMtx); CGraphics::SetModelMatrix(zeus::CTransform()); - if (x32c_chargePhase >= EChargePhase::FxGrown && x32c_chargePhase < EChargePhase::ComboXfer) - x800_auxMuzzleGenerators[int(x320_currentAuxBeam)]->Render(); + if (x32c_chargePhase >= EChargePhase::FxGrown && x32c_chargePhase < EChargePhase::ComboXfer) { + x800_auxMuzzleGenerators[size_t(x320_currentAuxBeam)]->Render(); + } - if (x832_25_chargeEffectVisible && (x38c_muzzleEffectVisTimer > 0.f || x32c_chargePhase > EChargePhase::AnimAndSfx)) + if (x832_25_chargeEffectVisible && (x38c_muzzleEffectVisTimer > 0.f || x32c_chargePhase > EChargePhase::AnimAndSfx)) { x72c_currentBeam->DrawMuzzleFx(mgr); + } if (x678_morph.GetGunState() == CGunMorph::EGunState::InWipe || - x678_morph.GetGunState() == CGunMorph::EGunState::OutWipe) + x678_morph.GetGunState() == CGunMorph::EGunState::OutWipe) { x774_holoTransitionGen->Render(); + } CGraphics::SetViewPointMatrix(oldViewMtx); - if ((x2f8_stateFlags & 0x10) == 0x10) + if ((x2f8_stateFlags & 0x10) == 0x10) { x744_auxWeapon->RenderMuzzleFx(); + } x72c_currentBeam->PreRenderGunFx(mgr, offsetWorldXf); bool drawSuitArm = diff --git a/Runtime/Weapon/CPlayerGun.hpp b/Runtime/Weapon/CPlayerGun.hpp index 4962a5707..8ecefbd63 100644 --- a/Runtime/Weapon/CPlayerGun.hpp +++ b/Runtime/Weapon/CPlayerGun.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -215,7 +216,7 @@ private: std::unique_ptr x754_waveBeam; std::unique_ptr x758_plasmaBeam; std::unique_ptr x75c_phazonBeam; - CGunWeapon* x760_selectableBeams[4] = {}; // Used to be reserved_vector + std::array x760_selectableBeams{}; // Used to be reserved_vector std::unique_ptr x774_holoTransitionGen; std::unique_ptr x77c_comboXferGen; rstl::reserved_vector, 2>, 2> x784_bombEffects;