mirror of https://github.com/AxioDL/metaforce.git
Merge pull request #74 from lioncash/player
CPlayer: Use std::array where applicable
This commit is contained in:
commit
a4262dc4d2
|
@ -1,71 +1,216 @@
|
||||||
#include "CPlayer.hpp"
|
#include "Runtime/World/CPlayer.hpp"
|
||||||
#include "CActorParameters.hpp"
|
|
||||||
#include "CStateManager.hpp"
|
#include <algorithm>
|
||||||
#include "CSimplePool.hpp"
|
#include <array>
|
||||||
#include "GameGlobalObjects.hpp"
|
#include <cmath>
|
||||||
#include "Camera/CFirstPersonCamera.hpp"
|
#include <string>
|
||||||
#include "Camera/CBallCamera.hpp"
|
|
||||||
#include "Camera/CCinematicCamera.hpp"
|
#include "Runtime/CDependencyGroup.hpp"
|
||||||
#include "TCastTo.hpp"
|
#include "Runtime/CGameState.hpp"
|
||||||
#include "CScriptGrapplePoint.hpp"
|
#include "Runtime/CSimplePool.hpp"
|
||||||
#include "CPatterned.hpp"
|
#include "Runtime/CStateManager.hpp"
|
||||||
#include "CScriptWater.hpp"
|
#include "Runtime/TCastTo.hpp"
|
||||||
#include "CDependencyGroup.hpp"
|
#include "Runtime/Audio/CStreamAudioManager.hpp"
|
||||||
#include "Character/CSteeringBehaviors.hpp"
|
#include "Runtime/Camera/CBallCamera.hpp"
|
||||||
#include "Weapon/CEnergyProjectile.hpp"
|
#include "Runtime/Camera/CCinematicCamera.hpp"
|
||||||
#include "MP1/World/CThardusRockProjectile.hpp"
|
#include "Runtime/Camera/CFirstPersonCamera.hpp"
|
||||||
#include "MP1/World/CMetroidBeta.hpp"
|
#include "Runtime/Character/CSteeringBehaviors.hpp"
|
||||||
#include "Collision/CMetroidAreaCollider.hpp"
|
#include "Runtime/Collision/CGameCollision.hpp"
|
||||||
#include "Collision/CGameCollision.hpp"
|
#include "Runtime/Collision/CMetroidAreaCollider.hpp"
|
||||||
#include "Input/ControlMapper.hpp"
|
#include "Runtime/GameGlobalObjects.hpp"
|
||||||
#include "CGameState.hpp"
|
#include "Runtime/Input/ControlMapper.hpp"
|
||||||
#include "MP1/CSamusHud.hpp"
|
#include "Runtime/MP1/CSamusHud.hpp"
|
||||||
#include "CHUDBillboardEffect.hpp"
|
#include "Runtime/MP1/World/CMetroidBeta.hpp"
|
||||||
#include "Audio/CStreamAudioManager.hpp"
|
#include "Runtime/MP1/World/CThardusRockProjectile.hpp"
|
||||||
#include "CScriptPlayerHint.hpp"
|
#include "Runtime/Weapon/CEnergyProjectile.hpp"
|
||||||
#include "CScriptAreaAttributes.hpp"
|
#include "Runtime/World/CActorParameters.hpp"
|
||||||
|
#include "Runtime/World/CHUDBillboardEffect.hpp"
|
||||||
|
#include "Runtime/World/CPatterned.hpp"
|
||||||
|
#include "Runtime/World/CScriptAreaAttributes.hpp"
|
||||||
|
#include "Runtime/World/CScriptGrapplePoint.hpp"
|
||||||
|
#include "Runtime/World/CScriptPlayerHint.hpp"
|
||||||
|
#include "Runtime/World/CScriptWater.hpp"
|
||||||
|
|
||||||
|
#include <logvisor/logvisor.hpp>
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
|
namespace {
|
||||||
|
logvisor::Module Log("urde::CPlayer");
|
||||||
|
|
||||||
static logvisor::Module Log("urde::CPlayer");
|
const CMaterialFilter SolidMaterialFilter = CMaterialFilter::MakeInclude(CMaterialList(EMaterialTypes::Solid));
|
||||||
|
|
||||||
static const CMaterialFilter SolidMaterialFilter = CMaterialFilter::MakeInclude(CMaterialList(EMaterialTypes::Solid));
|
const CMaterialFilter LineOfSightFilter = CMaterialFilter::MakeIncludeExclude(
|
||||||
|
|
||||||
static const CMaterialFilter LineOfSightFilter = CMaterialFilter::MakeIncludeExclude(
|
|
||||||
{EMaterialTypes::Solid},
|
{EMaterialTypes::Solid},
|
||||||
{EMaterialTypes::ProjectilePassthrough, EMaterialTypes::ScanPassthrough, EMaterialTypes::Player});
|
{EMaterialTypes::ProjectilePassthrough, EMaterialTypes::ScanPassthrough, EMaterialTypes::Player});
|
||||||
|
|
||||||
static const CMaterialFilter OccluderFilter = CMaterialFilter::MakeIncludeExclude(
|
const CMaterialFilter OccluderFilter = CMaterialFilter::MakeIncludeExclude(
|
||||||
{EMaterialTypes::Solid, EMaterialTypes::Occluder},
|
{EMaterialTypes::Solid, EMaterialTypes::Occluder},
|
||||||
{EMaterialTypes::ProjectilePassthrough, EMaterialTypes::ScanPassthrough, EMaterialTypes::Player});
|
{EMaterialTypes::ProjectilePassthrough, EMaterialTypes::ScanPassthrough, EMaterialTypes::Player});
|
||||||
|
|
||||||
static CModelData MakePlayerAnimRes(CAssetId resId, const zeus::CVector3f& scale) {
|
const CMaterialFilter BallTransitionCollide = CMaterialFilter::MakeIncludeExclude(
|
||||||
|
{EMaterialTypes::Solid}, {EMaterialTypes::ProjectilePassthrough, EMaterialTypes::Player, EMaterialTypes::Character,
|
||||||
|
EMaterialTypes::CameraPassthrough});
|
||||||
|
|
||||||
|
constexpr std::array<float, 8> skStrafeDistances{
|
||||||
|
11.8f, 11.8f, 11.8f, 5.0f, 6.0f, 5.0f, 5.0f, 6.0f,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr std::array<float, 8> skDashStrafeDistances{
|
||||||
|
30.0f, 22.6f, 10.0f, 10.0f, 10.0f, 10.0f, 10.0f,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr std::array<float, 8> skOrbitForwardDistances{
|
||||||
|
11.8f, 11.8f, 11.8f, 5.0f, 6.0f, 5.0f, 5.0f, 6.0f,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr std::array<const char*, 2> UnlockMessageResBases{
|
||||||
|
"STRG_SlideShow_Unlock1_",
|
||||||
|
"STRG_SlideShow_Unlock2_",
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr std::array<u16, 24> skPlayerLandSfxSoft{
|
||||||
|
0xFFFF,
|
||||||
|
SFXsam_landstone_00,
|
||||||
|
SFXsam_landmetl_00,
|
||||||
|
SFXsam_landgrass_00,
|
||||||
|
SFXsam_landice_00,
|
||||||
|
0xFFFF,
|
||||||
|
SFXsam_landgrate_00,
|
||||||
|
SFXsam_landphazon_00,
|
||||||
|
SFXsam_landdirt_00,
|
||||||
|
SFXlav_landlava_00,
|
||||||
|
SFXsam_landlavastone_00,
|
||||||
|
SFXsam_landsnow_00,
|
||||||
|
SFXsam_landmud_00,
|
||||||
|
0xFFFF,
|
||||||
|
SFXsam_landgrass_00,
|
||||||
|
SFXsam_landmetl_00,
|
||||||
|
SFXsam_landmetl_00,
|
||||||
|
SFXsam_landdirt_00,
|
||||||
|
0xFFFF,
|
||||||
|
0xFFFF,
|
||||||
|
0xFFFF,
|
||||||
|
0xFFFF,
|
||||||
|
SFXsam_landwood_00,
|
||||||
|
SFXsam_b_landorg_00,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr std::array<u16, 24> skPlayerLandSfxHard{
|
||||||
|
0xFFFF,
|
||||||
|
SFXsam_landstone_02,
|
||||||
|
SFXsam_b_landmetl_02,
|
||||||
|
SFXsam_landgrass_02,
|
||||||
|
SFXsam_landice_02,
|
||||||
|
0xFFFF,
|
||||||
|
SFXsam_landgrate_02,
|
||||||
|
SFXsam_landphazon_02,
|
||||||
|
SFXsam_landdirt_02,
|
||||||
|
SFXlav_landlava_02,
|
||||||
|
SFXsam_landlavastone_02,
|
||||||
|
SFXsam_landsnow_02,
|
||||||
|
SFXsam_landmud_02,
|
||||||
|
0xFFFF,
|
||||||
|
SFXsam_landgrass_02,
|
||||||
|
SFXsam_b_landmetl_02,
|
||||||
|
SFXsam_b_landmetl_02,
|
||||||
|
SFXsam_landdirt_02,
|
||||||
|
0xFFFF,
|
||||||
|
0xFFFF,
|
||||||
|
0xFFFF,
|
||||||
|
0xFFFF,
|
||||||
|
SFXsam_landwood_02,
|
||||||
|
SFXsam_landorg_02,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr std::array<u16, 24> skLeftStepSounds{
|
||||||
|
0xFFFF,
|
||||||
|
SFXsam_wlkstone_00,
|
||||||
|
SFXsam_wlkmetal_00,
|
||||||
|
SFXsam_b_wlkgrass_00,
|
||||||
|
SFXsam_wlkice_00,
|
||||||
|
0xFFFF,
|
||||||
|
SFXsam_wlkgrate_00,
|
||||||
|
SFXsam_wlkphazon_00,
|
||||||
|
SFXsam_wlkdirt_00,
|
||||||
|
SFXlav_wlklava_00,
|
||||||
|
SFXsam_wlklavastone_00,
|
||||||
|
SFXsam_wlksnow_00,
|
||||||
|
SFXsam_wlkmud_00,
|
||||||
|
0xFFFF,
|
||||||
|
SFXsam_b_wlkorg_00,
|
||||||
|
SFXsam_wlkmetal_00,
|
||||||
|
SFXsam_wlkmetal_00,
|
||||||
|
SFXsam_wlkdirt_00,
|
||||||
|
0xFFFF,
|
||||||
|
0xFFFF,
|
||||||
|
0xFFFF,
|
||||||
|
0xFFFF,
|
||||||
|
SFXsam_wlkwood_00,
|
||||||
|
SFXsam_b_wlkorg_00,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr std::array<u16, 24> skRightStepSounds{
|
||||||
|
0xFFFF,
|
||||||
|
SFXsam_wlkstone_01,
|
||||||
|
SFXsam_wlkmetal_01,
|
||||||
|
SFXsam_b_wlkgrass_01,
|
||||||
|
SFXsam_wlkice_01,
|
||||||
|
0xFFFF,
|
||||||
|
SFXsam_wlkgrate_01,
|
||||||
|
SFXsam_wlkphazon_01,
|
||||||
|
SFXsam_wlkdirt_01,
|
||||||
|
SFXlav_wlklava_01,
|
||||||
|
SFXsam_wlklavastone_01,
|
||||||
|
SFXsam_wlksnow_01,
|
||||||
|
SFXsam_wlkmud_01,
|
||||||
|
0xFFFF,
|
||||||
|
SFXsam_b_wlkorg_01,
|
||||||
|
SFXsam_wlkmetal_01,
|
||||||
|
SFXsam_wlkmetal_01,
|
||||||
|
SFXsam_wlkdirt_01,
|
||||||
|
0xFFFF,
|
||||||
|
0xFFFF,
|
||||||
|
0xFFFF,
|
||||||
|
0xFFFF,
|
||||||
|
SFXsam_wlkwood_01,
|
||||||
|
SFXsam_b_wlkorg_01,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr std::array<std::pair<CPlayerState::EItemType, ControlMapper::ECommands>, 4> skVisorToItemMapping{{
|
||||||
|
{CPlayerState::EItemType::CombatVisor, ControlMapper::ECommands::NoVisor},
|
||||||
|
{CPlayerState::EItemType::XRayVisor, ControlMapper::ECommands::XrayVisor},
|
||||||
|
{CPlayerState::EItemType::ScanVisor, ControlMapper::ECommands::InviroVisor},
|
||||||
|
{CPlayerState::EItemType::ThermalVisor, ControlMapper::ECommands::ThermoVisor},
|
||||||
|
}};
|
||||||
|
|
||||||
|
CModelData MakePlayerAnimRes(CAssetId resId, const zeus::CVector3f& scale) {
|
||||||
return {CAnimRes(resId, 0, scale, 0, true), 1};
|
return {CAnimRes(resId, 0, scale, 0, true), 1};
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t GetOrbitScreenBoxHalfExtentXScaled(int zone) {
|
uint32_t GetOrbitScreenBoxHalfExtentXScaled(int zone) {
|
||||||
return g_tweakPlayer->GetOrbitScreenBoxHalfExtentX(zone) * g_Viewport.x8_width / 640;
|
return g_tweakPlayer->GetOrbitScreenBoxHalfExtentX(zone) * g_Viewport.x8_width / 640;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t GetOrbitScreenBoxHalfExtentYScaled(int zone) {
|
uint32_t GetOrbitScreenBoxHalfExtentYScaled(int zone) {
|
||||||
return g_tweakPlayer->GetOrbitScreenBoxHalfExtentY(zone) * g_Viewport.xc_height / 448;
|
return g_tweakPlayer->GetOrbitScreenBoxHalfExtentY(zone) * g_Viewport.xc_height / 448;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t GetOrbitScreenBoxCenterXScaled(int zone) {
|
uint32_t GetOrbitScreenBoxCenterXScaled(int zone) {
|
||||||
return g_tweakPlayer->GetOrbitScreenBoxCenterX(zone) * g_Viewport.x8_width / 640;
|
return g_tweakPlayer->GetOrbitScreenBoxCenterX(zone) * g_Viewport.x8_width / 640;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t GetOrbitScreenBoxCenterYScaled(int zone) {
|
uint32_t GetOrbitScreenBoxCenterYScaled(int zone) {
|
||||||
return g_tweakPlayer->GetOrbitScreenBoxCenterY(zone) * g_Viewport.xc_height / 448;
|
return g_tweakPlayer->GetOrbitScreenBoxCenterY(zone) * g_Viewport.xc_height / 448;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t GetOrbitZoneIdealXScaled(int zone) {
|
uint32_t GetOrbitZoneIdealXScaled(int zone) {
|
||||||
return g_tweakPlayer->GetOrbitZoneIdealX(zone) * g_Viewport.x8_width / 640;
|
return g_tweakPlayer->GetOrbitZoneIdealX(zone) * g_Viewport.x8_width / 640;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t GetOrbitZoneIdealYScaled(int zone) {
|
uint32_t GetOrbitZoneIdealYScaled(int zone) {
|
||||||
return g_tweakPlayer->GetOrbitZoneIdealY(zone) * g_Viewport.xc_height / 448;
|
return g_tweakPlayer->GetOrbitZoneIdealY(zone) * g_Viewport.xc_height / 448;
|
||||||
}
|
}
|
||||||
|
} // Anonymous namespace
|
||||||
|
|
||||||
CPlayer::CPlayer(TUniqueId uid, const zeus::CTransform& xf, const zeus::CAABox& aabb, CAssetId resId,
|
CPlayer::CPlayer(TUniqueId uid, const zeus::CTransform& xf, const zeus::CAABox& aabb, CAssetId resId,
|
||||||
const zeus::CVector3f& playerScale, float mass, float stepUp, float stepDown, float ballRadius,
|
const zeus::CVector3f& playerScale, float mass, float stepUp, float stepDown, float ballRadius,
|
||||||
|
@ -141,10 +286,6 @@ float CPlayer::GetTransitionAlpha(const zeus::CVector3f& camPos, float zNear) co
|
||||||
return 0.f;
|
return 0.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const CMaterialFilter BallTransitionCollide = CMaterialFilter::MakeIncludeExclude(
|
|
||||||
{EMaterialTypes::Solid}, {EMaterialTypes::ProjectilePassthrough, EMaterialTypes::Player, EMaterialTypes::Character,
|
|
||||||
EMaterialTypes::CameraPassthrough});
|
|
||||||
|
|
||||||
s32 CPlayer::ChooseTransitionToAnimation(float dt, CStateManager& mgr) const {
|
s32 CPlayer::ChooseTransitionToAnimation(float dt, CStateManager& mgr) const {
|
||||||
if (x258_movementState == EPlayerMovementState::ApplyJump)
|
if (x258_movementState == EPlayerMovementState::ApplyJump)
|
||||||
return 3; // B_airposetoball_samus
|
return 3; // B_airposetoball_samus
|
||||||
|
@ -561,12 +702,6 @@ void CPlayer::Update(float dt, CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const float skStrafeDistances[] = {11.8f, 11.8f, 11.8f, 5.0f, 6.0f, 5.0f, 5.0f, 6.0f};
|
|
||||||
|
|
||||||
static const float skDashStrafeDistances[] = {30.0f, 22.6f, 10.0f, 10.0f, 10.0f, 10.0f, 10.0f};
|
|
||||||
|
|
||||||
static const float skOrbitForwardDistances[] = {11.8f, 11.8f, 11.8f, 5.0f, 6.0f, 5.0f, 5.0f, 6.0f};
|
|
||||||
|
|
||||||
float CPlayer::UpdateCameraBob(float dt, CStateManager& mgr) {
|
float CPlayer::UpdateCameraBob(float dt, CStateManager& mgr) {
|
||||||
float bobMag = 0.f;
|
float bobMag = 0.f;
|
||||||
CPlayerCameraBob::ECameraBobState state;
|
CPlayerCameraBob::ECameraBobState state;
|
||||||
|
@ -580,11 +715,11 @@ float CPlayer::UpdateCameraBob(float dt, CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
state = CPlayerCameraBob::ECameraBobState::Orbit;
|
state = CPlayerCameraBob::ECameraBobState::Orbit;
|
||||||
float f29 = backupVel.dot(x34_transform.basis[0]);
|
const float f29 = backupVel.dot(x34_transform.basis[0]);
|
||||||
float f30 = backupVel.dot(x34_transform.basis[1]);
|
const float f30 = backupVel.dot(x34_transform.basis[1]);
|
||||||
float maxVel = GetActualFirstPersonMaxVelocity(dt);
|
const float maxVel = GetActualFirstPersonMaxVelocity(dt);
|
||||||
float strafeDist =
|
const float strafeDist =
|
||||||
skStrafeDistances[int(x2b0_outOfWaterTicks == 2 ? x2ac_surfaceRestraint : ESurfaceRestraints::Water)];
|
skStrafeDistances[size_t(x2b0_outOfWaterTicks == 2 ? x2ac_surfaceRestraint : ESurfaceRestraints::Water)];
|
||||||
bobMag = std::min(std::sqrt(f30 * f30 + f29 * f29) / std::sqrt(strafeDist * strafeDist + maxVel * maxVel) *
|
bobMag = std::min(std::sqrt(f30 * f30 + f29 * f29) / std::sqrt(strafeDist * strafeDist + maxVel * maxVel) *
|
||||||
CPlayerCameraBob::kOrbitBobScale,
|
CPlayerCameraBob::kOrbitBobScale,
|
||||||
CPlayerCameraBob::kMaxOrbitBobScale);
|
CPlayerCameraBob::kMaxOrbitBobScale);
|
||||||
|
@ -1031,28 +1166,29 @@ static bool IsDataLoreResearchScan(CAssetId id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* UnlockMessageResBases[] = {"STRG_SlideShow_Unlock1_", "STRG_SlideShow_Unlock2_"};
|
|
||||||
|
|
||||||
static CAssetId UpdatePersistentScanPercent(u32 prevLogScans, u32 logScans, u32 totalLogScans) {
|
static CAssetId UpdatePersistentScanPercent(u32 prevLogScans, u32 logScans, u32 totalLogScans) {
|
||||||
if (prevLogScans == logScans)
|
if (prevLogScans == logScans) {
|
||||||
return {};
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
float scanPercent = logScans / float(totalLogScans) * 100.f;
|
const float scanPercent = logScans / float(totalLogScans) * 100.f;
|
||||||
float prevScanPercent = prevLogScans / float(totalLogScans) * 100.f;
|
const float prevScanPercent = prevLogScans / float(totalLogScans) * 100.f;
|
||||||
float scanMessageInterval = g_tweakSlideShow->GetScanPercentInterval();
|
const float scanMessageInterval = g_tweakSlideShow->GetScanPercentInterval();
|
||||||
auto scanPercentProgStep = int(scanPercent / scanMessageInterval);
|
const auto scanPercentProgStep = int(scanPercent / scanMessageInterval);
|
||||||
auto prevScanPercentProgStep = int(prevScanPercent / scanMessageInterval);
|
const auto prevScanPercentProgStep = int(prevScanPercent / scanMessageInterval);
|
||||||
bool firstTime = scanPercent > g_GameState->SystemOptions().GetLogScanPercent();
|
const bool firstTime = scanPercent > g_GameState->SystemOptions().GetLogScanPercent();
|
||||||
|
|
||||||
if (firstTime)
|
if (firstTime) {
|
||||||
g_GameState->SystemOptions().SetLogScanPercent(u32(scanPercent));
|
g_GameState->SystemOptions().SetLogScanPercent(u32(scanPercent));
|
||||||
|
}
|
||||||
|
|
||||||
if (scanPercentProgStep > prevScanPercentProgStep) {
|
if (scanPercentProgStep > prevScanPercentProgStep) {
|
||||||
auto message =
|
const char* const messageResBase = UnlockMessageResBases[zeus::clamp(0, scanPercentProgStep - 1, 1)];
|
||||||
std::string(UnlockMessageResBases[zeus::clamp(0, scanPercentProgStep - 1, 1)]) + (firstTime ? '1' : '2');
|
const auto message = std::string(messageResBase).append(1, firstTime ? '1' : '2');
|
||||||
auto id = g_ResFactory->GetResourceIdByName(message.c_str());
|
const auto id = g_ResFactory->GetResourceIdByName(message);
|
||||||
if (id != nullptr)
|
if (id != nullptr) {
|
||||||
return id->id;
|
return id->id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
@ -2328,56 +2464,6 @@ void CPlayer::PreThink(float dt, CStateManager& mgr) {
|
||||||
xa04_preThinkDt = dt;
|
xa04_preThinkDt = dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const u16 skPlayerLandSfxSoft[] = {0xFFFF,
|
|
||||||
SFXsam_landstone_00,
|
|
||||||
SFXsam_landmetl_00,
|
|
||||||
SFXsam_landgrass_00,
|
|
||||||
SFXsam_landice_00,
|
|
||||||
0xFFFF,
|
|
||||||
SFXsam_landgrate_00,
|
|
||||||
SFXsam_landphazon_00,
|
|
||||||
SFXsam_landdirt_00,
|
|
||||||
SFXlav_landlava_00,
|
|
||||||
SFXsam_landlavastone_00,
|
|
||||||
SFXsam_landsnow_00,
|
|
||||||
SFXsam_landmud_00,
|
|
||||||
0xFFFF,
|
|
||||||
SFXsam_landgrass_00,
|
|
||||||
SFXsam_landmetl_00,
|
|
||||||
SFXsam_landmetl_00,
|
|
||||||
SFXsam_landdirt_00,
|
|
||||||
0xFFFF,
|
|
||||||
0xFFFF,
|
|
||||||
0xFFFF,
|
|
||||||
0xFFFF,
|
|
||||||
SFXsam_landwood_00,
|
|
||||||
SFXsam_b_landorg_00};
|
|
||||||
|
|
||||||
static const u16 skPlayerLandSfxHard[] = {0xFFFF,
|
|
||||||
SFXsam_landstone_02,
|
|
||||||
SFXsam_b_landmetl_02,
|
|
||||||
SFXsam_landgrass_02,
|
|
||||||
SFXsam_landice_02,
|
|
||||||
0xFFFF,
|
|
||||||
SFXsam_landgrate_02,
|
|
||||||
SFXsam_landphazon_02,
|
|
||||||
SFXsam_landdirt_02,
|
|
||||||
SFXlav_landlava_02,
|
|
||||||
SFXsam_landlavastone_02,
|
|
||||||
SFXsam_landsnow_02,
|
|
||||||
SFXsam_landmud_02,
|
|
||||||
0xFFFF,
|
|
||||||
SFXsam_landgrass_02,
|
|
||||||
SFXsam_b_landmetl_02,
|
|
||||||
SFXsam_b_landmetl_02,
|
|
||||||
SFXsam_landdirt_02,
|
|
||||||
0xFFFF,
|
|
||||||
0xFFFF,
|
|
||||||
0xFFFF,
|
|
||||||
0xFFFF,
|
|
||||||
SFXsam_landwood_02,
|
|
||||||
SFXsam_landorg_02};
|
|
||||||
|
|
||||||
void CPlayer::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) {
|
void CPlayer::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) {
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case EScriptObjectMessage::OnFloor:
|
case EScriptObjectMessage::OnFloor:
|
||||||
|
@ -2386,12 +2472,12 @@ void CPlayer::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CState
|
||||||
if (x258_movementState != EPlayerMovementState::Falling) {
|
if (x258_movementState != EPlayerMovementState::Falling) {
|
||||||
float hardThres = 30.f * 2.f * -g_tweakPlayer->GetNormalGravAccel();
|
float hardThres = 30.f * 2.f * -g_tweakPlayer->GetNormalGravAccel();
|
||||||
hardThres = (hardThres != 0.f) ? hardThres * std::sqrt(hardThres) : 0.f;
|
hardThres = (hardThres != 0.f) ? hardThres * std::sqrt(hardThres) : 0.f;
|
||||||
float landVol = zeus::clamp(95.f, 1.6f * -x794_lastVelocity.z() + 95.f, 127.f) / 127.f;
|
const float landVol = zeus::clamp(95.f, 1.6f * -x794_lastVelocity.z() + 95.f, 127.f) / 127.f;
|
||||||
u16 landSfx;
|
u16 landSfx;
|
||||||
if (-x794_lastVelocity.z() < hardThres) {
|
if (-x794_lastVelocity.z() < hardThres) {
|
||||||
landSfx = GetMaterialSoundUnderPlayer(mgr, skPlayerLandSfxSoft, std::size(skPlayerLandSfxSoft), 0xffff);
|
landSfx = GetMaterialSoundUnderPlayer(mgr, skPlayerLandSfxSoft.data(), skPlayerLandSfxSoft.size(), 0xffff);
|
||||||
} else {
|
} else {
|
||||||
landSfx = GetMaterialSoundUnderPlayer(mgr, skPlayerLandSfxHard, std::size(skPlayerLandSfxHard), 0xffff);
|
landSfx = GetMaterialSoundUnderPlayer(mgr, skPlayerLandSfxHard.data(), skPlayerLandSfxHard.size(), 0xffff);
|
||||||
StartSamusVoiceSfx(SFXsam_voxland_02, 1.f, 5);
|
StartSamusVoiceSfx(SFXsam_voxland_02, 1.f, 5);
|
||||||
x55c_damageAmt = 0.f;
|
x55c_damageAmt = 0.f;
|
||||||
x560_prevDamageAmt = 10.f;
|
x560_prevDamageAmt = 10.f;
|
||||||
|
@ -2535,56 +2621,6 @@ void CPlayer::SetVisorSteam(float targetAlpha, float alphaInDur, float alphaOutD
|
||||||
x7a0_visorSteam.SetSteam(targetAlpha, alphaInDur, alphaOutDur, txtr, affectsThermal);
|
x7a0_visorSteam.SetSteam(targetAlpha, alphaInDur, alphaOutDur, txtr, affectsThermal);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const u16 skLeftStepSounds[] = {0xFFFF,
|
|
||||||
SFXsam_wlkstone_00,
|
|
||||||
SFXsam_wlkmetal_00,
|
|
||||||
SFXsam_b_wlkgrass_00,
|
|
||||||
SFXsam_wlkice_00,
|
|
||||||
0xFFFF,
|
|
||||||
SFXsam_wlkgrate_00,
|
|
||||||
SFXsam_wlkphazon_00,
|
|
||||||
SFXsam_wlkdirt_00,
|
|
||||||
SFXlav_wlklava_00,
|
|
||||||
SFXsam_wlklavastone_00,
|
|
||||||
SFXsam_wlksnow_00,
|
|
||||||
SFXsam_wlkmud_00,
|
|
||||||
0xFFFF,
|
|
||||||
SFXsam_b_wlkorg_00,
|
|
||||||
SFXsam_wlkmetal_00,
|
|
||||||
SFXsam_wlkmetal_00,
|
|
||||||
SFXsam_wlkdirt_00,
|
|
||||||
0xFFFF,
|
|
||||||
0xFFFF,
|
|
||||||
0xFFFF,
|
|
||||||
0xFFFF,
|
|
||||||
SFXsam_wlkwood_00,
|
|
||||||
SFXsam_b_wlkorg_00};
|
|
||||||
|
|
||||||
static const u16 skRightStepSounds[] = {0xFFFF,
|
|
||||||
SFXsam_wlkstone_01,
|
|
||||||
SFXsam_wlkmetal_01,
|
|
||||||
SFXsam_b_wlkgrass_01,
|
|
||||||
SFXsam_wlkice_01,
|
|
||||||
0xFFFF,
|
|
||||||
SFXsam_wlkgrate_01,
|
|
||||||
SFXsam_wlkphazon_01,
|
|
||||||
SFXsam_wlkdirt_01,
|
|
||||||
SFXlav_wlklava_01,
|
|
||||||
SFXsam_wlklavastone_01,
|
|
||||||
SFXsam_wlksnow_01,
|
|
||||||
SFXsam_wlkmud_01,
|
|
||||||
0xFFFF,
|
|
||||||
SFXsam_b_wlkorg_01,
|
|
||||||
SFXsam_wlkmetal_01,
|
|
||||||
SFXsam_wlkmetal_01,
|
|
||||||
SFXsam_wlkdirt_01,
|
|
||||||
0xFFFF,
|
|
||||||
0xFFFF,
|
|
||||||
0xFFFF,
|
|
||||||
0xFFFF,
|
|
||||||
SFXsam_wlkwood_01,
|
|
||||||
SFXsam_b_wlkorg_01};
|
|
||||||
|
|
||||||
void CPlayer::UpdateFootstepSounds(const CFinalInput& input, CStateManager& mgr, float dt) {
|
void CPlayer::UpdateFootstepSounds(const CFinalInput& input, CStateManager& mgr, float dt) {
|
||||||
if (x2f8_morphBallState != EPlayerMorphBallState::Unmorphed || x258_movementState != EPlayerMovementState::OnGround ||
|
if (x2f8_morphBallState != EPlayerMorphBallState::Unmorphed || x258_movementState != EPlayerMovementState::OnGround ||
|
||||||
x3dc_inFreeLook || x3dd_lookButtonHeld)
|
x3dc_inFreeLook || x3dd_lookButtonHeld)
|
||||||
|
@ -2646,9 +2682,9 @@ void CPlayer::UpdateFootstepSounds(const CFinalInput& input, CStateManager& mgr,
|
||||||
} else {
|
} else {
|
||||||
u16 sfx;
|
u16 sfx;
|
||||||
if (x790_footstepSfxSel == EFootstepSfx::Left) {
|
if (x790_footstepSfxSel == EFootstepSfx::Left) {
|
||||||
sfx = GetMaterialSoundUnderPlayer(mgr, skLeftStepSounds, std::size(skLeftStepSounds), -1);
|
sfx = GetMaterialSoundUnderPlayer(mgr, skLeftStepSounds.data(), skLeftStepSounds.size(), 0xffff);
|
||||||
} else {
|
} else {
|
||||||
sfx = GetMaterialSoundUnderPlayer(mgr, skRightStepSounds, std::size(skRightStepSounds), -1);
|
sfx = GetMaterialSoundUnderPlayer(mgr, skRightStepSounds.data(), skRightStepSounds.size(), 0xffff);
|
||||||
}
|
}
|
||||||
CSfxHandle hnd = CSfxManager::SfxStart(sfx, sfxVol, 0.f, true, 0x7f, false, kInvalidAreaId);
|
CSfxHandle hnd = CSfxManager::SfxStart(sfx, sfxVol, 0.f, true, 0x7f, false, kInvalidAreaId);
|
||||||
ApplySubmergedPitchBend(hnd);
|
ApplySubmergedPitchBend(hnd);
|
||||||
|
@ -2694,12 +2730,6 @@ void CPlayer::UpdateVisorTransition(float dt, CStateManager& mgr) {
|
||||||
mgr.GetPlayerState()->UpdateVisorTransition(dt);
|
mgr.GetPlayerState()->UpdateVisorTransition(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const std::pair<CPlayerState::EItemType, ControlMapper::ECommands> skVisorToItemMapping[] = {
|
|
||||||
{CPlayerState::EItemType::CombatVisor, ControlMapper::ECommands::NoVisor},
|
|
||||||
{CPlayerState::EItemType::XRayVisor, ControlMapper::ECommands::XrayVisor},
|
|
||||||
{CPlayerState::EItemType::ScanVisor, ControlMapper::ECommands::InviroVisor},
|
|
||||||
{CPlayerState::EItemType::ThermalVisor, ControlMapper::ECommands::ThermoVisor}};
|
|
||||||
|
|
||||||
void CPlayer::UpdateVisorState(const CFinalInput& input, float dt, CStateManager& mgr) {
|
void CPlayer::UpdateVisorState(const CFinalInput& input, float dt, CStateManager& mgr) {
|
||||||
x7a0_visorSteam.Update(dt);
|
x7a0_visorSteam.Update(dt);
|
||||||
if (x7a0_visorSteam.AffectsThermal())
|
if (x7a0_visorSteam.AffectsThermal())
|
||||||
|
@ -2719,17 +2749,20 @@ void CPlayer::UpdateVisorState(const CFinalInput& input, float dt, CStateManager
|
||||||
DrawGun(mgr);
|
DrawGun(mgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (size_t i = 0; i < skVisorToItemMapping.size(); ++i) {
|
||||||
if (mgr.GetPlayerState()->HasPowerUp(skVisorToItemMapping[i].first) &&
|
const auto mapping = skVisorToItemMapping[i];
|
||||||
ControlMapper::GetPressInput(skVisorToItemMapping[i].second, input)) {
|
|
||||||
|
if (mgr.GetPlayerState()->HasPowerUp(mapping.first) && ControlMapper::GetPressInput(mapping.second, input)) {
|
||||||
x9c4_24_visorChangeRequested = true;
|
x9c4_24_visorChangeRequested = true;
|
||||||
CPlayerState::EPlayerVisor visor = CPlayerState::EPlayerVisor(i);
|
const auto visor = CPlayerState::EPlayerVisor(i);
|
||||||
|
|
||||||
if (mgr.GetPlayerState()->GetTransitioningVisor() != visor) {
|
if (mgr.GetPlayerState()->GetTransitioningVisor() != visor) {
|
||||||
mgr.GetPlayerState()->StartTransitionToVisor(visor);
|
mgr.GetPlayerState()->StartTransitionToVisor(visor);
|
||||||
if (visor == CPlayerState::EPlayerVisor::Scan)
|
if (visor == CPlayerState::EPlayerVisor::Scan) {
|
||||||
HolsterGun(mgr);
|
HolsterGun(mgr);
|
||||||
else
|
} else {
|
||||||
DrawGun(mgr);
|
DrawGun(mgr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5056,17 +5089,21 @@ void CPlayer::FinishSidewaysDash() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayer::ComputeDash(const CFinalInput& input, float dt, CStateManager& mgr) {
|
void CPlayer::ComputeDash(const CFinalInput& input, float dt, CStateManager& mgr) {
|
||||||
float strafeInput = StrafeInput(input);
|
const float strafeInput = StrafeInput(input);
|
||||||
float forwardInput = ForwardInput(input, TurnInput(input));
|
const float forwardInput = ForwardInput(input, TurnInput(input));
|
||||||
zeus::CVector3f orbitPointFlattened(x314_orbitPoint.x(), x314_orbitPoint.y(), GetTranslation().z());
|
zeus::CVector3f orbitPointFlattened(x314_orbitPoint.x(), x314_orbitPoint.y(), GetTranslation().z());
|
||||||
zeus::CVector3f orbitToPlayer = GetTranslation() - orbitPointFlattened;
|
const zeus::CVector3f orbitToPlayer = GetTranslation() - orbitPointFlattened;
|
||||||
if (!orbitToPlayer.canBeNormalized())
|
if (!orbitToPlayer.canBeNormalized()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
zeus::CVector3f useOrbitToPlayer = orbitToPlayer;
|
zeus::CVector3f useOrbitToPlayer = orbitToPlayer;
|
||||||
ESurfaceRestraints restraints = GetSurfaceRestraint();
|
const ESurfaceRestraints restraints = GetSurfaceRestraint();
|
||||||
float strafeVel = dt * skStrafeDistances[int(restraints)];
|
float strafeVel = dt * skStrafeDistances[size_t(restraints)];
|
||||||
if (ControlMapper::GetDigitalInput(ControlMapper::ECommands::JumpOrBoost, input))
|
if (ControlMapper::GetDigitalInput(ControlMapper::ECommands::JumpOrBoost, input)) {
|
||||||
x388_dashButtonHoldTime += dt;
|
x388_dashButtonHoldTime += dt;
|
||||||
|
}
|
||||||
|
|
||||||
if (!x37c_sidewaysDashing) {
|
if (!x37c_sidewaysDashing) {
|
||||||
if (SidewaysDashAllowed(strafeInput, forwardInput, input, mgr)) {
|
if (SidewaysDashAllowed(strafeInput, forwardInput, input, mgr)) {
|
||||||
x37c_sidewaysDashing = true;
|
x37c_sidewaysDashing = true;
|
||||||
|
@ -5094,36 +5131,41 @@ void CPlayer::ComputeDash(const CFinalInput& input, float dt, CStateManager& mgr
|
||||||
CSfxManager::RemoveEmitter(x778_dashSfx);
|
CSfxManager::RemoveEmitter(x778_dashSfx);
|
||||||
} else {
|
} else {
|
||||||
if (x39c_noStrafeDashBlend) {
|
if (x39c_noStrafeDashBlend) {
|
||||||
strafeVel = dt * skDashStrafeDistances[int(restraints)] * x398_dashSpeedMultiplier;
|
strafeVel = dt * skDashStrafeDistances[size_t(restraints)] * x398_dashSpeedMultiplier;
|
||||||
} else {
|
} else {
|
||||||
strafeVel = ((skDashStrafeDistances[int(restraints)] - skStrafeDistances[int(restraints)]) *
|
strafeVel = ((skDashStrafeDistances[size_t(restraints)] - skStrafeDistances[size_t(restraints)]) *
|
||||||
(1.f - zeus::clamp(-1.f, x384_dashTimer / x3a4_strafeDashBlendDuration, 1.f)) +
|
(1.f - zeus::clamp(-1.f, x384_dashTimer / x3a4_strafeDashBlendDuration, 1.f)) +
|
||||||
skStrafeDistances[int(restraints)]) *
|
skStrafeDistances[size_t(restraints)]) *
|
||||||
x398_dashSpeedMultiplier * dt;
|
x398_dashSpeedMultiplier * dt;
|
||||||
}
|
}
|
||||||
if (x380_strafeInputAtDash < 0.f)
|
if (x380_strafeInputAtDash < 0.f) {
|
||||||
strafeVel = -strafeVel;
|
strafeVel = -strafeVel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float f3 = strafeVel / orbitToPlayer.magnitude();
|
const float f3 = strafeVel / orbitToPlayer.magnitude();
|
||||||
float f2 = dt * (x37c_sidewaysDashing ? M_PIF : (M_PIF * 2.f / 3.f));
|
const float f2 = dt * (x37c_sidewaysDashing ? M_PIF : (M_PIF * 2.f / 3.f));
|
||||||
useOrbitToPlayer =
|
useOrbitToPlayer =
|
||||||
zeus::CQuaternion::fromAxisAngle(zeus::skUp, zeus::clamp(-f2, f3, f2)).transform(orbitToPlayer);
|
zeus::CQuaternion::fromAxisAngle(zeus::skUp, zeus::clamp(-f2, f3, f2)).transform(orbitToPlayer);
|
||||||
orbitPointFlattened += useOrbitToPlayer;
|
orbitPointFlattened += useOrbitToPlayer;
|
||||||
if (!ControlMapper::GetDigitalInput(ControlMapper::ECommands::JumpOrBoost, input))
|
if (!ControlMapper::GetDigitalInput(ControlMapper::ECommands::JumpOrBoost, input)) {
|
||||||
x388_dashButtonHoldTime = 0.f;
|
x388_dashButtonHoldTime = 0.f;
|
||||||
strafeVel = skOrbitForwardDistances[int(restraints)] * forwardInput * dt;
|
}
|
||||||
|
|
||||||
|
strafeVel = skOrbitForwardDistances[size_t(restraints)] * forwardInput * dt;
|
||||||
orbitPointFlattened += -useOrbitToPlayer.normalized() * strafeVel;
|
orbitPointFlattened += -useOrbitToPlayer.normalized() * strafeVel;
|
||||||
zeus::CVector2f velFlat(x138_velocity.x(), x138_velocity.y());
|
const zeus::CVector2f velFlat(x138_velocity.x(), x138_velocity.y());
|
||||||
zeus::CVector3f newVelocity = (orbitPointFlattened - GetTranslation()) / dt;
|
zeus::CVector3f newVelocity = (orbitPointFlattened - GetTranslation()) / dt;
|
||||||
zeus::CVector3f velDelta(newVelocity.x() - x138_velocity.x(), newVelocity.y() - x138_velocity.y(), 0.f);
|
const zeus::CVector3f velDelta(newVelocity.x() - x138_velocity.x(), newVelocity.y() - x138_velocity.y(), 0.f);
|
||||||
strafeVel = velDelta.magnitude();
|
strafeVel = velDelta.magnitude();
|
||||||
|
|
||||||
if (strafeVel > FLT_EPSILON) {
|
if (strafeVel > FLT_EPSILON) {
|
||||||
float accel = dt * GetAcceleration();
|
const float accel = dt * GetAcceleration();
|
||||||
newVelocity = velDelta / strafeVel * accel * zeus::clamp(-1.f, strafeVel / accel, 1.f) + x138_velocity;
|
newVelocity = velDelta / strafeVel * accel * zeus::clamp(-1.f, strafeVel / accel, 1.f) + x138_velocity;
|
||||||
if (!x9c5_28_slidingOnWall)
|
if (!x9c5_28_slidingOnWall) {
|
||||||
SetVelocityWR(newVelocity);
|
SetVelocityWR(newVelocity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,32 +1,39 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CPhysicsActor.hpp"
|
#include <memory>
|
||||||
#include "zeus/CAABox.hpp"
|
#include <optional>
|
||||||
#include "zeus/CTransform.hpp"
|
#include <vector>
|
||||||
#include "Weapon/CWeaponMgr.hpp"
|
|
||||||
#include "CPlayerEnergyDrain.hpp"
|
#include "Runtime/Weapon/CPlayerGun.hpp"
|
||||||
#include "Weapon/CPlayerGun.hpp"
|
#include "Runtime/Weapon/CWeaponMgr.hpp"
|
||||||
#include "CMorphBall.hpp"
|
#include "Runtime/World/CMorphBall.hpp"
|
||||||
|
#include "Runtime/World/CPhysicsActor.hpp"
|
||||||
|
#include "Runtime/World/CPlayerEnergyDrain.hpp"
|
||||||
|
|
||||||
|
#include <zeus/CAABox.hpp>
|
||||||
|
#include <zeus/CTransform.hpp>
|
||||||
|
#include <zeus/CVector3f.hpp>
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
|
class CCollidableSphere;
|
||||||
|
class CDamageInfo;
|
||||||
|
class CFirstPersonCamera;
|
||||||
class CMaterialList;
|
class CMaterialList;
|
||||||
class CMorphBall;
|
class CMorphBall;
|
||||||
|
class CPlayerCameraBob;
|
||||||
class CPlayerGun;
|
class CPlayerGun;
|
||||||
class CDamageInfo;
|
class CScriptPlayerHint;
|
||||||
class CScriptWater;
|
class CScriptWater;
|
||||||
class IVisitor;
|
class IVisitor;
|
||||||
|
|
||||||
struct CFinalInput;
|
struct CFinalInput;
|
||||||
class CPlayerCameraBob;
|
|
||||||
class CFirstPersonCamera;
|
|
||||||
class CCollidableSphere;
|
|
||||||
class CScriptPlayerHint;
|
|
||||||
|
|
||||||
class CPlayer : public CPhysicsActor {
|
class CPlayer : public CPhysicsActor {
|
||||||
friend class CStateManager;
|
|
||||||
friend class CFirstPersonCamera;
|
friend class CFirstPersonCamera;
|
||||||
friend class CPlayerCameraBob;
|
|
||||||
friend class CMorphBall;
|
|
||||||
friend class CGroundMovement;
|
friend class CGroundMovement;
|
||||||
|
friend class CMorphBall;
|
||||||
|
friend class CPlayerCameraBob;
|
||||||
|
friend class CStateManager;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class EPlayerScanState { NotScanning, Scanning, ScanComplete };
|
enum class EPlayerScanState { NotScanning, Scanning, ScanComplete };
|
||||||
|
|
Loading…
Reference in New Issue