Additional CPlayer imps

This commit is contained in:
Jack Andersen 2017-08-01 21:13:11 -10:00
parent 0cae1bb036
commit 884a18b80b
11 changed files with 277 additions and 18 deletions

View File

@ -1878,7 +1878,7 @@ void CStateManager::Update(float dt)
}
if (x904_gameState != EGameState::Paused)
UpdatePlayer(dt);
PostUpdatePlayer(dt);
if (xf84_ == xf80_hudMessageFrameCount)
{
@ -2110,9 +2110,9 @@ void CStateManager::ThinkEffectsAndActors(float dt)
}
}
void CStateManager::UpdatePlayer(float dt)
void CStateManager::PostUpdatePlayer(float dt)
{
x84c_player->Update(dt, *this);
x84c_player->PostUpdate(dt, *this);
}
void CStateManager::ShowPausedHUDMemo(ResId strg, float time)

View File

@ -359,7 +359,7 @@ public:
void MoveDoors(float dt);
void CrossTouchActors();
void ThinkEffectsAndActors(float dt);
void UpdatePlayer(float dt);
void PostUpdatePlayer(float dt);
void ShowPausedHUDMemo(ResId strg, float time);
void ClearGraveyard();
void FrameBegin(s32 frameCount);

View File

@ -25,4 +25,9 @@ void CBallCamera::Reset(const zeus::CTransform&, CStateManager& mgr)
{
}
void CBallCamera::SetState(EBallCameraState state, CStateManager& mgr)
{
}
}

View File

@ -8,12 +8,19 @@ namespace urde
class CBallCamera : public CGameCamera
{
public:
enum class EBallCameraState
{
Zero
};
private:
public:
CBallCamera(TUniqueId, TUniqueId, const zeus::CTransform& xf, float, float, float, float);
void Accept(IVisitor& visitor);
void ProcessInput(const CFinalInput&, CStateManager& mgr);
void Reset(const zeus::CTransform&, CStateManager& mgr);
void SetState(EBallCameraState state, CStateManager& mgr);
};
}

View File

@ -308,4 +308,14 @@ void CCameraManager::RenderCameras(const CStateManager& mgr)
for (CEntity* cam : mgr.GetCameraObjectList())
static_cast<CGameCamera*>(cam)->Render(mgr);
}
void CCameraManager::SetupBallCamera(CStateManager& mgr)
{
}
void CCameraManager::LeaveBallCamera(CStateManager& mgr, TUniqueId newCamId)
{
}
}

View File

@ -125,6 +125,9 @@ public:
void ProcessInput(const CFinalInput& input, CStateManager& stateMgr);
void RenderCameras(const CStateManager& mgr);
void SetupBallCamera(CStateManager& mgr);
void LeaveBallCamera(CStateManager& mgr, TUniqueId newCamId);
int GetFluidCounter() const { return x74_fluidCounter; }
};
}

View File

@ -41,6 +41,7 @@ public:
void CalculateGunFollowOrientationAndTransform(zeus::CTransform&, zeus::CQuaternion&, float, zeus::CVector3f&);
void SetScriptPitchId(TUniqueId uid) { x1c4_pitchId = uid; }
void SetX18C(bool v) { x18c_ = v; }
void SetX1C6_24(bool v) { x1c6_24_ = v; }
};
}

View File

@ -40,7 +40,15 @@ private:
std::unique_ptr<CModelData> x70_frozenBallModel;
u32 x74_frozenBallModelShader = 0;
u32 x187c_ = 0;
float x1914_ = 0.f;
float x1918_ = 0.f;
float x191c_damageTimer = 0.f;
bool x1920_ = false;
zeus::CTransform x1924_;
bool x1954_isProjectile = false;
u32 x195c_ = false;
u32 x1960_ = false;
u32 x1964_ = false;
float x1DE8_boostTime = 0.f;
CMorphBallShadow* x1e50_shadow = nullptr;
@ -52,7 +60,7 @@ public:
zeus::CVector3f GetBallContactSurfaceNormal() const { return {}; }
void GetModel() const {}
const CCollidableSphere* GetCollidableSphere() const { return nullptr; }
bool IsProjectile() const { return false; }
bool IsProjectile() const { return x1954_isProjectile; }
void GetBallContactMeterials() const {}
void GetWallBumpCounter() const {}
void GetBoostChargeTimer() const {}
@ -131,6 +139,7 @@ public:
bool IsClimbable(const CCollisionInfo&) const { return false; }
void FluidFXThink(CActor::EFluidState, CScriptWater&, CStateManager&) {}
void GetMorphBallModel(const std::string&, float) {}
void LoadMorphBallModel(CStateManager& mgr) {}
void AddSpiderBallElectricalEffect() {}
void UpdateSpiderBallElectricalEffect() {}
void RenderSpiderBallElectricalEffect() const {}

