Work on CPlayer

This commit is contained in:
Jack Andersen 2017-07-19 20:04:40 -10:00
parent c5514b3374
commit 5f02951f72
11 changed files with 217 additions and 69 deletions

View File

@ -29,6 +29,8 @@ struct ITweakPlayer : ITweak
virtual bool GetScanFreezesGame() const=0; // x21c_25
virtual bool GetFiringCancelsCameraPitch() const=0;
virtual float GetScanningFrameSenseRange() const=0;
virtual bool GetGunButtonTogglesHolster() const=0;
virtual bool GetGunNotFiringHolstersGun() const=0;
virtual float GetPlayerHeight() const=0; // x26c
virtual float GetPlayerXYHalfExtent() const=0; // x270
virtual bool GetX228_24() const=0; // x228_24

View File

@ -205,10 +205,10 @@ void CTweakPlayer::read(athena::io::IStreamReader& __dna_reader)
x229_28_ = __dna_reader.readBool();
/* x229_29_ */
x229_29_ = __dna_reader.readBool();
/* x229_30_ */
x229_30_ = __dna_reader.readBool();
/* x229_31_ */
x229_31_ = __dna_reader.readBool();
/* x229_30_gunButtonTogglesHolster */
x229_30_gunButtonTogglesHolster = __dna_reader.readBool();
/* x229_31_gunNotFiringHolstersGun */
x229_31_gunNotFiringHolstersGun = __dna_reader.readBool();
/* x22a_24_ */
x22a_24_ = __dna_reader.readBool();
/* x22a_25_ */
@ -645,10 +645,10 @@ void CTweakPlayer::write(athena::io::IStreamWriter& __dna_writer) const
__dna_writer.writeBool(x229_28_);
/* x229_29_ */
__dna_writer.writeBool(x229_29_);
/* x229_30_ */
__dna_writer.writeBool(x229_30_);
/* x229_31_ */
__dna_writer.writeBool(x229_31_);
/* x229_30_gunButtonTogglesHolster */
__dna_writer.writeBool(x229_30_gunButtonTogglesHolster);
/* x229_31_gunNotFiringHolstersGun */
__dna_writer.writeBool(x229_31_gunNotFiringHolstersGun);
/* x22a_24_ */
__dna_writer.writeBool(x22a_24_);
/* x22a_25_ */
@ -1115,10 +1115,10 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin)
x229_28_ = __dna_docin.readBool("x229_28_");
/* x229_29_ */
x229_29_ = __dna_docin.readBool("x229_29_");
/* x229_30_ */
x229_30_ = __dna_docin.readBool("x229_30_");
/* x229_31_ */
x229_31_ = __dna_docin.readBool("x229_31_");
/* x229_30_gunButtonTogglesHolster */
x229_30_gunButtonTogglesHolster = __dna_docin.readBool("x229_30_gunButtonTogglesHolster");
/* x229_31_gunNotFiringHolstersGun */
x229_31_gunNotFiringHolstersGun = __dna_docin.readBool("x229_31_gunNotFiringHolstersGun");
/* x22a_24_ */
x22a_24_ = __dna_docin.readBool("x22a_24_");
/* x22a_25_ */
@ -1624,10 +1624,10 @@ void CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout) const
__dna_docout.writeBool("x229_28_", x229_28_);
/* x229_29_ */
__dna_docout.writeBool("x229_29_", x229_29_);
/* x229_30_ */
__dna_docout.writeBool("x229_30_", x229_30_);
/* x229_31_ */
__dna_docout.writeBool("x229_31_", x229_31_);
/* x229_30_gunButtonTogglesHolster */
__dna_docout.writeBool("x229_30_gunButtonTogglesHolster", x229_30_gunButtonTogglesHolster);
/* x229_31_gunNotFiringHolstersGun */
__dna_docout.writeBool("x229_31_gunNotFiringHolstersGun", x229_31_gunNotFiringHolstersGun);
/* x22a_24_ */
__dna_docout.writeBool("x22a_24_", x22a_24_);
/* x22a_25_ */

