Merge pull request #209 from lioncash/cast

CPlayerGun: Minor cleanup
This commit is contained in:
Phillip Stephens 2020-03-12 15:10:07 -07:00 committed by GitHub
commit 2a2b471671
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 172 additions and 104 deletions

View File

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

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <array>
#include <memory> #include <memory>
#include <vector> #include <vector>
@ -215,7 +216,7 @@ private:
std::unique_ptr<CWaveBeam> x754_waveBeam; std::unique_ptr<CWaveBeam> x754_waveBeam;
std::unique_ptr<CPlasmaBeam> x758_plasmaBeam; std::unique_ptr<CPlasmaBeam> x758_plasmaBeam;
std::unique_ptr<CPhazonBeam> x75c_phazonBeam; std::unique_ptr<CPhazonBeam> x75c_phazonBeam;
CGunWeapon* x760_selectableBeams[4] = {}; // Used to be reserved_vector std::array<CGunWeapon*, 4> x760_selectableBeams{}; // Used to be reserved_vector
std::unique_ptr<CElementGen> x774_holoTransitionGen; std::unique_ptr<CElementGen> x774_holoTransitionGen;
std::unique_ptr<CElementGen> x77c_comboXferGen; std::unique_ptr<CElementGen> x77c_comboXferGen;
rstl::reserved_vector<rstl::reserved_vector<TLockedToken<CGenDescription>, 2>, 2> x784_bombEffects; rstl::reserved_vector<rstl::reserved_vector<TLockedToken<CGenDescription>, 2>, 2> x784_bombEffects;