CPowerBeam: Make use of std::array where applicable

Same behavior, stronger typing.

We can also narrow the scope of the array.
This commit is contained in:
Lioncash 2020-04-07 13:56:22 -04:00
parent 5405dad069
commit ad1f56bfda
1 changed files with 8 additions and 3 deletions

View File

@ -1,5 +1,7 @@
#include "Runtime/Weapon/CPowerBeam.hpp" #include "Runtime/Weapon/CPowerBeam.hpp"
#include <array>
#include "Runtime/CSimplePool.hpp" #include "Runtime/CSimplePool.hpp"
#include "Runtime/GameGlobalObjects.hpp" #include "Runtime/GameGlobalObjects.hpp"
@ -69,12 +71,15 @@ void CPowerBeam::UpdateGunFx(bool shotSmoke, float dt, const CStateManager& mgr,
CGunWeapon::UpdateGunFx(shotSmoke, dt, mgr, xf); CGunWeapon::UpdateGunFx(shotSmoke, dt, mgr, xf);
} }
static const u16 skSoundId[] = {SFXwpn_fire_power_normal, SFXwpn_fire_power_charged};
void CPowerBeam::Fire(bool underwater, float dt, EChargeState chargeState, const zeus::CTransform& xf, void CPowerBeam::Fire(bool underwater, float dt, EChargeState chargeState, const zeus::CTransform& xf,
CStateManager& mgr, TUniqueId homingTarget, float chargeFactor1, float chargeFactor2) { CStateManager& mgr, TUniqueId homingTarget, float chargeFactor1, float chargeFactor2) {
static constexpr std::array<u16, 2> skSoundId{
SFXwpn_fire_power_normal,
SFXwpn_fire_power_charged,
};
CGunWeapon::Fire(underwater, dt, chargeState, xf, mgr, homingTarget, chargeFactor1, chargeFactor2); CGunWeapon::Fire(underwater, dt, chargeState, xf, mgr, homingTarget, chargeFactor1, chargeFactor2);
NWeaponTypes::play_sfx(skSoundId[int(chargeState)], underwater, false, 0.165f); NWeaponTypes::play_sfx(skSoundId[size_t(chargeState)], underwater, false, 0.165f);
} }
void CPowerBeam::EnableSecondaryFx(ESecondaryFxType type) { void CPowerBeam::EnableSecondaryFx(ESecondaryFxType type) {