View File

@ -111,8 +111,8 @@ struct CTweakPlayer : ITweakPlayer
Value<bool> x229_27_ : 1;
Value<bool> x229_28_ : 1;
Value<bool> x229_29_ : 1;
Value<bool> x229_30_ : 1;
Value<bool> x229_31_ : 1;
Value<bool> x229_30_gunButtonTogglesHolster : 1;
Value<bool> x229_31_gunNotFiringHolstersGun : 1;
Value<bool> x22a_24_ : 1;
Value<bool> x22a_25_ : 1;
Value<bool> x22a_26_firingCancelsCameraPitch : 1;
@ -194,6 +194,8 @@ struct CTweakPlayer : ITweakPlayer
float GetScanningRange() const { return x218_scanningRange; }
bool GetScanFreezesGame() const { return x21c_25_scanFreezesGame; }
float GetScanningFrameSenseRange() const { return x224_scanningFrameSenseRange; }
bool GetGunButtonTogglesHolster() const { return x229_30_gunButtonTogglesHolster; }
bool GetGunNotFiringHolstersGun() const { return x229_31_gunNotFiringHolstersGun; }
bool GetFiringCancelsCameraPitch() const { return x22a_26_firingCancelsCameraPitch; }
float GetPlayerHeight() const { return x26c_playerHeight; }
float GetPlayerXYHalfExtent() const { return x270_playerXYHalfExtent; }

View File

@ -456,6 +456,8 @@ public:
u32 GetBossStringIdx() const { return xf20_bossStringIdx; }
const SOnScreenTex& GetPendingScreenTex() const { return xef4_pendingScreenTex; }
void SetViewportScale(const zeus::CVector2f& scale) { xf2c_viewportScale = scale; }
float GetThermalColdScale2() const { return xf28_thermColdScale2; }
void SetThermalColdScale2(float s) { xf28_thermColdScale2 = s; }
static float g_EscapeShakeCountdown;
static bool g_EscapeShakeCountdownInit;

View File

@ -33,7 +33,7 @@ public:
IceBeam,
WaveBeam,
PlasmaBeam,
ToggleHolster,
ToggleHolster = 23,
OrbitClose,
OrbitFar,
OrbitObject,
@ -58,14 +58,16 @@ public:
MapMoveRight,
MapZoomIn,
MapZoomOut,
SpiderBall,
ChaseCamera,
XrayVisor,
ThermoVisor,
InviroVisor,
NoVisor,
XrayVisor = 50,
ThermoVisor = 51,
InviroVisor = 52,
NoVisor = 53,
VisorMenu,
VisorUp,
VisorDown,
ShowCrosshairs,
UseSheild=0x3B,
ScanItem=0x3C,
PreviousPauseScreen=0x41,

View File

@ -417,11 +417,5 @@ CIOWin::EMessageReturn CMFGameLoader::OnMessage(const CArchitectureMessage& msg,
void CMFGameLoader::Draw() const { g_GameState->GetWorldTransitionManager()->Draw(); }
void CMFGameLoader::Touch()
{
x14_stateMgr->TouchSky();
x14_stateMgr->TouchPlayerActor();
x14_stateMgr->Player()->Touch();
}
}
}

View File

@ -84,7 +84,6 @@ public:
CMFGameLoader();
EMessageReturn OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue);
void Draw() const;
void Touch();
};
}

View File

@ -17,7 +17,7 @@ CPlayerGun::CPlayerGun(TUniqueId id)
x66c_ = g_tweakPlayerGun->GetX28();
x832_31_ = true;
x833_24_ = true;
x833_24_isFidgeting = true;
x833_30_ = true;
x6e0_.SetSortThermal(true);

View File