View File

@ -61,8 +61,8 @@ CPlayer::CPlayer(TUniqueId uid, const zeus::CTransform& xf, const zeus::CAABox&
CPlayerCameraBob::kCameraBobExtentY},
CPlayerCameraBob::kCameraBobPeriod));
x9c4_26_ = true;
x9c4_27_ = true;
x9c4_28_ = true;
x9c4_27_canEnterMorphBall = true;
x9c4_28_canLeaveMorphBall = true;
x9c5_31_ = true;
ResId beamId = g_tweakPlayerRes->GetBeamBallTransitionModel(x7ec_beam);
x7f0_ballTransitionBeamModel = std::make_unique<CModelData>(CStaticRes(beamId, playerScale));
@ -105,7 +105,12 @@ void CPlayer::InitializeBallTransition()
bool CPlayer::IsTransparent() const { return x588_alpha < 1.f; }
void CPlayer::Update(float, CStateManager& mgr) {}
void CPlayer::Update(float dt, CStateManager& mgr) {}
void CPlayer::PostUpdate(float dt, CStateManager& mgr)
{
}
bool CPlayer::StartSamusVoiceSfx(u16 sfx, float vol, int prio)
{
@ -1191,7 +1196,8 @@ void CPlayer::ProcessInput(const CFinalInput& input, CStateManager& mgr)
x498_gunHolsterState == EGunHolsterState::Drawn))
{
x490_gun->ProcessInput(input, mgr);
if (x2f8_morphTransState == EPlayerMorphBallState::Morphed && x2fc_ != kInvalidUniqueId)
if (x2f8_morphTransState == EPlayerMorphBallState::Morphed &&
x26c_ != kInvalidUniqueId)
{
if (ControlMapper::GetPressInput(ControlMapper::ECommands::TurnLeft, input) ||
ControlMapper::GetPressInput(ControlMapper::ECommands::TurnRight, input) ||
@ -3894,13 +3900,216 @@ float CPlayer::GetWeight() const { return 0.f; }
zeus::CVector3f CPlayer::GetDampedClampedVelocityWR() const { return {}; }
const CScriptWater* CPlayer::GetVisorRunoffEffect(const CStateManager& mgr) const
{
if (xc4_fluidId == kInvalidUniqueId)
return nullptr;
return TCastToConstPtr<CScriptWater>(mgr.GetObjectById(xc4_fluidId)).GetPtr();
}
void CPlayer::SetMorphBallState(EPlayerMorphBallState state, CStateManager& mgr)
{
if (x2f8_morphTransState == EPlayerMorphBallState::Morphed &&
state != EPlayerMorphBallState::Morphed)
x9c5_26_ = x9c4_31_dampUnderwaterMotion;
x2f8_morphTransState = state;
xf9_standardCollider = state == EPlayerMorphBallState::Morphed;
switch (x2f8_morphTransState)
{
case EPlayerMorphBallState::Unmorphed:
if (x9c5_26_ && mgr.GetCameraManager()->GetFluidCounter() == 0)
{
if (auto water = GetVisorRunoffEffect(mgr))
{
if (const auto& effect = water->GetVisorRunoffEffect())
{
CHUDBillboardEffect* sheets = new CHUDBillboardEffect(*effect, {}, mgr.AllocateUniqueId(),
true, "WaterSheets", CHUDBillboardEffect::GetNearClipDistance(mgr),
CHUDBillboardEffect::GetScaleForPOV(mgr), zeus::CColor::skWhite,
zeus::CVector3f::skOne, zeus::CVector3f::skZero);
mgr.AddObject(sheets);
}
CSfxHandle hnd = CSfxManager::SfxStart(water->GetVisorRunoffSfx(), 1.f, 0.f,
false, 0x7f, false, kInvalidAreaId);
ApplySubmergedPitchBend(hnd);
}
}
break;
case EPlayerMorphBallState::Morphed:
case EPlayerMorphBallState::Morphing:
x768_morphball->LoadMorphBallModel(mgr);
break;
default:
break;
}
}
bool CPlayer::CanLeaveMorphBallState(CStateManager& mgr, zeus::CVector3f& pos) const
{
if (x768_morphball->IsProjectile() || !x590_ ||
(IsUnderBetaMetroidAttack(mgr) && x2f8_morphTransState == EPlayerMorphBallState::Morphed))
return false;
if (!x9c4_28_canLeaveMorphBall)
return false;
CMaterialFilter filter = CMaterialFilter::MakeInclude({EMaterialTypes::Solid});
zeus::CAABox aabb(x2d8_fpBounds.min - zeus::CVector3f(1.f) + GetTranslation(),
x2d8_fpBounds.max + zeus::CVector3f(1.f) + GetTranslation());
rstl::reserved_vector<TUniqueId, 1024> nearList;
mgr.BuildColliderList(nearList, *this, aabb);
const zeus::CAABox& baseAABB = GetBaseBoundingBox();
pos = zeus::CVector3f::skZero;
for (int i=0 ; i<8 ; ++i)
{
zeus::CAABox aabb(baseAABB.min + pos + GetTranslation(),
baseAABB.max + pos + GetTranslation());
CCollidableAABox cAABB(aabb, CMaterialList());
if (!CGameCollision::DetectCollisionBoolean(mgr, cAABB, zeus::CTransform::Identity(), filter, nearList))
return true;
pos.z += 0.1f;
}
return false;
}
void CPlayer::SetHudDisable(float f1, float f2, float f3)
{
x740_ = f1;
x744_ = f2;
x748_ = f3;
if (x744_ != 0.f)
return;
if (x740_ == 0.f)
x74c_visorStaticAlpha = 1.f;
else
x74c_visorStaticAlpha = 0.f;
}
void CPlayer::SetIntoBallReadyAnimation(CStateManager& mgr)
{
CAnimPlaybackParms parms(2, -1, 1.f, true);
x64_modelData->AnimationData()->SetAnimation(parms, false);
x64_modelData->AnimationData()->EnableLooping(false);
x64_modelData->AdvanceAnimation(0.f, mgr, kInvalidAreaId, true);
x64_modelData->AnimationData()->EnableAnimation(false);
}
void CPlayer::LeaveMorphBallState(CStateManager& mgr)
{
x730_transitionModels.clear();
AddMaterial(EMaterialTypes::GroundCollider, mgr);
x150_momentum = zeus::CVector3f::skZero;
SetMorphBallState(EPlayerMorphBallState::Unmorphed, mgr);
SetHudDisable(FLT_EPSILON, 0.f, 2.f);
SetHudDisable(FLT_EPSILON, 0.f, 2.f);
SetIntoBallReadyAnimation(mgr);
CPhysicsActor::Stop();
x3e4_ = 0.f;
x3e8_horizFreeLookAngleVel = 0.f;
x3ec_freeLookPitchAngle = 0.f;
x3f0_vertFreeLookAngleVel = 0.f;
x768_morphball->LeaveMorphBallState(mgr);
mgr.GetCameraManager()->LeaveBallCamera(mgr, mgr.GetCameraManager()->GetFirstPersonCamera()->GetUniqueId());
mgr.GetCameraManager()->GetBallCamera()->SetState(CBallCamera::EBallCameraState::Zero, mgr);
SetCameraState(EPlayerCameraState::Zero, mgr);
mgr.GetCameraManager()->GetFirstPersonCamera()->SetX1C6_24(true);
mgr.GetCameraManager()->GetFirstPersonCamera()->Think(0.f, mgr);
ForceGunOrientation(x34_transform, mgr);
DrawGun(mgr);
}
bool CPlayer::CanEnterMorphBallState(CStateManager& mgr, float f1) const
{
if (x3b8_grappleState != EGrappleState::None ||
(IsUnderBetaMetroidAttack(mgr) && x2f8_morphTransState == EPlayerMorphBallState::Unmorphed))
return false;
return x9c4_27_canEnterMorphBall;
}
void CPlayer::EnterMorphBallState(CStateManager& mgr)
{
SetMorphBallState(EPlayerMorphBallState::Morphed, mgr);
RemoveMaterial(EMaterialTypes::GroundCollider, mgr);
x730_transitionModels.clear();
SetAngularVelocityOR(zeus::CAxisAngle(
zeus::CVector3f(x138_velocity.magnitude() / g_tweakPlayer->GetPlayerBallHalfExtent(), 0.f, 0.f)));
x768_morphball->EnterMorphBallState(mgr);
x768_morphball->TakeDamage(-1.f);
x768_morphball->SetDamageTimer(0.f);
mgr.GetPlayerState()->StartVisorTransition(CPlayerState::EPlayerVisor::Combat);
}
void CPlayer::ActivateMorphBallCamera(CStateManager& mgr)
{
SetCameraState(EPlayerCameraState::One, mgr);
mgr.GetCameraManager()->GetBallCamera()->SetState(CBallCamera::EBallCameraState::Zero, mgr);
}
void CPlayer::UpdateCinematicState(CStateManager& mgr)
{
if (mgr.GetCameraManager()->IsInCinematicCamera())
{
switch (x2f4_cameraState)
if (x2f4_cameraState != EPlayerCameraState::Four)
{
x2fc_cinematicMorphTransState = x2f8_morphTransState;
if (x2fc_cinematicMorphTransState == EPlayerMorphBallState::Unmorphing)
x2fc_cinematicMorphTransState = EPlayerMorphBallState::Unmorphed;
if (x2fc_cinematicMorphTransState == EPlayerMorphBallState::Morphing)
x2fc_cinematicMorphTransState = EPlayerMorphBallState::Morphed;
SetCameraState(EPlayerCameraState::Four, mgr);
}
}
else
{
if (x2f4_cameraState == EPlayerCameraState::Four)
{
if (x2fc_cinematicMorphTransState == x2f8_morphTransState)
{
switch (x2fc_cinematicMorphTransState)
{
case EPlayerMorphBallState::Morphed:
SetCameraState(EPlayerCameraState::One, mgr);
break;
case EPlayerMorphBallState::Unmorphed:
SetCameraState(EPlayerCameraState::Zero, mgr);
if (mgr.GetPlayerState()->GetCurrentVisor() != CPlayerState::EPlayerVisor::Scan)
{
ForceGunOrientation(x34_transform, mgr);
DrawGun(mgr);
}
default:
break;
}
}
else
{
CPhysicsActor::Stop();
SetOrbitRequest(EPlayerOrbitRequest::One, mgr);
switch (x2fc_cinematicMorphTransState)
{
case EPlayerMorphBallState::Unmorphed:
{
zeus::CVector3f vec;
if (CanLeaveMorphBallState(mgr, vec))
{
SetTranslation(GetTranslation() + vec);
LeaveMorphBallState(mgr);
SetCameraState(EPlayerCameraState::Zero, mgr);
ForceGunOrientation(x34_transform, mgr);
DrawGun(mgr);
}
break;
}
case EPlayerMorphBallState::Morphed:
EnterMorphBallState(mgr);
ActivateMorphBallCamera(mgr);
mgr.GetCameraManager()->SetupBallCamera(mgr);
mgr.GetCameraManager()->GetBallCamera()->Reset(
CreateTransformFromMovementDirection(), mgr);
default:
break;
}
}
}
}
}

View File

@ -226,7 +226,7 @@ private:
float x2f0_ballTransHeight = 0.f;
EPlayerCameraState x2f4_cameraState = EPlayerCameraState::Zero;
EPlayerMorphBallState x2f8_morphTransState = EPlayerMorphBallState::Unmorphed;
u32 x2fc_ = 0;
EPlayerMorphBallState x2fc_cinematicMorphTransState = EPlayerMorphBallState::Unmorphed;
float x300_fallingTime = 0.f;
EPlayerOrbitState x304_orbitState = EPlayerOrbitState::Zero;
EPlayerOrbitType x308_orbitType = EPlayerOrbitType::Zero;
@ -306,6 +306,8 @@ private:
u32 x57c_ = 0;
u32 x580_ = 0;
float x588_alpha = 1.f;
float x58c_ = 0.f;
bool x590_ = true;
TReservedAverage<zeus::CTransform, 4> x594_transisionBeamXfs;
TReservedAverage<zeus::CTransform, 4> x658_transitionModelXfs;
TReservedAverage<float, 4> x71c_transitionModelAlphas;
@ -355,8 +357,8 @@ private:
bool x9c4_24_visorChangeRequested : 1;
bool x9c4_25_showCrosshairs : 1;
bool x9c4_26_ : 1;
bool x9c4_27_ : 1;
bool x9c4_28_ : 1;
bool x9c4_27_canEnterMorphBall : 1;
bool x9c4_28_canLeaveMorphBall : 1;
bool x9c4_29_ : 1;
bool x9c4_30_ : 1;
bool x9c4_31_dampUnderwaterMotion : 1;
@ -419,6 +421,7 @@ public:
bool IsTransparent() const;
void Update(float, CStateManager& mgr);
void PostUpdate(float, CStateManager& mgr);
bool StartSamusVoiceSfx(u16 sfx, float vol, int prio);
bool IsPlayerDeadEnough() const;
void AsyncLoadSuit(CStateManager& mgr);
@ -572,6 +575,15 @@ public:
const CVisorSteam& GetVisorSteam() const { return x7a0_visorSteam; }
float GetVisorStaticAlpha() const { return x74c_visorStaticAlpha; }
float GetMapAlpha() const { return x494_mapAlpha; }
const CScriptWater* GetVisorRunoffEffect(const CStateManager& mgr) const;
void SetMorphBallState(EPlayerMorphBallState state, CStateManager& mgr);
bool CanLeaveMorphBallState(CStateManager& mgr, zeus::CVector3f& pos) const;
void SetHudDisable(float f1, float f2, float f3);
void SetIntoBallReadyAnimation(CStateManager& mgr);
void LeaveMorphBallState(CStateManager& mgr);
bool CanEnterMorphBallState(CStateManager& mgr, float f1) const;
void EnterMorphBallState(CStateManager& mgr);
void ActivateMorphBallCamera(CStateManager& mgr);
void UpdateCinematicState(CStateManager& mgr);
void SetCameraState(EPlayerCameraState camState, CStateManager& stateMgr);
bool IsEnergyLow(const CStateManager& mgr) const;

View File

@ -33,12 +33,12 @@ private:
u32 x238_;
u32 x248_;
u32 x24c_;
bool x25c_;
s16 x260_;
s16 x262_;
std::experimental::optional<TLockedToken<CGenDescription>> x250_visorRunoffEffect;
u16 x260_;
u16 x262_visorRunoffSfx;
u32 x264_ = 0;
TLockedToken<CParticleGen> x268_splashEffects[5];
s16 x29c_splashSounds[5];
u16 x29c_splashSounds[5];
public:
CScriptWater(CStateManager&, TUniqueId, const std::string& name, const CEntityInfo&, const zeus::CVector3f&,
const zeus::CAABox&, CDamageInfo const&, zeus::CVector3f&, ETriggerFlags, bool, bool, ResId, ResId, ResId, ResId,
@ -74,6 +74,9 @@ public:
void SetFrustumPlanes(const zeus::CFrustum& frustum);
const zeus::CFrustum& GetFrustumPlanes() const;
CFluidPlaneCPU& GetFluidPlane() const { return *x1b4_fluidPlane; }
const std::experimental::optional<TLockedToken<CGenDescription>>& GetVisorRunoffEffect() const
{ return x250_visorRunoffEffect; }
u16 GetVisorRunoffSfx() const { return x262_visorRunoffSfx; }
};
}