@ -175,7 +175,7 @@ private:
bool x832_30_ : 1;
bool x832_31_ : 1;
bool x833_24_ : 1;
bool x833_24_isFidgeting : 1;
bool x833_25_ : 1;
bool x833_26_ : 1;
bool x833_27_ : 1;
@ -212,6 +212,7 @@ public:
void AsyncLoadSuit(CStateManager& mgr);
void TouchModel(CStateManager& stateMgr);
EMissleMode GetMissleMode() const { return x31c_missileMode; }
bool IsFidgeting() const { return x833_24_isFidgeting; }
bool IsCharging() const { return x834_24_charging; }
float GetChargeBeamFactor() const { return x340_chargeBeamFactor; }
bool IsBombReady() const { return x835_28_bombReady; }

View File

@ -50,7 +50,7 @@ CPlayer::CPlayer(TUniqueId uid, const zeus::CTransform& xf, const zeus::CAABox&
stepDown), x7d0_animRes(resId, 0, playerScale, 0, true)
{
x490_gun.reset(new CPlayerGun(uid));
x49c_gunNotFiringTimeout = g_tweakPlayerGun->GetGunNotFiringTime();
x49c_gunHolsterRemTime = g_tweakPlayerGun->GetGunNotFiringTime();
x4a0_failsafeTest.reset(new CFailsafeTest());
x76c_cameraBob.reset(new CPlayerCameraBob(CPlayerCameraBob::ECameraBobType::One,
zeus::CVector2f{CPlayerCameraBob::kCameraBobExtentX,
@ -401,9 +401,20 @@ bool CPlayer::IsUnderBetaMetroidAttack(CStateManager& mgr) const
return false;
}
rstl::optional_object<zeus::CAABox> CPlayer::GetTouchBounds() const { return {}; }
void CPlayer::Touch(CActor&, CStateManager& mgr) {}
rstl::optional_object<zeus::CAABox> CPlayer::GetTouchBounds() const
{
if (x2f8_morphTransState == EPlayerMorphBallState::Morphed)
{
float ballTouchRad = x768_morphball->GetBallTouchRadius();
zeus::CVector3f ballCenter =
GetTranslation() + zeus::CVector3f(0.f, 0.f, x768_morphball->GetBallRadius());
return zeus::CAABox(ballCenter - ballTouchRad, ballCenter + ballTouchRad);
}
else
{
return GetBoundingBox();
}
}
void CPlayer::DoPreThink(float dt, CStateManager& mgr)
{
@ -1133,7 +1144,10 @@ void CPlayer::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CState
CActor::AcceptScriptMsg(msg, sender, mgr);
}
void CPlayer::SetVisorSteam(float, float, float, ResId, bool) {}
void CPlayer::SetVisorSteam(float f1, float f2, float f3, ResId txtr, bool affectsThermal)
{
x7a0_visorSteam.SetSteam(f1, f2, f3, txtr, affectsThermal);
}
static const u16 skLeftStepSounds[] =
{
@ -1279,20 +1293,149 @@ u16 CPlayer::SfxIdFromMaterial(const CMaterialList& mat, const u16* idList, u32
return id;
}
void CPlayer::UpdateCrosshairsState(const CFinalInput&) {}
void CPlayer::UpdateVisorTransition(float, CStateManager& mgr) {}
void CPlayer::UpdateVisorState(const CFinalInput&, float, CStateManager& mgr) {}
void CPlayer::UpdateGunState(const CFinalInput&, CStateManager& mgr)
void CPlayer::UpdateCrosshairsState(const CFinalInput& input)
{
x9c4_25_showCrosshairs = ControlMapper::GetDigitalInput(ControlMapper::ECommands::ShowCrosshairs, input);
}
void CPlayer::UpdateVisorTransition(float dt, CStateManager& mgr)
{
if (mgr.GetPlayerState()->GetIsVisorTransitioning())
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)
{
x7a0_visorSteam.Update(dt);
if (x7a0_visorSteam.AffectsThermal())
mgr.SetThermalColdScale2(mgr.GetThermalColdScale2() + x7a0_visorSteam.GetAlpha());
if (x304_orbitState == EPlayerOrbitState::Five ||
TCastToPtr<CScriptGrapplePoint>(mgr.ObjectById(x310_orbitTargetId)) ||
x2f8_morphTransState != EPlayerMorphBallState::Unmorphed ||
mgr.GetPlayerState()->GetIsVisorTransitioning() ||
x3a8_scanState != EPlayerScanState::NotScanning)
return;
if (mgr.GetPlayerState()->GetTransitioningVisor() == CPlayerState::EPlayerVisor::Scan &&
(ControlMapper::GetDigitalInput(ControlMapper::ECommands::FireOrBomb, input) ||
ControlMapper::GetDigitalInput(ControlMapper::ECommands::MissileOrPowerBomb, input)) &&
mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::CombatVisor))
{
mgr.GetPlayerState()->StartVisorTransition(CPlayerState::EPlayerVisor::Combat);
DrawGun(mgr);
}
for (int i=0 ; i<4 ; ++i)
{
if (mgr.GetPlayerState()->HasPowerUp(skVisorToItemMapping[i].first) &&
ControlMapper::GetPressInput(skVisorToItemMapping[i].second, input))
{
x9c4_24_visorChangeRequested = true;
CPlayerState::EPlayerVisor visor = CPlayerState::EPlayerVisor(i);
if (mgr.GetPlayerState()->GetTransitioningVisor() != visor)
{
mgr.GetPlayerState()->StartVisorTransition(visor);
if (visor == CPlayerState::EPlayerVisor::Scan)
HolsterGun(mgr);
else
DrawGun(mgr);
}
}
}
}
void CPlayer::UpdateGunState(const CFinalInput& input, CStateManager& mgr)
{
switch (x498_gunHolsterState)
{
case EGunHolsterState::Drawn:
{
bool needsHolster = false;
if (g_tweakPlayer->GetGunButtonTogglesHolster())
{
if (ControlMapper::GetPressInput(ControlMapper::ECommands::ToggleHolster, input))
needsHolster = true;
if (!ControlMapper::GetDigitalInput(ControlMapper::ECommands::FireOrBomb, input) &&
!ControlMapper::GetDigitalInput(ControlMapper::ECommands::MissileOrPowerBomb, input) &&
g_tweakPlayer->GetGunNotFiringHolstersGun())
{
x49c_gunHolsterRemTime -= input.DeltaTime();
if (x49c_gunHolsterRemTime <= 0.f)
needsHolster = true;
}
}
else
{
if (!ControlMapper::GetDigitalInput(ControlMapper::ECommands::FireOrBomb, input) &&
!ControlMapper::GetDigitalInput(ControlMapper::ECommands::MissileOrPowerBomb, input) &&
x490_gun->IsFidgeting())
{
if (g_tweakPlayer->GetGunNotFiringHolstersGun())
x49c_gunHolsterRemTime -= input.DeltaTime();
}
else
{
x49c_gunHolsterRemTime = g_tweakPlayerGun->GetGunNotFiringTime();
}
}
if (needsHolster)
HolsterGun(mgr);
break;
}
case EGunHolsterState::Drawing:
{
if (x49c_gunHolsterRemTime > 0.f)
{
x49c_gunHolsterRemTime -= input.DeltaTime();
} else
{
x498_gunHolsterState = EGunHolsterState::Drawn;
x49c_gunHolsterRemTime = g_tweakPlayerGun->GetGunNotFiringTime();
}
break;
}
case EGunHolsterState::Holstered:
{
bool needsDraw = false;
if (ControlMapper::GetDigitalInput(ControlMapper::ECommands::FireOrBomb, input) ||
ControlMapper::GetDigitalInput(ControlMapper::ECommands::MissileOrPowerBomb, input) ||
x3b8_grappleState == EGrappleState::Zero ||
(g_tweakPlayer->GetGunButtonTogglesHolster() &&
ControlMapper::GetPressInput(ControlMapper::ECommands::ToggleHolster, input)))
needsDraw = true;
if (x3b8_grappleState == EGrappleState::Zero &&
(mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Scan ||
mgr.GetPlayerState()->GetTransitioningVisor() == CPlayerState::EPlayerVisor::Scan ))
needsDraw = false;
if (needsDraw)
DrawGun(mgr);
break;
}
case EGunHolsterState::Holstering:
if (x49c_gunHolsterRemTime > 0.f)
x49c_gunHolsterRemTime -= input.DeltaTime();
else
x498_gunHolsterState = EGunHolsterState::Holstered;
break;
}
}
void CPlayer::ResetGun(CStateManager& mgr)
{
x498_gunHolsterState = EGunHolsterState::Holstered;
x49c_gunNotFiringTimeout = 0.f;
x49c_gunHolsterRemTime = 0.f;
x490_gun->CancelFiring(mgr);
ResetAimTargetPrediction(kInvalidUniqueId);
}
@ -1395,7 +1538,7 @@ void CPlayer::UpdateGunTransform(const zeus::CVector3f& gunPos, CStateManager& m
{
case EGunHolsterState::Drawing:
{
float liftAngle = zeus::clamp(-1.f, x49c_gunNotFiringTimeout / 0.45f, 1.f);
float liftAngle = zeus::clamp(-1.f, x49c_gunHolsterRemTime / 0.45f, 1.f);
if (liftAngle > 0.01f)
{
gunXf = zeus::CQuaternion::fromAxisAngle(rightDir, -liftAngle *
@ -1415,9 +1558,9 @@ void CPlayer::UpdateGunTransform(const zeus::CVector3f& gunPos, CStateManager& m
case EGunHolsterState::Holstering:
{
float liftAngle = 1.f -
zeus::clamp(-1.f, x49c_gunNotFiringTimeout / g_tweakPlayerGun->GetGunHolsterTime(), 1.f);
zeus::clamp(-1.f, x49c_gunHolsterRemTime / g_tweakPlayerGun->GetGunHolsterTime(), 1.f);
if (x2f8_morphTransState == EPlayerMorphBallState::Morphing)
liftAngle = 1.f - zeus::clamp(-1.f, x49c_gunNotFiringTimeout / 0.1f, 1.f);
liftAngle = 1.f - zeus::clamp(-1.f, x49c_gunHolsterRemTime / 0.1f, 1.f);
if (liftAngle > 0.01f)
{
gunXf = zeus::CQuaternion::fromAxisAngle(rightDir, -liftAngle *
@ -1458,7 +1601,7 @@ void CPlayer::DrawGun(CStateManager& mgr)
if (x498_gunHolsterState != EGunHolsterState::Holstered || InGrappleJumpCooldown())
return;
x498_gunHolsterState = EGunHolsterState::Drawing;
x49c_gunNotFiringTimeout = 0.45f;
x49c_gunHolsterRemTime = 0.45f;
x490_gun->ResetIdle(mgr);
}
@ -1470,9 +1613,9 @@ void CPlayer::HolsterGun(CStateManager& mgr)
float time = x2f8_morphTransState == EPlayerMorphBallState::Morphing ? 0.1f :
g_tweakPlayerGun->GetGunHolsterTime();
if (x498_gunHolsterState == EGunHolsterState::Drawing)
x49c_gunNotFiringTimeout = time * (1.f - x49c_gunNotFiringTimeout / 0.45f);
x49c_gunHolsterRemTime = time * (1.f - x49c_gunHolsterRemTime / 0.45f);
else
x49c_gunNotFiringTimeout = time;
x49c_gunHolsterRemTime = time;
x498_gunHolsterState = EGunHolsterState::Holstering;
x490_gun->CancelFiring(mgr);
ResetAimTargetPrediction(kInvalidUniqueId);
@ -2249,35 +2392,39 @@ void CPlayer::SetPlayerHitWallDuringMove()
x2d0_ = 1;
}
void CPlayer::Touch() {}
void CPlayer::CVisorSteam::SetSteam(float a, float b, float c, ResId d, bool e)
void CPlayer::Touch(CActor& actor, CStateManager& mgr)
{
if (x1c_ == kInvalidResId || a > x10_)
if (x2f8_morphTransState == EPlayerMorphBallState::Morphed)
x768_morphball->Touch(actor, mgr);
}
void CPlayer::CVisorSteam::SetSteam(float a, float b, float c, ResId txtr, bool affectsThermal)
{
if (x1c_txtr == kInvalidResId || a > x10_)
{
x10_ = a;
x14_ = b;
x18_ = c;
x1c_ = d;
x1c_txtr = txtr;
}
x28_ = e;
x28_affectsThermal = affectsThermal;
}
ResId CPlayer::CVisorSteam::GetTextureId() const { return xc_tex; }
void CPlayer::CVisorSteam::Update(float dt)
{
if (x1c_ == kInvalidResId)
if (x1c_txtr == kInvalidResId)
x0_ = 0.f;
else
{
x0_ = x10_;
x4_ = x14_;
x8_ = x18_;
xc_tex = x1c_;
xc_tex = x1c_txtr;
}
x1c_ = kInvalidResId;
x1c_txtr = kInvalidResId;
if ((x20_alpha - x0_) < 0.000009999f || std::fabs(x20_alpha) > 0.000009999f)
return;

View File

@ -169,17 +169,18 @@ private:
float x10_ = 0.f;
float x14_ = 0.f;
float x18_ = 0.f;
ResId x1c_ = kInvalidResId;
ResId x1c_txtr = kInvalidResId;
float x20_alpha = 0.f;
float x24_ = 0.f;
bool x28_ = false;
bool x28_affectsThermal = false;
public:
CVisorSteam(float a, float b, float c, ResId tex) : x0_(a), x4_(b), x8_(c), xc_tex(tex) {}
ResId GetTextureId() const;
void SetSteam(float a, float b, float c, ResId d, bool e);
void SetSteam(float a, float b, float c, ResId txtr, bool affectsThermal);
void Update(float dt);
float GetAlpha() const { return x20_alpha; }
bool AffectsThermal() const { return x28_affectsThermal; }
};
class CFailsafeTest
@ -282,7 +283,7 @@ private:
std::unique_ptr<CPlayerGun> x490_gun;
float x494_mapAlpha = 1.f;
EGunHolsterState x498_gunHolsterState = EGunHolsterState::Drawn;
float x49c_gunNotFiringTimeout;
float x49c_gunHolsterRemTime;
std::unique_ptr<CFailsafeTest> x4a0_failsafeTest;
u32 x4a4_ = 0;
float x4f8_ = 0.f;
@ -351,8 +352,8 @@ private:
{
struct
{
bool x9c4_24_ : 1;
bool x9c4_25_ : 1;
bool x9c4_24_visorChangeRequested : 1;
bool x9c4_25_showCrosshairs : 1;
bool x9c4_26_ : 1;
bool x9c4_27_ : 1;
bool x9c4_28_ : 1;
@ -439,7 +440,7 @@ public:
static CHealthInfo* HealthInfo(const CStateManager& mgr);
bool IsUnderBetaMetroidAttack(CStateManager& mgr) const;
rstl::optional_object<zeus::CAABox> GetTouchBounds() const;
void Touch(CActor&, CStateManager& mgr);
void Touch(CActor& actor, CStateManager& mgr);
void DoPreThink(float dt, CStateManager& mgr);
void DoThink(float dt, CStateManager& mgr);
void UpdateScanningState(const CFinalInput& input, CStateManager& mgr, float);
@ -600,8 +601,6 @@ public:
const std::vector<TUniqueId>& GetOffScreenOrbitObjects() const { return x364_offScreenOrbitObjects; }
void SetPlayerHitWallDuringMove();
void Touch();
void DecrementPhazon();
void IncrementPhazon();
void ApplySubmergedPitchBend(CSfxHandle& sfx);